Skip to content

Commit a5f45ff

Browse files
committed
Modularize chipyard
1 parent bc48eeb commit a5f45ff

File tree

15 files changed

+130
-275
lines changed

15 files changed

+130
-275
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: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,51 @@ 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+
val discovered = optionalModules.filter { case (dir, _) => (file(s"generators/$dir/.git")).exists }
186+
187+
// Wire in project dependencies only for discovered modules
188+
if (discovered.nonEmpty) {
189+
// dependsOn requires ClasspathDep[ProjectReference]; wrap explicitly
190+
cy = cy.dependsOn(discovered.map { case (_, pr) => sbt.ClasspathDependency(pr, None) }: _*)
191+
}
192+
193+
// Also add their Chipyard-facing sources without symlinks
194+
cy.settings(
195+
Compile / unmanagedSourceDirectories ++=
196+
discovered.map { case (dir, _) => baseDirectory.value / s"generators/$dir/chipyard" }.filter(_.exists)
197+
)
198+
199+
cy
200+
}
170201

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

common.mk

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,33 @@ HELP_COMMANDS += \
6565
# include additional subproject make fragments
6666
# see HELP_COMPILATION_VARIABLES
6767
#########################################################################################
68-
include $(base_dir)/generators/cva6/cva6.mk
69-
include $(base_dir)/generators/ibex/ibex.mk
70-
include $(base_dir)/generators/ara/ara.mk
7168
include $(base_dir)/generators/tracegen/tracegen.mk
72-
include $(base_dir)/generators/nvdla/nvdla.mk
73-
include $(base_dir)/generators/radiance/radiance.mk
7469
include $(base_dir)/tools/torture.mk
70+
# Optional generator make fragments should not fail build if absent
71+
-include $(base_dir)/generators/cva6/cva6.mk
72+
-include $(base_dir)/generators/ibex/ibex.mk
73+
-include $(base_dir)/generators/ara/ara.mk
74+
-include $(base_dir)/generators/nvdla/nvdla.mk
75+
-include $(base_dir)/generators/radiance/radiance.mk
76+
# Wildcard include for standardized per-generator make fragments
77+
-include $(wildcard $(base_dir)/generators/*/chipyard.mk)
78+
7579

7680
#########################################################################################
7781
# Prerequisite lists
7882
#########################################################################################
7983
# Returns a list of files in directories $1 with single file extension $2.
8084
# If available, use 'fd' to find the list of files, which is faster than 'find'.
8185
ifeq ($(shell which fd 2> /dev/null),)
82-
lookup_srcs = $(shell find -L $(1)/ -name target -prune -o \( -iname "*.$(2)" ! -iname ".*" \) -print 2> /dev/null)
86+
lookup_srcs = $(shell find -L $(1)/ -name target -prune -o \( ! -xtype l -a -iname "*.$(2)" ! -iname ".*" \) -print 2> /dev/null)
8387
else
8488
lookup_srcs = $(shell fd -L -t f -e $(2) . $(1))
8589
endif
8690

8791
# Returns a list of files in directories $1 with *any* of the file extensions in $2
8892
lookup_srcs_by_multiple_type = $(foreach type,$(2),$(call lookup_srcs,$(1),$(type)))
8993

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

9296
SCALA_EXT = scala
9397
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)