Use sized integer literals if bit width exceeds 32-bits. #43

This commit is contained in:
Alex Mykyta
2023-06-08 22:55:20 -07:00
parent f36d7614c8
commit 50d8779283
4 changed files with 18 additions and 7 deletions

View File

@@ -64,3 +64,11 @@ def ref_is_internal(top_node: AddrmapNode, ref: Union[Node, PropertyReference])
# A root signal was referenced, which dodged the top addrmap
# This is considerd internal for this exporter
return True
def get_sv_int(n: int) -> str:
if n.bit_length() <= 32:
return f"'h{n:x}"
else:
# SV standard only enforces that unsized literals shall be at least 32-bits
# To support larger literals, they need to be sized explicitly
return f"{n.bit_length()}'h{n:x}"