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
d847fdfa
Commit
d847fdfa
authored
Feb 08, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split phases into sections
parent
5c263298
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
36 deletions
+48
-36
src/Convert.hs
+38
-29
src/Convert/Jump.hs
+2
-3
src/Convert/Logic.hs
+4
-2
src/Convert/RemoveComments.hs
+4
-2
No files found.
src/Convert.hs
View file @
d847fdfa
...
...
@@ -51,15 +51,19 @@ import qualified Convert.Unsigned
import
qualified
Convert.Wildcard
type
Phase
=
[
AST
]
->
[
AST
]
type
Selector
=
Job
.
Exclude
->
Phase
->
Phase
phases
::
[
Job
.
Exclude
]
->
[
Phase
]
phases
excludes
=
finalPhases
::
Selector
->
[
Phase
]
finalPhases
_
=
[
Convert
.
NamedBlock
.
convert
,
Convert
.
DuplicateGenvar
.
convert
]
mainPhases
::
Selector
->
[
Phase
]
mainPhases
selectExclude
=
[
Convert
.
AsgnOp
.
convert
,
Convert
.
NamedBlock
.
convert
,
selectExclude
(
Job
.
Assert
,
Convert
.
Assertion
.
convert
)
,
Convert
.
BlockDecl
.
convert
,
Convert
.
DuplicateGenvar
.
convert
,
selectExclude
(
Job
.
Logic
,
Convert
.
Logic
.
convert
)
,
selectExclude
Job
.
Logic
Convert
.
Logic
.
convert
,
Convert
.
FuncRet
.
convert
,
Convert
.
FuncRoutine
.
convert
,
Convert
.
EmptyArgs
.
convert
...
...
@@ -67,7 +71,6 @@ phases excludes =
,
Convert
.
Inside
.
convert
,
Convert
.
IntTypes
.
convert
,
Convert
.
KWArgs
.
convert
,
Convert
.
LogOp
.
convert
,
Convert
.
MultiplePacked
.
convert
,
Convert
.
UnbasedUnsized
.
convert
,
Convert
.
Cast
.
convert
...
...
@@ -79,39 +82,45 @@ phases excludes =
,
Convert
.
Struct
.
convert
,
Convert
.
TFBlock
.
convert
,
Convert
.
Typedef
.
convert
,
Convert
.
Unique
.
convert
,
Convert
.
UnpackedArray
.
convert
,
Convert
.
Unsigned
.
convert
,
Convert
.
Wildcard
.
convert
,
Convert
.
Enum
.
convert
,
Convert
.
ForDecl
.
convert
,
Convert
.
Jump
.
convert
,
Convert
.
Foreach
.
convert
,
Convert
.
StringParam
.
convert
,
selectExclude
(
Job
.
Interface
,
Convert
.
Interface
.
convert
)
,
Convert
.
StarPort
.
convert
,
selectExclude
(
Job
.
Always
,
Convert
.
AlwaysKW
.
convert
)
,
selectExclude
(
Job
.
Succinct
,
Convert
.
RemoveComments
.
convert
)
,
selectExclude
Job
.
Interface
Convert
.
Interface
.
convert
,
selectExclude
Job
.
Succinct
Convert
.
RemoveComments
.
convert
]
where
selectExclude
::
(
Job
.
Exclude
,
Phase
)
->
Phase
selectExclude
(
exclude
,
phase
)
=
if
elem
exclude
excludes
then
id
else
phase
run
::
[
Job
.
Exclude
]
->
Phase
run
excludes
=
foldr
(
.
)
id
$
phases
excludes
initialPhases
::
Selector
->
[
Phase
]
initialPhases
selectExclude
=
[
Convert
.
Jump
.
convert
,
Convert
.
Unique
.
convert
,
Convert
.
LogOp
.
convert
,
Convert
.
Foreach
.
convert
,
Convert
.
StarPort
.
convert
,
selectExclude
Job
.
Assert
Convert
.
Assertion
.
convert
,
selectExclude
Job
.
Always
Convert
.
AlwaysKW
.
convert
,
Convert
.
Package
.
convert
,
Convert
.
ParamNoDefault
.
convert
]
convert
::
[
Job
.
Exclude
]
->
Phase
convert
excludes
=
convert'
.
Convert
.
Package
.
convert
.
Convert
.
ParamNoDefault
.
convert
final
.
loopMain
.
initial
where
convert'
::
Phase
convert'
descriptions
=
final
=
combine
$
finalPhases
selectExclude
main
=
combine
$
mainPhases
selectExclude
initial
=
combine
$
initialPhases
selectExclude
combine
=
foldr1
(
.
)
loopMain
::
Phase
loopMain
descriptions
=
if
descriptions
==
descriptions'
then
descriptions
else
convert'
descriptions'
where
descriptions'
=
run
excludes
descriptions
else
loopMain
descriptions'
where
descriptions'
=
main
descriptions
selectExclude
::
Selector
selectExclude
exclude
phase
=
if
elem
exclude
excludes
then
id
else
phase
src/Convert/Jump.hs
View file @
d847fdfa
...
...
@@ -139,9 +139,8 @@ convertStmt (Block Par x decls stmts) = do
modify
$
\
s
->
s
{
sJumpAllowed
=
jumpAllowed
,
sReturnAllowed
=
returnAllowed
}
return
$
Block
Par
x
decls
stmts'
convertStmt
(
Block
Seq
x
decls
stmts
)
=
do
stmts'
<-
step
stmts
return
$
Block
Seq
x
decls
$
filter
(
/=
Null
)
stmts'
convertStmt
(
Block
Seq
x
decls
stmts
)
=
step
stmts
>>=
return
.
Block
Seq
x
decls
where
step
::
[
Stmt
]
->
State
Info
[
Stmt
]
step
[]
=
return
[]
...
...
src/Convert/Logic.hs
View file @
d847fdfa
...
...
@@ -103,6 +103,8 @@ traverseModuleItem ports scopes =
Just
(
_
,
_
,
t
)
->
tell
[
isRegType
t
]
_
->
tell
[
False
]
always_comb
=
AlwaysC
Always
.
Timing
(
Event
SenseStar
)
fixModuleItem
::
ModuleItem
->
ModuleItem
-- rewrite bad continuous assignments to use procedural assignments
fixModuleItem
(
Assign
AssignOptionNone
lhs
expr
)
=
...
...
@@ -112,7 +114,7 @@ traverseModuleItem ports scopes =
Generate
$
map
GenModuleItem
[
MIPackageItem
(
Decl
(
Variable
Local
t
x
[]
Nil
))
,
Assign
AssignOptionNone
(
LHSIdent
x
)
expr
,
AlwaysC
AlwaysC
omb
$
Asgn
AsgnOpEq
Nothing
lhs
(
Ident
x
)
,
always_c
omb
$
Asgn
AsgnOpEq
Nothing
lhs
(
Ident
x
)
]
where
t
=
Net
(
NetType
TWire
)
Unspecified
...
...
@@ -146,7 +148,7 @@ traverseModuleItem ports scopes =
[(
DimsFn
FnBits
$
Right
expr
,
RawNum
1
)]
items
=
[
MIPackageItem
$
Decl
$
Variable
Local
t
tmp
[]
Nil
,
AlwaysC
AlwaysC
omb
$
Asgn
AsgnOpEq
Nothing
lhs
tmpExpr
]
,
always_c
omb
$
Asgn
AsgnOpEq
Nothing
lhs
tmpExpr
]
lhs
=
case
exprToLHS
expr
of
Just
l
->
l
Nothing
->
...
...
src/Convert/RemoveComments.hs
View file @
d847fdfa
...
...
@@ -45,8 +45,10 @@ convertPackageItem other = other
convertStmt
::
Stmt
->
Stmt
convertStmt
(
CommentStmt
_
)
=
Null
convertStmt
(
Block
kw
name
decls
stmts
)
=
Block
kw
name
decls'
stmts
where
decls'
=
convertDecls
decls
Block
kw
name
decls'
stmts'
where
decls'
=
convertDecls
decls
stmts'
=
filter
(
/=
Null
)
stmts
convertStmt
(
For
(
Left
decls
)
cond
incr
stmt
)
=
For
(
Left
decls'
)
cond
incr
stmt
where
decls'
=
convertDecls
decls
...
...
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