Skip to content

Commit 1a4240f

Browse files
committed
Modularize out cores
1 parent b69b359 commit 1a4240f

31 files changed

+275
-477
lines changed

.github/workflows/chipyard-run-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ jobs:
150150
- name: Check that documentation builds with no warnings/errors
151151
run: |
152152
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)
153+
scripts/init-submodules-no-riscv-tools.sh --full
153154
make -C docs html
154155
- name: Show error log from sphinx if failed
155156
if: ${{ failure() }}

build.sbt

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ lazy val rocketLibDeps = (rocketchip / Keys.libraryDependencies)
148148

149149
// -- Chipyard-managed External Projects --
150150

151-
lazy val testchipip = (project in file("generators/testchipip"))
151+
lazy val testchipip = withInitCheck((project in file("generators/testchipip")), "testchipip")
152152
.dependsOn(rocketchip, rocketchip_blocks)
153153
.settings(libraryDependencies ++= rocketLibDeps.value)
154154
.settings(commonSettings)
@@ -160,9 +160,9 @@ lazy val chipyard = {
160160
.dependsOn(
161161
testchipip, rocketchip, boom, rocketchip_blocks, rocketchip_inclusive_cache,
162162
dsptools, rocket_dsp_utils,
163-
radiance, gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, fft_generator,
163+
icenet, tracegen,
164164
constellation, barf, shuttle, rerocc,
165-
firrtl2_bridge, vexiiriscv, tacit
165+
firrtl2_bridge, tacit
166166
)
167167
.settings(libraryDependencies ++= rocketLibDeps.value)
168168
.settings(
@@ -175,11 +175,20 @@ lazy val chipyard = {
175175

176176
// Optional modules discovered via initialized submodules (no env or manifest)
177177
val optionalModules: Seq[(String, ProjectReference)] = Seq(
178+
// Generators with Chipyard-facing glue compiled from their repos
179+
"cva6" -> cva6,
180+
"ibex" -> ibex,
181+
"vexiiriscv" -> vexiiriscv,
182+
"riscv-sodor" -> sodor,
178183
"ara" -> ara,
179184
"saturn" -> saturn,
185+
"gemmini" -> gemmini,
186+
"nvdla" -> nvdla,
187+
"radiance" -> radiance,
180188
"caliptra-aes-acc" -> caliptra_aes,
181189
"compress-acc" -> compressacc,
182-
"mempress" -> mempress
190+
"mempress" -> mempress,
191+
"fft-generator" -> fft_generator
183192
)
184193

185194
// Discover optional modules if their submodule is initialized
@@ -205,32 +214,32 @@ lazy val chipyard = {
205214
cy
206215
}
207216

208-
lazy val compressacc = (project in file("generators/compress-acc"))
217+
lazy val compressacc = withInitCheck((project in file("generators/compress-acc")), "compress-acc")
209218
.dependsOn(rocketchip)
210219
.settings(libraryDependencies ++= rocketLibDeps.value)
211220
.settings(commonSettings)
212221

213-
lazy val mempress = (project in file("generators/mempress"))
222+
lazy val mempress = withInitCheck((project in file("generators/mempress")), "mempress")
214223
.dependsOn(rocketchip)
215224
.settings(libraryDependencies ++= rocketLibDeps.value)
216225
.settings(commonSettings)
217226

218-
lazy val barf = (project in file("generators/bar-fetchers"))
227+
lazy val barf = withInitCheck((project in file("generators/bar-fetchers")), "bar-fetchers")
219228
.dependsOn(rocketchip)
220229
.settings(libraryDependencies ++= rocketLibDeps.value)
221230
.settings(commonSettings)
222231

223-
lazy val saturn = (project in file("generators/saturn"))
232+
lazy val saturn = withInitCheck((project in file("generators/saturn")), "saturn")
224233
.dependsOn(rocketchip, shuttle)
225234
.settings(libraryDependencies ++= rocketLibDeps.value)
226235
.settings(commonSettings)
227236

228-
lazy val constellation = (project in file("generators/constellation"))
237+
lazy val constellation = withInitCheck((project in file("generators/constellation")), "constellation")
229238
.dependsOn(rocketchip)
230239
.settings(libraryDependencies ++= rocketLibDeps.value)
231240
.settings(commonSettings)
232241

233-
lazy val fft_generator = (project in file("generators/fft-generator"))
242+
lazy val fft_generator = withInitCheck((project in file("generators/fft-generator")), "fft-generator")
234243
.dependsOn(rocketchip, rocket_dsp_utils, testchipip)
235244
.settings(libraryDependencies ++= rocketLibDeps.value)
236245
.settings(commonSettings)
@@ -240,7 +249,7 @@ lazy val tracegen = (project in file("generators/tracegen"))
240249
.settings(libraryDependencies ++= rocketLibDeps.value)
241250
.settings(commonSettings)
242251

243-
lazy val icenet = (project in file("generators/icenet"))
252+
lazy val icenet = withInitCheck((project in file("generators/icenet")), "icenet")
244253
.dependsOn(rocketchip)
245254
.settings(libraryDependencies ++= rocketLibDeps.value)
246255
.settings(commonSettings)
@@ -250,37 +259,57 @@ lazy val boom = freshProject("boom", file("generators/boom"))
250259
.settings(libraryDependencies ++= rocketLibDeps.value)
251260
.settings(commonSettings)
252261

253-
lazy val shuttle = (project in file("generators/shuttle"))
262+
lazy val shuttle = withInitCheck((project in file("generators/shuttle")), "shuttle")
254263
.dependsOn(rocketchip)
255264
.settings(libraryDependencies ++= rocketLibDeps.value)
256265
.settings(commonSettings)
257266

258-
lazy val cva6 = (project in file("generators/cva6"))
267+
// Helper: fail fast if a generator project is used without its submodule initialized.
268+
def withInitCheck(p: Project, genDirName: String): Project = {
269+
val checkTask = Def.task {
270+
val root = (ThisBuild / baseDirectory).value
271+
val dir = root / s"generators/$genDirName"
272+
val looksInitialized = (dir / ".git").exists
273+
if (!dir.exists || !looksInitialized) {
274+
sys.error(
275+
s"Generator '$genDirName' is not initialized at '" + dir.getAbsolutePath +
276+
"'. Run scripts/build-setup.sh or init the submodule (scripts/init-submodules-no-riscv-tools-nolog.sh).")
277+
}
278+
}
279+
p.settings(
280+
// Run the check whenever this project's code is compiled/tested/run
281+
Compile / compile := (Compile / compile).dependsOn(checkTask).value,
282+
Test / compile := (Test / compile).dependsOn(checkTask).value,
283+
Compile / run := (Compile / run).dependsOn(checkTask).evaluated
284+
)
285+
}
286+
287+
lazy val cva6 = withInitCheck((project in file("generators/cva6")), "cva6")
259288
.dependsOn(rocketchip)
260289
.settings(libraryDependencies ++= rocketLibDeps.value)
261290
.settings(commonSettings)
262291

263-
lazy val ara = (project in file("generators/ara"))
292+
lazy val ara = withInitCheck((project in file("generators/ara")), "ara")
264293
.dependsOn(rocketchip, shuttle)
265294
.settings(libraryDependencies ++= rocketLibDeps.value)
266295
.settings(commonSettings)
267296

268-
lazy val ibex = (project in file("generators/ibex"))
297+
lazy val ibex = withInitCheck((project in file("generators/ibex")), "ibex")
269298
.dependsOn(rocketchip)
270299
.settings(libraryDependencies ++= rocketLibDeps.value)
271300
.settings(commonSettings)
272301

273-
lazy val vexiiriscv = (project in file("generators/vexiiriscv"))
302+
lazy val vexiiriscv = withInitCheck((project in file("generators/vexiiriscv")), "vexiiriscv")
274303
.dependsOn(rocketchip)
275304
.settings(libraryDependencies ++= rocketLibDeps.value)
276305
.settings(commonSettings)
277306

278-
lazy val sodor = (project in file("generators/riscv-sodor"))
307+
lazy val sodor = withInitCheck((project in file("generators/riscv-sodor")), "riscv-sodor")
279308
.dependsOn(rocketchip)
280309
.settings(libraryDependencies ++= rocketLibDeps.value)
281310
.settings(commonSettings)
282311

283-
lazy val radiance = (project in file("generators/radiance"))
312+
lazy val radiance = withInitCheck((project in file("generators/radiance")), "radiance")
284313
.dependsOn(rocketchip, gemmini, testchipip)
285314
.settings(libraryDependencies ++= rocketLibDeps.value)
286315
.settings(libraryDependencies ++= Seq(
@@ -291,32 +320,32 @@ lazy val radiance = (project in file("generators/radiance"))
291320
))
292321
.settings(commonSettings)
293322

294-
lazy val gemmini = freshProject("gemmini", file("generators/gemmini"))
323+
lazy val gemmini = withInitCheck(freshProject("gemmini", file("generators/gemmini")), "gemmini")
295324
.dependsOn(rocketchip)
296325
.settings(libraryDependencies ++= rocketLibDeps.value)
297326
.settings(commonSettings)
298327

299-
lazy val nvdla = (project in file("generators/nvdla"))
328+
lazy val nvdla = withInitCheck((project in file("generators/nvdla")), "nvdla")
300329
.dependsOn(rocketchip, testchipip)
301330
.settings(libraryDependencies ++= rocketLibDeps.value)
302331
.settings(commonSettings)
303332

304-
lazy val tacit = (project in file("generators/tacit"))
333+
lazy val tacit = withInitCheck((project in file("generators/tacit")), "tacit")
305334
.dependsOn(rocketchip, shuttle, testchipip)
306335
.settings(libraryDependencies ++= rocketLibDeps.value)
307336
.settings(commonSettings)
308337

309-
lazy val caliptra_aes = (project in file("generators/caliptra-aes-acc"))
338+
lazy val caliptra_aes = withInitCheck((project in file("generators/caliptra-aes-acc")), "caliptra-aes-acc")
310339
.dependsOn(rocketchip, rocc_acc_utils, testchipip)
311340
.settings(libraryDependencies ++= rocketLibDeps.value)
312341
.settings(commonSettings)
313342

314-
lazy val rerocc = (project in file("generators/rerocc"))
343+
lazy val rerocc = withInitCheck((project in file("generators/rerocc")), "rerocc")
315344
.dependsOn(rocketchip, constellation, boom, shuttle)
316345
.settings(libraryDependencies ++= rocketLibDeps.value)
317346
.settings(commonSettings)
318347

319-
lazy val rocc_acc_utils = (project in file("generators/rocc-acc-utils"))
348+
lazy val rocc_acc_utils = withInitCheck((project in file("generators/rocc-acc-utils")), "rocc-acc-utils")
320349
.dependsOn(rocketchip)
321350
.settings(libraryDependencies ++= rocketLibDeps.value)
322351
.settings(commonSettings)
@@ -354,12 +383,12 @@ lazy val rocket_dsp_utils = freshProject("rocket-dsp-utils", file("./tools/rocke
354383
.settings(libraryDependencies ++= rocketLibDeps.value)
355384
.settings(commonSettings)
356385

357-
lazy val rocketchip_blocks = (project in file("generators/rocket-chip-blocks"))
386+
lazy val rocketchip_blocks = withInitCheck((project in file("generators/rocket-chip-blocks")), "rocket-chip-blocks")
358387
.dependsOn(rocketchip)
359388
.settings(libraryDependencies ++= rocketLibDeps.value)
360389
.settings(commonSettings)
361390

362-
lazy val rocketchip_inclusive_cache = (project in file("generators/rocket-chip-inclusive-cache"))
391+
lazy val rocketchip_inclusive_cache = withInitCheck((project in file("generators/rocket-chip-inclusive-cache")), "rocket-chip-inclusive-cache")
363392
.settings(
364393
commonSettings,
365394
Compile / scalaSource := baseDirectory.value / "design/craft")

common.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ HELP_COMMANDS += \
7878
include $(base_dir)/generators/tracegen/tracegen.mk
7979
include $(base_dir)/tools/torture.mk
8080
# Optional generator make fragments should not fail build if absent
81-
-include $(base_dir)/generators/cva6/cva6.mk
82-
-include $(base_dir)/generators/ibex/ibex.mk
83-
-include $(base_dir)/generators/nvdla/nvdla.mk
84-
-include $(base_dir)/generators/radiance/radiance.mk
8581
# Wildcard include for standardized per-generator make fragments
8682
-include $(wildcard $(base_dir)/generators/*/chipyard.mk)
8783

docs/Chipyard-Basics/Configs-Parameters-Mixins.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,11 @@ Another description of traits/mixins and config fragments is given in :ref:`Cust
123123
Additionally, a brief explanation of some of these topics (with slightly different naming) is given in the following video: https://www.youtube.com/watch?v=Eko86PGEoDY.
124124

125125
.. Note:: Chipyard uses the name "config fragments" over "config mixins" to avoid confusion between a mixin applying to a config or to the system ``Top`` (even though both are technically Scala mixins).
126+
127+
Optional Generator Injectors
128+
----------------------------
129+
130+
Some generic Chipyard config fragments (for example, trace toggles and tile prefetch settings) are designed to affect optional generators without hard dependencies. Chipyard discovers generator-provided injectors at elaboration time and applies them, allowing fragments like ``WithTraceIO`` and ``WithTilePrefetchers`` to work across different tiles.
131+
132+
- Generators that want to participate implement ``chipyard.config.TilePluginProvider`` under their ``generators/<name>/chipyard`` sources. Chipyard discovers implementations via classpath scanning and applies the provided injectors.
133+
- This keeps the core fragments generic, while enabling per-generator behavior (e.g., mapping a prefetch intent to the correct port parameters for that tile).

docs/Chipyard-Basics/Initial-Repo-Setup.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ See ``./build-setup.sh --help`` for more details on what this does and how to di
9797

9898
.. Note:: If you already have a working conda environment setup, separate Chipyard clones can use that pre-used environment in combination with running the aforementioned scripts yourself (``init-submodules...``, ``build-toolchain...``, etc).
9999

100+
.. Note for power users: Chipyard includes internal scripts that can selectively initialize generator submodules. The default ``./build-setup.sh`` initializes all standard generator submodules and is the recommended path.
101+
100102
.. Note:: If you are a power user and would like to build your own compiler/toolchain, you can refer to the https://github.com/ucb-bar/riscv-tools-feedstock repository (submoduled in the ``toolchains/*`` directories) on how to build the compiler yourself.
101103

102104
By running the following command you should see an environment listed with the path ``$CHIPYARD_DIRECTORY/.conda-env``.

docs/Generators/CVA6.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ CVA6 Core
22
====================================
33

44
`CVA6 <https://github.com/openhwgroup/cva6>`__ (previously called Ariane) is a 6-stage in-order scalar processor core, originally developed at ETH-Zurich by F. Zaruba and L. Benini.
5-
The `CVA6 core` is wrapped in an `CVA6 tile` so it can be used as a component within the `Rocket Chip SoC generator`.
5+
The `CVA6 core` is wrapped in a `CVA6 tile` so it can be used as a component within the `Rocket Chip SoC generator`.
66
The core by itself exposes an AXI interface, interrupt ports, and other misc. ports that are connected from within the tile to TileLink buses and other parameterization signals.
77

88
.. Warning:: Since the core uses an AXI interface to connect to memory, it is highly recommended to use the core in a single-core setup (since AXI is a non-coherent memory interface).
99

1010
While the core itself is not a generator, we expose the same parameterization that the CVA6 core provides (i.e. change branch prediction parameters).
1111

12+
Configuration classes and Chipyard glue for CVA6 live under ``generators/cva6/chipyard`` and are compiled directly from the CVA6 repository sources. After running the standard setup (``./build-setup.sh``), you can build a CVA6 config like ``CVA6Config`` with the normal flow:
13+
14+
::
15+
16+
cd sims/vcs && make CONFIG=CVA6Config
17+
1218
.. Warning:: This target does not support Verilator simulation at this time. Please use VCS.
1319

1420
For more information, please refer to the `GitHub repository <https://github.com/openhwgroup/cva6>`__.

docs/Generators/Ibex.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ The core exposes a custom memory interface, interrupt ports, and other misc. por
99

1010
.. Warning:: The Ibex reset vector is located at BOOT_ADDR + 0x80.
1111

12-
While the core itself is not a generator, we expose the same parameterization that the Ibex core provides so that all supported Ibex configurations are available.
13-
12+
While the core itself is not a generator, we expose the same parameterization that the Ibex core provides so that all supported Ibex configurations are available.
13+
1414
For more information, see the `GitHub repository for Ibex <https://github.com/lowRISC/ibex>`__.
15+
16+
Configuration classes and Chipyard glue for Ibex live under ``generators/ibex/chipyard`` and are compiled directly from the Ibex repository sources. After running the standard setup (``./build-setup.sh``), build the example config with:
17+
18+
::
19+
20+
cd sims/vcs && make CONFIG=IbexConfig

docs/Generators/Sodor.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ The five available cores and their corresponding generator configuration are:
1515
* "bus"-based micro-coded implementation - ``SodorUCodeConfig``
1616

1717
For more information, please refer to the `GitHub repository <https://github.com/ucb-bar/riscv-sodor>`__.
18+
19+
Configuration classes and Chipyard glue for Sodor live under ``generators/riscv-sodor/chipyard`` and are compiled directly from the Sodor repository sources. After running the standard setup (``./build-setup.sh``), build a config (e.g., 3-stage) with:
20+
21+
::
22+
23+
cd sims/vcs && make CONFIG=Sodor3StageConfig

docs/Generators/VexiiRiscv.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ VexiiRiscv implements cache-coherent TileLink L1 data caches and is integrated a
77
The example VexiiRiscv config is ``VexiiRiscvConfig``.
88
When building this Config, Chipyard will call VexiiRiscv's SpinalHDL RTL generator to generate the core's SystemVerilog, before integrating it as a Chisel blackbox.
99

10+
Configuration classes and Chipyard glue for VexiiRiscv live under ``generators/vexiiriscv/chipyard`` and are compiled directly from the VexiiRiscv repository sources. After running the standard setup (``./build-setup.sh``), build the example config with:
11+
12+
::
13+
14+
cd sims/vcs && make CONFIG=VexiiRiscvConfig

docs/Generators/fft.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Configuration
77
--------------------------
88
The following configuration creates an 8-point FFT:
99

10-
.. literalinclude:: ../../generators/chipyard/src/main/scala/config/MMIOAcceleratorConfigs.scala
10+
.. literalinclude:: ../../generators/fft-generator/chipyard/FFTConfigs.scala
1111
:language: scala
1212
:start-after: DOC include start: FFTRocketConfig
1313
:end-before: DOC include end: FFTRocketConfig

0 commit comments

Comments
 (0)