Skip to content

Commit 796347d

Browse files
committed
[rdl2ot] add UDPs to rdljson output
Signed-off-by: Douglas Reis <doreis@lowrisc.org>
1 parent bcceb67 commit 796347d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

rdl2ot/src/rdl2ot/rtl_exporter.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from jinja2 import Environment, FileSystemLoader
1212
from systemrdl import node
1313
from systemrdl.rdltypes import OnReadType
14+
from systemrdl.rdltypes.user_struct import UserStruct
1415

1516
from rdl2ot import opentitan
1617

@@ -172,6 +173,9 @@ def get_mem(self, mem: node.FieldNode) -> dict:
172173
obj["offset"] = mem.address_offset
173174
obj["size"] = obj["width"] * obj["entries"] // 8
174175
obj["integrity_bypass"] = mem.get_property("integrity_bypass", default=False)
176+
if udps := self.get_udps(mem):
177+
obj["udps"] = udps
178+
175179
self.all_async_clk &= bool(mem.get_property("async_clk", default=False))
176180
self.num_windows += 1
177181
return obj
@@ -243,6 +247,24 @@ def get_paramesters(self, obj: node.AddrmapNode | node.RegfileNode) -> [dict]:
243247
for param in obj.inst.parameters
244248
]
245249

250+
251+
def get_udps(self, obj: node.AddrmapNode | node.RegfileNode) -> [dict]:
252+
"""
253+
Parse the customs properties and return a list of dictionaries.
254+
"""
255+
udps = obj.list_properties(include_native=False)
256+
if len(udps) < 1:
257+
return None
258+
res = {}
259+
for name in udps:
260+
udp = obj.get_property(name)
261+
if isinstance(udp, list) and isinstance(udp[0], UserStruct):
262+
res.update({name: [dict(item.members) for item in udp ]})
263+
else:
264+
res.update({name: udp})
265+
266+
return res
267+
246268
def get_interface(self, addrmap: node.AddrmapNode, defalt_name: None | str = None) -> dict:
247269
"""Parse an interface and return a dictionary."""
248270
self.num_regs = 0
@@ -308,10 +330,12 @@ def get_interface(self, addrmap: node.AddrmapNode, defalt_name: None | str = Non
308330
def parse_ip_block(self, ip_block: node.AddrmapNode) -> dict:
309331
"""Parse the ip_block node of an IP block and return a dictionary."""
310332
obj = {"name": ip_block.inst_name, "type": "device", "type_name": ip_block.type_name}
311-
params = self.get_paramesters(ip_block)
312-
if params:
333+
if params:= self.get_paramesters(ip_block):
313334
obj["parameters"] = params
314335

336+
if udps := self.get_udps(ip_block):
337+
obj["udps"] = udps
338+
315339
obj["offsets"] = self.parse_array(ip_block)
316340
obj["size"] = ip_block.array_stride if ip_block.is_array else ip_block.size
317341

0 commit comments

Comments
 (0)