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
167c65db
Commit
167c65db
authored
Oct 10, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass through downstream compiler directives
parent
6d79e0b4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
10 deletions
+31
-10
src/Convert/Logic.hs
+0
-1
src/Convert/NestPI.hs
+3
-2
src/Convert/Package.hs
+4
-3
src/Convert/Traverse.hs
+2
-1
src/Language/SystemVerilog/AST/Description.hs
+2
-2
src/Language/SystemVerilog/Parser/Lex.x
+14
-1
src/Language/SystemVerilog/Parser/Parse.y
+5
-0
src/Language/SystemVerilog/Parser/Tokens.hs
+1
-0
No files found.
src/Convert/Logic.hs
View file @
167c65db
...
@@ -68,7 +68,6 @@ convertDescription ports orig =
...
@@ -68,7 +68,6 @@ convertDescription ports orig =
Part
_
_
Module
_
_
_
_
->
True
Part
_
_
Module
_
_
_
_
->
True
PackageItem
_
->
True
PackageItem
_
->
True
Package
_
_
_
->
False
Package
_
_
_
->
False
Directive
_
->
False
origIdents
=
execWriter
(
collectModuleItemsM
regIdents
orig
)
origIdents
=
execWriter
(
collectModuleItemsM
regIdents
orig
)
fixed
=
traverseModuleItems
fixModuleItem
orig
fixed
=
traverseModuleItems
fixModuleItem
orig
...
...
src/Convert/NestPI.hs
View file @
167c65db
...
@@ -98,5 +98,6 @@ piName (Decl (Variable _ _ ident _ _)) = Just ident
...
@@ -98,5 +98,6 @@ piName (Decl (Variable _ _ ident _ _)) = Just ident
piName
(
Decl
(
Param
_
_
ident
_
))
=
Just
ident
piName
(
Decl
(
Param
_
_
ident
_
))
=
Just
ident
piName
(
Decl
(
ParamType
_
ident
_
))
=
Just
ident
piName
(
Decl
(
ParamType
_
ident
_
))
=
Just
ident
piName
(
Import
x
y
)
=
Just
$
show
$
Import
x
y
piName
(
Import
x
y
)
=
Just
$
show
$
Import
x
y
piName
(
Export
_
)
=
Nothing
piName
(
Export
_
)
=
Nothing
piName
(
Comment
_
)
=
Nothing
piName
(
Comment
_
)
=
Nothing
piName
(
Directive
_
)
=
Nothing
src/Convert/Package.hs
View file @
167c65db
...
@@ -183,6 +183,7 @@ piName (Typedef _ ident ) = Just ident
...
@@ -183,6 +183,7 @@ piName (Typedef _ ident ) = Just ident
piName
(
Decl
(
Variable
_
_
ident
_
_
))
=
Just
ident
piName
(
Decl
(
Variable
_
_
ident
_
_
))
=
Just
ident
piName
(
Decl
(
Param
_
_
ident
_
))
=
Just
ident
piName
(
Decl
(
Param
_
_
ident
_
))
=
Just
ident
piName
(
Decl
(
ParamType
_
ident
_
))
=
Just
ident
piName
(
Decl
(
ParamType
_
ident
_
))
=
Just
ident
piName
(
Import
_
_
)
=
Nothing
piName
(
Import
_
_
)
=
Nothing
piName
(
Export
_
)
=
Nothing
piName
(
Export
_
)
=
Nothing
piName
(
Comment
_
)
=
Nothing
piName
(
Comment
_
)
=
Nothing
piName
(
Directive
_
)
=
Nothing
src/Convert/Traverse.hs
View file @
167c65db
...
@@ -174,7 +174,6 @@ traverseModuleItemsM mapper (Package lifetime name packageItems) = do
...
@@ -174,7 +174,6 @@ traverseModuleItemsM mapper (Package lifetime name packageItems) = do
_
->
error
$
"redirected Package traverse failed: "
_
->
error
$
"redirected Package traverse failed: "
++
show
converted
++
show
converted
return
$
Package
lifetime
name
$
map
(
\
(
MIPackageItem
item
)
->
item
)
items'
return
$
Package
lifetime
name
$
map
(
\
(
MIPackageItem
item
)
->
item
)
items'
traverseModuleItemsM
_
(
Directive
str
)
=
return
$
Directive
str
traverseModuleItems
::
Mapper
ModuleItem
->
Mapper
Description
traverseModuleItems
::
Mapper
ModuleItem
->
Mapper
Description
traverseModuleItems
=
unmonad
traverseModuleItemsM
traverseModuleItems
=
unmonad
traverseModuleItemsM
...
@@ -623,6 +622,8 @@ traverseExprsM' strat exprMapper = moduleItemMapper
...
@@ -623,6 +622,8 @@ traverseExprsM' strat exprMapper = moduleItemMapper
moduleItemMapper
(
Generate
items
)
=
do
moduleItemMapper
(
Generate
items
)
=
do
items'
<-
mapM
(
traverseNestedGenItemsM
genItemMapper
)
items
items'
<-
mapM
(
traverseNestedGenItemsM
genItemMapper
)
items
return
$
Generate
items'
return
$
Generate
items'
moduleItemMapper
(
MIPackageItem
(
Directive
c
))
=
return
$
MIPackageItem
$
Directive
c
moduleItemMapper
(
MIPackageItem
(
Comment
c
))
=
moduleItemMapper
(
MIPackageItem
(
Comment
c
))
=
return
$
MIPackageItem
$
Comment
c
return
$
MIPackageItem
$
Comment
c
moduleItemMapper
(
MIPackageItem
(
Import
x
y
))
=
moduleItemMapper
(
MIPackageItem
(
Import
x
y
))
=
...
...
src/Language/SystemVerilog/AST/Description.hs
View file @
167c65db
...
@@ -28,7 +28,6 @@ data Description
...
@@ -28,7 +28,6 @@ data Description
=
Part
[
Attr
]
Bool
PartKW
(
Maybe
Lifetime
)
Identifier
[
Identifier
]
[
ModuleItem
]
=
Part
[
Attr
]
Bool
PartKW
(
Maybe
Lifetime
)
Identifier
[
Identifier
]
[
ModuleItem
]
|
PackageItem
PackageItem
|
PackageItem
PackageItem
|
Package
(
Maybe
Lifetime
)
Identifier
[
PackageItem
]
|
Package
(
Maybe
Lifetime
)
Identifier
[
PackageItem
]
|
Directive
String
-- currently unused
deriving
Eq
deriving
Eq
instance
Show
Description
where
instance
Show
Description
where
...
@@ -53,7 +52,6 @@ instance Show Description where
...
@@ -53,7 +52,6 @@ instance Show Description where
where
where
bodyStr
=
indent
$
unlines'
$
map
show
items
bodyStr
=
indent
$
unlines'
$
map
show
items
show
(
PackageItem
i
)
=
show
i
show
(
PackageItem
i
)
=
show
i
show
(
Directive
str
)
=
str
data
PackageItem
data
PackageItem
=
Typedef
Type
Identifier
=
Typedef
Type
Identifier
...
@@ -62,6 +60,7 @@ data PackageItem
...
@@ -62,6 +60,7 @@ data PackageItem
|
Import
Identifier
(
Maybe
Identifier
)
|
Import
Identifier
(
Maybe
Identifier
)
|
Export
(
Maybe
(
Identifier
,
Maybe
Identifier
))
|
Export
(
Maybe
(
Identifier
,
Maybe
Identifier
))
|
Decl
Decl
|
Decl
Decl
|
Directive
String
|
Comment
String
|
Comment
String
deriving
Eq
deriving
Eq
...
@@ -79,6 +78,7 @@ instance Show PackageItem where
...
@@ -79,6 +78,7 @@ instance Show PackageItem where
show
(
Export
Nothing
)
=
"export *::*"
;
show
(
Export
Nothing
)
=
"export *::*"
;
show
(
Export
(
Just
(
x
,
y
)))
=
printf
"export %s::%s;"
x
(
fromMaybe
"*"
y
)
show
(
Export
(
Just
(
x
,
y
)))
=
printf
"export %s::%s;"
x
(
fromMaybe
"*"
y
)
show
(
Decl
decl
)
=
show
decl
show
(
Decl
decl
)
=
show
decl
show
(
Directive
str
)
=
str
show
(
Comment
c
)
=
show
(
Comment
c
)
=
if
elem
'
\n
'
c
if
elem
'
\n
'
c
then
"// "
++
show
c
then
"// "
++
show
c
...
...
src/Language/SystemVerilog/Parser/Lex.x
View file @
167c65db
...
@@ -884,6 +884,10 @@ handleDirective (posOrig, _, _, strOrig) len = do
...
@@ -884,6 +884,10 @@ handleDirective (posOrig, _, _, strOrig) len = do
env <- gets lsEnv
env <- gets lsEnv
tempInput <- alexGetInput
tempInput <- alexGetInput
let dropUntilNewline = removeUntil "\n" tempInput 0
let dropUntilNewline = removeUntil "\n" tempInput 0
let passThrough = do
rest <- takeUntilNewline
let str = '`' : directive ++ rest
tok Spe_Directive (posOrig, ' ', [], strOrig) (length str)
condStack <- gets lsCondStack
condStack <- gets lsCondStack
if any (/= CurrentlyTrue) condStack
if any (/= CurrentlyTrue) condStack
...
@@ -891,9 +895,18 @@ handleDirective (posOrig, _, _, strOrig) len = do
...
@@ -891,9 +895,18 @@ handleDirective (posOrig, _, _, strOrig) len = do
then alexMonadScan
then alexMonadScan
else case directive of
else case directive of
"default_nettype" -> dropUntilNewline
"timescale" -> dropUntilNewline
"timescale" -> dropUntilNewline
"celldefine" -> passThrough
"endcelldefine" -> passThrough
"unconnected_drive" -> passThrough
"nounconnected_drive" -> passThrough
"default_nettype" -> passThrough
"pragma" -> passThrough
"resetall" -> passThrough
"__FILE__" -> do
"__FILE__" -> do
tokPos <- toTokPos posOrig
tokPos <- toTokPos posOrig
currFile <- gets lsCurrFile
currFile <- gets lsCurrFile
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
167c65db
...
@@ -293,6 +293,7 @@ systemIdentifier { Token Id_system _ _ }
...
@@ -293,6 +293,7 @@ systemIdentifier { Token Id_system _ _ }
number { Token Lit_number _ _ }
number { Token Lit_number _ _ }
string { Token Lit_string _ _ }
string { Token Lit_string _ _ }
time { Token Lit_time _ _ }
time { Token Lit_time _ _ }
directive { Token Spe_Directive _ _ }
"(" { Token Sym_paren_l _ _ }
"(" { Token Sym_paren_l _ _ }
")" { Token Sym_paren_r _ _ }
")" { Token Sym_paren_r _ _ }
...
@@ -775,6 +776,7 @@ NonDeclPackageItem :: { [PackageItem] }
...
@@ -775,6 +776,7 @@ NonDeclPackageItem :: { [PackageItem] }
| "export" "*" "::" "*" ";" { [Export Nothing] } -- "Nothing" being no restrictions
| "export" "*" "::" "*" ";" { [Export Nothing] } -- "Nothing" being no restrictions
| ForwardTypedef ";" { $1 }
| ForwardTypedef ";" { $1 }
| TimeunitsDeclaration { $1 }
| TimeunitsDeclaration { $1 }
| Directive { [Directive $1] }
ForwardTypedef :: { [PackageItem] }
ForwardTypedef :: { [PackageItem] }
: "typedef" Identifier { [] }
: "typedef" Identifier { [] }
| "typedef" "enum" Identifier { [] }
| "typedef" "enum" Identifier { [] }
...
@@ -785,6 +787,9 @@ TimeunitsDeclaration :: { [PackageItem] }
...
@@ -785,6 +787,9 @@ TimeunitsDeclaration :: { [PackageItem] }
| "timeunit" Time "/" Time ";" { [] }
| "timeunit" Time "/" Time ";" { [] }
| "timeprecision" Time ";" { [] }
| "timeprecision" Time ";" { [] }
Directive :: { String }
: directive { tokenString $1 }
PackageImportItems :: { [(Identifier, Maybe Identifier)] }
PackageImportItems :: { [(Identifier, Maybe Identifier)] }
: PackageImportItem { [$1] }
: PackageImportItem { [$1] }
| PackageImportItems "," PackageImportItem { $1 ++ [$3] }
| PackageImportItems "," PackageImportItem { $1 ++ [$3] }
...
...
src/Language/SystemVerilog/Parser/Tokens.hs
View file @
167c65db
...
@@ -378,6 +378,7 @@ data TokenName
...
@@ -378,6 +378,7 @@ data TokenName
|
Sym_amp_amp_amp
|
Sym_amp_amp_amp
|
Sym_lt_lt_lt_eq
|
Sym_lt_lt_lt_eq
|
Sym_gt_gt_gt_eq
|
Sym_gt_gt_gt_eq
|
Spe_Directive
|
Unknown
|
Unknown
|
MacroBoundary
|
MacroBoundary
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