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
e4adf6a7
Commit
e4adf6a7
authored
Jan 25, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply reordering in generate blocks
parent
8c967ea9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
5 deletions
+41
-5
src/Convert/AsgnOp.hs
+1
-1
src/Convert/Package.hs
+15
-2
src/Convert/Traverse.hs
+1
-2
test/basic/reorder.sv
+11
-0
test/basic/reorder.v
+13
-0
No files found.
src/Convert/AsgnOp.hs
View file @
e4adf6a7
...
...
@@ -15,7 +15,7 @@ convert :: [AST] -> [AST]
convert
=
map
$
traverseDescriptions
$
traverseModuleItems
$
(
traverseStmts
convertStmt
.
traverseGenItems
convertGenItem
.
traverseGenItems
(
traverseNestedGenItems
convertGenItem
)
)
convertGenItem
::
GenItem
->
GenItem
...
...
src/Convert/Package.hs
View file @
e4adf6a7
...
...
@@ -407,13 +407,27 @@ convertDescription _ other = other
-- attempt to fix simple declaration order issues
reorderItems
::
[
ModuleItem
]
->
[
ModuleItem
]
reorderItems
items
=
addItems
localPIs
Set
.
empty
(
map
addUsedPIs
items
)
addItems
localPIs
Set
.
empty
$
map
addUsedPIs
$
map
(
traverseGenItems
$
traverseNestedGenItems
reorderGenItem
)
items
where
localPIs
=
Map
.
fromList
$
concat
$
mapMaybe
toPIElem
items
toPIElem
::
ModuleItem
->
Maybe
[(
Identifier
,
PackageItem
)]
toPIElem
(
MIPackageItem
item
)
=
Just
$
map
(,
item
)
(
piNames
item
)
toPIElem
_
=
Nothing
-- attempt to declaration order issues within generate blocks
reorderGenItem
::
GenItem
->
GenItem
reorderGenItem
(
GenBlock
name
genItems
)
=
GenBlock
name
$
map
unwrap
$
reorderItems
$
map
wrap
genItems
where
wrap
::
GenItem
->
ModuleItem
wrap
(
GenModuleItem
item
)
=
item
wrap
item
=
Generate
[
item
]
unwrap
::
ModuleItem
->
GenItem
unwrap
(
Generate
[
item
])
=
item
unwrap
item
=
GenModuleItem
item
reorderGenItem
item
=
item
-- iteratively inserts missing package items exactly where they are needed
addItems
::
PIs
->
Idents
->
[(
ModuleItem
,
Idents
)]
->
[
ModuleItem
]
addItems
pis
existingPIs
((
item
,
usedPIs
)
:
items
)
=
...
...
@@ -523,7 +537,6 @@ traverseStmtIdentsM identMapper = fullMapper
fullMapper
=
stmtMapper
>=>
traverseStmtExprsM
(
traverseExprIdentsM
identMapper
)
>=>
traverseStmtLHSsM
(
traverseLHSIdentsM
identMapper
)
>=>
traverseSinglyNestedStmtsM
fullMapper
stmtMapper
(
Subroutine
(
Ident
x
)
args
)
=
identMapper
x
>>=
\
x'
->
return
$
Subroutine
(
Ident
x'
)
args
stmtMapper
other
=
return
other
...
...
src/Convert/Traverse.hs
View file @
e4adf6a7
...
...
@@ -978,9 +978,8 @@ collectTypesM = collectTypesM' IncludeParamTypes
traverseGenItemsM
::
Monad
m
=>
MapperM
m
GenItem
->
MapperM
m
ModuleItem
traverseGenItemsM
mapper
=
moduleItemMapper
where
fullMapper
=
traverseNestedGenItemsM
mapper
moduleItemMapper
(
Generate
genItems
)
=
mapM
fullM
apper
genItems
>>=
return
.
Generate
mapM
m
apper
genItems
>>=
return
.
Generate
moduleItemMapper
other
=
return
other
traverseGenItems
::
Mapper
GenItem
->
Mapper
ModuleItem
...
...
test/basic/reorder.sv
View file @
e4adf6a7
...
...
@@ -2,4 +2,15 @@ module top;
assign
arr
[
0
][
0
]
=
1
;
logic
[
1
:
0
][
2
:
0
]
arr
;
initial
$
display
(
"%b"
,
arr
)
;
parameter
YES
=
1
;
if
(
YES
)
begin
:
blk
assign
brr
[
0
][
0
]
=
1
;
logic
[
2
:
0
][
3
:
0
]
brr
;
initial
$
display
(
"%b"
,
brr
)
;
if
(
YES
)
begin
:
blk2
assign
crr
[
0
][
0
]
=
1
;
logic
[
3
:
0
][
4
:
0
]
crr
;
initial
$
display
(
"%b"
,
crr
)
;
end
end
endmodule
test/basic/reorder.v
View file @
e4adf6a7
...
...
@@ -2,4 +2,17 @@ module top;
wire
[
5
:
0
]
arr
;
assign
arr
[
0
]
=
1
;
initial
$
display
(
"%b"
,
arr
)
;
parameter
YES
=
1
;
generate
if
(
YES
)
begin
:
blk
wire
[
11
:
0
]
brr
;
assign
brr
[
0
]
=
1
;
initial
$
display
(
"%b"
,
brr
)
;
if
(
YES
)
begin
:
blk2
assign
crr
[
0
]
=
1
;
wire
[
19
:
0
]
crr
;
initial
$
display
(
"%b"
,
crr
)
;
end
end
endgenerate
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