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
b2b1c9e5
Commit
b2b1c9e5
authored
Mar 07, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow .* as element of partial port bindings
parent
f97e069e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
23 deletions
+26
-23
src/Convert/Interface.hs
+2
-2
src/Convert/StarPort.hs
+13
-6
src/Convert/Traverse.hs
+3
-7
src/Language/SystemVerilog/AST.hs
+4
-4
src/Language/SystemVerilog/Parser/Parse.y
+3
-3
src/Language/SystemVerilog/Parser/ParseDecl.hs
+1
-1
No files found.
src/Convert/Interface.hs
View file @
b2b1c9e5
...
@@ -73,12 +73,12 @@ convertDescription interfaces (Part Module name ports items) =
...
@@ -73,12 +73,12 @@ convertDescription interfaces (Part Module name ports items) =
mapper
=
\
(
dir
,
port
,
Just
expr
)
->
mapper
=
\
(
dir
,
port
,
Just
expr
)
->
Variable
dir
(
lookupType
interfaceItems
expr
)
Variable
dir
(
lookupType
interfaceItems
expr
)
(
ident
++
"_"
++
port
)
[]
Nothing
(
ident
++
"_"
++
port
)
[]
Nothing
mapInterface
(
Instance
part
params
ident
(
Just
instancePorts
)
)
=
mapInterface
(
Instance
part
params
ident
instancePorts
)
=
case
Map
.
lookup
part
interfaces
of
case
Map
.
lookup
part
interfaces
of
Just
interface
->
Just
interface
->
Generate
$
map
GenModuleItem
$
Generate
$
map
GenModuleItem
$
inlineInterface
interface
(
ident
,
expandedPorts
)
inlineInterface
interface
(
ident
,
expandedPorts
)
Nothing
->
Instance
part
params
ident
(
Just
expandedPorts
)
Nothing
->
Instance
part
params
ident
expandedPorts
where
expandedPorts
=
concatMap
expandPortBinding
instancePorts
where
expandedPorts
=
concatMap
expandPortBinding
instancePorts
mapInterface
other
=
other
mapInterface
other
=
other
...
...
src/Convert/StarPort.hs
View file @
b2b1c9e5
...
@@ -22,11 +22,18 @@ convert descriptions =
...
@@ -22,11 +22,18 @@ convert descriptions =
getPorts
_
=
return
()
getPorts
_
=
return
()
mapInstance
::
ModuleItem
->
ModuleItem
mapInstance
::
ModuleItem
->
ModuleItem
mapInstance
(
Instance
m
p
x
Nothing
)
=
mapInstance
(
Instance
m
p
x
bindings
)
=
Instance
m
p
x
(
Just
portBindings
)
Instance
m
p
x
$
concatMap
expandBinding
bindings
where
where
ports
=
case
Map
.
lookup
m
modulePorts
of
alreadyBound
::
[
Identifier
]
Nothing
->
error
$
"could not convert `.*` in instantiation of "
++
m
alreadyBound
=
map
fst
bindings
Just
l
->
l
expandBinding
::
PortBinding
->
[
PortBinding
]
portBindings
=
map
(
\
port
->
(
port
,
Just
$
Ident
port
))
ports
expandBinding
(
"*"
,
Nothing
)
=
case
Map
.
lookup
m
modulePorts
of
Just
l
->
map
(
\
port
->
(
port
,
Just
$
Ident
port
))
$
filter
(
\
s
->
not
$
elem
s
alreadyBound
)
$
l
-- if we can't find it, just skip :(
Nothing
->
[(
"*"
,
Nothing
)]
expandBinding
other
=
[
other
]
mapInstance
other
=
other
mapInstance
other
=
other
src/Convert/Traverse.hs
View file @
b2b1c9e5
...
@@ -45,7 +45,6 @@ module Convert.Traverse
...
@@ -45,7 +45,6 @@ module Convert.Traverse
,
traverseNestedStmts
,
traverseNestedStmts
)
where
)
where
import
Data.Maybe
(
fromJust
)
import
Control.Monad.State
import
Control.Monad.State
import
Language.SystemVerilog.AST
import
Language.SystemVerilog.AST
...
@@ -302,12 +301,9 @@ traverseExprsM mapper = moduleItemMapper
...
@@ -302,12 +301,9 @@ traverseExprsM mapper = moduleItemMapper
decls'
<-
mapM
declMapper
decls
decls'
<-
mapM
declMapper
decls
stmts'
<-
mapM
stmtMapper
stmts
stmts'
<-
mapM
stmtMapper
stmts
return
$
MIPackageItem
$
Task
lifetime
f
decls'
stmts'
return
$
MIPackageItem
$
Task
lifetime
f
decls'
stmts'
moduleItemMapper
(
Instance
m
params
x
ml
)
=
do
moduleItemMapper
(
Instance
m
params
x
l
)
=
do
if
ml
==
Nothing
l'
<-
mapM
portBindingMapper
l
then
return
$
Instance
m
params
x
Nothing
return
$
Instance
m
params
x
l'
else
do
l
<-
mapM
portBindingMapper
(
fromJust
ml
)
return
$
Instance
m
params
x
(
Just
l
)
moduleItemMapper
(
Modport
x
l
)
=
moduleItemMapper
(
Modport
x
l
)
=
mapM
modportDeclMapper
l
>>=
return
.
Modport
x
mapM
modportDeclMapper
l
>>=
return
.
Modport
x
moduleItemMapper
(
Genvar
x
)
=
return
$
Genvar
x
moduleItemMapper
(
Genvar
x
)
=
return
$
Genvar
x
...
...
src/Language/SystemVerilog/AST.hs
View file @
b2b1c9e5
...
@@ -177,7 +177,7 @@ data ModuleItem
...
@@ -177,7 +177,7 @@ data ModuleItem
=
MIDecl
Decl
=
MIDecl
Decl
|
AlwaysC
AlwaysKW
Stmt
|
AlwaysC
AlwaysKW
Stmt
|
Assign
LHS
Expr
|
Assign
LHS
Expr
|
Instance
Identifier
[
PortBinding
]
Identifier
(
Maybe
[
PortBinding
])
-- `Nothing` represents `.*`
|
Instance
Identifier
[
PortBinding
]
Identifier
[
PortBinding
]
|
Genvar
Identifier
|
Genvar
Identifier
|
Generate
[
GenItem
]
|
Generate
[
GenItem
]
|
Modport
Identifier
[
ModportDecl
]
|
Modport
Identifier
[
ModportDecl
]
...
@@ -207,18 +207,18 @@ instance Show ModuleItem where
...
@@ -207,18 +207,18 @@ instance Show ModuleItem where
AlwaysC
k
b
->
printf
"%s %s"
(
show
k
)
(
show
b
)
AlwaysC
k
b
->
printf
"%s %s"
(
show
k
)
(
show
b
)
Assign
a
b
->
printf
"assign %s = %s;"
(
show
a
)
(
show
b
)
Assign
a
b
->
printf
"assign %s = %s;"
(
show
a
)
(
show
b
)
Instance
m
params
i
ports
Instance
m
params
i
ports
|
null
params
->
printf
"%s %s%s;"
m
i
(
show
Maybe
Ports
ports
)
|
null
params
->
printf
"%s %s%s;"
m
i
(
showPorts
ports
)
|
otherwise
->
printf
"%s #%s %s%s;"
m
(
showPorts
params
)
i
(
show
Maybe
Ports
ports
)
|
otherwise
->
printf
"%s #%s %s%s;"
m
(
showPorts
params
)
i
(
showPorts
ports
)
Genvar
x
->
printf
"genvar %s;"
x
Genvar
x
->
printf
"genvar %s;"
x
Generate
b
->
printf
"generate
\n
%s
\n
endgenerate"
(
indent
$
unlines'
$
map
show
b
)
Generate
b
->
printf
"generate
\n
%s
\n
endgenerate"
(
indent
$
unlines'
$
map
show
b
)
Modport
x
l
->
printf
"modport %s(
\n
%s
\n
);"
x
(
indent
$
intercalate
",
\n
"
$
map
showModportDecl
l
)
Modport
x
l
->
printf
"modport %s(
\n
%s
\n
);"
x
(
indent
$
intercalate
",
\n
"
$
map
showModportDecl
l
)
Initial
s
->
printf
"initial %s"
(
show
s
)
Initial
s
->
printf
"initial %s"
(
show
s
)
MIPackageItem
i
->
show
i
MIPackageItem
i
->
show
i
where
where
showMaybePorts
=
maybe
"(.*)"
showPorts
showPorts
::
[
PortBinding
]
->
String
showPorts
::
[
PortBinding
]
->
String
showPorts
ports
=
indentedParenList
$
map
showPort
ports
showPorts
ports
=
indentedParenList
$
map
showPort
ports
showPort
::
PortBinding
->
String
showPort
::
PortBinding
->
String
showPort
(
"*"
,
Nothing
)
=
".*"
showPort
(
i
,
arg
)
=
showPort
(
i
,
arg
)
=
if
i
==
""
if
i
==
""
then
show
(
fromJust
arg
)
then
show
(
fromJust
arg
)
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
b2b1c9e5
...
@@ -344,9 +344,8 @@ Lifetime :: { Lifetime }
...
@@ -344,9 +344,8 @@ Lifetime :: { Lifetime }
: "static" { Static }
: "static" { Static }
| "automatic" { Automatic }
| "automatic" { Automatic }
ModuleInstantiation :: { (Identifier, Maybe [PortBinding]) }
ModuleInstantiation :: { (Identifier, [PortBinding]) }
: Identifier "(" Bindings ")" { ($1, Just $3) }
: Identifier "(" Bindings ")" { ($1, $3) }
| Identifier "(" ".*" ")" { ($1, Nothing) }
TFItems :: { [Decl] }
TFItems :: { [Decl] }
: "(" DeclTokens(")") ";" { parseDTsAsDecls $2 }
: "(" DeclTokens(")") ";" { parseDTsAsDecls $2 }
...
@@ -396,6 +395,7 @@ Binding :: { (Identifier, Maybe Expr) }
...
@@ -396,6 +395,7 @@ Binding :: { (Identifier, Maybe Expr) }
: "." Identifier "(" opt(Expr) ")" { ($2, $4) }
: "." Identifier "(" opt(Expr) ")" { ($2, $4) }
| "." Identifier { ($2, Just $ Ident $2) }
| "." Identifier { ($2, Just $ Ident $2) }
| Expr { ("", Just $1) }
| Expr { ("", Just $1) }
| ".*" { ("*", Nothing) }
ParameterBindings :: { [(Identifier, Maybe Expr)] }
ParameterBindings :: { [(Identifier, Maybe Expr)] }
: "#" "(" BindingsNonEmpty ")" { $3 }
: "#" "(" BindingsNonEmpty ")" { $3 }
...
...
src/Language/SystemVerilog/Parser/ParseDecl.hs
View file @
b2b1c9e5
...
@@ -53,7 +53,7 @@ data DeclToken
...
@@ -53,7 +53,7 @@ data DeclToken
|
DTDir
Direction
|
DTDir
Direction
|
DTType
([
Range
]
->
Type
)
|
DTType
([
Range
]
->
Type
)
|
DTParams
[
PortBinding
]
|
DTParams
[
PortBinding
]
|
DTInstance
(
Identifier
,
Maybe
[
PortBinding
])
|
DTInstance
(
Identifier
,
[
PortBinding
])
|
DTBit
Expr
|
DTBit
Expr
|
DTConcat
[
LHS
]
|
DTConcat
[
LHS
]
deriving
(
Show
,
Eq
)
deriving
(
Show
,
Eq
)
...
...
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