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
1aa30ea8
Commit
1aa30ea8
authored
Jul 27, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow genvars to be shadowed
parent
e0d425d9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
11 deletions
+64
-11
src/Convert/DuplicateGenvar.hs
+1
-1
src/Convert/Scoper.hs
+13
-1
src/Convert/TypeOf.hs
+15
-9
test/core/duplicate_genvar_shadow.sv
+26
-0
test/core/duplicate_genvar_shadow.v
+9
-0
No files found.
src/Convert/DuplicateGenvar.hs
View file @
1aa30ea8
...
@@ -18,7 +18,7 @@ traverseDescription = partScoper return traverseModuleItemM return return
...
@@ -18,7 +18,7 @@ traverseDescription = partScoper return traverseModuleItemM return return
traverseModuleItemM
::
ModuleItem
->
Scoper
()
ModuleItem
traverseModuleItemM
::
ModuleItem
->
Scoper
()
ModuleItem
traverseModuleItemM
(
Genvar
x
)
=
do
traverseModuleItemM
(
Genvar
x
)
=
do
details
<-
lookup
Elem
M
x
details
<-
lookup
LocalIdent
M
x
if
details
==
Nothing
if
details
==
Nothing
then
insertElem
x
()
>>
return
(
Genvar
x
)
then
insertElem
x
()
>>
return
(
Genvar
x
)
else
return
$
Generate
[]
else
return
$
Generate
[]
...
...
src/Convert/Scoper.hs
View file @
1aa30ea8
...
@@ -56,6 +56,8 @@ module Convert.Scoper
...
@@ -56,6 +56,8 @@ module Convert.Scoper
,
procedureLocM
,
procedureLocM
,
isLoopVar
,
isLoopVar
,
isLoopVarM
,
isLoopVarM
,
loopVarDepth
,
loopVarDepthM
,
lookupLocalIdent
,
lookupLocalIdent
,
lookupLocalIdentM
,
lookupLocalIdentM
,
scopeModuleItemT
,
scopeModuleItemT
...
@@ -65,7 +67,7 @@ module Convert.Scoper
...
@@ -65,7 +67,7 @@ module Convert.Scoper
import
Control.Monad.State.Strict
import
Control.Monad.State.Strict
import
Data.Functor.Identity
(
runIdentity
)
import
Data.Functor.Identity
(
runIdentity
)
import
Data.List
(
partition
)
import
Data.List
(
findIndices
,
partition
)
import
Data.Maybe
(
isNothing
)
import
Data.Maybe
(
isNothing
)
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Map.Strict
as
Map
...
@@ -357,6 +359,16 @@ isLoopVar scopes x = any matches $ sCurrent scopes
...
@@ -357,6 +359,16 @@ isLoopVar scopes x = any matches $ sCurrent scopes
isLoopVarM
::
Monad
m
=>
Identifier
->
ScoperT
a
m
Bool
isLoopVarM
::
Monad
m
=>
Identifier
->
ScoperT
a
m
Bool
isLoopVarM
=
embedScopes
isLoopVar
isLoopVarM
=
embedScopes
isLoopVar
loopVarDepth
::
Scopes
a
->
Identifier
->
Maybe
Int
loopVarDepth
scopes
x
=
case
findIndices
matches
$
sCurrent
scopes
of
[]
->
Nothing
indices
->
Just
$
last
indices
where
matches
=
(
==
x
)
.
tierIndex
loopVarDepthM
::
Monad
m
=>
Identifier
->
ScoperT
a
m
(
Maybe
Int
)
loopVarDepthM
=
embedScopes
loopVarDepth
evalScoper
evalScoper
::
MapperM
(
Scoper
a
)
Decl
::
MapperM
(
Scoper
a
)
Decl
->
MapperM
(
Scoper
a
)
ModuleItem
->
MapperM
(
Scoper
a
)
ModuleItem
...
...
src/Convert/TypeOf.hs
View file @
1aa30ea8
...
@@ -157,18 +157,24 @@ traverseTypeM other =
...
@@ -157,18 +157,24 @@ traverseTypeM other =
-- attempts to find the given (potentially hierarchical or generate-scoped)
-- attempts to find the given (potentially hierarchical or generate-scoped)
-- expression in the available scope information
-- expression in the available scope information
lookupTypeOf
::
Expr
->
ST
Type
lookupTypeOf
::
Expr
->
ST
Type
lookupTypeOf
expr
@
(
Ident
x
)
=
do
details
<-
lookupElemM
x
loopVar
<-
loopVarDepthM
x
return
$
case
details
of
Nothing
->
if
loopVar
==
Nothing
then
TypeOf
expr
else
IntegerAtom
TInteger
Unspecified
Just
(
accesses
,
replacements
,
typ
)
->
if
maybe
True
(
length
accesses
>
)
loopVar
then
replaceInType
replacements
typ
else
IntegerAtom
TInteger
Unspecified
lookupTypeOf
expr
=
do
lookupTypeOf
expr
=
do
details
<-
lookupElemM
expr
details
<-
lookupElemM
expr
case
details
of
return
$
case
details
of
Nothing
->
case
expr
of
Nothing
->
TypeOf
expr
Ident
x
->
do
isGenvar
<-
isLoopVarM
x
return
$
if
isGenvar
then
IntegerAtom
TInteger
Unspecified
else
TypeOf
expr
_
->
return
$
TypeOf
expr
Just
(
_
,
replacements
,
typ
)
->
Just
(
_
,
replacements
,
typ
)
->
re
turn
$
re
placeInType
replacements
typ
replaceInType
replacements
typ
-- determines the type of an expression based on the available scope information
-- determines the type of an expression based on the available scope information
-- according the semantics defined in IEEE 1800-2017, especially Section 11.6
-- according the semantics defined in IEEE 1800-2017, especially Section 11.6
...
...
test/core/duplicate_genvar_shadow.sv
0 → 100644
View file @
1aa30ea8
`define
DUMP
(
L
)
initial
$
display
(
`
"L %0d`"
,
$
bits
(
i
))
;
module
top
;
genvar
i
;
for
(
i
=
0
;
i
<
1
;
i
=
1
)
begin
`DUMP
(
A
)
if
(
1
)
begin
localparam
[
9
:
0
]
i
=
1
;
`DUMP
(
B
)
if
(
1
)
begin
genvar
i
;
for
(
i
=
0
;
i
<
1
;
i
=
1
)
begin
`DUMP
(
C
)
if
(
1
)
begin
localparam
[
5
:
0
]
i
=
1
;
`DUMP
(
D
)
if
(
1
)
begin
genvar
i
;
for
(
i
=
0
;
i
<
1
;
i
=
1
)
`DUMP
(
E
)
end
end
end
end
end
end
endmodule
test/core/duplicate_genvar_shadow.v
0 → 100644
View file @
1aa30ea8
module
top
;
initial
begin
$
display
(
"A %0d"
,
32
)
;
$
display
(
"B %0d"
,
10
)
;
$
display
(
"C %0d"
,
32
)
;
$
display
(
"D %0d"
,
6
)
;
$
display
(
"E %0d"
,
32
)
;
end
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