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
8f7968bf
Commit
8f7968bf
authored
Aug 31, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support data declarations with automatic lifetime (closes #20)
parent
243f7736
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
9 deletions
+53
-9
src/Language/SystemVerilog/Parser/Parse.y
+1
-0
src/Language/SystemVerilog/Parser/ParseDecl.hs
+16
-9
test/basic/data_lifetime.sv
+17
-0
test/basic/data_lifetime.v
+19
-0
No files found.
src/Language/SystemVerilog/Parser/Parse.y
View file @
8f7968bf
...
...
@@ -427,6 +427,7 @@ DeclOrStmtToken :: { DeclToken }
| PartialType { DTType $1 }
| "." Identifier { DTDot $2 }
| Signing { DTSigning $1 }
| Lifetime { DTLifetime $1 }
| Identifier "::" Identifier { DTPSIdent $1 $3 }
VariablePortIdentifiers :: { [(Identifier, Maybe Expr)] }
...
...
src/Language/SystemVerilog/Parser/ParseDecl.hs
View file @
8f7968bf
...
...
@@ -22,11 +22,10 @@
- increasingly convoluted grammars, this became more and more untenable as I
- added support for more SystemVerilog constructs.
-
- Because of how liberal this parser is, the parser will accept some
- syntactically invalid files. In the future, we may add some basic
- type-checking to complain about malformed input files. However, we generally
- assume that users have tested their code with commercial simulator before
- running it through our tool.
- This parser is very liberal, and so accepts some syntactically invalid files.
- In the future, we may add some basic type-checking to complain about
- malformed input files. However, we generally assume that users have tested
- their code with a commercial simulator before running it through our tool.
-}
module
Language.SystemVerilog.Parser.ParseDecl
...
...
@@ -60,6 +59,7 @@ data DeclToken
|
DTConcat
[
LHS
]
|
DTDot
Identifier
|
DTSigning
Signing
|
DTLifetime
Lifetime
deriving
(
Show
,
Eq
)
...
...
@@ -263,12 +263,15 @@ parseDTsAsComponents tokens =
parseDTsAsComponent
::
[
DeclToken
]
->
(
Component
,
[
DeclToken
])
parseDTsAsComponent
[]
=
error
"parseDTsAsComponent unexpected end of tokens"
parseDTsAsComponent
l0
=
(
component
,
l4
)
if
l
/=
Nothing
&&
l
/=
Just
Automatic
then
error
$
"unexpected non-automatic lifetime: "
++
show
l0
else
(
component
,
l5
)
where
(
dir
,
l1
)
=
takeDir
l0
(
tf
,
l2
)
=
takeType
l1
(
rs
,
l3
)
=
takeRanges
l2
(
tps
,
l4
)
=
takeTrips
l3
True
(
l
,
l2
)
=
takeLifetime
l1
(
tf
,
l3
)
=
takeType
l2
(
rs
,
l4
)
=
takeRanges
l3
(
tps
,
l5
)
=
takeTrips
l4
True
component
=
(
dir
,
tf
rs
,
tps
)
...
...
@@ -312,6 +315,10 @@ takeDir :: [DeclToken] -> (Direction, [DeclToken])
takeDir
(
DTDir
dir
:
rest
)
=
(
dir
,
rest
)
takeDir
rest
=
(
Local
,
rest
)
takeLifetime
::
[
DeclToken
]
->
(
Maybe
Lifetime
,
[
DeclToken
])
takeLifetime
(
DTLifetime
l
:
rest
)
=
(
Just
l
,
rest
)
takeLifetime
rest
=
(
Nothing
,
rest
)
takeType
::
[
DeclToken
]
->
([
Range
]
->
Type
,
[
DeclToken
])
takeType
(
DTIdent
a
:
DTDot
b
:
rest
)
=
(
InterfaceT
a
(
Just
b
),
rest
)
takeType
(
DTType
tf
:
DTSigning
sg
:
rest
)
=
(
tf
sg
,
rest
)
...
...
test/basic/data_lifetime.sv
0 → 100644
View file @
8f7968bf
module
top
;
function
automatic
logic
[
31
:
0
]
lcg
(
input
logic
[
31
:
0
]
x
)
;
automatic
logic
[
3
:
0
]
temp
;
lcg
=
x
;
for
(
temp
=
0
;
temp
<
3
;
temp
++
)
begin
lcg
*=
1664525
;
lcg
+=
1013904223
;
end
endfunction
initial
$
display
(
lcg
(
0
))
;
initial
$
display
(
lcg
(
1
))
;
initial
$
display
(
lcg
(
2
))
;
initial
$
display
(
lcg
(
3
))
;
initial
$
display
(
lcg
(
4
))
;
initial
$
display
(
lcg
(
5
))
;
endmodule
test/basic/data_lifetime.v
0 → 100644
View file @
8f7968bf
module
top
;
function
automatic
[
31
:
0
]
lcg
(
input
[
31
:
0
]
x
)
;
begin
:
foo
reg
[
3
:
0
]
temp
;
lcg
=
x
;
for
(
temp
=
0
;
temp
<
3
;
temp
++
)
begin
lcg
*=
1664525
;
lcg
+=
1013904223
;
end
end
endfunction
initial
$
display
(
lcg
(
0
))
;
initial
$
display
(
lcg
(
1
))
;
initial
$
display
(
lcg
(
2
))
;
initial
$
display
(
lcg
(
3
))
;
initial
$
display
(
lcg
(
4
))
;
initial
$
display
(
lcg
(
5
))
;
endmodule
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