Skip to content

Commit

Permalink
Add user defined properties cpuif and addrwidth
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusGOlsen committed Jan 8, 2024
1 parent 0d39774 commit ab6650b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
10 changes: 10 additions & 0 deletions hdl-src/regblock_udps.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ property wr_swacc {
component = field;
type = boolean;
};

property cpuif {
component = addrmap;
type = string;
};

property addrwidth {
component = addrmap;
type = longint unsigned;
};
18 changes: 15 additions & 3 deletions src/peakrdl_regblock/__peakrdl__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def add_exporter_arguments(self, arg_group: 'argparse.ArgumentParser') -> None:
arg_group.add_argument(
"--cpuif",
choices=cpuifs.keys(),
default="apb3",
help="Select the CPU interface protocol to use [apb3]"
)

Expand Down Expand Up @@ -202,12 +201,25 @@ def do_export(self, top_node: 'AddrmapNode', options: 'argparse.Namespace') -> N
else:
raise RuntimeError

# Get cpuif. Favor command-line over SystemRDL, defaults to apb3.
if options.cpuif is not None:
cpuif = cpuifs[options.cpuif]
elif top_node.get_property('cpuif') is not None:
cpuif_name = top_node.get_property('cpuif')
if cpuif_name not in cpuifs:
raise RuntimeError(f"error: unknown cpuif: {cpuif_name} (choose from: {' '.join(cpuifs.keys())})")
cpuif = cpuifs[cpuif_name]
else:
cpuif = cpuifs['apb3']

# Get cpuif addr_width. Favor command-line over SystemRDL.
addr_width = options.addr_width or top_node.get_property('addrwidth')

x = RegblockExporter()
x.export(
top_node,
options.output,
cpuif_cls=cpuifs[options.cpuif],
cpuif_cls=cpuif,
module_name=options.module_name,
package_name=options.package_name,
reuse_hwif_typedefs=(options.type_style == "lexical"),
Expand All @@ -218,7 +230,7 @@ def do_export(self, top_node: 'AddrmapNode', options: 'argparse.Namespace') -> N
retime_external_mem=retime_external_mem,
retime_external_addrmap=retime_external_addrmap,
generate_hwif_report=options.hwif_report,
address_width=options.addr_width,
address_width=addr_width,
default_reset_activelow=default_reset_activelow,
default_reset_async=default_reset_async,
)
3 changes: 3 additions & 0 deletions src/peakrdl_regblock/udps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .rw_buffering import BufferWrites, WBufferTrigger
from .rw_buffering import BufferReads, RBufferTrigger
from .extended_swacc import ReadSwacc, WriteSwacc
from .cpuif import CpuIf, AddrWidth

ALL_UDPS = [
BufferWrites,
Expand All @@ -9,4 +10,6 @@
RBufferTrigger,
ReadSwacc,
WriteSwacc,
CpuIf,
AddrWidth,
]
24 changes: 24 additions & 0 deletions src/peakrdl_regblock/udps/cpuif.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from typing import TYPE_CHECKING, Any

from systemrdl.udp import UDPDefinition
from systemrdl.component import Addrmap

if TYPE_CHECKING:
from systemrdl.node import Node

class CpuIf(UDPDefinition):
name = "cpuif"
valid_components = {Addrmap}
valid_type = str

def get_unassigned_default(self, node: 'Node') -> Any:
return None


class AddrWidth(UDPDefinition):
name = "addrwidth"
valid_components = {Addrmap}
valid_type = int

def get_unassigned_default(self, node: 'Node') -> Any:
return None

0 comments on commit ab6650b

Please sign in to comment.