Add signed/fixedpoint properties (#140)
* declared intwidth, fracwidth, and is_signed UDPs * fix boolean type name in UDP definition * generate hwif fields with fixedpoint indices * make "counter" and "encode" properties mutualy exclusive with signed/fixedpoint * add signed/unsigned to hwif * improved fixedpoint error messages, added validation tests * added fixedpoint tests * fixedpoint/signed not allowed for signal components * added signed/fixedpoint UDP docs * handle single-bit fixedpoint numbers * fix too many positional arguments lint * changed spelling of fixedpoint to fixed-point * use "logic" in place of "unsigned logic" * split signed and fixedpoint docs, added examples * allow enums with is_signed=false * split signed and fixedpoint implementations * assorted nits picked * updated is_signed validation unit test
This commit is contained in:
@@ -88,16 +88,30 @@ class StructGenerator:
|
||||
self._struct_stack.append(s)
|
||||
|
||||
|
||||
def add_member(self, name: str, width: int = 1, array_dimensions: Optional[List[int]] = None) -> None:
|
||||
def add_member(
|
||||
self,
|
||||
name: str,
|
||||
width: int = 1,
|
||||
array_dimensions: Optional[List[int]] = None,
|
||||
*,
|
||||
lsb: int = 0,
|
||||
signed: bool = False,
|
||||
) -> None:
|
||||
if array_dimensions:
|
||||
suffix = "[" + "][".join((str(n) for n in array_dimensions)) + "]"
|
||||
else:
|
||||
suffix = ""
|
||||
|
||||
if width == 1:
|
||||
m = f"logic {name}{suffix};"
|
||||
if signed:
|
||||
sign = "signed "
|
||||
else:
|
||||
m = f"logic [{width-1}:0] {name}{suffix};"
|
||||
# the default 'logic' type is unsigned per SV LRM 6.11.3
|
||||
sign = ""
|
||||
|
||||
if width == 1 and lsb == 0:
|
||||
m = f"logic {sign}{name}{suffix};"
|
||||
else:
|
||||
m = f"logic {sign}[{lsb+width-1}:{lsb}] {name}{suffix};"
|
||||
self.current_struct.children.append(m)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user