Skip to content

Commit f7bf1a1

Browse files
committed
[reggen, systemrdl] Create udp for multibit regwen
One example is fund in mbx.hjson
1 parent 86955fa commit f7bf1a1

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

util/reggen/systemrdl/udp.rdl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ enum MultiBitBool32 {
7070
False = 0x69696969;
7171
};
7272

73+
/*
74+
* The same as swwe, but supports multibit references.
75+
*/
76+
property mubi_swwe {
77+
type = ref;
78+
component = reg|field;
79+
};
80+
7381
/**
7482
* true if hardware uses `re` signal, which is latched signal of software read pulse.
7583
* The standard SystemRDL property `swacc` cannot be used here because `swacc = hwre | swmod`.

util/reggen/systemrdl_exporter.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,22 @@ def _get_mubi_name(self) -> str:
102102
alignment = 4
103103
aligned_width = (self.inner.bits.width() + alignment - 1) & ~(alignment - 1)
104104
return f"MultiBitBool{aligned_width}"
105-
106-
def assign_swwe(self, field: systemrdl.component.Field, regwen: str) -> None:
105+
106+
def assign_swwe(self, field: systemrdl.component.Component, regwen: str | None) -> None:
107107
if swwe := bool(regwen):
108+
property_name = "swwe"
108109
if reg_ref := self.root.get_child_by_name(str(regwen)):
110+
wen_field = reg_ref.children[0]
109111
# This is a workaround and shall be fixed when the Issue
110112
# https://github.com/SystemRDL/systemrdl-compiler/issues/183 is fixed.
111113
swwe = InstRef(
112114
self.importer.compiler.env,
113115
self.root,
114-
[(str(regwen), [], None), (str(reg_ref.children[0].inst_name), [], None)],
116+
[(str(regwen), [], None), (str(wen_field.inst_name), [], None)],
115117
) # type: ignore
116-
self.importer.assign_property(field, "swwe", swwe)
117-
118+
if wen_field.width > 1: # type: ignore
119+
property_name = "mubi_swwe"
120+
self.importer.assign_property(field, property_name, swwe)
118121

119122
def export(
120123
self, strip_suffix: bool = False, regwen: str | None = None
@@ -162,6 +165,7 @@ def post_process(self, regwen: str) -> None:
162165
if field := self.parent.get_child_by_name(self.inner.name.upper()):
163166
self.assign_swwe(field, regwen)
164167

168+
165169
@dataclass
166170
class Window2Systemrdl:
167171
inner: Window

0 commit comments

Comments
 (0)