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
ff812671
Commit
ff812671
authored
Mar 04, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added conversion for genvar iteration AsgnOps
parent
460c0ee4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
17 deletions
+68
-17
src/Convert.hs
+3
-1
src/Convert/AsgnOp.hs
+22
-0
src/Convert/Traverse.hs
+42
-16
sv2v.cabal
+1
-0
No files found.
src/Convert.hs
View file @
ff812671
...
...
@@ -10,6 +10,7 @@ import Language.SystemVerilog.AST
import
Job
(
Target
(
..
))
import
qualified
Convert.AlwaysKW
import
qualified
Convert.AsgnOp
import
qualified
Convert.CaseKW
import
qualified
Convert.Enum
import
qualified
Convert.Logic
...
...
@@ -23,7 +24,8 @@ type Phase = AST -> AST
phases
::
Target
->
[
Phase
]
phases
YOSYS
=
[
Convert
.
Enum
.
convert
[
Convert
.
AsgnOp
.
convert
,
Convert
.
Enum
.
convert
,
Convert
.
PackedArray
.
convert
,
Convert
.
StarPort
.
convert
,
Convert
.
Typedef
.
convert
...
...
src/Convert/AsgnOp.hs
0 → 100644
View file @
ff812671
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
- Conversion for binary assignment operators, which only appear in generate for
- loops. We simply elaborate them in the obvious manner.
-}
module
Convert.AsgnOp
(
convert
)
where
import
Convert.Traverse
import
Language.SystemVerilog.AST
convert
::
AST
->
AST
convert
=
traverseDescriptions
$
traverseModuleItems
$
traverseGenItems
convertGenItem
convertGenItem
::
GenItem
->
GenItem
convertGenItem
(
GenFor
a
b
(
ident
,
AsgnOp
op
,
expr
)
c
d
)
=
GenFor
a
b
(
ident
,
AsgnOpEq
,
BinOp
op
(
Ident
ident
)
expr
)
c
d
convertGenItem
other
=
other
src/Convert/Traverse.hs
View file @
ff812671
...
...
@@ -33,6 +33,9 @@ module Convert.Traverse
,
traverseTypesM
,
traverseTypes
,
collectTypesM
,
traverseGenItemsM
,
traverseGenItems
,
collectGenItemsM
)
where
import
Data.Maybe
(
fromJust
)
...
...
@@ -70,28 +73,15 @@ traverseModuleItemsM mapper (Part kw name ports items) =
mapM
fullMapper
items
>>=
return
.
Part
kw
name
ports
where
fullMapper
(
Generate
genItems
)
=
mapM
g
enItemMapper
genItems
>>=
mapper
.
Generate
mapM
fullG
enItemMapper
genItems
>>=
mapper
.
Generate
fullMapper
other
=
mapper
other
-- maps all ModuleItems within the given GenItem
genItemMapper
(
GenBlock
x
subItems
)
=
mapM
genItemMapper
subItems
>>=
return
.
GenBlock
x
genItemMapper
(
GenFor
a
b
c
d
subItems
)
=
mapM
genItemMapper
subItems
>>=
return
.
GenFor
a
b
c
d
genItemMapper
(
GenIf
e
i1
i2
)
=
do
i1'
<-
genItemMapper
i1
i2'
<-
genItemMapper
i2
return
$
GenIf
e
i1'
i2'
genItemMapper
(
GenNull
)
=
return
GenNull
fullGenItemMapper
=
traverseNestedGenItemsM
genItemMapper
genItemMapper
(
GenModuleItem
moduleItem
)
=
do
moduleItem'
<-
fullMapper
moduleItem
return
$
case
moduleItem'
of
Generate
subItems
->
GenBlock
Nothing
subItems
_
->
GenModuleItem
moduleItem'
genItemMapper
(
GenCase
e
cases
def
)
=
do
caseItems
<-
mapM
(
genItemMapper
.
snd
)
cases
let
cases'
=
zip
(
map
fst
cases
)
caseItems
def'
<-
maybeDo
genItemMapper
def
return
$
GenCase
e
cases'
def'
genItemMapper
other
=
return
other
traverseModuleItemsM
_
orig
=
return
orig
traverseModuleItems
::
Mapper
ModuleItem
->
Mapper
Description
...
...
@@ -354,3 +344,39 @@ traverseTypes :: Mapper Type -> Mapper ModuleItem
traverseTypes
=
unmonad
traverseTypesM
collectTypesM
::
Monad
m
=>
CollectorM
m
Type
->
CollectorM
m
ModuleItem
collectTypesM
=
collectify
traverseTypesM
traverseGenItemsM
::
Monad
m
=>
MapperM
m
GenItem
->
MapperM
m
ModuleItem
traverseGenItemsM
mapper
=
moduleItemMapper
where
fullMapper
=
traverseNestedGenItemsM
mapper
moduleItemMapper
(
Generate
genItems
)
=
mapM
fullMapper
genItems
>>=
return
.
Generate
moduleItemMapper
other
=
return
other
traverseGenItems
::
Mapper
GenItem
->
Mapper
ModuleItem
traverseGenItems
=
unmonad
traverseGenItemsM
collectGenItemsM
::
Monad
m
=>
CollectorM
m
GenItem
->
CollectorM
m
ModuleItem
collectGenItemsM
=
collectify
traverseGenItemsM
-- traverses all GenItems within a given GenItem, but doesn't inspect within
-- GenModuleItems
traverseNestedGenItemsM
::
Monad
m
=>
MapperM
m
GenItem
->
MapperM
m
GenItem
traverseNestedGenItemsM
mapper
=
fullMapper
where
fullMapper
genItem
=
gim
genItem
>>=
mapper
gim
(
GenBlock
x
subItems
)
=
mapM
fullMapper
subItems
>>=
return
.
GenBlock
x
gim
(
GenFor
a
b
c
d
subItems
)
=
mapM
fullMapper
subItems
>>=
return
.
GenFor
a
b
c
d
gim
(
GenIf
e
i1
i2
)
=
do
i1'
<-
fullMapper
i1
i2'
<-
fullMapper
i2
return
$
GenIf
e
i1'
i2'
gim
(
GenCase
e
cases
def
)
=
do
caseItems
<-
mapM
(
fullMapper
.
snd
)
cases
let
cases'
=
zip
(
map
fst
cases
)
caseItems
def'
<-
maybeDo
fullMapper
def
return
$
GenCase
e
cases'
def'
gim
(
GenModuleItem
moduleItem
)
=
return
$
GenModuleItem
moduleItem
gim
(
GenNull
)
=
return
GenNull
sv2v.cabal
View file @
ff812671
...
...
@@ -41,6 +41,7 @@ executable sv2v
-- Conversion modules
Convert
Convert.AlwaysKW
Convert.AsgnOp
Convert.CaseKW
Convert.Enum
Convert.Logic
...
...
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