Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
04de45b0
Commit
04de45b0
authored
Sep 01, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
language support for streaming operators
parent
638adb35
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
6 deletions
+39
-6
src/Convert/Struct.hs
+5
-0
src/Convert/Traverse.hs
+4
-0
src/Language/SystemVerilog/AST/Expr.hs
+2
-0
src/Language/SystemVerilog/AST/Op.hs
+14
-4
src/Language/SystemVerilog/Parser/Parse.y
+14
-2
No files found.
src/Convert/Struct.hs
View file @
04de45b0
...
@@ -386,6 +386,11 @@ convertAsgn structs types (lhs, expr) =
...
@@ -386,6 +386,11 @@ convertAsgn structs types (lhs, expr) =
(
tf
,
rs
)
->
tf
$
tail
rs
(
tf
,
rs
)
->
tf
$
tail
rs
convertSubExpr
(
Concat
exprs
)
=
convertSubExpr
(
Concat
exprs
)
=
(
Implicit
Unspecified
[]
,
Concat
$
map
(
snd
.
convertSubExpr
)
exprs
)
(
Implicit
Unspecified
[]
,
Concat
$
map
(
snd
.
convertSubExpr
)
exprs
)
convertSubExpr
(
Stream
o
e
exprs
)
=
(
Implicit
Unspecified
[]
,
Stream
o
e'
exprs'
)
where
e'
=
(
snd
.
convertSubExpr
)
e
exprs'
=
map
(
snd
.
convertSubExpr
)
exprs
convertSubExpr
(
BinOp
op
e1
e2
)
=
convertSubExpr
(
BinOp
op
e1
e2
)
=
(
Implicit
Unspecified
[]
,
BinOp
op
e1'
e2'
)
(
Implicit
Unspecified
[]
,
BinOp
op
e1'
e2'
)
where
where
...
...
src/Convert/Traverse.hs
View file @
04de45b0
...
@@ -429,6 +429,10 @@ traverseNestedExprsM mapper = exprMapper
...
@@ -429,6 +429,10 @@ traverseNestedExprsM mapper = exprMapper
return
$
Repeat
e'
l'
return
$
Repeat
e'
l'
em
(
Concat
l
)
=
em
(
Concat
l
)
=
mapM
exprMapper
l
>>=
return
.
Concat
mapM
exprMapper
l
>>=
return
.
Concat
em
(
Stream
o
e
l
)
=
do
e'
<-
exprMapper
e
l'
<-
mapM
exprMapper
l
return
$
Stream
o
e'
l'
em
(
Call
ps
f
(
Args
l
p
))
=
do
em
(
Call
ps
f
(
Args
l
p
))
=
do
l'
<-
mapM
maybeExprMapper
l
l'
<-
mapM
maybeExprMapper
l
pes
<-
mapM
maybeExprMapper
$
map
snd
p
pes
<-
mapM
maybeExprMapper
$
map
snd
p
...
...
src/Language/SystemVerilog/AST/Expr.hs
View file @
04de45b0
...
@@ -39,6 +39,7 @@ data Expr
...
@@ -39,6 +39,7 @@ data Expr
|
Bit
Expr
Expr
|
Bit
Expr
Expr
|
Repeat
Expr
[
Expr
]
|
Repeat
Expr
[
Expr
]
|
Concat
[
Expr
]
|
Concat
[
Expr
]
|
Stream
StreamOp
Expr
[
Expr
]
|
Call
(
Maybe
Identifier
)
Identifier
Args
|
Call
(
Maybe
Identifier
)
Identifier
Args
|
UniOp
UniOp
Expr
|
UniOp
UniOp
Expr
|
BinOp
BinOp
Expr
Expr
|
BinOp
BinOp
Expr
Expr
...
@@ -58,6 +59,7 @@ instance Show Expr where
...
@@ -58,6 +59,7 @@ instance Show Expr where
show
(
Range
e
m
r
)
=
printf
"%s[%s%s%s]"
(
show
e
)
(
show
$
fst
r
)
(
show
m
)
(
show
$
snd
r
)
show
(
Range
e
m
r
)
=
printf
"%s[%s%s%s]"
(
show
e
)
(
show
$
fst
r
)
(
show
m
)
(
show
$
snd
r
)
show
(
Repeat
e
l
)
=
printf
"{%s {%s}}"
(
show
e
)
(
commas
$
map
show
l
)
show
(
Repeat
e
l
)
=
printf
"{%s {%s}}"
(
show
e
)
(
commas
$
map
show
l
)
show
(
Concat
l
)
=
printf
"{%s}"
(
commas
$
map
show
l
)
show
(
Concat
l
)
=
printf
"{%s}"
(
commas
$
map
show
l
)
show
(
Stream
o
e
l
)
=
printf
"{%s %s%s}"
(
show
o
)
(
show
e
)
(
show
$
Concat
l
)
show
(
UniOp
a
b
)
=
printf
"(%s %s)"
(
show
a
)
(
show
b
)
show
(
UniOp
a
b
)
=
printf
"(%s %s)"
(
show
a
)
(
show
b
)
show
(
BinOp
o
a
b
)
=
printf
"(%s %s %s)"
(
show
a
)
(
show
o
)
(
show
b
)
show
(
BinOp
o
a
b
)
=
printf
"(%s %s %s)"
(
show
a
)
(
show
o
)
(
show
b
)
show
(
Dot
e
n
)
=
printf
"%s.%s"
(
show
e
)
n
show
(
Dot
e
n
)
=
printf
"%s.%s"
(
show
e
)
n
...
...
src/Language/SystemVerilog/AST/Op.hs
View file @
04de45b0
...
@@ -2,13 +2,14 @@
...
@@ -2,13 +2,14 @@
- Author: Zachary Snow <zach@zachjs.com>
- Author: Zachary Snow <zach@zachjs.com>
- Initial Verilog AST Author: Tom Hawkins <tomahawkins@gmail.com>
- Initial Verilog AST Author: Tom Hawkins <tomahawkins@gmail.com>
-
-
- SystemVerilog operators (unary, binary, a
nd assignment
)
- SystemVerilog operators (unary, binary, a
ssignment, and stream
)
-}
-}
module
Language.SystemVerilog.AST.Op
module
Language.SystemVerilog.AST.Op
(
UniOp
(
..
)
(
UniOp
(
..
)
,
BinOp
(
..
)
,
BinOp
(
..
)
,
AsgnOp
(
..
)
,
AsgnOp
(
..
)
,
StreamOp
(
..
)
)
where
)
where
data
UniOp
data
UniOp
...
@@ -101,3 +102,12 @@ data AsgnOp
...
@@ -101,3 +102,12 @@ data AsgnOp
instance
Show
AsgnOp
where
instance
Show
AsgnOp
where
show
AsgnOpEq
=
"="
show
AsgnOpEq
=
"="
show
(
AsgnOp
op
)
=
(
show
op
)
++
"="
show
(
AsgnOp
op
)
=
(
show
op
)
++
"="
data
StreamOp
=
StreamL
|
StreamR
deriving
(
Eq
,
Ord
)
instance
Show
StreamOp
where
show
StreamL
=
"<<"
show
StreamR
=
">>"
src/Language/SystemVerilog/Parser/Parse.y
View file @
04de45b0
...
@@ -834,8 +834,8 @@ Expr :: { Expr }
...
@@ -834,8 +834,8 @@ Expr :: { Expr }
| Identifier "::" Identifier { PSIdent $1 $3 }
| Identifier "::" Identifier { PSIdent $1 $3 }
| Expr PartSelect { Range $1 (fst $2) (snd $2) }
| Expr PartSelect { Range $1 (fst $2) (snd $2) }
| Expr "[" Expr "]" { Bit $1 $3 }
| Expr "[" Expr "]" { Bit $1 $3 }
| "{" Expr
"{" Exprs "}" "}" { Repeat $2 $4
}
| "{" Expr
Concat "}" { Repeat $2 $3
}
|
"{" Exprs "}" { Concat $2
}
|
Concat { Concat $1
}
| Expr "?" Expr ":" Expr { Mux $1 $3 $5 }
| Expr "?" Expr ":" Expr { Mux $1 $3 $5 }
| CastingType "'" "(" Expr ")" { Cast (Left $1) $4 }
| CastingType "'" "(" Expr ")" { Cast (Left $1) $4 }
| Number "'" "(" Expr ")" { Cast (Right $ Number $1) $4 }
| Number "'" "(" Expr ")" { Cast (Right $ Number $1) $4 }
...
@@ -843,6 +843,8 @@ Expr :: { Expr }
...
@@ -843,6 +843,8 @@ Expr :: { Expr }
| Identifier "::" Identifier "'" "(" Expr ")" { Cast (Left $ Alias (Just $1) $3 []) $6 }
| Identifier "::" Identifier "'" "(" Expr ")" { Cast (Left $ Alias (Just $1) $3 []) $6 }
| Expr "." Identifier { Dot $1 $3 }
| Expr "." Identifier { Dot $1 $3 }
| "'" "{" PatternItems "}" { Pattern $3 }
| "'" "{" PatternItems "}" { Pattern $3 }
| "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 }
| "{" StreamOp Concat "}" { Stream $2 (Number "1") $3 }
-- binary expressions
-- binary expressions
| Expr "||" Expr { BinOp LogOr $1 $3 }
| Expr "||" Expr { BinOp LogOr $1 $3 }
| Expr "&&" Expr { BinOp LogAnd $1 $3 }
| Expr "&&" Expr { BinOp LogAnd $1 $3 }
...
@@ -896,6 +898,16 @@ PatternNamedItem :: { (Identifier, Expr) }
...
@@ -896,6 +898,16 @@ PatternNamedItem :: { (Identifier, Expr) }
PatternUnnamedItems :: { [Expr] }
PatternUnnamedItems :: { [Expr] }
: Exprs { $1 }
: Exprs { $1 }
Concat :: { [Expr] }
: "{" Exprs "}" { $2 }
StreamOp :: { StreamOp }
: "<<" { StreamL }
| ">>" { StreamR }
StreamSize :: { Expr }
: TypeNonIdent { Bits $ Left $1 }
| Expr { $1 }
GenItemOrNull :: { GenItem }
GenItemOrNull :: { GenItem }
: GenItem { $1 }
: GenItem { $1 }
| ";" { GenNull }
| ";" { GenNull }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment