floogen 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- floogen-0.8.0/LICENSE-APACHE +201 -0
- floogen-0.8.0/PKG-INFO +72 -0
- floogen-0.8.0/docs/floogen/overview.md +45 -0
- floogen-0.8.0/floogen/__init__.py +3 -0
- floogen-0.8.0/floogen/cli.py +266 -0
- floogen-0.8.0/floogen/config_parser.py +116 -0
- floogen-0.8.0/floogen/examples/axi_mesh_id.yml +69 -0
- floogen-0.8.0/floogen/examples/axi_mesh_src.yml +69 -0
- floogen-0.8.0/floogen/examples/axi_mesh_xy.yml +69 -0
- floogen-0.8.0/floogen/examples/collective.yml +99 -0
- floogen-0.8.0/floogen/examples/mcast.yml +86 -0
- floogen-0.8.0/floogen/examples/nw_mesh_id.yml +86 -0
- floogen-0.8.0/floogen/examples/nw_mesh_src.yml +86 -0
- floogen-0.8.0/floogen/examples/nw_mesh_xy.yml +86 -0
- floogen-0.8.0/floogen/examples/occamy_mesh_src.yml +119 -0
- floogen-0.8.0/floogen/examples/occamy_mesh_xy.yml +125 -0
- floogen-0.8.0/floogen/examples/occamy_tree.yml +106 -0
- floogen-0.8.0/floogen/examples/single_cluster.yml +96 -0
- floogen-0.8.0/floogen/examples/terapool.yml +130 -0
- floogen-0.8.0/floogen/model/__init__.py +3 -0
- floogen-0.8.0/floogen/model/connection.py +64 -0
- floogen-0.8.0/floogen/model/endpoint.py +126 -0
- floogen-0.8.0/floogen/model/graph.py +310 -0
- floogen-0.8.0/floogen/model/link.py +180 -0
- floogen-0.8.0/floogen/model/network.py +801 -0
- floogen-0.8.0/floogen/model/network_interface.py +98 -0
- floogen-0.8.0/floogen/model/protocol.py +167 -0
- floogen-0.8.0/floogen/model/router.py +103 -0
- floogen-0.8.0/floogen/model/routing.py +948 -0
- floogen-0.8.0/floogen/query.py +73 -0
- floogen-0.8.0/floogen/templates/floo_addrmap.rdl.mako +19 -0
- floogen-0.8.0/floogen/templates/floo_axi_chimney.sv.mako +63 -0
- floogen-0.8.0/floogen/templates/floo_axi_router.sv.mako +88 -0
- floogen-0.8.0/floogen/templates/floo_axi_tile.sv.mako +133 -0
- floogen-0.8.0/floogen/templates/floo_noc.sv.mako +27 -0
- floogen-0.8.0/floogen/templates/floo_noc_pkg.sv.mako +63 -0
- floogen-0.8.0/floogen/templates/floo_nw_chimney.sv.mako +111 -0
- floogen-0.8.0/floogen/templates/floo_nw_router.sv.mako +124 -0
- floogen-0.8.0/floogen/tests/__init__.py +3 -0
- floogen-0.8.0/floogen/tests/address_test.py +108 -0
- floogen-0.8.0/floogen/tests/graph_test.py +390 -0
- floogen-0.8.0/floogen/utils.py +303 -0
- floogen-0.8.0/pyproject.toml +74 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 ETH Zurich
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
floogen-0.8.0/PKG-INFO
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: floogen
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: A Network Generator for FlooNoC
|
|
5
|
+
Keywords: noc,network-on-chip,generator,systemverilog,eda,pulp-platform
|
|
6
|
+
Author: Tim Fischer
|
|
7
|
+
Author-email: Tim Fischer <fischeti@iis.ee.ethz.ch>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE-APACHE
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Requires-Dist: pydantic
|
|
16
|
+
Requires-Dist: networkx
|
|
17
|
+
Requires-Dist: matplotlib
|
|
18
|
+
Requires-Dist: mako
|
|
19
|
+
Requires-Dist: ruamel-yaml
|
|
20
|
+
Requires-Dist: click>=8.3.1
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Project-URL: Homepage, https://github.com/pulp-platform/FlooNoC
|
|
23
|
+
Project-URL: Repository, https://github.com/pulp-platform/FlooNoC
|
|
24
|
+
Project-URL: Documentation, https://pulp-platform.github.io/FlooNoC/
|
|
25
|
+
Project-URL: Changelog, https://github.com/pulp-platform/FlooNoC/blob/main/CHANGELOG.md
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# _FlooGen_: The NoC Generation Framework
|
|
29
|
+
|
|
30
|
+
_FlooGen_ is the Python-based configuration and generation framework bundled with [_FlooNoC_](https://github.com/pulp-platform/FlooNoC). While [_FlooNoC_](https://github.com/pulp-platform/FlooNoC) provides the efficient hardware IP blocks (mainly routers and network interfaces), _FlooGen_ acts as the system architect that assembles them into a functional Network-on-Chip.
|
|
31
|
+
|
|
32
|
+
It transforms a high-level, human-readable description of your network (topology, routing rules, protocols) into fully connected, verified, and synthesizable SystemVerilog RTL.
|
|
33
|
+
|
|
34
|
+
## Why use a Generator?
|
|
35
|
+
|
|
36
|
+
Designing a Network-on-Chip manually is tedious and error-prone. Connecting hundreds of router ports, calculating deadlock-free routing tables, and maintaining consistent global address maps becomes unmanageable as system complexity grows.
|
|
37
|
+
|
|
38
|
+
_FlooGen_ solves this by raising the abstraction level. Instead of writing Verilog wire connections, you define **endpoints**, **routers** and their **connections**. _FlooGen_ handles the low-level implementation details, ensuring that:
|
|
39
|
+
|
|
40
|
+
* **Protocol conversion**: Network interfaces are automatically instantiated to bridge different endpoint protocols to the NoC link protocol.
|
|
41
|
+
* **Routing is correct**: Paths are calculated automatically based on the topology.
|
|
42
|
+
* **Configuration is consistent**: Address maps and endpoint IDs are allocated globally without overlaps.
|
|
43
|
+
|
|
44
|
+
## Key Capabilities
|
|
45
|
+
|
|
46
|
+
* **Topology Agnostic**: Generate standard topologies (Mesh, Ring, Tree) or completely custom irregular graphs based on your system constraints.
|
|
47
|
+
* **Automatic Routing**: Built-in engines to calculate routing tables for different routing algorithms.
|
|
48
|
+
* **Protocol Abstraction**: Define endpoints using high-level protocols (e.g., AXI4). _FlooGen_ automatically manages the conversion to the internal NoC link protocol.
|
|
49
|
+
* **Network Visualization**: Generate visual graphs of your network topology to inspect connections and routing paths before simulation.
|
|
50
|
+
* **Validation**: The internal graph model checks for errors such as overlapping address regions, isolated nodes, or invalid port assignments before a single line of RTL is generated.
|
|
51
|
+
|
|
52
|
+
## The Generation Flow
|
|
53
|
+
|
|
54
|
+
_FlooGen_ operates in four distinct stages to turn your configuration into hardware:
|
|
55
|
+
|
|
56
|
+
1. **Parse & Elaborate**: Reads the YAML configuration file to understand the requested nodes, links, and system parameters.
|
|
57
|
+
2. **Graph Construction**: Builds an internal Network Graph representation of the system.
|
|
58
|
+
3. **Routing & Mapping**:
|
|
59
|
+
* Runs routing algorithms on the graph.
|
|
60
|
+
* Allocates Endpoint IDs.
|
|
61
|
+
* Computes the global system address map.
|
|
62
|
+
4. **Render**: Generates the final SystemVerilog code using validated templates.
|
|
63
|
+
|
|
64
|
+
## Generated Artifacts
|
|
65
|
+
|
|
66
|
+
When you run _FlooGen_, it produces two primary outputs:
|
|
67
|
+
|
|
68
|
+
* **The NoC Top-Level (`floo_<name>_noc.sv`)**: A structural SystemVerilog module that instantiates all routers and network interfaces and connects them according to the topology.
|
|
69
|
+
* **The NoC Package (`floo_<name>_noc_pkg.sv`)**: A SystemVerilog package containing all the necessary metadata, including:
|
|
70
|
+
* Typedefs for flits and links.
|
|
71
|
+
* Routing tables and rules.
|
|
72
|
+
* System address maps and endpoint ID enumerations.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# _FlooGen_: The NoC Generation Framework
|
|
2
|
+
|
|
3
|
+
_FlooGen_ is the Python-based configuration and generation framework bundled with [_FlooNoC_](https://github.com/pulp-platform/FlooNoC). While [_FlooNoC_](https://github.com/pulp-platform/FlooNoC) provides the efficient hardware IP blocks (mainly routers and network interfaces), _FlooGen_ acts as the system architect that assembles them into a functional Network-on-Chip.
|
|
4
|
+
|
|
5
|
+
It transforms a high-level, human-readable description of your network (topology, routing rules, protocols) into fully connected, verified, and synthesizable SystemVerilog RTL.
|
|
6
|
+
|
|
7
|
+
## Why use a Generator?
|
|
8
|
+
|
|
9
|
+
Designing a Network-on-Chip manually is tedious and error-prone. Connecting hundreds of router ports, calculating deadlock-free routing tables, and maintaining consistent global address maps becomes unmanageable as system complexity grows.
|
|
10
|
+
|
|
11
|
+
_FlooGen_ solves this by raising the abstraction level. Instead of writing Verilog wire connections, you define **endpoints**, **routers** and their **connections**. _FlooGen_ handles the low-level implementation details, ensuring that:
|
|
12
|
+
|
|
13
|
+
* **Protocol conversion**: Network interfaces are automatically instantiated to bridge different endpoint protocols to the NoC link protocol.
|
|
14
|
+
* **Routing is correct**: Paths are calculated automatically based on the topology.
|
|
15
|
+
* **Configuration is consistent**: Address maps and endpoint IDs are allocated globally without overlaps.
|
|
16
|
+
|
|
17
|
+
## Key Capabilities
|
|
18
|
+
|
|
19
|
+
* **Topology Agnostic**: Generate standard topologies (Mesh, Ring, Tree) or completely custom irregular graphs based on your system constraints.
|
|
20
|
+
* **Automatic Routing**: Built-in engines to calculate routing tables for different routing algorithms.
|
|
21
|
+
* **Protocol Abstraction**: Define endpoints using high-level protocols (e.g., AXI4). _FlooGen_ automatically manages the conversion to the internal NoC link protocol.
|
|
22
|
+
* **Network Visualization**: Generate visual graphs of your network topology to inspect connections and routing paths before simulation.
|
|
23
|
+
* **Validation**: The internal graph model checks for errors such as overlapping address regions, isolated nodes, or invalid port assignments before a single line of RTL is generated.
|
|
24
|
+
|
|
25
|
+
## The Generation Flow
|
|
26
|
+
|
|
27
|
+
_FlooGen_ operates in four distinct stages to turn your configuration into hardware:
|
|
28
|
+
|
|
29
|
+
1. **Parse & Elaborate**: Reads the YAML configuration file to understand the requested nodes, links, and system parameters.
|
|
30
|
+
2. **Graph Construction**: Builds an internal Network Graph representation of the system.
|
|
31
|
+
3. **Routing & Mapping**:
|
|
32
|
+
* Runs routing algorithms on the graph.
|
|
33
|
+
* Allocates Endpoint IDs.
|
|
34
|
+
* Computes the global system address map.
|
|
35
|
+
4. **Render**: Generates the final SystemVerilog code using validated templates.
|
|
36
|
+
|
|
37
|
+
## Generated Artifacts
|
|
38
|
+
|
|
39
|
+
When you run _FlooGen_, it produces two primary outputs:
|
|
40
|
+
|
|
41
|
+
* **The NoC Top-Level (`floo_<name>_noc.sv`)**: A structural SystemVerilog module that instantiates all routers and network interfaces and connects them according to the topology.
|
|
42
|
+
* **The NoC Package (`floo_<name>_noc_pkg.sv`)**: A SystemVerilog package containing all the necessary metadata, including:
|
|
43
|
+
* Typedefs for flits and links.
|
|
44
|
+
* Routing tables and rules.
|
|
45
|
+
* System address maps and endpoint ID enumerations.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright 2023 ETH Zurich and University of Bologna.
|
|
3
|
+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
#
|
|
6
|
+
# Author: Tim Fischer <fischeti@iis.ee.ethz.ch>
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from importlib.resources import files
|
|
11
|
+
|
|
12
|
+
from mako.template import Template
|
|
13
|
+
|
|
14
|
+
from floogen.config_parser import parse_config
|
|
15
|
+
from floogen.query import handle_query
|
|
16
|
+
from floogen.model.network import Network
|
|
17
|
+
from floogen.utils import verible_format
|
|
18
|
+
|
|
19
|
+
tpl_dir = files("floogen") / "templates"
|
|
20
|
+
|
|
21
|
+
def render_template(context: dict, tpl: Path,
|
|
22
|
+
outdir: Path = None, file_name: str = None,
|
|
23
|
+
format_output: bool=False, verible_fmt_bin: str = None,
|
|
24
|
+
verible_fmt_args: str = None):
|
|
25
|
+
"""Render a template, format if requested and write to file or print to stdout."""
|
|
26
|
+
if not tpl.exists():
|
|
27
|
+
# Search in the internal template directory if the template exists there
|
|
28
|
+
if (tpl_dir / tpl.name).exists():
|
|
29
|
+
tpl = tpl_dir / tpl.name
|
|
30
|
+
else:
|
|
31
|
+
raise FileNotFoundError(f"Template not found: {tpl}")
|
|
32
|
+
rendered = Template(filename=str(tpl.resolve())).render(**context)
|
|
33
|
+
if format_output:
|
|
34
|
+
rendered = verible_format(rendered, verible_fmt_bin, verible_fmt_args)
|
|
35
|
+
if outdir:
|
|
36
|
+
outdir.mkdir(parents=True, exist_ok=True)
|
|
37
|
+
if file_name:
|
|
38
|
+
outfile = outdir / file_name
|
|
39
|
+
else:
|
|
40
|
+
outfile = outdir / tpl.stem
|
|
41
|
+
with open(outfile, "w+", encoding="utf-8") as f:
|
|
42
|
+
f.write(rendered)
|
|
43
|
+
else:
|
|
44
|
+
print(rendered)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
48
|
+
"""Parse the command line arguments."""
|
|
49
|
+
|
|
50
|
+
# Parser that holds all common options
|
|
51
|
+
common = argparse.ArgumentParser(add_help=False)
|
|
52
|
+
common.add_argument(
|
|
53
|
+
"-c", "--config", type=Path, required=True,
|
|
54
|
+
help="Path to the configuration file."
|
|
55
|
+
)
|
|
56
|
+
common.add_argument(
|
|
57
|
+
"-o", "--outdir", type=Path, required=False,
|
|
58
|
+
help=(
|
|
59
|
+
"Path to the output directory of the generated output files. "
|
|
60
|
+
"If not specified, the files are printed to stdout."
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Parser for SystemVerilog formatting options
|
|
65
|
+
sv_format = argparse.ArgumentParser(add_help=False)
|
|
66
|
+
sv_format.add_argument(
|
|
67
|
+
"--no-format",
|
|
68
|
+
dest="no_format",
|
|
69
|
+
action="store_true",
|
|
70
|
+
help="Do not format the output.",
|
|
71
|
+
)
|
|
72
|
+
sv_format.add_argument(
|
|
73
|
+
"--verible-fmt-bin",
|
|
74
|
+
type=str,
|
|
75
|
+
default=None,
|
|
76
|
+
help="Overwrite default `verible-verilog-format` binary.",
|
|
77
|
+
)
|
|
78
|
+
sv_format.add_argument(
|
|
79
|
+
"--verible-fmt-args",
|
|
80
|
+
type=str,
|
|
81
|
+
default=None,
|
|
82
|
+
help="Additional arguments to pass to `verible-verilog-format`.",
|
|
83
|
+
)
|
|
84
|
+
sv_format.add_argument(
|
|
85
|
+
"--name",
|
|
86
|
+
type=str,
|
|
87
|
+
default=None,
|
|
88
|
+
help="Override the module/package name and prefix for generated files."
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# Top-level parser
|
|
92
|
+
parser = argparse.ArgumentParser(
|
|
93
|
+
description="FlooGen: A Network-on-Chip Generator for FlooNoC",
|
|
94
|
+
add_help=True,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
subparsers = parser.add_subparsers(dest="command")
|
|
98
|
+
|
|
99
|
+
# floogen rtl -> pkg + top
|
|
100
|
+
subparsers.add_parser(
|
|
101
|
+
"rtl",
|
|
102
|
+
parents=[common, sv_format],
|
|
103
|
+
add_help=True,
|
|
104
|
+
help="Generate both the NoC package and top-module.",
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# floogen pkg
|
|
108
|
+
subparsers.add_parser(
|
|
109
|
+
"pkg",
|
|
110
|
+
parents=[common, sv_format],
|
|
111
|
+
add_help=True,
|
|
112
|
+
help="Generate the NoC package.",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# floogen top
|
|
116
|
+
subparsers.add_parser(
|
|
117
|
+
"top",
|
|
118
|
+
parents=[common, sv_format],
|
|
119
|
+
add_help=True,
|
|
120
|
+
help="Generate the NoC top-module.",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# floogen rdl
|
|
124
|
+
p_rdl = subparsers.add_parser(
|
|
125
|
+
"rdl",
|
|
126
|
+
parents=[common],
|
|
127
|
+
add_help=True,
|
|
128
|
+
help="Generate the SystemRDL of all endpoint address regions.",
|
|
129
|
+
)
|
|
130
|
+
p_rdl.add_argument(
|
|
131
|
+
"--as-mem",
|
|
132
|
+
dest="as_mem",
|
|
133
|
+
action="store_true",
|
|
134
|
+
default=False,
|
|
135
|
+
help="Add memory blocks for address regions without 'rdl_name' declared.",
|
|
136
|
+
)
|
|
137
|
+
p_rdl.add_argument(
|
|
138
|
+
"--memwidth",
|
|
139
|
+
dest="memwidth",
|
|
140
|
+
type=int,
|
|
141
|
+
default=8,
|
|
142
|
+
help="Use the memory width of the RDL address region as the width of the memory block.",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# floogen templates <template1> <template2> ...
|
|
146
|
+
p_templates = subparsers.add_parser(
|
|
147
|
+
"template",
|
|
148
|
+
parents=[common, sv_format],
|
|
149
|
+
add_help=True,
|
|
150
|
+
help="Render custom (external) templates.",
|
|
151
|
+
)
|
|
152
|
+
p_templates.add_argument(
|
|
153
|
+
"template",
|
|
154
|
+
type=Path,
|
|
155
|
+
nargs="+",
|
|
156
|
+
help="Path to external template to render. Multiple templates can be specified.",
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# floogen visualize
|
|
160
|
+
subparsers.add_parser(
|
|
161
|
+
"visualize",
|
|
162
|
+
parents=[common],
|
|
163
|
+
add_help=True,
|
|
164
|
+
help="Visualize the network graph.",
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# floogen query <key>
|
|
168
|
+
p_query = subparsers.add_parser(
|
|
169
|
+
"query",
|
|
170
|
+
parents=[common],
|
|
171
|
+
add_help=True,
|
|
172
|
+
help="Query a specific key in the configuration.",
|
|
173
|
+
)
|
|
174
|
+
p_query.add_argument(
|
|
175
|
+
"query",
|
|
176
|
+
type=str,
|
|
177
|
+
help="Key to query in the configuration.",
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
return parser
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def main():
|
|
184
|
+
"""Generates the network."""
|
|
185
|
+
|
|
186
|
+
parser = build_parser()
|
|
187
|
+
args = parser.parse_args()
|
|
188
|
+
|
|
189
|
+
if args.command is None:
|
|
190
|
+
parser.print_help()
|
|
191
|
+
return 0
|
|
192
|
+
|
|
193
|
+
network = parse_config(Network, args.config)
|
|
194
|
+
|
|
195
|
+
network.create_network()
|
|
196
|
+
network.compile_network()
|
|
197
|
+
network.gen_routing_info()
|
|
198
|
+
|
|
199
|
+
# The general context to pass to all templates
|
|
200
|
+
context = {"noc": network}
|
|
201
|
+
|
|
202
|
+
# Additional render arguments
|
|
203
|
+
render_kwargs = {"outdir": args.outdir}
|
|
204
|
+
|
|
205
|
+
# Command specific render arguments
|
|
206
|
+
match args.command:
|
|
207
|
+
case "rtl" | "pkg" | "top" | "template":
|
|
208
|
+
render_kwargs["format_output"] = not args.no_format
|
|
209
|
+
render_kwargs["verible_fmt_bin"] = args.verible_fmt_bin
|
|
210
|
+
render_kwargs["verible_fmt_args"] = args.verible_fmt_args
|
|
211
|
+
context["name"] = args.name or network.name
|
|
212
|
+
pkg_file_name = f"floo_{args.name or network.name}_noc_pkg.sv"
|
|
213
|
+
top_file_name = f"floo_{args.name or network.name}_noc.sv"
|
|
214
|
+
case "rdl":
|
|
215
|
+
rdl_file_name = f"{network.name}_addrmap.rdl"
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
match args.command:
|
|
219
|
+
case "rtl":
|
|
220
|
+
render_template(context,
|
|
221
|
+
tpl=tpl_dir / "floo_noc_pkg.sv.mako",
|
|
222
|
+
file_name=pkg_file_name,
|
|
223
|
+
**render_kwargs,
|
|
224
|
+
)
|
|
225
|
+
render_template(context,
|
|
226
|
+
tpl=tpl_dir / "floo_noc.sv.mako",
|
|
227
|
+
file_name=top_file_name,
|
|
228
|
+
**render_kwargs,
|
|
229
|
+
)
|
|
230
|
+
case "pkg":
|
|
231
|
+
render_template(context,
|
|
232
|
+
tpl=tpl_dir / "floo_noc_pkg.sv.mako",
|
|
233
|
+
file_name=pkg_file_name,
|
|
234
|
+
**render_kwargs,
|
|
235
|
+
)
|
|
236
|
+
case "top":
|
|
237
|
+
render_template(context,
|
|
238
|
+
tpl=tpl_dir / "floo_noc.sv.mako",
|
|
239
|
+
file_name=top_file_name,
|
|
240
|
+
**render_kwargs,
|
|
241
|
+
)
|
|
242
|
+
case "rdl":
|
|
243
|
+
context["rdl_as_mem"] = args.as_mem
|
|
244
|
+
context["rdl_memwidth"] = args.memwidth
|
|
245
|
+
render_template(context,
|
|
246
|
+
tpl=tpl_dir / "floo_addrmap.rdl.mako",
|
|
247
|
+
file_name=rdl_file_name,
|
|
248
|
+
**render_kwargs,
|
|
249
|
+
)
|
|
250
|
+
case "template":
|
|
251
|
+
for tpl in args.template:
|
|
252
|
+
render_template(context,
|
|
253
|
+
tpl=tpl,
|
|
254
|
+
**render_kwargs,
|
|
255
|
+
)
|
|
256
|
+
case "visualize":
|
|
257
|
+
if args.outdir:
|
|
258
|
+
network.visualize(filename=args.outdir / (network.name + ".pdf"))
|
|
259
|
+
else:
|
|
260
|
+
network.visualize(savefig=False)
|
|
261
|
+
case "query":
|
|
262
|
+
handle_query(network, args.query)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if __name__ == "__main__":
|
|
266
|
+
main()
|