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
5e5ddca4
Commit
5e5ddca4
authored
Aug 08, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix broken two's complement logic
parent
59d37468
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
src/Language/SystemVerilog/AST/Number.hs
+5
-4
test/core/dimensions.sv
+1
-0
test/core/dimensions.v
+1
-0
No files found.
src/Language/SystemVerilog/AST/Number.hs
View file @
5e5ddca4
...
...
@@ -17,7 +17,7 @@ module Language.SystemVerilog.AST.Number
,
bitToVK
)
where
import
Data.Bits
((
.&.
),
shiftL
)
import
Data.Bits
((
.&.
),
shiftL
,
xor
)
import
Data.Char
(
digitToInt
,
intToDigit
,
toLower
)
import
Data.List
(
elemIndex
)
import
Text.Read
(
readMaybe
)
...
...
@@ -222,9 +222,10 @@ numberToInteger (UnbasedUnsized Bit0) = Just 0
numberToInteger
UnbasedUnsized
{}
=
Nothing
numberToInteger
(
Decimal
sz
sg
num
)
|
not
sg
||
num
.&.
pow
==
0
=
Just
num
|
num
==
1
=
Just
$
-
1
|
otherwise
=
Just
$
negate
$
num
-
pow
where
pow
=
2
^
(
abs
sz
-
1
)
|
otherwise
=
Just
$
negate
$
num
`
xor
`
mask
+
1
where
pow
=
2
^
(
abs
sz
-
1
)
mask
=
pow
+
pow
-
1
numberToInteger
(
Based
sz
sg
_
num
0
)
=
numberToInteger
$
Decimal
sz
sg
num
numberToInteger
Based
{}
=
Nothing
...
...
test/core/dimensions.sv
View file @
5e5ddca4
...
...
@@ -43,6 +43,7 @@ module top;
$
display
(
"args %b"
,
$
size
(
RamPair
,
1
'
sb1
))
;
$
display
(
"args %b"
,
$
size
(
RamPair
,
2
'
sb1
))
;
$
display
(
"args %b"
,
$
size
(
RamPair
,
2
'
sb01
))
;
$
display
(
"args %b"
,
$
size
(
RamPair
,
2
'
sb10
))
;
$
display
(
"args %b"
,
$
size
(
RamPair
,
2
'
sb11
))
;
$
display
(
"args %b"
,
$
size
(
RamPair
,
'1
))
;
$
display
(
"args %b"
,
$
size
(
RamPair
,
'
o1
))
;
...
...
test/core/dimensions.v
View file @
5e5ddca4
...
...
@@ -41,6 +41,7 @@ module top;
$
display
(
"args %b"
,
2
)
;
$
display
(
"args %b"
,
2
)
;
$
display
(
"args %b"
,
1'bx
)
;
$
display
(
"args %b"
,
1'bx
)
;
$
display
(
"args %b"
,
2
)
;
$
display
(
"args %b"
,
2
)
;
$
display
(
"args %b"
,
2
)
;
...
...
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