Fix missing error message if multiple unconditional field assignments are inferred. #93

This commit is contained in:
Alex Mykyta
2025-03-06 22:12:26 -08:00
parent 54ac56e1c3
commit d3cd51f500
5 changed files with 60 additions and 27 deletions

View File

@@ -1,18 +1,17 @@
from typing import TYPE_CHECKING, List
from .bases import NextStateConditional
from .bases import NextStateConditional, NextStateUnconditional
if TYPE_CHECKING:
from systemrdl.node import FieldNode
class AlwaysWrite(NextStateConditional):
class AlwaysWrite(NextStateUnconditional):
"""
hw writable, without any qualifying we/wel
"""
is_unconditional = True
comment = "HW Write"
unconditional_explanation = "A hardware-writable field without a write-enable (we/wel) will always update the field value"
def is_match(self, field: 'FieldNode') -> bool:
return (
@@ -40,8 +39,28 @@ class AlwaysWrite(NextStateConditional):
"load_next_c = '1;",
]
class WEWrite(AlwaysWrite):
is_unconditional = False
class _QualifiedWrite(NextStateConditional):
def get_assignments(self, field: 'FieldNode') -> List[str]:
hwmask = field.get_property('hwmask')
hwenable = field.get_property('hwenable')
I = str(self.exp.hwif.get_input_identifier(field))
R = self.exp.field_logic.get_storage_identifier(field)
if hwmask is not None:
M = self.exp.dereferencer.get_value(hwmask)
next_val = f"{I} & ~{M} | {R} & {M}"
elif hwenable is not None:
E = self.exp.dereferencer.get_value(hwenable)
next_val = f"{I} & {E} | {R} & ~{E}"
else:
next_val = I
return [
f"next_c = {next_val};",
"load_next_c = '1;",
]
class WEWrite(_QualifiedWrite):
comment = "HW Write - we"
def is_match(self, field: 'FieldNode') -> bool:
return (
@@ -58,8 +77,7 @@ class WEWrite(AlwaysWrite):
identifier = str(self.exp.dereferencer.get_value(prop))
return identifier
class WELWrite(AlwaysWrite):
is_unconditional = False
class WELWrite(_QualifiedWrite):
comment = "HW Write - wel"
def is_match(self, field: 'FieldNode') -> bool:
return (