Skip to content

Commit 4929918

Browse files
committed
Modularize out cores
1 parent b69b359 commit 4929918

33 files changed

+283
-540
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: 56 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
166166
)
167167
.settings(libraryDependencies ++= rocketLibDeps.value)
168168
.settings(
@@ -175,11 +175,21 @@ 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+
"tacit" -> tacit,
186+
"gemmini" -> gemmini,
187+
"nvdla" -> nvdla,
188+
"radiance" -> radiance,
180189
"caliptra-aes-acc" -> caliptra_aes,
181190
"compress-acc" -> compressacc,
182-
"mempress" -> mempress
191+
"mempress" -> mempress,
192+
"fft-generator" -> fft_generator
183193
)
184194

185195
// Discover optional modules if their submodule is initialized
@@ -205,32 +215,32 @@ lazy val chipyard = {
205215
cy
206216
}
207217

208-
lazy val compressacc = (project in file("generators/compress-acc"))
218+
lazy val compressacc = withInitCheck((project in file("generators/compress-acc")), "compress-acc")
209219
.dependsOn(rocketchip)
210220
.settings(libraryDependencies ++= rocketLibDeps.value)
211221
.settings(commonSettings)
212222

213-
lazy val mempress = (project in file("generators/mempress"))
223+
lazy val mempress = withInitCheck((project in file("generators/mempress")), "mempress")
214224
.dependsOn(rocketchip)
215225
.settings(libraryDependencies ++= rocketLibDeps.value)
216226
.settings(commonSettings)
217227

218-
lazy val barf = (project in file("generators/bar-fetchers"))
228+
lazy val barf = withInitCheck((project in file("generators/bar-fetchers")), "bar-fetchers")
219229
.dependsOn(rocketchip)
220230
.settings(libraryDependencies ++= rocketLibDeps.value)
221231
.settings(commonSettings)
222232

223-
lazy val saturn = (project in file("generators/saturn"))
233+
lazy val saturn = withInitCheck((project in file("generators/saturn")), "saturn")
224234
.dependsOn(rocketchip, shuttle)
225235
.settings(libraryDependencies ++= rocketLibDeps.value)
226236
.settings(commonSettings)
227237

228-
lazy val constellation = (project in file("generators/constellation"))
238+
lazy val constellation = withInitCheck((project in file("generators/constellation")), "constellation")
229239
.dependsOn(rocketchip)
230240
.settings(libraryDependencies ++= rocketLibDeps.value)
231241
.settings(commonSettings)
232242

233-
lazy val fft_generator = (project in file("generators/fft-generator"))
243+
lazy val fft_generator = withInitCheck((project in file("generators/fft-generator")), "fft-generator")
234244
.dependsOn(rocketchip, rocket_dsp_utils, testchipip)
235245
.settings(libraryDependencies ++= rocketLibDeps.value)
236246
.settings(commonSettings)
@@ -240,7 +250,7 @@ lazy val tracegen = (project in file("generators/tracegen"))
240250
.settings(libraryDependencies ++= rocketLibDeps.value)
241251
.settings(commonSettings)
242252

243-
lazy val icenet = (project in file("generators/icenet"))
253+
lazy val icenet = withInitCheck((project in file("generators/icenet")), "icenet")
244254
.dependsOn(rocketchip)
245255
.settings(libraryDependencies ++= rocketLibDeps.value)
246256
.settings(commonSettings)
@@ -250,37 +260,57 @@ lazy val boom = freshProject("boom", file("generators/boom"))
250260
.settings(libraryDependencies ++= rocketLibDeps.value)
251261
.settings(commonSettings)
252262

253-
lazy val shuttle = (project in file("generators/shuttle"))
263+
lazy val shuttle = withInitCheck((project in file("generators/shuttle")), "shuttle")
254264
.dependsOn(rocketchip)
255265
.settings(libraryDependencies ++= rocketLibDeps.value)
256266
.settings(commonSettings)
257267

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

263-
lazy val ara = (project in file("generators/ara"))
293+
lazy val ara = withInitCheck((project in file("generators/ara")), "ara")
264294
.dependsOn(rocketchip, shuttle)
265295
.settings(libraryDependencies ++= rocketLibDeps.value)
266296
.settings(commonSettings)
267297

268-
lazy val ibex = (project in file("generators/ibex"))
298+
lazy val ibex = withInitCheck((project in file("generators/ibex")), "ibex")
269299
.dependsOn(rocketchip)
270300
.settings(libraryDependencies ++= rocketLibDeps.value)
271301
.settings(commonSettings)
272302

273-
lazy val vexiiriscv = (project in file("generators/vexiiriscv"))
303+
lazy val vexiiriscv = withInitCheck((project in file("generators/vexiiriscv")), "vexiiriscv")
274304
.dependsOn(rocketchip)
275305
.settings(libraryDependencies ++= rocketLibDeps.value)
276306
.settings(commonSettings)
277307

278-
lazy val sodor = (project in file("generators/riscv-sodor"))
308+
lazy val sodor = withInitCheck((project in file("generators/riscv-sodor")), "riscv-sodor")
279309
.dependsOn(rocketchip)
280310
.settings(libraryDependencies ++= rocketLibDeps.value)
281311
.settings(commonSettings)
282312

283-
lazy val radiance = (project in file("generators/radiance"))
313+
lazy val radiance = withInitCheck((project in file("generators/radiance")), "radiance")
284314
.dependsOn(rocketchip, gemmini, testchipip)
285315
.settings(libraryDependencies ++= rocketLibDeps.value)
286316
.settings(libraryDependencies ++= Seq(
@@ -291,32 +321,32 @@ lazy val radiance = (project in file("generators/radiance"))
291321
))
292322
.settings(commonSettings)
293323

294-
lazy val gemmini = freshProject("gemmini", file("generators/gemmini"))
324+
lazy val gemmini = withInitCheck(freshProject("gemmini", file("generators/gemmini")), "gemmini")
295325
.dependsOn(rocketchip)
296326
.settings(libraryDependencies ++= rocketLibDeps.value)
297327
.settings(commonSettings)
298328

299-
lazy val nvdla = (project in file("generators/nvdla"))
329+
lazy val nvdla = withInitCheck((project in file("generators/nvdla")), "nvdla")
300330
.dependsOn(rocketchip, testchipip)
301331
.settings(libraryDependencies ++= rocketLibDeps.value)
302332
.settings(commonSettings)
303333

304-
lazy val tacit = (project in file("generators/tacit"))
334+
lazy val tacit = withInitCheck((project in file("generators/tacit")), "tacit")
305335
.dependsOn(rocketchip, shuttle, testchipip)
306336
.settings(libraryDependencies ++= rocketLibDeps.value)
307337
.settings(commonSettings)
308338

309-
lazy val caliptra_aes = (project in file("generators/caliptra-aes-acc"))
339+
lazy val caliptra_aes = withInitCheck((project in file("generators/caliptra-aes-acc")), "caliptra-aes-acc")
310340
.dependsOn(rocketchip, rocc_acc_utils, testchipip)
311341
.settings(libraryDependencies ++= rocketLibDeps.value)
312342
.settings(commonSettings)
313343

314-
lazy val rerocc = (project in file("generators/rerocc"))
344+
lazy val rerocc = withInitCheck((project in file("generators/rerocc")), "rerocc")
315345
.dependsOn(rocketchip, constellation, boom, shuttle)
316346
.settings(libraryDependencies ++= rocketLibDeps.value)
317347
.settings(commonSettings)
318348

319-
lazy val rocc_acc_utils = (project in file("generators/rocc-acc-utils"))
349+
lazy val rocc_acc_utils = withInitCheck((project in file("generators/rocc-acc-utils")), "rocc-acc-utils")
320350
.dependsOn(rocketchip)
321351
.settings(libraryDependencies ++= rocketLibDeps.value)
322352
.settings(commonSettings)
@@ -354,12 +384,12 @@ lazy val rocket_dsp_utils = freshProject("rocket-dsp-utils", file("./tools/rocke
354384
.settings(libraryDependencies ++= rocketLibDeps.value)
355385
.settings(commonSettings)
356386

357-
lazy val rocketchip_blocks = (project in file("generators/rocket-chip-blocks"))
387+
lazy val rocketchip_blocks = withInitCheck((project in file("generators/rocket-chip-blocks")), "rocket-chip-blocks")
358388
.dependsOn(rocketchip)
359389
.settings(libraryDependencies ++= rocketLibDeps.value)
360390
.settings(commonSettings)
361391

362-
lazy val rocketchip_inclusive_cache = (project in file("generators/rocket-chip-inclusive-cache"))
392+
lazy val rocketchip_inclusive_cache = withInitCheck((project in file("generators/rocket-chip-inclusive-cache")), "rocket-chip-inclusive-cache")
363393
.settings(
364394
commonSettings,
365395
Compile / scalaSource := baseDirectory.value / "design/craft")

common.mk

Lines changed: 0 additions & 15 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

@@ -100,8 +96,6 @@ endif
10096
# Returns a list of files in directories $1 with *any* of the file extensions in $2
10197
lookup_srcs_by_multiple_type = $(foreach type,$(2),$(call lookup_srcs,$(1),$(type)))
10298

103-
CHECK_SUBMODULES_COMMAND = echo "Checking required submodules in generators/ are initialized. Uninitialized submodules will be displayed" ; ! git submodule status $(base_dir)/generators | grep '^-.*' | grep -vE "(ara|caliptra|compress|mempress|saturn)"
104-
10599
SCALA_EXT = scala
106100
VLOG_EXT = sv v
107101
FIRESIM_SOURCE_DIRS = $(addprefix sims/firesim/,sim/firesim-lib sim/midas/targetutils) $(addprefix generators/firechip/,chip bridgeinterfaces bridgestubs) tools/firrtl2
@@ -124,7 +118,6 @@ $(build_dir):
124118
# compile scala jars
125119
#########################################################################################
126120
$(GENERATOR_CLASSPATH) &: $(CHIPYARD_SCALA_SOURCES) $(SCALA_BUILDTOOL_DEPS) $(CHIPYARD_VLOG_SOURCES)
127-
$(CHECK_SUBMODULES_COMMAND)
128121
mkdir -p $(dir $@)
129122
$(call run_sbt_assembly,$(SBT_PROJECT),$(GENERATOR_CLASSPATH))
130123

@@ -460,14 +453,6 @@ find-configs:
460453
help:
461454
@for line in $(HELP_LINES); do echo "$$line"; done
462455

463-
#########################################################################################
464-
# Check submodule status
465-
#########################################################################################
466-
467-
.PHONY: check-submodule-status
468-
check-submodule-status:
469-
$(CHECK_SUBMODULES_COMMAND)
470-
471456
#########################################################################################
472457
# Implicit rule handling
473458
#########################################################################################

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)