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
45d16a30
Commit
45d16a30
authored
Mar 22, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support non-blocking assignments with delay or event controls
parent
9259fef2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
22 deletions
+37
-22
src/Convert/PackedArray.hs
+1
-1
src/Convert/Traverse.hs
+10
-6
src/Language/SystemVerilog/AST.hs
+2
-2
src/Language/SystemVerilog/Parser/Parse.y
+18
-7
src/Language/SystemVerilog/Parser/ParseDecl.hs
+6
-6
No files found.
src/Convert/PackedArray.hs
View file @
45d16a30
...
...
@@ -255,7 +255,7 @@ rewriteModuleItem info =
rewriteStmt
::
Stmt
->
Stmt
rewriteStmt
(
AsgnBlk
op
lhs
expr
)
=
convertAssignment
(
AsgnBlk
op
)
lhs
expr
rewriteStmt
(
Asgn
lhs
expr
)
=
convertAssignment
Asgn
lhs
expr
rewriteStmt
(
Asgn
mt
lhs
expr
)
=
convertAssignment
(
Asgn
mt
)
lhs
expr
rewriteStmt
other
=
other
convertAssignment
::
(
LHS
->
Expr
->
Stmt
)
->
LHS
->
Expr
->
Stmt
convertAssignment
constructor
(
lhs
@
(
LHSIdent
ident
))
(
expr
@
(
Repeat
_
exprs
))
=
...
...
src/Convert/Traverse.hs
View file @
45d16a30
...
...
@@ -143,7 +143,7 @@ traverseNestedStmtsM mapper = fullMapper
def'
<-
maybeDo
fullMapper
def
return
$
Case
u
kw
expr
cases'
def'
cs
(
AsgnBlk
op
lhs
expr
)
=
return
$
AsgnBlk
op
lhs
expr
cs
(
Asgn
lhs
expr
)
=
return
$
Asgn
lhs
expr
cs
(
Asgn
mt
lhs
expr
)
=
return
$
Asgn
mt
lhs
expr
cs
(
For
a
b
c
stmt
)
=
fullMapper
stmt
>>=
return
.
For
a
b
c
cs
(
While
e
stmt
)
=
fullMapper
stmt
>>=
return
.
While
e
cs
(
RepeatL
e
stmt
)
=
fullMapper
stmt
>>=
return
.
RepeatL
e
...
...
@@ -165,8 +165,12 @@ traverseStmtLHSsM mapper = traverseNestedStmtsM stmtMapper
stmtMapper
(
Timing
(
Event
sense
)
stmt
)
=
do
sense'
<-
senseMapper
sense
return
$
Timing
(
Event
sense'
)
stmt
stmtMapper
(
Asgn
(
Just
(
Event
sense
))
lhs
expr
)
=
do
lhs'
<-
fullMapper
lhs
sense'
<-
senseMapper
sense
return
$
Asgn
(
Just
$
Event
sense'
)
lhs'
expr
stmtMapper
(
AsgnBlk
op
lhs
expr
)
=
fullMapper
lhs
>>=
\
lhs'
->
return
$
AsgnBlk
op
lhs'
expr
stmtMapper
(
Asgn
lhs
expr
)
=
fullMapper
lhs
>>=
\
lhs'
->
return
$
Asgn
lhs'
expr
stmtMapper
(
Asgn
mt
lhs
expr
)
=
fullMapper
lhs
>>=
\
lhs'
->
return
$
Asgn
mt
lhs'
expr
stmtMapper
other
=
return
other
senseMapper
(
Sense
lhs
)
=
fullMapper
lhs
>>=
return
.
Sense
senseMapper
(
SensePosedge
lhs
)
=
fullMapper
lhs
>>=
return
.
SensePosedge
...
...
@@ -268,8 +272,8 @@ traverseExprsM mapper = moduleItemMapper
return
$
Case
u
kw
e'
cases'
def
flatStmtMapper
(
AsgnBlk
op
lhs
expr
)
=
exprMapper
expr
>>=
return
.
AsgnBlk
op
lhs
flatStmtMapper
(
Asgn
lhs
expr
)
=
exprMapper
expr
>>=
return
.
Asgn
lhs
flatStmtMapper
(
Asgn
mt
lhs
expr
)
=
exprMapper
expr
>>=
return
.
Asgn
mt
lhs
flatStmtMapper
(
For
(
x1
,
e1
)
cc
(
x2
,
e2
)
stmt
)
=
do
e1'
<-
exprMapper
e1
e2'
<-
exprMapper
e2
...
...
@@ -502,9 +506,9 @@ traverseAsgnsM mapper = moduleItemMapper
stmtMapper
(
AsgnBlk
op
lhs
expr
)
=
do
(
lhs'
,
expr'
)
<-
mapper
(
lhs
,
expr
)
return
$
AsgnBlk
op
lhs'
expr'
stmtMapper
(
Asgn
lhs
expr
)
=
do
stmtMapper
(
Asgn
mt
lhs
expr
)
=
do
(
lhs'
,
expr'
)
<-
mapper
(
lhs
,
expr
)
return
$
Asgn
lhs'
expr'
return
$
Asgn
mt
lhs'
expr'
stmtMapper
other
=
return
other
traverseAsgns
::
Mapper
(
LHS
,
Expr
)
->
Mapper
ModuleItem
...
...
src/Language/SystemVerilog/AST.hs
View file @
45d16a30
...
...
@@ -457,7 +457,7 @@ data Stmt
|
Case
Bool
CaseKW
Expr
[
Case
]
(
Maybe
Stmt
)
|
For
(
Identifier
,
Expr
)
Expr
(
Identifier
,
Expr
)
Stmt
|
AsgnBlk
AsgnOp
LHS
Expr
|
Asgn
LHS
Expr
|
Asgn
(
Maybe
Timing
)
LHS
Expr
|
While
Expr
Stmt
|
RepeatL
Expr
Stmt
|
DoWhile
Expr
Stmt
...
...
@@ -488,7 +488,7 @@ instance Show Stmt where
Just
c
->
printf
"
\n\t
default: %s"
(
show
c
)
show
(
For
(
a
,
b
)
c
(
d
,
e
)
f
)
=
printf
"for (%s = %s; %s; %s = %s)
\n
%s"
a
(
show
b
)
(
show
c
)
d
(
show
e
)
$
indent
$
show
f
show
(
AsgnBlk
o
v
e
)
=
printf
"%s %s %s;"
(
show
v
)
(
show
o
)
(
show
e
)
show
(
Asgn
v
e
)
=
printf
"%s <= %s;"
(
show
v
)
(
show
e
)
show
(
Asgn
t
v
e
)
=
printf
"%s <= %s%s;"
(
show
v
)
(
maybe
""
showPad
t
)
(
show
e
)
show
(
While
e
s
)
=
printf
"while (%s) %s"
(
show
e
)
(
show
s
)
show
(
RepeatL
e
s
)
=
printf
"repeat (%s) %s"
(
show
e
)
(
show
s
)
show
(
DoWhile
e
s
)
=
printf
"do %s while (%s);"
(
show
s
)
(
show
e
)
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
45d16a30
...
...
@@ -295,10 +295,10 @@ DeclToken :: { DeclToken }
DeclOrStmtTokens(delim) :: { [DeclToken] }
: DeclOrStmtToken delim { [$1] }
| DeclOrStmtToken DeclOrStmtTokens(delim) { [$1] ++ $2 }
| AsgnOp Expr "," DeclOrStmtTokens(delim) { [DTAsgn $1
$2, DTComma] ++ $4 }
|
"<=" Expr "," DeclOrStmtTokens(delim) { [DTAsgnNBlk $2, DTComma] ++ $4
}
|
AsgnOp Expr delim { [DTAsgn $1 $2]
}
| "<="
Expr delim { [DTAsgnNBlk $2
] }
| AsgnOp Expr "," DeclOrStmtTokens(delim) { [DTAsgn $1 $2, DTComma] ++ $4 }
|
AsgnOp Expr delim { [DTAsgn $1 $2]
}
|
"<=" opt(DelayOrEventControl) Expr "," DeclOrStmtTokens(delim) { [DTAsgnNBlk $2 $3, DTComma] ++ $5
}
| "<="
opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3
] }
DeclOrStmtToken :: { DeclToken }
: "," { DTComma }
| Range { DTRange $1 }
...
...
@@ -456,8 +456,8 @@ Stmts :: { [Stmt] }
Stmt :: { Stmt }
: StmtNonAsgn { $1 }
| LHS AsgnOp Expr ";" { AsgnBlk $2 $1 $3 }
| LHS "<=" Expr ";" { Asgn $1 $3 }
| Identifier ";" { Subroutine $1 [] }
| LHS "<=" opt(DelayOrEventControl) Expr ";" { Asgn $3 $1 $4 }
StmtNonAsgn :: { Stmt }
: ";" { Null }
| "begin" opt(Tag) DeclsAndStmts "end" opt(Tag) { Block (combineTags $2 $5) (fst $3) (snd $3) }
...
...
@@ -483,11 +483,14 @@ DeclOrStmt :: { ([Decl], [Stmt]) }
| "localparam" ParamType DeclAsgns ";" { (map (uncurry $ Localparam $2) $3, []) }
TimingControl :: { Timing }
: DelayOrEventControl { $1 }
| CycleDelay { $1 }
DelayOrEventControl :: { Timing }
: DelayControl { $1 }
| CycleDelay { $1 }
| EventControl { $1 }
DelayControl :: { Timing }
: "#" Expr { Delay $2 }
: "#" DelayValue { Delay $2 }
| "#" "(" Expr ")" { Delay $3 }
CycleDelay :: { Timing }
: "##" Expr { Cycle $2 }
EventControl :: { Timing }
...
...
@@ -503,6 +506,14 @@ Sense :: { Sense }
| "posedge" LHS { SensePosedge $2 }
| "negedge" LHS { SenseNegedge $2 }
DelayValue :: { Expr }
: Number { Number $1 }
-- TODO: Support these other DelayValues?
-- | real_number
-- | ps_identifier
-- | time_literal
-- | 1step
Unique :: { Bool }
: "unique" { True }
| {- empty -} { False }
...
...
src/Language/SystemVerilog/Parser/ParseDecl.hs
View file @
45d16a30
...
...
@@ -47,7 +47,7 @@ import Language.SystemVerilog.AST
data
DeclToken
=
DTComma
|
DTAsgn
AsgnOp
Expr
|
DTAsgnNBlk
Expr
|
DTAsgnNBlk
(
Maybe
Timing
)
Expr
|
DTRange
Range
|
DTIdent
Identifier
|
DTDir
Direction
...
...
@@ -70,7 +70,7 @@ forbidNonEqAsgn tokens =
else
id
where
isNonEqAsgn
::
DeclToken
->
Bool
isNonEqAsgn
(
DTAsgnNBlk
_
)
=
True
isNonEqAsgn
(
DTAsgnNBlk
_
_
)
=
True
isNonEqAsgn
(
DTAsgn
(
AsgnOp
_
)
_
)
=
True
isNonEqAsgn
_
=
False
...
...
@@ -173,14 +173,14 @@ parseDTsAsDeclOrAsgn tokens =
else
(
parseDTsAsDecl
tokens
,
[]
)
where
(
constructor
,
expr
)
=
case
last
tokens
of
DTAsgn
op
e
->
(
AsgnBlk
op
,
e
)
DTAsgnNBlk
e
->
(
Asgn
,
e
)
DTAsgn
op
e
->
(
AsgnBlk
op
,
e
)
DTAsgnNBlk
mt
e
->
(
Asgn
mt
,
e
)
_
->
error
$
"invalid block item decl or stmt: "
++
(
show
tokens
)
Just
lhs
=
foldl
takeLHSStep
Nothing
$
init
tokens
isAsgnToken
::
DeclToken
->
Bool
isAsgnToken
(
DTBit
_
)
=
True
isAsgnToken
(
DTConcat
_
)
=
True
isAsgnToken
(
DTAsgnNBlk
_
)
=
True
isAsgnToken
(
DTAsgnNBlk
_
_
)
=
True
isAsgnToken
(
DTAsgn
(
AsgnOp
_
)
_
)
=
True
isAsgnToken
_
=
False
...
...
@@ -280,7 +280,7 @@ takeRanges (token : tokens) =
-- `DTAsgnNBlk`, so this doesn't liberalize the parser.
takeAsgn
::
[
DeclToken
]
->
(
Maybe
Expr
,
[
DeclToken
])
takeAsgn
(
DTAsgn
AsgnOpEq
e
:
rest
)
=
(
Just
e
,
rest
)
takeAsgn
(
DTAsgnNBlk
e
:
rest
)
=
(
Just
e
,
rest
)
takeAsgn
(
DTAsgnNBlk
_
e
:
rest
)
=
(
Just
e
,
rest
)
takeAsgn
rest
=
(
Nothing
,
rest
)
takeComma
::
[
DeclToken
]
->
(
Bool
,
[
DeclToken
])
...
...
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