Skip to content

Commit d89548d

Browse files
committed
Modularize chipyard
1 parent 484fc3b commit d89548d

File tree

17 files changed

+142
-280
lines changed

17 files changed

+142
-280
lines changed

.github/actions/run-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
run: |
2121
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)
2222
git submodule sync
23-
./scripts/init-submodules-no-riscv-tools.sh
23+
./scripts/init-submodules-no-riscv-tools.sh --full
2424
shell: bash -leo pipefail {0}
2525

2626
# Note: You shouldn't need the other inputs since it shouldn't build RTL from scratch

.github/scripts/remote-do-rtl-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ source $SCRIPT_DIR/defaults.sh
1616

1717
cd $REMOTE_CHIPYARD_DIR
1818
git submodule sync
19-
./scripts/init-submodules-no-riscv-tools.sh
19+
./scripts/init-submodules-no-riscv-tools.sh --full
2020

2121
# Constellation can run without espresso, but this improves
2222
# elaboration time drastically

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ jobs:
365365
- name: Build Gemmini FireMarshal
366366
run: |
367367
conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)
368-
cd ${{ github.workspace }} && ./scripts/init-submodules-no-riscv-tools.sh
368+
cd ${{ github.workspace }} && ./scripts/init-submodules-no-riscv-tools.sh --full
369369
cd ${{ github.workspace }} && source ./scripts/fix-open-files.sh
370370
git submodule update --init software/firemarshal && cd software/firemarshal && ./init-submodules.sh
371371
cd ${{ github.workspace }}/generators/gemmini/software && ${{ github.workspace }}/software/firemarshal/marshal -v -d build gemmini-smoke.json

build.sbt

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,58 @@ lazy val testchipip = (project in file("generators/testchipip"))
153153
.settings(libraryDependencies ++= rocketLibDeps.value)
154154
.settings(commonSettings)
155155

156-
lazy val chipyard = (project in file("generators/chipyard"))
157-
.dependsOn(testchipip, rocketchip, boom, rocketchip_blocks, rocketchip_inclusive_cache,
158-
dsptools, rocket_dsp_utils,
159-
radiance, gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, fft_generator,
160-
constellation, mempress, barf, shuttle, caliptra_aes, rerocc,
161-
compressacc, saturn, ara, firrtl2_bridge, vexiiriscv, tacit)
162-
.settings(libraryDependencies ++= rocketLibDeps.value)
163-
.settings(
164-
libraryDependencies ++= Seq(
165-
"org.reflections" % "reflections" % "0.10.2"
156+
lazy val chipyard = {
157+
// Base chipyard project with always-on dependencies
158+
// Use explicit Project(...) so the project id remains 'chipyard'
159+
var cy = Project(id = "chipyard", base = file("generators/chipyard"))
160+
.dependsOn(
161+
testchipip, rocketchip, boom, rocketchip_blocks, rocketchip_inclusive_cache,
162+
dsptools, rocket_dsp_utils,
163+
radiance, gemmini, icenet, tracegen, cva6, nvdla, sodor, ibex, fft_generator,
164+
constellation, barf, shuttle, rerocc,
165+
firrtl2_bridge, vexiiriscv, tacit
166166
)
167+
.settings(libraryDependencies ++= rocketLibDeps.value)
168+
.settings(
169+
libraryDependencies ++= Seq(
170+
"org.reflections" % "reflections" % "0.10.2"
171+
)
172+
)
173+
.settings(commonSettings)
174+
.settings(Compile / unmanagedSourceDirectories += file("tools/stage/src/main/scala"))
175+
176+
// Optional modules discovered via initialized submodules (no env or manifest)
177+
val optionalModules: Seq[(String, ProjectReference)] = Seq(
178+
"ara" -> ara,
179+
"saturn" -> saturn,
180+
"caliptra-aes-acc" -> caliptra_aes,
181+
"compress-acc" -> compressacc,
182+
"mempress" -> mempress
167183
)
168-
.settings(commonSettings)
169-
.settings(Compile / unmanagedSourceDirectories += file("tools/stage/src/main/scala"))
184+
185+
// Discover optional modules if their submodule is initialized OR if their
186+
// Chipyard-facing sources exist locally (useful for vendored copies).
187+
val discovered = optionalModules.filter { case (dir, _) =>
188+
file(s"generators/$dir/.git").exists || file(s"generators/$dir/chipyard").exists
189+
}
190+
191+
// Wire in project dependencies only for discovered modules
192+
if (discovered.nonEmpty) {
193+
// dependsOn requires ClasspathDep[ProjectReference]; wrap explicitly
194+
cy = cy.dependsOn(discovered.map { case (_, pr) => sbt.ClasspathDependency(pr, None) }: _*)
195+
}
196+
197+
// Also add their Chipyard-facing sources without symlinks
198+
cy = cy.settings(
199+
Compile / unmanagedSourceDirectories ++=
200+
discovered.map { case (dir, _) =>
201+
// Resolve from repo root so paths are correct regardless of project base
202+
(ThisBuild / baseDirectory).value / s"generators/$dir/chipyard"
203+
}.filter(_.exists)
204+
)
205+
206+
cy
207+
}
170208

171209
lazy val compressacc = (project in file("generators/compress-acc"))
172210
.dependsOn(rocketchip)

common.mk

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ HELP_COMMANDS += \
7575
# include additional subproject make fragments
7676
# see HELP_COMPILATION_VARIABLES
7777
#########################################################################################
78-
include $(base_dir)/generators/cva6/cva6.mk
79-
include $(base_dir)/generators/ibex/ibex.mk
80-
include $(base_dir)/generators/ara/ara.mk
8178
include $(base_dir)/generators/tracegen/tracegen.mk
82-
include $(base_dir)/generators/nvdla/nvdla.mk
83-
include $(base_dir)/generators/radiance/radiance.mk
8479
include $(base_dir)/tools/torture.mk
80+
# 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
85+
# Wildcard include for standardized per-generator make fragments
86+
-include $(wildcard $(base_dir)/generators/*/chipyard.mk)
87+
8588

8689
#########################################################################################
8790
# Prerequisite lists
@@ -97,7 +100,7 @@ endif
97100
# Returns a list of files in directories $1 with *any* of the file extensions in $2
98101
lookup_srcs_by_multiple_type = $(foreach type,$(2),$(call lookup_srcs,$(1),$(type)))
99102

100-
CHECK_SUBMODULES_COMMAND = echo "Checking all submodules in generators/ are initialized. Uninitialized submodules will be displayed" ; ! git submodule status $(base_dir)/generators | grep ^-
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)"
101104

102105
SCALA_EXT = scala
103106
VLOG_EXT = sv v

docs/Generators/Ara.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Ara
33

44
`Ara <https://github.com/pulp-platform/ara>`__ is a RISC-V vector unit developed by the PULP project.
55
The Ara vector unit supports integration with either the Rocket or Shuttle in-order cores, following a similar methodology as used in the original Ara+CVA6 system.
6-
Example Ara configurations are listed in ``generators/chipyard/src/main/scala/config/AraConfigs.scala``.
6+
Example Ara configurations are provided by the Ara repository and compiled directly from ``generators/ara/chipyard/`` when the Ara submodule is initialized.
77

88
.. Warning:: Ara only supports a partial subset of the full V-extension. Notably, we do not support virtual memory or precise traps with Ara.
99

docs/Generators/Saturn.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Saturn is a parameterized RISC-V Vector Unit generator currently supporting inte
55
Saturn implements a compact short-vector-length vector microarchitecture suitable for deployment in a DSP-optimized core or area-efficient general-purpose core.
66

77
More documentation on Saturn will be released in the future.
8-
A partial listing of supported Saturn configurations is in ``generators/chipyard/src/main/scala/config/SaturnConfigs.scala``.
8+
A partial listing of supported Saturn configurations is maintained in the Saturn repository and compiled directly from ``generators/saturn/chipyard/`` when the Saturn submodule is initialized.
99

1010
For now, the recommended Saturn configuration is ``GENV256D128ShuttleConfig``, which builds a dual-issue core with 256-bit VLEN, 128-bit wide SIMD datapath, and separate floating-point and integer vector issue units.
1111

@@ -20,4 +20,3 @@ For now, the recommended Saturn configuration is ``GENV256D128ShuttleConfig``, w
2020
* ``Zve64d`` support for vector FP32 and FP64
2121
* Configurable vector length, from ``Zvl64b`` up (tested to ``Zvl4096b``)
2222
* Configurable datapath width, from 64b up (tested to 512b)
23-

generators/ara

generators/chipyard/src/main/scala/config/AraConfigs.scala

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)