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
a8346f2f
Commit
a8346f2f
authored
Jun 06, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actually fix unbased unsized literals in ternary exprs
parent
71d17487
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
20 deletions
+21
-20
src/Convert/UnbasedUnsized.hs
+19
-18
test/basic/unbased_unsized.sv
+1
-1
test/basic/unbased_unsized.v
+1
-1
No files found.
src/Convert/UnbasedUnsized.hs
View file @
a8346f2f
...
@@ -3,10 +3,13 @@
...
@@ -3,10 +3,13 @@
-
-
- Conversion for unbased, unsized literals ('0, '1, 'z, 'x)
- Conversion for unbased, unsized literals ('0, '1, 'z, 'x)
-
-
- The literals are given a binary base and are made signed to enable sign
- The literals are given a binary base, a size of 1, and are made signed to
- extension. In self-determined contexts, the literals are additionally given
- allow sign extension. This enables the desired implicit casting in
- an explicit size of 1. This enables the desired implicit casting in
- Verilog-2005.
- Verilog-2005.
-
- However, in a ternary expressions, these literals should take on the sign and
- size of their counterpart. To work around this, we explicitly size cast these
- literlas when they appear within a ternary expression.
-}
-}
module
Convert.UnbasedUnsized
(
convert
)
where
module
Convert.UnbasedUnsized
(
convert
)
where
...
@@ -23,26 +26,24 @@ convert =
...
@@ -23,26 +26,24 @@ convert =
digits
::
[
Char
]
digits
::
[
Char
]
digits
=
[
'0'
,
'1'
,
'x'
,
'z'
,
'X'
,
'Z'
]
digits
=
[
'0'
,
'1'
,
'x'
,
'z'
,
'X'
,
'Z'
]
literalFor
::
String
->
Char
->
Expr
literalFor
::
Char
->
Expr
literalFor
prefix
ch
=
literalFor
ch
=
if
elem
ch
digits
if
elem
ch
digits
then
Number
(
prefix
++
[
ch
])
then
Number
(
"1'sb"
++
[
ch
])
else
error
$
"unexpected unbased-unsized digit: "
++
[
ch
]
else
error
$
"unexpected unbased-unsized digit: "
++
[
ch
]
sizedLiteralFor
::
Char
->
Expr
sizedLiteralFor
=
literalFor
"1'sb"
unsizedLiteralFor
::
Char
->
Expr
unsizedLiteralFor
=
literalFor
"'sb"
convertExpr
::
Expr
->
Expr
convertExpr
::
Expr
->
Expr
convertExpr
(
Mux
cond
left
right
)
=
convertExpr
(
Mux
cond
left
right
)
=
Mux
cond
(
convertExpr
Unsized
left
)
(
convertExprUnsized
righ
t
)
Mux
cond
(
convertExpr
Cast
left
right
)
(
convertExprCast
right
lef
t
)
convertExpr
(
Number
[
'
\'
',
ch
])
=
convertExpr
(
Number
[
'
\'
',
ch
])
=
sizedL
iteralFor
ch
l
iteralFor
ch
convertExpr
other
=
other
convertExpr
other
=
other
convertExprUnsized
::
Expr
->
Expr
convertExprCast
::
Expr
->
Expr
->
Expr
convertExprUnsized
(
Number
[
'
\'
',
ch
])
=
convertExprCast
(
Number
[
'
\'
',
ch
])
other
=
unsizedLiteralFor
ch
Cast
(
Right
size
)
(
literalFor
ch
)
convertExprUnsized
other
=
other
where
size
=
case
other
of
Number
[
'
\'
',
_
]
->
Number
"32"
_
->
DimsFn
FnBits
$
Right
other
convertExprCast
other
_
=
other
test/basic/unbased_unsized.sv
View file @
a8346f2f
...
@@ -17,7 +17,7 @@ module top;
...
@@ -17,7 +17,7 @@ module top;
i
=
42
;
i
=
42
;
flag
=
1
;
flag
=
1
;
a
=
(
flag
?
'1
:
i
)
;
a
=
(
flag
?
'1
:
i
)
;
b
=
(
flag
?
1
'
sb1
:
i
)
;
b
=
(
flag
?
'x
:
i
)
;
c
=
(
flag
?
'1
:
'0
)
;
c
=
(
flag
?
'1
:
'0
)
;
$
display
(
"%b"
,
a
)
;
$
display
(
"%b"
,
a
)
;
$
display
(
"%b"
,
b
)
;
$
display
(
"%b"
,
b
)
;
...
...
test/basic/unbased_unsized.v
View file @
a8346f2f
...
@@ -17,7 +17,7 @@ module top;
...
@@ -17,7 +17,7 @@ module top;
i
=
42
;
i
=
42
;
flag
=
1
;
flag
=
1
;
a
=
(
flag
?
32'hFFFFFFFF
:
i
)
;
a
=
(
flag
?
32'hFFFFFFFF
:
i
)
;
b
=
(
flag
?
1
'
sb1
:
i
)
;
b
=
(
flag
?
32
'
hXXXXXXXX
:
i
)
;
c
=
(
flag
?
32'hFFFFFFFF
:
i
)
;
c
=
(
flag
?
32'hFFFFFFFF
:
i
)
;
$
display
(
"%b"
,
a
)
;
$
display
(
"%b"
,
a
)
;
$
display
(
"%b"
,
b
)
;
$
display
(
"%b"
,
b
)
;
...
...
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