Skip to content

Commit 3e0aa4b

Browse files
authored
floogen: Separate generated SV package and top-module (#110)
* floogen(utils): Update warning messages * floogen(pkg): Support package-only creation * docs: Update CHANGELOG * docs: Update CHANGELOG * docs: Update CHANGELOG with links to corresponding PRs * bender: Add new generated packages to `Bender.yml` * bender: Use `floo_test` target to avoid import of testbenches
1 parent 5c2762f commit 3e0aa4b

8 files changed

+144
-94
lines changed

Bender.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ sources:
5959
- hw/floo_nw_vc_chimney.sv
6060
- hw/floo_nw_vc_router.sv
6161

62-
- target: test
62+
- target: floo_test
6363
include_dirs:
6464
- hw/test/include
6565
files:
@@ -80,16 +80,18 @@ sources:
8080
- hw/tb/tb_floo_rob.sv
8181
- hw/tb/tb_floo_vc_router.sv
8282

83-
- target: all(test, axi_mesh)
83+
- target: all(floo_test, axi_mesh)
8484
include_dirs:
8585
- hw/test/include
8686
files:
87+
- generated/floo_axi_mesh_noc_pkg.sv
8788
- generated/floo_axi_mesh_noc.sv
8889
- hw/tb/tb_floo_axi_mesh.sv
8990

90-
- target: all(test, nw_mesh)
91+
- target: all(floo_test, nw_mesh)
9192
include_dirs:
9293
- hw/test/include
9394
files:
95+
- generated/floo_nw_mesh_noc_pkg.sv
9496
- generated/floo_nw_mesh_noc.sv
9597
- hw/tb/tb_floo_nw_mesh.sv

CHANGELOG.md

+39-36
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,72 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
99
### Added
1010

1111
#### Hardware
12-
- The `floo_pkg` was extended with helper functions to calculate the size of AXI payloads and mapping of AXI to Floo Channels.
13-
- Multiple configuration structs were introduced to enable a more flexible and non-verbose configuration of the FlooNoC modules.
12+
- The `floo_pkg` was extended with helper functions to calculate the size of AXI payloads and mapping of AXI to Floo Channels. (https://github.com/pulp-platform/FlooNoC/pull/65)
13+
- Multiple configuration structs were introduced to enable a more flexible and non-verbose configuration of the FlooNoC modules. (https://github.com/pulp-platform/FlooNoC/pull/65)
1414
- The `AxiCfg` describes all the necessary parameters needed for the type definitions of a bidirectional AXI interface
1515
- The `RouteCfg` describes all the necessary routing information parameters required by the chimneys.
1616
- The `ChimneyCfg` describes all other parameters for the data path of the chimney (e.g. Mgr/Sbr port enable, number of oustanding transactions, RoB types & sizes, etc.)
17-
- The `floo_test_pkg` now defines default configurations for all the new configuration structs that are used by the testbenches.
18-
- Add `floo_axi_router` module, which is a wrapper similar to the `floo_nw_router` but for single-AXI configurations, and can be used in conjunction with `floo_axi_chimney`.
17+
- The `floo_test_pkg` now defines default configurations for all the new configuration structs that are used by the testbenches. (https://github.com/pulp-platform/FlooNoC/pull/65)
18+
- Add `floo_axi_router` module, which is a wrapper similar to the `floo_nw_router` but for single-AXI configurations, and can be used in conjunction with `floo_axi_chimney`. (https://github.com/pulp-platform/FlooNoC/pull/69)
1919
- `floo_nw_join` now also allows to convert to a narrow AXI interface, which is useful for accessing peripherals for instance.
2020
- The atomic adapter in `floo_nw_join` can now be disabled with `EnAtopAdapter`.
2121

2222
#### FlooGen
23-
- The `data_width` and `user_width` fields for `protocols` are now also validated to be compatible with each other.
24-
- All the various `*Cfg`'s is now rendered by _FlooGen_, either in the `*_noc_pkg` or in the `*_noc` module itself.
25-
- Added support for single-AXI configuration networks.
26-
- Support for negative increments when specifying a `src_range` or `dst_range` in the `connections` schema.
27-
- Add support for multiple non-contiguous address ranges for endpoints.
23+
- The `data_width` and `user_width` fields for `protocols` are now also validated to be compatible with each other. (https://github.com/pulp-platform/FlooNoC/pull/65)
24+
- All the various `*Cfg`'s is now rendered by _FlooGen_, either in the `*_noc_pkg` or in the `*_noc` module itself. (https://github.com/pulp-platform/FlooNoC/pull/65)
25+
- Added support for single-AXI configuration networks. (https://github.com/pulp-platform/FlooNoC/pull/69)
26+
- Support for negative increments when specifying a `src_range` or `dst_range` in the `connections` schema. (https://github.com/pulp-platform/FlooNoC/pull/77)
27+
- Add support for multiple non-contiguous address ranges for endpoints. (https://github.com/pulp-platform/FlooNoC/pull/80)
2828

2929
### Changed
3030

3131
#### Hardware
32-
- The `floo_narrow_wide_*` modules and the corresponding testbenches were renamed to `floo_nw_*` to be more concise.
33-
- The flit type definitions are now implemented as SystemVerilog macros in `typedef.svh`.
34-
- The parametrization of the chimney modules has changed dramatically. They now use the newly introduced `*Cfg`'s from the `floo_pkg`. In the narrow-wide chimneys, both datapaths now have their own configs (i.e. `*CfgN` and `*CfgW`), to reduce the verbosity of the module instantiation.
35-
- The payload field name in each `*_chan_t` type previously had its own name. This was unified to `payload` since `*_chan_t` already determines the type of the payload.
36-
- The input and output buffer FIFO depth of the routers were renamed to `InFifoDepth` and `OutFifoDepth` to be more consistent (previously `ChannelFifoDepth` and `OutputFifoDepth`).
37-
- The narrow-wide router wrapper now also requires the `AxiCfg` structs to redefine the link types internally.
38-
- The `ReorderBufferSize` parameters was shortened to `RoBSize`.
39-
- All testbenches were adapted to all changes.
40-
- All verification IPs were adapted to the new configuration structs.
32+
- The `floo_narrow_wide_*` modules and the corresponding testbenches were renamed to `floo_nw_*` to be more concise. (https://github.com/pulp-platform/FlooNoC/pull/65)
33+
- The flit type definitions are now implemented as SystemVerilog macros in `typedef.svh`. (https://github.com/pulp-platform/FlooNoC/pull/65)
34+
- The parametrization of the chimney modules has changed dramatically. They now use the newly introduced `*Cfg`'s from the `floo_pkg`. In the narrow-wide chimneys, both datapaths now have their own configs (i.e. `*CfgN` and `*CfgW`), to reduce the verbosity of the module instantiation. (https://github.com/pulp-platform/FlooNoC/pull/65)
35+
- The payload field name in each `*_chan_t` type previously had its own name. This was unified to `payload` since `*_chan_t` already determines the type of the payload. (https://github.com/pulp-platform/FlooNoC/pull/65)
36+
- The input and output buffer FIFO depth of the routers were renamed to `InFifoDepth` and `OutFifoDepth` to be more consistent (previously `ChannelFifoDepth` and `OutputFifoDepth`). (https://github.com/pulp-platform/FlooNoC/pull/65)
37+
- The narrow-wide router wrapper now also requires the `AxiCfg` structs to redefine the link types internally. (https://github.com/pulp-platform/FlooNoC/pull/65)
38+
- The `ReorderBufferSize` parameters was shortened to `RoBSize`. (https://github.com/pulp-platform/FlooNoC/pull/65)
39+
- All testbenches were adapted to all changes. (https://github.com/pulp-platform/FlooNoC/pull/65)
40+
- All verification IPs were adapted to the new configuration structs. (https://github.com/pulp-platform/FlooNoC/pull/65)
4141

4242
#### FlooGen
43-
- The link typedefs are now renderd with the macros in `typedef.svh` instead of rendering them in pure SystemVerilog.
44-
- The template files were renamed to use the more concise `nw` naming scheme.
45-
- The generated modules and packages of _FlooGen_ are now named `floo_*_noc` resp. `floo_*_noc_pkg` which is more consistent since all other modules have the `floo_*` prefix.
46-
- The `protocols` schema was adapted a bit to be more intuitive.
43+
- The link typedefs are now renderd with the macros in `typedef.svh` instead of rendering them in pure SystemVerilog. (https://github.com/pulp-platform/FlooNoC/pull/65)
44+
- The template files were renamed to use the more concise `nw` naming scheme. (https://github.com/pulp-platform/FlooNoC/pull/65)
45+
- The generated modules and packages of _FlooGen_ are now named `floo_*_noc` resp. `floo_*_noc_pkg` which is more consistent since all other modules have the `floo_*` prefix. (https://github.com/pulp-platform/FlooNoC/pull/65)
46+
- The `protocols` schema was adapted a bit to be more intuitive. (https://github.com/pulp-platform/FlooNoC/pull/65)
4747
- The `type` field was renamed to `protocol`, which currently only accepts `AXI4`. A new `type` field now is used by _FlooGen_ to now where to attach the protocol in the network interface. Currently, _FlooGen_ only supports the narrow-wide AXI configuration, hence only `narrow|wide` is allowed as `type` values.
4848
- The `direction` field in the `protocol` schema is no longer required, since the direction is determined when specifying `mgr_port_protocol` and `sbr_port_protocol`.
4949
- The `name` field must be unique now, since it is used by `mgr_port_protocol` and `sbr_port_protocol` to reference the exact protocol.
5050
- All examples were adapted to reflect those changes.
51-
- A FlooGen configuration file now requires a `network_type` field, to determine the type of network to generate. The options are `axi` for single-AXI networks and `narrow-wide` for the narrow-wide AXI configurations.
52-
- The system address map `Sam` is now sorted correctly and can be indexed with `ep_id_e` values.
53-
- `id_offset` was renamed to `xy_id_offset`, since this is now only applicable in `XYRouting` networks. An ID offset does not make sense for other types of routing algorithms. The use of `id_offset` is anyway not recommended anymore, since the direction of the connections can be specified in the `connections` schema.
54-
- Endpoint names in the `ep_id_e` enum, which are created as 2D arrays now have clearer naming scheme by prefixing them with `X` and `Y`.
51+
- A _FlooGen_ configuration file now requires a `network_type` field, to determine the type of network to generate. The options are `axi` for single-AXI networks and `narrow-wide` for the narrow-wide AXI configurations. (https://github.com/pulp-platform/FlooNoC/pull/69)
52+
- The system address map `Sam` is now sorted correctly and can be indexed with `ep_id_e` values. (https://github.com/pulp-platform/FlooNoC/pull/72)
53+
- `id_offset` was renamed to `xy_id_offset`, since this is now only applicable in `XYRouting` networks. An ID offset does not make sense for other types of routing algorithms. The use of `id_offset` is anyway not recommended anymore, since the direction of the connections can be specified in the `connections` schema. (https://github.com/pulp-platform/FlooNoC/pull/72)
54+
- Endpoint names in the `ep_id_e` enum, which are created as 2D arrays now have clearer naming scheme by prefixing them with `X` and `Y`. (https://github.com/pulp-platform/FlooNoC/pull/90)
55+
- The package and the top-module of the generated network are now seperated into its own modules `floo_*_noc.sv` and `floo_*_noc_pkg.sv`. (https://github.com/pulp-platform/FlooNoC/pull/110)
56+
- The `--only-pkg` and `-only-top` flags were added to the _FlooGen_ CLI to omit the generation of the package resp. the top-module. (https://github.com/pulp-platform/FlooNoC/pull/110)
57+
- If `--outdir` resp. `-o` is not specified _FlooGen_ will print the generated files to stdout instead of writing them to a file. (https://github.com/pulp-platform/FlooNoC/pull/110)
5558

5659
### Fixed
5760

58-
- A bug in the calcuation of the RoB offset in `floo_rob` was fixed. Previously, the allocation and the write process used the same counter in bursts for offset calculation, which resulted in wrong offsets.
59-
- Routers with `XYRouting` do now use the global `id_offset`, which was previously not accounted for (or had to be specified manually).
60-
- Fixed elaboration errors in the chimneys that occured.
61-
- Fixed Synopsys DC elaboration error due to concatenation in `id_i` port connection of chimneys and routers.
61+
- A bug in the calcuation of the RoB offset in `floo_rob` was fixed. Previously, the allocation and the write process used the same counter in bursts for offset calculation, which resulted in wrong offsets. (https://github.com/pulp-platform/FlooNoC/pull/65)
62+
- Routers with `XYRouting` do now use the global `id_offset`, which was previously not accounted for (or had to be specified manually). (https://github.com/pulp-platform/FlooNoC/pull/72)
63+
- Fixed elaboration errors in the chimneys that occured. (https://github.com/pulp-platform/FlooNoC/pull/75)
64+
- Fixed Synopsys DC elaboration error due to concatenation in `id_i` port connection of chimneys and routers. (https://github.com/pulp-platform/FlooNoC/pull/103)
6265

6366
### Removed
6467

6568
#### Hardware
6669

67-
- As the flit type definitions were moved to `typedef.svh`, the auto-generated `floo_*_pkg` packages were removed from the repository. Furthermore, all the (global) imports of those packages in the modules were replaced by parameters.
68-
- The testbench `tb_floo_nw_chimney` was removed since it was neither used nor maintained anymore.
69-
- The `IdIsPort` routing algorithm was removed since it can only be used for routes over a single router. The same functionality can be achieved with the `SourceRouting` algorithm.
70-
- The `dma_mesh` testbench was removed in favor of `nw_mesh` and `axi_mesh` which use generated networks with _FlooGen_.
70+
- As the flit type definitions were moved to `typedef.svh`, the auto-generated `floo_*_pkg` packages were removed from the repository. Furthermore, all the (global) imports of those packages in the modules were replaced by parameters. (https://github.com/pulp-platform/FlooNoC/pull/65)
71+
- The testbench `tb_floo_nw_chimney` was removed since it was neither used nor maintained anymore. (https://github.com/pulp-platform/FlooNoC/pull/65)
72+
- The `IdIsPort` routing algorithm was removed since it can only be used for routes over a single router. The same functionality can be achieved with the `SourceRouting` algorithm. (https://github.com/pulp-platform/FlooNoC/pull/65)
73+
- The `dma_mesh` testbench was removed in favor of `nw_mesh` and `axi_mesh` which use generated networks with _FlooGen_. (https://github.com/pulp-platform/FlooNoC/pull/72)
7174

7275
#### FlooGen
73-
- The package generation was removed from _FlooGen_ since it is now handled by the `typedef.svh` file. Further, the `--only-pkg` and `--pkg-outdir` flags were removed from the _FlooGen_ CLI.
74-
- The calculation of link sizes and AXI to Floo channel mapping was removed from the _FlooGen_ configuration file. This is now handled by the `floo_pkg` helper functions.
76+
- The package generation was removed from _FlooGen_ since it is now handled by the `typedef.svh` file. Further, the `--only-pkg` and `--pkg-outdir` flags were removed from the _FlooGen_ CLI. (https://github.com/pulp-platform/FlooNoC/pull/65)
77+
- The calculation of link sizes and AXI to Floo channel mapping was removed from the _FlooGen_ configuration file. This is now handled by the `floo_pkg` helper functions. (https://github.com/pulp-platform/FlooNoC/pull/65)
7578

7679
## [0.5.0] - 2024-09-13
7780

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ VLOGAN ?= vcs-2022.06 vlogan
3636

3737
BENDER_FLAGS += -t rtl
3838
BENDER_FLAGS += -t test
39+
BENDER_FLAGS += -t floo_test
3940
BENDER_FLAGS += -t snitch_cluster
4041
BENDER_FLAGS += -t idma_test
4142
BENDER_FLAGS := $(BENDER_FLAGS) $(EXTRA_BENDER_FLAGS)

floogen/floo_gen.py

+44-14
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,24 @@ def parse_args():
2525
"--outdir",
2626
type=Path,
2727
required=False,
28-
help="Path to the output directory of the generated output.",
28+
help=(
29+
"Path to the output directory of the generated output files. "
30+
"If not specified, the files are printed to stdout."
31+
),
32+
)
33+
parser.add_argument(
34+
"--only-pkg",
35+
dest="only_pkg",
36+
action="store_true",
37+
default=False,
38+
help="Only generate the NoC package.",
39+
)
40+
parser.add_argument(
41+
"--only-top",
42+
dest="only_top",
43+
action="store_true",
44+
default=False,
45+
help="Only generate the NoC top-module.",
2946
)
3047
parser.add_argument(
3148
"--no-format",
@@ -43,35 +60,48 @@ def main(): # pylint: disable=too-many-branches
4360
args = parse_args()
4461
network = parse_config(Network, args.config)
4562

46-
if args.outdir:
47-
outdir = Path(os.getcwd(), args.outdir)
48-
else:
49-
# default output directory
50-
outdir = Path(os.getcwd(), "generated")
51-
5263
network.create_network()
5364
network.compile_network()
5465
network.gen_routing_info()
5566

67+
# Create the output directory if it doesn't exist
68+
if args.outdir:
69+
outdir = Path(args.outdir)
70+
if not outdir.is_absolute():
71+
outdir = Path(os.getcwd(), outdir)
72+
outdir.mkdir(parents=True, exist_ok=True)
73+
5674
# Visualize the network graph
5775
if args.visualize:
58-
if outdir:
76+
if args.outdir:
5977
network.visualize(filename=outdir / (network.name + ".pdf"))
6078
else:
6179
network.visualize(savefig=False)
6280

6381
# Generate the network description
82+
rendered_pkg = network.render_package()
6483
rendered_top = network.render_network()
84+
85+
# Format the output if requested
6586
if not args.no_format:
6687
rendered_top = verible_format(rendered_top)
88+
rendered_pkg = verible_format(rendered_pkg)
89+
6790
# Write the network description to file or print it to stdout
68-
if outdir:
69-
outdir.mkdir(parents=True, exist_ok=True)
70-
top_file_name = outdir / f"floo_{network.name}_noc.sv"
71-
with open(top_file_name, "w+", encoding="utf-8") as top_file:
72-
top_file.write(rendered_top)
91+
if args.outdir:
92+
if not args.only_top:
93+
pkg_file_name = outdir / f"floo_{network.name}_noc_pkg.sv"
94+
with open(pkg_file_name, "w+", encoding="utf-8") as pkg_file:
95+
pkg_file.write(rendered_pkg)
96+
if not args.only_pkg:
97+
top_file_name = outdir / f"floo_{network.name}_noc.sv"
98+
with open(top_file_name, "w+", encoding="utf-8") as top_file:
99+
top_file.write(rendered_top)
73100
else:
74-
print(rendered_top)
101+
if not args.only_top:
102+
print(rendered_pkg)
103+
if not args.only_pkg:
104+
print(rendered_top)
75105

76106

77107
if __name__ == "__main__":

floogen/model/network.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class Network(BaseModel): # pylint: disable=too-many-public-methods
3636
model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid")
3737

3838
with as_file(files(floogen.templates).joinpath("floo_top_noc.sv.mako")) as _tpl_path:
39-
tpl: ClassVar = Template(filename=str(_tpl_path))
39+
noc_tpl: ClassVar = Template(filename=str(_tpl_path))
40+
with as_file(files(floogen.templates).joinpath("floo_top_noc_pkg.sv.mako")) as _tpl_path:
41+
pkg_tpl: ClassVar = Template(filename=str(_tpl_path))
4042

4143
name: str
4244
description: Optional[str]
@@ -760,7 +762,11 @@ def render_ep_enum(self):
760762

761763
def render_network(self):
762764
"""Render the network in the generated code."""
763-
return self.tpl.render(noc=self)
765+
return self.noc_tpl.render(noc=self)
766+
767+
def render_package(self):
768+
"""Render the network package in the generated code."""
769+
return self.pkg_tpl.render(noc=self)
764770

765771
def visualize(self, savefig=True, filename: pathlib.Path = "network.png"):
766772
"""Visualize the network graph."""

floogen/templates/floo_top_noc.sv.mako

-38
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,6 @@
77

88
// AUTOMATICALLY GENERATED! DO NOT EDIT!
99

10-
`include "axi/typedef.svh"
11-
`include "floo_noc/typedef.svh"
12-
13-
package floo_${noc.name}_noc_pkg;
14-
15-
import floo_pkg::*;
16-
17-
/////////////////////
18-
// Address Map //
19-
/////////////////////
20-
21-
${noc.render_ep_enum()}
22-
23-
${noc.routing.render_typedefs()}
24-
25-
% if noc.routing.use_id_table:
26-
${noc.routing.sam.render(aw=noc.routing.addr_width)}
27-
% else:
28-
localparam int unsigned NumSamRules = 1;
29-
typedef logic sam_rule_t;
30-
localparam sam_rule_t Sam = '0;
31-
% endif
32-
33-
% if noc.routing.route_algo.value == "SourceRouting":
34-
${noc.render_ni_tables()}
35-
% endif
36-
37-
${noc.routing.render_route_cfg(name="RouteCfg")}
38-
39-
% for prot in noc.protocols:
40-
${prot.render_typedefs()}
41-
% endfor
42-
43-
${noc.routing.render_hdr_typedef(network_type=noc.network_type)}
44-
${noc.render_link_typedefs()}
45-
46-
endpackage
47-
4810
module floo_${noc.name}_noc
4911
import floo_pkg::*;
5012
import floo_${noc.name}_noc_pkg::*;

0 commit comments

Comments
 (0)