Skip to content

Commit 51bf98e

Browse files
committed
[rdl2ot] add UDPs to rdljson output
Signed-off-by: Douglas Reis <[email protected]>
1 parent b2602c8 commit 51bf98e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

rdl2ot/src/rdl2ot/rtl_exporter.py

Lines changed: 23 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,21 @@ def get_paramesters(self, obj: node.AddrmapNode | node.RegfileNode) -> [dict]:
243247
for param in obj.inst.parameters
244248
]
245249

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

333+
if udps := self.get_udps(ip_block):
334+
obj["udps"] = udps
335+
315336
obj["offsets"] = self.parse_array(ip_block)
316337
obj["size"] = ip_block.array_stride if ip_block.is_array else ip_block.size
317338

0 commit comments

Comments
 (0)