Remove dangerous usage of non-public parts of the systemrdl-compiler API

This commit is contained in:
Alex Mykyta
2025-11-04 23:05:50 -08:00
parent 17465e5f97
commit 543bf2be9a
11 changed files with 26 additions and 28 deletions

View File

@@ -7,7 +7,7 @@ name = "peakrdl-regblock"
dynamic = ["version"] dynamic = ["version"]
requires-python = ">=3.7" requires-python = ">=3.7"
dependencies = [ dependencies = [
"systemrdl-compiler ~= 1.29", "systemrdl-compiler ~= 1.30",
"Jinja2 >= 2.11", "Jinja2 >= 2.11",
] ]

View File

@@ -70,7 +70,7 @@ class Dereferencer:
# No reset value defined! # No reset value defined!
obj.env.msg.warning( obj.env.msg.warning(
f"Field '{obj.inst_name}' is a constant but does not have a known value (missing reset). Assigning it a value of X.", f"Field '{obj.inst_name}' is a constant but does not have a known value (missing reset). Assigning it a value of X.",
obj.inst.inst_src_ref obj.inst_src_ref,
) )
return "'X" return "'X"

View File

@@ -315,7 +315,7 @@ class DesignState:
# Assume 32-bits # Assume 32-bits
msg.warning( msg.warning(
"Addrmap being exported only contains external components. Unable to infer the CPUIF bus width. Assuming 32-bits.", "Addrmap being exported only contains external components. Unable to infer the CPUIF bus width. Assuming 32-bits.",
self.top_node.inst.def_src_ref self.top_node.def_src_ref
) )
self.cpuif_data_width = 32 self.cpuif_data_width = 32

View File

@@ -227,7 +227,7 @@ class FieldLogicGenerator(RDLForLoopGenerator):
"Field has multiple conflicting properties that unconditionally set its state:\n" "Field has multiple conflicting properties that unconditionally set its state:\n"
f" * {conditional.unconditional_explanation}\n" f" * {conditional.unconditional_explanation}\n"
f" * {unconditional.unconditional_explanation}", f" * {unconditional.unconditional_explanation}",
node.inst.inst_src_ref node.inst_src_ref
) )
unconditional = conditional unconditional = conditional
else: else:

View File

@@ -51,16 +51,14 @@ class Hwif:
def get_extra_package_params(self) -> str: def get_extra_package_params(self) -> str:
lines = [""] lines = [""]
for name, value in self.top_node.parameters.items():
for param in self.top_node.inst.parameters:
value = param.get_value()
if isinstance(value, int): if isinstance(value, int):
lines.append( lines.append(
f"localparam {param.name} = {SVInt(value)};" f"localparam {name} = {SVInt(value)};"
) )
elif isinstance(value, str): elif isinstance(value, str):
lines.append( lines.append(
f"localparam {param.name} = {value};" f"localparam {name} = {value};"
) )
return "\n".join(lines) return "\n".join(lines)

View File

@@ -53,7 +53,7 @@ class DesignScanner(RDLListener):
if self.top_node.get_property('bridge'): if self.top_node.get_property('bridge'):
self.msg.error( self.msg.error(
"Regblock generator does not support exporting bridge address maps", "Regblock generator does not support exporting bridge address maps",
self.top_node.inst.property_src_ref.get('bridge', self.top_node.inst.inst_src_ref) self.top_node.property_src_ref.get('bridge', self.top_node.inst_src_ref),
) )
RDLWalker().walk(self.top_node, self) RDLWalker().walk(self.top_node, self)
@@ -117,5 +117,5 @@ class DesignScanner(RDLListener):
f"Field '{node.inst_name}' includes parity check logic, but " f"Field '{node.inst_name}' includes parity check logic, but "
"its reset value was not defined. Will result in an undefined " "its reset value was not defined. Will result in an undefined "
"value on the module's 'parity_error' output.", "value on the module's 'parity_error' output.",
self.top_node.inst.property_src_ref.get('paritycheck', self.top_node.inst.inst_src_ref) self.top_node.property_src_ref.get('paritycheck', self.top_node.inst_src_ref)
) )

View File

@@ -16,7 +16,7 @@ class _FixedpointWidth(UDPDefinition):
fracwidth = node.get_property("fracwidth") fracwidth = node.get_property("fracwidth")
assert intwidth is not None assert intwidth is not None
assert fracwidth is not None assert fracwidth is not None
prop_ref = node.inst.property_src_ref.get(self.name) prop_ref = node.property_src_ref.get(self.name, node.inst_src_ref)
# incompatible with "counter" fields # incompatible with "counter" fields
if node.get_property("counter"): if node.get_property("counter"):

View File

@@ -16,14 +16,14 @@ class IsSigned(UDPDefinition):
if value and node.get_property("counter"): if value and node.get_property("counter"):
self.msg.error( self.msg.error(
"The property is_signed=true is not supported for counter fields.", "The property is_signed=true is not supported for counter fields.",
node.inst.property_src_ref["is_signed"] node.property_src_ref.get("is_signed", node.inst_src_ref)
) )
# incompatible with "encode" fields # incompatible with "encode" fields
if value and node.get_property("encode") is not None: if value and node.get_property("encode") is not None:
self.msg.error( self.msg.error(
"The property is_signed=true is not supported for fields encoded as an enum.", "The property is_signed=true is not supported for fields encoded as an enum.",
node.inst.property_src_ref["is_signed"] node.property_src_ref.get("is_signed", node.inst_src_ref)
) )
def get_unassigned_default(self, node: "Node") -> Any: def get_unassigned_default(self, node: "Node") -> Any:

View File

@@ -49,7 +49,7 @@ class DesignValidator(RDLListener):
if isinstance(value, PropertyReference): if isinstance(value, PropertyReference):
src_ref = value.src_ref src_ref = value.src_ref
else: else:
src_ref = node.inst.property_src_ref.get(prop_name, node.inst.inst_src_ref) src_ref = node.property_src_ref.get(prop_name, node.inst_src_ref)
self.msg.error( self.msg.error(
"Property is assigned a reference that points to a component not internal to the regblock being exported.", "Property is assigned a reference that points to a component not internal to the regblock being exported.",
src_ref src_ref
@@ -65,7 +65,7 @@ class DesignValidator(RDLListener):
"Only cpuif_reset signals that are instantiated in the top-level " "Only cpuif_reset signals that are instantiated in the top-level "
"addrmap or above will be honored. Any cpuif_reset signals nested " "addrmap or above will be honored. Any cpuif_reset signals nested "
"within children of the addrmap being exported will be ignored.", "within children of the addrmap being exported will be ignored.",
node.inst.inst_src_ref node.inst_src_ref
) )
def enter_AddressableComponent(self, node: 'AddressableNode') -> None: def enter_AddressableComponent(self, node: 'AddressableNode') -> None:
@@ -75,13 +75,13 @@ class DesignValidator(RDLListener):
self.msg.error( self.msg.error(
"Unaligned registers are not supported. Address offset of " "Unaligned registers are not supported. Address offset of "
f"instance '{node.inst_name}' must be a multiple of {alignment}", f"instance '{node.inst_name}' must be a multiple of {alignment}",
node.inst.inst_src_ref node.inst_src_ref
) )
if node.is_array and (node.array_stride % alignment) != 0: # type: ignore # is_array implies stride is not none if node.is_array and (node.array_stride % alignment) != 0: # type: ignore # is_array implies stride is not none
self.msg.error( self.msg.error(
"Unaligned registers are not supported. Address stride of " "Unaligned registers are not supported. Address stride of "
f"instance array '{node.inst_name}' must be a multiple of {alignment}", f"instance array '{node.inst_name}' must be a multiple of {alignment}",
node.inst.inst_src_ref node.inst_src_ref
) )
if not isinstance(node, RegNode): if not isinstance(node, RegNode):
@@ -102,7 +102,7 @@ class DesignValidator(RDLListener):
if node.get_property('sharedextbus'): if node.get_property('sharedextbus'):
self.msg.error( self.msg.error(
"This exporter does not support enabling the 'sharedextbus' property yet.", "This exporter does not support enabling the 'sharedextbus' property yet.",
node.inst.property_src_ref.get('sharedextbus', node.inst.inst_src_ref) node.property_src_ref.get('sharedextbus', node.inst_src_ref)
) )
def enter_Reg(self, node: 'RegNode') -> None: def enter_Reg(self, node: 'RegNode') -> None:
@@ -117,7 +117,7 @@ class DesignValidator(RDLListener):
f"Multi-word registers that have an accesswidth ({accesswidth}) " f"Multi-word registers that have an accesswidth ({accesswidth}) "
"that are inconsistent with this regblock's CPU bus width " "that are inconsistent with this regblock's CPU bus width "
f"({self.exp.cpuif.data_width}) are not supported.", f"({self.exp.cpuif.data_width}) are not supported.",
node.inst.inst_src_ref node.inst_src_ref
) )
@@ -138,7 +138,7 @@ class DesignValidator(RDLListener):
" multiple software-accessible subwords. Consider enabling" " multiple software-accessible subwords. Consider enabling"
" write double-buffering.\n" " write double-buffering.\n"
"For more details, see: https://peakrdl-regblock.readthedocs.io/en/latest/udps/write_buffering.html", "For more details, see: https://peakrdl-regblock.readthedocs.io/en/latest/udps/write_buffering.html",
node.inst.inst_src_ref node.inst_src_ref
) )
if node.get_property('onread') is not None and not node.parent.get_property('buffer_reads'): if node.get_property('onread') is not None and not node.parent.get_property('buffer_reads'):
@@ -150,7 +150,7 @@ class DesignValidator(RDLListener):
" access its value correctly. Consider enabling read" " access its value correctly. Consider enabling read"
" double-buffering. \n" " double-buffering. \n"
"For more details, see: https://peakrdl-regblock.readthedocs.io/en/latest/udps/read_buffering.html", "For more details, see: https://peakrdl-regblock.readthedocs.io/en/latest/udps/read_buffering.html",
node.inst.inst_src_ref node.inst_src_ref
) )
# Check for unsynthesizable reset # Check for unsynthesizable reset
@@ -166,7 +166,7 @@ class DesignValidator(RDLListener):
if is_async_reset: if is_async_reset:
self.msg.error( self.msg.error(
"A field that uses an asynchronous reset cannot use a dynamic reset value. This is not synthesizable.", "A field that uses an asynchronous reset cannot use a dynamic reset value. This is not synthesizable.",
node.inst.inst_src_ref node.inst_src_ref
) )
@@ -195,7 +195,7 @@ class DesignValidator(RDLListener):
self.msg.error( self.msg.error(
f"Address offset +0x{node.raw_address_offset:x} of instance '{node.inst_name}' is not a power of 2 multiple of its size 0x{node.size:x}. " f"Address offset +0x{node.raw_address_offset:x} of instance '{node.inst_name}' is not a power of 2 multiple of its size 0x{node.size:x}. "
f"This is required by the regblock exporter if a component {err_suffix}.", f"This is required by the regblock exporter if a component {err_suffix}.",
node.inst.inst_src_ref node.inst_src_ref
) )
if node.is_array: if node.is_array:
assert node.array_stride is not None assert node.array_stride is not None
@@ -203,5 +203,5 @@ class DesignValidator(RDLListener):
self.msg.error( self.msg.error(
f"Address stride of instance array '{node.inst_name}' is not a power of 2" f"Address stride of instance array '{node.inst_name}' is not a power of 2"
f"This is required by the regblock exporter if a component {err_suffix}.", f"This is required by the regblock exporter if a component {err_suffix}.",
node.inst.inst_src_ref node.inst_src_ref
) )

View File

@@ -35,7 +35,7 @@ class WBufLogicGenerator(RDLForLoopGenerator):
n_subwords = regwidth // accesswidth n_subwords = regwidth // accesswidth
for i in range(n_subwords): for i in range(n_subwords):
strobe = strb_prefix + f"[{i}]" strobe = strb_prefix + f"[{i}]"
if node.inst.is_msb0_order: if node.is_msb0_order:
bslice = f"[{regwidth - (accesswidth * i) - 1}: {regwidth - (accesswidth * (i+1))}]" bslice = f"[{regwidth - (accesswidth * i) - 1}: {regwidth - (accesswidth * (i+1))}]"
else: else:
bslice = f"[{(accesswidth * (i + 1)) - 1}:{accesswidth * i}]" bslice = f"[{(accesswidth * (i + 1)) - 1}:{accesswidth * i}]"

View File

@@ -15,7 +15,7 @@ always_ff {{get_always_ff_event(cpuif.reset)}} begin
{%- for segment in segments %} {%- for segment in segments %}
if({{segment.strobe}} && decoded_req_is_wr) begin if({{segment.strobe}} && decoded_req_is_wr) begin
{{wbuf_prefix}}.pending <= '1; {{wbuf_prefix}}.pending <= '1;
{%- if node.inst.is_msb0_order %} {%- if node.is_msb0_order %}
{{wbuf_prefix}}.data{{segment.bslice}} <= ({{wbuf_prefix}}.data{{segment.bslice}} & ~decoded_wr_biten_bswap) | (decoded_wr_data_bswap & decoded_wr_biten_bswap); {{wbuf_prefix}}.data{{segment.bslice}} <= ({{wbuf_prefix}}.data{{segment.bslice}} & ~decoded_wr_biten_bswap) | (decoded_wr_data_bswap & decoded_wr_biten_bswap);
{{wbuf_prefix}}.biten{{segment.bslice}} <= {{wbuf_prefix}}.biten{{segment.bslice}} | decoded_wr_biten_bswap; {{wbuf_prefix}}.biten{{segment.bslice}} <= {{wbuf_prefix}}.biten{{segment.bslice}} | decoded_wr_biten_bswap;
{%- else %} {%- else %}