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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
18 deletions
+62
-18
src/Language/SystemVerilog/Parser/Parse.y
+9
-8
src/Language/SystemVerilog/Parser/ParseDecl.hs
+17
-10
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
...
@@ -419,14 +419,15 @@ DeclOrStmtTokens(delim) :: { [DeclToken] }
...
@@ -419,14 +419,15 @@ DeclOrStmtTokens(delim) :: { [DeclToken] }
| "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] }
| "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] }
DeclOrStmtToken :: { DeclToken }
DeclOrStmtToken :: { DeclToken }
: "," { DTComma }
: "," { DTComma }
| PartSelect { DTRange $1 }
| PartSelect { DTRange $1 }
| Identifier { DTIdent $1 }
| Identifier { DTIdent $1 }
| Direction { DTDir $1 }
| Direction { DTDir $1 }
| "[" Expr "]" { DTBit $2 }
| "[" Expr "]" { DTBit $2 }
| "{" LHSs "}" { DTConcat $2 }
| "{" LHSs "}" { DTConcat $2 }
| PartialType { DTType $1 }
| PartialType { DTType $1 }
| "." Identifier { DTDot $2 }
| "." Identifier { DTDot $2 }
| Signing { DTSigning $1 }
| Signing { DTSigning $1 }
| Lifetime { DTLifetime $1 }
| Identifier "::" Identifier { DTPSIdent $1 $3 }
| Identifier "::" Identifier { DTPSIdent $1 $3 }
VariablePortIdentifiers :: { [(Identifier, Maybe Expr)] }
VariablePortIdentifiers :: { [(Identifier, Maybe Expr)] }
...
...
src/Language/SystemVerilog/Parser/ParseDecl.hs
View file @
8f7968bf
...
@@ -22,11 +22,10 @@
...
@@ -22,11 +22,10 @@
- increasingly convoluted grammars, this became more and more untenable as I
- increasingly convoluted grammars, this became more and more untenable as I
- added support for more SystemVerilog constructs.
- added support for more SystemVerilog constructs.
-
-
- Because of how liberal this parser is, the parser will accept some
- This parser is very liberal, and so accepts some syntactically invalid files.
- syntactically invalid files. In the future, we may add some basic
- In the future, we may add some basic type-checking to complain about
- type-checking to complain about malformed input files. However, we generally
- malformed input files. However, we generally assume that users have tested
- assume that users have tested their code with commercial simulator before
- their code with a commercial simulator before running it through our tool.
- running it through our tool.
-}
-}
module
Language.SystemVerilog.Parser.ParseDecl
module
Language.SystemVerilog.Parser.ParseDecl
...
@@ -60,6 +59,7 @@ data DeclToken
...
@@ -60,6 +59,7 @@ data DeclToken
|
DTConcat
[
LHS
]
|
DTConcat
[
LHS
]
|
DTDot
Identifier
|
DTDot
Identifier
|
DTSigning
Signing
|
DTSigning
Signing
|
DTLifetime
Lifetime
deriving
(
Show
,
Eq
)
deriving
(
Show
,
Eq
)
...
@@ -263,12 +263,15 @@ parseDTsAsComponents tokens =
...
@@ -263,12 +263,15 @@ parseDTsAsComponents tokens =
parseDTsAsComponent
::
[
DeclToken
]
->
(
Component
,
[
DeclToken
])
parseDTsAsComponent
::
[
DeclToken
]
->
(
Component
,
[
DeclToken
])
parseDTsAsComponent
[]
=
error
"parseDTsAsComponent unexpected end of tokens"
parseDTsAsComponent
[]
=
error
"parseDTsAsComponent unexpected end of tokens"
parseDTsAsComponent
l0
=
parseDTsAsComponent
l0
=
(
component
,
l4
)
if
l
/=
Nothing
&&
l
/=
Just
Automatic
then
error
$
"unexpected non-automatic lifetime: "
++
show
l0
else
(
component
,
l5
)
where
where
(
dir
,
l1
)
=
takeDir
l0
(
dir
,
l1
)
=
takeDir
l0
(
tf
,
l2
)
=
takeType
l1
(
l
,
l2
)
=
takeLifetime
l1
(
rs
,
l3
)
=
takeRanges
l2
(
tf
,
l3
)
=
takeType
l2
(
tps
,
l4
)
=
takeTrips
l3
True
(
rs
,
l4
)
=
takeRanges
l3
(
tps
,
l5
)
=
takeTrips
l4
True
component
=
(
dir
,
tf
rs
,
tps
)
component
=
(
dir
,
tf
rs
,
tps
)
...
@@ -312,6 +315,10 @@ takeDir :: [DeclToken] -> (Direction, [DeclToken])
...
@@ -312,6 +315,10 @@ takeDir :: [DeclToken] -> (Direction, [DeclToken])
takeDir
(
DTDir
dir
:
rest
)
=
(
dir
,
rest
)
takeDir
(
DTDir
dir
:
rest
)
=
(
dir
,
rest
)
takeDir
rest
=
(
Local
,
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
::
[
DeclToken
]
->
([
Range
]
->
Type
,
[
DeclToken
])
takeType
(
DTIdent
a
:
DTDot
b
:
rest
)
=
(
InterfaceT
a
(
Just
b
),
rest
)
takeType
(
DTIdent
a
:
DTDot
b
:
rest
)
=
(
InterfaceT
a
(
Just
b
),
rest
)
takeType
(
DTType
tf
:
DTSigning
sg
:
rest
)
=
(
tf
sg
,
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