Skip to content

Commit

Permalink
Merge pull request #107 from leonardt/patch-sv-literals
Browse files Browse the repository at this point in the history
Explicitly set integer literal size in SV backend
  • Loading branch information
leonardt committed May 22, 2019
2 parents 4d1ce8b + 805accf commit 3381904
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fault/system_verilog_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ def make_name(self, port):
return name

def process_value(self, port, value):
if isinstance(port, m.SIntType) and value < 0:
# Handle sign extension for verilator since it expects and
# unsigned c type
if isinstance(value, BitVector):
value = f"{len(value)}'d{value.as_uint()}"
elif isinstance(port, m.SIntType) and value < 0:
port_len = len(port)
value = BitVector(value, port_len).as_uint()
value = f"{port_len}'d{value}"
elif value is fault.UnknownValue:
value = "'X"
elif isinstance(value, actions.Peek):
Expand Down

0 comments on commit 3381904

Please sign in to comment.