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
0c319365
Commit
0c319365
authored
Dec 10, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maintain explicit padding in unsized number literals
parent
c39371c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
src/Language/SystemVerilog/AST/Number.hs
+11
-7
test/lex/number.sv
+14
-0
No files found.
src/Language/SystemVerilog/AST/Number.hs
View file @
0c319365
...
...
@@ -78,7 +78,7 @@ parseNumber' str =
if
rawSize
/=
0
then
rawSize
else
if
maybeBase
/=
Nothing
then
negate
$
max
32
(
bitsPerDigit
*
numDigits
)
negate
$
bitsPerDigit
*
numDigits
else
-
32
bitsPerDigit
=
bits
$
baseSize
base
-
1
...
...
@@ -170,7 +170,11 @@ baseSize Hex = 16
numberBitLength
::
Number
->
Integer
numberBitLength
UnbasedUnsized
{}
=
32
numberBitLength
(
Decimal
size
_
_
)
=
fromIntegral
$
abs
size
numberBitLength
(
Based
size
_
_
_
_
)
=
fromIntegral
$
abs
size
numberBitLength
(
Based
size
_
_
_
_
)
=
fromIntegral
$
if
size
<
0
then
max
32
$
negate
size
else
size
-- get whether or not a number is signed
numberIsSized
::
Number
->
Bool
...
...
@@ -226,16 +230,16 @@ instance Show Number where
sizeStr
=
if
size
>
0
then
show
size
else
""
signedStr
=
if
signed
then
"s"
else
""
[
baseCh
]
=
show
base
valueStr
=
showBasedDigits
(
baseSize
base
)
size
value
kinds
valueStr
=
showBasedDigits
signed
(
baseSize
base
)
size
value
kinds
showBasedDigits
::
Int
->
Int
->
Integer
->
Integer
->
String
showBasedDigits
base
size
values
kinds
=
showBasedDigits
::
Bool
->
Int
->
Int
->
Integer
->
Integer
->
String
showBasedDigits
signed
base
size
values
kinds
=
if
numDigits
>
sizeDigits
then
error
$
"invalid based literal digits: "
++
show
(
base
,
size
,
values
,
kinds
,
numDigits
,
sizeDigits
)
else
if
size
<
-
32
then
else
if
size
<
-
32
||
(
size
<
0
&&
signed
)
then
padList
'0'
sizeDigits
digits
else
if
leadingXZ
&&
size
<
0
then
else
if
leadingXZ
&&
size
<
0
&&
sizeDigits
==
numDigits
then
removeExtraPadding
digits
else
if
leadingXZ
||
(
256
>=
size
&&
size
>
0
)
then
padList
'0'
sizeDigits
digits
...
...
test/lex/number.sv
View file @
0c319365
...
...
@@ -37,5 +37,19 @@ module top;
`TEST
(
'h01
xz01xz
)
`TEST
(
'h101
xz01xz
)
`TEST
(
36'h01
xz01xz
)
`TEST
(
37'h01
xz01xz
)
`TEST
(
36'hb01
xz01xz
)
`TEST
(
37'hb01
xz01xz
)
`TEST
(
'
sb0
)
`TEST
(
'
sb1
)
`TEST
(
'
sb00
)
`TEST
(
'
sb10
)
`TEST
(
'
sb01
)
`TEST
(
'
sb11
)
`TEST
(
'
sb000
)
`TEST
(
'
sb001
)
`TEST
(
'
sb010
)
`TEST
(
'
sb011
)
`TEST
(
'
sb100
)
`TEST
(
'
sb101
)
`TEST
(
'
sb110
)
`TEST
(
'
sb111
)
`TEST
(
'b0
)
`TEST
(
'b1
)
`TEST
(
'b00
)
`TEST
(
'b10
)
`TEST
(
'b01
)
`TEST
(
'b11
)
`TEST
(
'b000
)
`TEST
(
'b001
)
`TEST
(
'b010
)
`TEST
(
'b011
)
`TEST
(
'b100
)
`TEST
(
'b101
)
`TEST
(
'b110
)
`TEST
(
'b111
)
`TEST
(
'b0x
)
`TEST
(
'
sb0x
)
`TEST
(
'b0z
)
`TEST
(
'
sb0z
)
`TEST
(
'
o0x
)
`TEST
(
'
so0x
)
`TEST
(
'
o0z
)
`TEST
(
'
so0z
)
`TEST
(
'h0
x
)
`TEST
(
'
sh0x
)
`TEST
(
'h0
z
)
`TEST
(
'
sh0z
)
end
endmodule
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