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
35a75cc4
Commit
35a75cc4
authored
Feb 18, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more proper support for always constructs and event_controls
parent
d47c5493
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
7 deletions
+36
-7
Convert.hs
+2
-1
Language/SystemVerilog/AST.hs
+18
-3
Language/SystemVerilog/Parser/Lex.x
+4
-1
Language/SystemVerilog/Parser/Parse.y
+12
-2
No files found.
Convert.hs
View file @
35a75cc4
...
...
@@ -72,12 +72,13 @@ getStmtLHSs (BlockingAssignment lhs _) = [lhs]
getStmtLHSs
(
NonBlockingAssignment
lhs
_
)
=
[
lhs
]
getStmtLHSs
(
For
_
_
_
stmt
)
=
getStmtLHSs
stmt
getStmtLHSs
(
If
_
s1
s2
)
=
(
getStmtLHSs
s1
)
++
(
getStmtLHSs
s2
)
getStmtLHSs
(
Timing
_
s
)
=
getStmtLHSs
s
getStmtLHSs
(
Null
)
=
[]
getTypeInfoModuleItem
::
ModulePorts
->
ModuleItem
->
TypeInfo
getTypeInfoModuleItem
_
(
Assign
lhs
_
)
=
Map
.
fromList
$
zip
(
getLHSIdentifiers
lhs
)
(
repeat
onlyAsWire
)
getTypeInfoModuleItem
_
(
Always
_
stmt
)
=
getTypeInfoModuleItem
_
(
Always
C
_
stmt
)
=
Map
.
fromList
$
zip
idents
(
repeat
onlyAsReg
)
where
lhss
=
getStmtLHSs
stmt
...
...
Language/SystemVerilog/AST.hs
View file @
35a75cc4
...
...
@@ -15,6 +15,7 @@ module Language.SystemVerilog.AST
,
Localparam
(
..
)
,
IntegerV
(
..
)
,
GenItem
(
..
)
,
AlwaysKW
(
..
)
,
PortBinding
,
Case
,
Range
...
...
@@ -82,7 +83,7 @@ data ModuleItem
|
MIIntegerV
IntegerV
|
PortDecl
Direction
(
Maybe
Range
)
Identifier
|
LocalNet
Type
Identifier
RangesOrAssignment
|
Always
(
Maybe
Sense
)
Stmt
|
Always
C
AlwaysKW
Stmt
|
Assign
LHS
Expr
|
Instance
Identifier
[
PortBinding
]
Identifier
[
PortBinding
]
|
Function
(
Maybe
FuncRet
)
Identifier
[(
Bool
,
BlockItemDeclaration
)]
Stmt
...
...
@@ -90,6 +91,19 @@ data ModuleItem
|
Generate
[
GenItem
]
deriving
Eq
data
AlwaysKW
=
Always
|
AlwaysComb
|
AlwaysFF
|
AlwaysLatch
deriving
Eq
instance
Show
AlwaysKW
where
show
Always
=
"always"
show
AlwaysComb
=
"always_comb"
show
AlwaysFF
=
"always_ff"
show
AlwaysLatch
=
"always_latch"
-- "function inputs and outputs are inferred to be of type reg if no internal
-- data types for the ports are declared"
...
...
@@ -115,8 +129,7 @@ instance Show ModuleItem where
MIIntegerV
nest
->
show
nest
PortDecl
d
r
x
->
printf
"%s %s%s;"
(
show
d
)
(
showRange
r
)
x
LocalNet
t
x
v
->
printf
"%s%s%s;"
(
show
t
)
x
(
showRangesOrAssignment
v
)
Always
Nothing
b
->
printf
"always
\n
%s"
$
indent
$
show
b
Always
(
Just
a
)
b
->
printf
"always @(%s)
\n
%s"
(
show
a
)
$
indent
$
show
b
AlwaysC
k
b
->
printf
"%s %s"
(
show
k
)
(
show
b
)
Assign
a
b
->
printf
"assign %s = %s;"
(
show
a
)
(
show
b
)
Instance
m
params
i
ports
|
null
params
->
printf
"%s %s %s;"
m
i
(
showPorts
show
ports
)
...
...
@@ -290,6 +303,7 @@ data Stmt
|
NonBlockingAssignment
LHS
Expr
|
For
(
Identifier
,
Expr
)
Expr
(
Identifier
,
Expr
)
Stmt
|
If
Expr
Stmt
Stmt
|
Timing
Sense
Stmt
|
Null
deriving
Eq
...
...
@@ -306,6 +320,7 @@ instance Show Stmt where
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
(
If
a
b
Null
)
=
printf
"if (%s)
\n
%s"
(
show
a
)
(
indent
$
show
b
)
show
(
If
a
b
c
)
=
printf
"if (%s)
\n
%s
\n
else
\n
%s"
(
show
a
)
(
indent
$
show
b
)
(
indent
$
show
c
)
show
(
Timing
t
s
)
=
printf
"@(%s) %s"
(
show
t
)
(
show
s
)
show
(
Null
)
=
";"
data
BlockItemDeclaration
...
...
Language/SystemVerilog/Parser/Lex.x
View file @
35a75cc4
...
...
@@ -57,7 +57,10 @@ $decimalDigit = [0-9]
tokens :-
"always" { tok KW_always }
"always" { tok KW_always }
"always_comb" { tok KW_always_comb }
"always_ff" { tok KW_always_ff }
"always_latch" { tok KW_always_latch }
"assign" { tok KW_assign }
"begin" { tok KW_begin }
"case" { tok KW_case }
...
...
Language/SystemVerilog/Parser/Parse.y
View file @
35a75cc4
...
...
@@ -17,7 +17,10 @@ import Language.SystemVerilog.Parser.Tokens
%token
"always" { Token KW_always _ _ }
"always" { Token KW_always _ _ }
"always_comb" { Token KW_always_comb _ _ }
"always_ff" { Token KW_always_ff _ _ }
"always_latch" { Token KW_always_latch _ _ }
"assign" { Token KW_assign _ _ }
"begin" { Token KW_begin _ _ }
"case" { Token KW_case _ _ }
...
...
@@ -228,12 +231,18 @@ ModuleItem :: { [ModuleItem] }
| LocalparamDeclaration { map MILocalparam $1 }
| IntegerDeclaration { map MIIntegerV $1 }
| "assign" LHS "=" Expr ";" { [Assign $2 $4] }
|
"always" opt(EventControl) Stmt { [Always $2 $3
] }
|
AlwaysKW Stmt { [AlwaysC $1 $2
] }
| Identifier ParameterBindings ModuleInstantiations ";" { map (uncurry $ Instance $1 $2) $3 }
| "function" opt(RangeOrType) Identifier FunctionItems Stmt "endfunction" { [Function $2 $3 $4 $5] }
| "genvar" Identifiers ";" { map Genvar $2 }
| "generate" GenItems "endgenerate" { [Generate $2] }
AlwaysKW :: { AlwaysKW }
: "always" { Always }
| "always_comb" { AlwaysComb }
| "always_ff" { AlwaysFF }
| "always_latch" { AlwaysLatch }
ModuleInstantiations :: { [(Identifier, [PortBinding])] }
: ModuleInstantiation { [$1] }
| ModuleInstantiations "," ModuleInstantiation { $1 ++ [$3] }
...
...
@@ -346,6 +355,7 @@ Stmt :: { Stmt }
| LHS "=" Expr ";" { BlockingAssignment $1 $3 }
| LHS "<=" Expr ";" { NonBlockingAssignment $1 $3 }
| "case" "(" Expr ")" Cases opt(CaseDefault) "endcase" { Case $3 $5 $6 }
| EventControl Stmt { Timing $1 $2 }
BlockItemDeclarations :: { [BlockItemDeclaration] }
: BlockItemDeclaration { $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