Skip to content

Commit 38a1b70

Browse files
authored
floogen: Render endpoint enums to index into Sam (#111)
* floogen(tpl): Remove obsolete template * floogen(routing): Allow description of address rules * floogen(tpl): Render enums to index the SAM * hw(pkg): Add `min` helper function * docs: Update CHANGELOG
1 parent 3e0aa4b commit 38a1b70

File tree

6 files changed

+24
-55
lines changed

6 files changed

+24
-55
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
2525
- Added support for single-AXI configuration networks. (https://github.com/pulp-platform/FlooNoC/pull/69)
2626
- Support for negative increments when specifying a `src_range` or `dst_range` in the `connections` schema. (https://github.com/pulp-platform/FlooNoC/pull/77)
2727
- Add support for multiple non-contiguous address ranges for endpoints. (https://github.com/pulp-platform/FlooNoC/pull/80)
28+
- Added a `sam_idx_e` enum in the package, which allows to directly index into the system address map. (https://github.com/pulp-platform/FlooNoC/pull/111)
2829

2930
### Changed
3031

floogen/model/network.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,14 @@ def gen_sam(self):
660660
dest = ni.id
661661
if self.routing.xy_id_offset is not None:
662662
dest -= self.routing.xy_id_offset
663-
for addr_range in ni.addr_range:
664-
addr_rule = RouteMapRule(dest=dest, addr_range=addr_range, desc=ni.name)
663+
for i, addr_range in enumerate(ni.addr_range):
664+
rule_name = ni.render_enum_name()
665+
if addr_range.desc is not None:
666+
rule_name += f"_{addr_range.desc}"
667+
elif len(ni.addr_range) > 1:
668+
rule_name += f"_{i}"
669+
rule_name += "_sam_idx"
670+
addr_rule = RouteMapRule(dest=dest, addr_range=addr_range, desc=rule_name)
665671
addr_table.append(addr_rule)
666672
return RouteMap(name="sam", rules=addr_table)
667673

@@ -760,6 +766,13 @@ def render_ep_enum(self):
760766
fields_dict["num_endpoints"] = len(fields_dict)
761767
return sv_enum_typedef(name="ep_id_e", fields_dict=fields_dict)
762768

769+
def render_sam_idx_enum(self):
770+
"""Render the system address map index enum in the generated code."""
771+
fields_dict = {}
772+
for i, desc in enumerate(reversed(self.routing.sam.rules)):
773+
fields_dict[desc.desc] = i
774+
return sv_enum_typedef(name="sam_idx_e", fields_dict=fields_dict)
775+
763776
def render_network(self):
764777
"""Render the network in the generated code."""
765778
return self.noc_tpl.render(noc=self)

floogen/model/routing.py

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ class AddrRange(BaseModel):
175175
size: int
176176
base: Optional[int] = None
177177
idx: Optional[int] = None
178+
desc: Optional[str] = None
178179

179180
def __str__(self):
180181
return f"[{self.start:X}:{self.end:X}]"

floogen/templates/floo_flit_pkg.sv.mako

-53
This file was deleted.

floogen/templates/floo_top_noc_pkg.sv.mako

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package floo_${noc.name}_noc_pkg;
2020

2121
${noc.render_ep_enum()}
2222

23+
${noc.render_sam_idx_enum()}
24+
2325
${noc.routing.render_typedefs()}
2426

2527
% if noc.routing.use_id_table:

hw/floo_pkg.sv

+5
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ package floo_pkg;
254254
return (a > b) ? a : b;
255255
endfunction
256256

257+
/// Helper function to calculate the minimum of two unsigned integers
258+
function automatic int unsigned min(int unsigned a, int unsigned b);
259+
return (a < b) ? a : b;
260+
endfunction
261+
257262
/// Returns the AXI config the resulting AXI config when joining a narrow
258263
/// and wide AXI subordinate interfaces.
259264
function automatic axi_cfg_t axi_join_cfg(axi_cfg_t cfg_n, axi_cfg_t cfg_w);

0 commit comments

Comments
 (0)