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
eebe4142
Commit
eebe4142
authored
Oct 31, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
language support for final blocks
parent
eeb2d809
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
1 deletions
+19
-1
src/Convert/Jump.hs
+7
-0
src/Convert/Logic.hs
+2
-0
src/Convert/Traverse.hs
+7
-1
src/Language/SystemVerilog/AST/ModuleItem.hs
+2
-0
src/Language/SystemVerilog/Parser/Parse.y
+1
-0
No files found.
src/Convert/Jump.hs
View file @
eebe4142
...
@@ -60,6 +60,13 @@ convertModuleItem (Initial stmt) =
...
@@ -60,6 +60,13 @@ convertModuleItem (Initial stmt) =
where
where
initialState
=
Info
{
sJumpType
=
JTNone
,
sLoopID
=
""
}
initialState
=
Info
{
sJumpType
=
JTNone
,
sLoopID
=
""
}
(
stmt'
,
finalState
)
=
runState
(
convertStmt
stmt
)
initialState
(
stmt'
,
finalState
)
=
runState
(
convertStmt
stmt
)
initialState
convertModuleItem
(
Final
stmt
)
=
if
sJumpType
finalState
==
JTNone
then
Final
stmt'
else
error
"illegal jump statement within final construct"
where
initialState
=
Info
{
sJumpType
=
JTNone
,
sLoopID
=
""
}
(
stmt'
,
finalState
)
=
runState
(
convertStmt
stmt
)
initialState
convertModuleItem
(
AlwaysC
kw
stmt
)
=
convertModuleItem
(
AlwaysC
kw
stmt
)
=
if
sJumpType
finalState
==
JTNone
if
sJumpType
finalState
==
JTNone
then
AlwaysC
kw
stmt'
then
AlwaysC
kw
stmt'
...
...
src/Convert/Logic.hs
View file @
eebe4142
...
@@ -144,6 +144,8 @@ regIdents (AlwaysC _ stmt) =
...
@@ -144,6 +144,8 @@ regIdents (AlwaysC _ stmt) =
removeTimings
other
=
other
removeTimings
other
=
other
regIdents
(
Initial
stmt
)
=
regIdents
(
Initial
stmt
)
=
regIdents
$
AlwaysC
Always
stmt
regIdents
$
AlwaysC
Always
stmt
regIdents
(
Final
stmt
)
=
regIdents
$
AlwaysC
Always
stmt
regIdents
_
=
return
()
regIdents
_
=
return
()
lhsIdents
::
LHS
->
Writer
Idents
()
lhsIdents
::
LHS
->
Writer
Idents
()
...
...
src/Convert/Traverse.hs
View file @
eebe4142
...
@@ -199,6 +199,8 @@ traverseStmtsM' strat mapper = moduleItemMapper
...
@@ -199,6 +199,8 @@ traverseStmtsM' strat mapper = moduleItemMapper
return
$
MIPackageItem
$
Task
lifetime
name
decls
stmts'
return
$
MIPackageItem
$
Task
lifetime
name
decls
stmts'
moduleItemMapper
(
Initial
stmt
)
=
moduleItemMapper
(
Initial
stmt
)
=
fullMapper
stmt
>>=
return
.
Initial
fullMapper
stmt
>>=
return
.
Initial
moduleItemMapper
(
Final
stmt
)
=
fullMapper
stmt
>>=
return
.
Final
moduleItemMapper
other
=
return
$
other
moduleItemMapper
other
=
return
$
other
fullMapper
=
traverseNestedStmtsM
mapper
fullMapper
=
traverseNestedStmtsM
mapper
...
@@ -577,6 +579,8 @@ traverseExprsM' strat exprMapper = moduleItemMapper
...
@@ -577,6 +579,8 @@ traverseExprsM' strat exprMapper = moduleItemMapper
stmtMapper
stmt
>>=
return
.
AlwaysC
kw
stmtMapper
stmt
>>=
return
.
AlwaysC
kw
moduleItemMapper
(
Initial
stmt
)
=
moduleItemMapper
(
Initial
stmt
)
=
stmtMapper
stmt
>>=
return
.
Initial
stmtMapper
stmt
>>=
return
.
Initial
moduleItemMapper
(
Final
stmt
)
=
stmtMapper
stmt
>>=
return
.
Final
moduleItemMapper
(
Assign
delay
lhs
expr
)
=
do
moduleItemMapper
(
Assign
delay
lhs
expr
)
=
do
delay'
<-
maybeExprMapper
delay
delay'
<-
maybeExprMapper
delay
lhs'
<-
lhsMapper
lhs
lhs'
<-
lhsMapper
lhs
...
@@ -1034,7 +1038,7 @@ collectNestedExprsM :: Monad m => CollectorM m Expr -> CollectorM m Expr
...
@@ -1034,7 +1038,7 @@ collectNestedExprsM :: Monad m => CollectorM m Expr -> CollectorM m Expr
collectNestedExprsM
=
collectify
traverseNestedExprsM
collectNestedExprsM
=
collectify
traverseNestedExprsM
-- Traverse all the declaration scopes within a ModuleItem. Note that Functions,
-- Traverse all the declaration scopes within a ModuleItem. Note that Functions,
-- Tasks, Always
and Initi
al blocks are all NOT passed through ModuleItem
-- Tasks, Always
/Initial/Fin
al blocks are all NOT passed through ModuleItem
-- mapper, and Decl ModuleItems are NOT passed through the Decl mapper. The
-- mapper, and Decl ModuleItems are NOT passed through the Decl mapper. The
-- state is restored to its previous value after each scope is exited. Only the
-- state is restored to its previous value after each scope is exited. Only the
-- Decl mapper may modify the state, as we maintain the invariant that all other
-- Decl mapper may modify the state, as we maintain the invariant that all other
...
@@ -1082,6 +1086,8 @@ traverseScopesM declMapper moduleItemMapper stmtMapper =
...
@@ -1082,6 +1086,8 @@ traverseScopesM declMapper moduleItemMapper stmtMapper =
fullStmtMapper
stmt
>>=
return
.
AlwaysC
kw
fullStmtMapper
stmt
>>=
return
.
AlwaysC
kw
redirectModuleItem
(
Initial
stmt
)
=
redirectModuleItem
(
Initial
stmt
)
=
fullStmtMapper
stmt
>>=
return
.
Initial
fullStmtMapper
stmt
>>=
return
.
Initial
redirectModuleItem
(
Final
stmt
)
=
fullStmtMapper
stmt
>>=
return
.
Final
redirectModuleItem
item
=
redirectModuleItem
item
=
moduleItemMapper
item
moduleItemMapper
item
...
...
src/Language/SystemVerilog/AST/ModuleItem.hs
View file @
eebe4142
...
@@ -41,6 +41,7 @@ data ModuleItem
...
@@ -41,6 +41,7 @@ data ModuleItem
|
Generate
[
GenItem
]
|
Generate
[
GenItem
]
|
Modport
Identifier
[
ModportDecl
]
|
Modport
Identifier
[
ModportDecl
]
|
Initial
Stmt
|
Initial
Stmt
|
Final
Stmt
|
MIPackageItem
PackageItem
|
MIPackageItem
PackageItem
|
NInputGate
NInputGateKW
(
Maybe
Identifier
)
LHS
[
Expr
]
|
NInputGate
NInputGateKW
(
Maybe
Identifier
)
LHS
[
Expr
]
|
NOutputGate
NOutputGateKW
(
Maybe
Identifier
)
[
LHS
]
Expr
|
NOutputGate
NOutputGateKW
(
Maybe
Identifier
)
[
LHS
]
Expr
...
@@ -56,6 +57,7 @@ instance Show ModuleItem where
...
@@ -56,6 +57,7 @@ instance Show ModuleItem where
show
(
Generate
b
)
=
printf
"generate
\n
%s
\n
endgenerate"
(
indent
$
unlines'
$
map
show
b
)
show
(
Generate
b
)
=
printf
"generate
\n
%s
\n
endgenerate"
(
indent
$
unlines'
$
map
show
b
)
show
(
Modport
x
l
)
=
printf
"modport %s(
\n
%s
\n
);"
x
(
indent
$
intercalate
",
\n
"
$
map
showModportDecl
l
)
show
(
Modport
x
l
)
=
printf
"modport %s(
\n
%s
\n
);"
x
(
indent
$
intercalate
",
\n
"
$
map
showModportDecl
l
)
show
(
Initial
s
)
=
printf
"initial %s"
(
show
s
)
show
(
Initial
s
)
=
printf
"initial %s"
(
show
s
)
show
(
Final
s
)
=
printf
"final %s"
(
show
s
)
show
(
NInputGate
kw
x
lhs
exprs
)
=
printf
"%s%s (%s, %s);"
(
show
kw
)
(
maybe
""
(
" "
++
)
x
)
(
show
lhs
)
(
commas
$
map
show
exprs
)
show
(
NInputGate
kw
x
lhs
exprs
)
=
printf
"%s%s (%s, %s);"
(
show
kw
)
(
maybe
""
(
" "
++
)
x
)
(
show
lhs
)
(
commas
$
map
show
exprs
)
show
(
NOutputGate
kw
x
lhss
expr
)
=
printf
"%s%s (%s, %s);"
(
show
kw
)
(
maybe
""
(
" "
++
)
x
)
(
commas
$
map
show
lhss
)
(
show
expr
)
show
(
NOutputGate
kw
x
lhss
expr
)
=
printf
"%s%s (%s, %s);"
(
show
kw
)
(
maybe
""
(
" "
++
)
x
)
(
commas
$
map
show
lhss
)
(
show
expr
)
show
(
Assign
d
a
b
)
=
show
(
Assign
d
a
b
)
=
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
eebe4142
...
@@ -649,6 +649,7 @@ NonGenerateModuleItem :: { [ModuleItem] }
...
@@ -649,6 +649,7 @@ NonGenerateModuleItem :: { [ModuleItem] }
| "assign" opt(DelayControl) LHSAsgns ";" { map (uncurry $ Assign $2) $3 }
| "assign" opt(DelayControl) LHSAsgns ";" { map (uncurry $ Assign $2) $3 }
| AlwaysKW Stmt { [AlwaysC $1 $2] }
| AlwaysKW Stmt { [AlwaysC $1 $2] }
| "initial" Stmt { [Initial $2] }
| "initial" Stmt { [Initial $2] }
| "final" Stmt { [Final $2] }
| "genvar" Identifiers ";" { map Genvar $2 }
| "genvar" Identifiers ";" { map Genvar $2 }
| "modport" ModportItems ";" { map (uncurry Modport) $2 }
| "modport" ModportItems ";" { map (uncurry Modport) $2 }
| NonDeclPackageItem { map MIPackageItem $1 }
| NonDeclPackageItem { map MIPackageItem $1 }
...
...
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