"updt"
This commit is contained in:
15
src/peakrdl_busdecoder/sv_int.py
Normal file
15
src/peakrdl_busdecoder/sv_int.py
Normal file
@@ -0,0 +1,15 @@
|
||||
class SVInt:
|
||||
def __init__(self, value: int, width: int | None = None) -> None:
|
||||
self.value = value
|
||||
self.width = width
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self.width is not None:
|
||||
# Explicit width
|
||||
return f"{self.width}'h{self.value:x}"
|
||||
elif self.value.bit_length() > 32:
|
||||
# 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"{self.value.bit_length()}'h{self.value:x}"
|
||||
else:
|
||||
return f"'h{self.value:x}"
|
||||
Reference in New Issue
Block a user