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
ecf047e3
Commit
ecf047e3
authored
Jun 04, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix declaration order of nested package items
parent
b6f4f690
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
12 deletions
+39
-12
src/Convert/NestPI.hs
+21
-12
test/basic/nest_order.sv
+11
-0
test/basic/nest_order.v
+7
-0
No files found.
src/Convert/NestPI.hs
View file @
ecf047e3
...
@@ -49,24 +49,33 @@ convertDescription pis (orig @ Part{}) =
...
@@ -49,24 +49,33 @@ convertDescription pis (orig @ Part{}) =
Part
attrs
extern
kw
lifetime
name
ports
items'
Part
attrs
extern
kw
lifetime
name
ports
items'
where
where
Part
attrs
extern
kw
lifetime
name
ports
items
=
orig
Part
attrs
extern
kw
lifetime
name
ports
items
=
orig
existingPIs
=
execWriter
$
collectModuleItemsM
collectPIsM
orig
items'
=
addItems
pis
Set
.
empty
items
runner
f
=
execWriter
$
collectModuleItemsM
f
orig
convertDescription
_
other
=
other
usedPIs
=
Set
.
unions
$
map
runner
$
-- iteratively inserts missing package items exactly where they are needed
addItems
::
PIs
->
Idents
->
[
ModuleItem
]
->
[
ModuleItem
]
addItems
pis
existingPIs
(
item
:
items
)
=
if
not
$
Set
.
disjoint
existingPIs
thisPI
then
-- this item was re-imported earlier in the module
addItems
pis
existingPIs
items
else
if
null
itemsToAdd
then
-- this item has no additional dependencies
item
:
addItems
pis
(
Set
.
union
existingPIs
thisPI
)
items
else
-- this item has at least one un-met dependency
addItems
pis
existingPIs
(
head
itemsToAdd
:
item
:
items
)
where
thisPI
=
execWriter
$
collectPIsM
item
runner
f
=
execWriter
$
collectNestedModuleItemsM
f
item
usedPIs
=
Set
.
unions
$
map
runner
[
collectStmtsM
collectSubroutinesM
[
collectStmtsM
collectSubroutinesM
,
collectTypesM
$
collectNestedTypesM
collectTypenamesM
,
collectTypesM
$
collectNestedTypesM
collectTypenamesM
,
collectExprsM
$
collectNestedExprsM
collectIdentsM
,
collectExprsM
$
collectNestedExprsM
collectIdentsM
]
]
neededPIs
=
Set
.
difference
usedPIs
existingPIs
neededPIs
=
Set
.
difference
usedPIs
existingPIs
newItems
=
map
MIPackageItem
$
Map
.
elems
$
itemsToAdd
=
map
MIPackageItem
$
Map
.
elems
$
Map
.
restrictKeys
pis
neededPIs
Map
.
restrictKeys
pis
neededPIs
-- place data declarations at the beginning to obey declaration
addItems
_
_
[]
=
[]
-- ordering; everything else can go at the end
newItemsBefore
=
filter
isDecl
newItems
newItemsAfter
=
filter
(
not
.
isDecl
)
newItems
items'
=
newItemsBefore
++
items
++
newItemsAfter
isDecl
(
MIPackageItem
(
Decl
{}))
=
True
isDecl
_
=
False
convertDescription
_
other
=
other
-- writes down the names of package items
-- writes down the names of package items
collectPIsM
::
ModuleItem
->
Writer
Idents
()
collectPIsM
::
ModuleItem
->
Writer
Idents
()
...
...
test/basic/nest_order.sv
0 → 100644
View file @
ecf047e3
localparam
Z
=
1
;
localparam
Y
=
5
'
(
Z
)
;
localparam
X
=
5
'
(
Y
)
;
module
top
;
initial
begin
$
display
(
"%b"
,
X
)
;
$
display
(
"%b"
,
Y
)
;
$
display
(
"%b"
,
Z
)
;
end
endmodule
test/basic/nest_order.v
0 → 100644
View file @
ecf047e3
module
top
;
initial
begin
$
display
(
"%b"
,
5'b1
)
;
$
display
(
"%b"
,
5'b1
)
;
$
display
(
"%b"
,
32'b1
)
;
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