Skip to content

Commit 961134e

Browse files
committed
Add full-config-finder: finds eligible CONFIG targets
1 parent bc48eeb commit 961134e

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

.github/workflows/chipyard-full-flow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
source env.sh
107107
cd sims/verilator
108108
make find-config-fragments
109+
make find-configs
109110
- name: Run smoke test
110111
run: |
111112
cd ${{ env.REMOTE_WORK_DIR }}

common.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ HELP_COMMANDS += \
5858
" firrtl = generate intermediate firrtl files from chisel elaboration" \
5959
" run-tests = run all assembly and benchmark tests" \
6060
" launch-sbt = start sbt terminal" \
61+
" find-configs = list Chipyard Config classes (eligible CONFIG=)" \
6162
" find-config-fragments = list all config. fragments" \
6263
" check-submodule-status = check that all submodules in generators/ have been initialized"
6364

@@ -441,6 +442,10 @@ endef
441442
find-config-fragments:
442443
$(call run_scala_main,chipyard,chipyard.ConfigFinder,)
443444

445+
.PHONY: find-configs
446+
find-configs:
447+
$(call run_scala_main,chipyard,chipyard.ChipyardConfigFinder,)
448+
444449
.PHONY: help
445450
help:
446451
@for line in $(HELP_LINES); do echo "$$line"; done

docs/Customization/Keys-Traits-Configs.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ We can use this config fragment when composing our configs.
7979
Chipyard Config Fragments
8080
-------------------------
8181

82-
For discoverability, users can run ``make find-config-fragments`` to see a list of config. fragments.
82+
For discoverability, users can run ``make find-configs`` to list Chipyard ``Config`` classes eligible for ``CONFIG=...`` (defaults to package ``chipyard``). Only classes whose names end with ``Config`` are shown.
83+
To see reusable building blocks, run ``make find-config-fragments`` to list config fragments.

docs/Simulation/Software-RTL-Simulation.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ Therefore, in order to simulate a simple Rocket-based example system we can use:
154154
make SUB_PROJECT=yourproject
155155
./simulator-<yourproject>-<yourconfig> ...
156156
157+
Listing available configs
158+
^^^^^^^^^^^^^^^^^^^^^^^^^
159+
160+
To discover available Chipyard configs that can be passed as ``CONFIG=...`` (under the default ``CONFIG_PACKAGE=chipyard``), run:
161+
162+
.. code-block:: shell
163+
164+
make find-configs
165+
166+
This lists Chipyard classes that extend ``Config``. Only classes whose names end with ``Config`` are shown.
167+
157168

158169
Finally, in the ``generated-src/<...>-<package>-<config>/`` directory resides all of the collateral while the generated Verilog source files resides in ``generated-src/<...>-<package>-<config>/gen-collateral`` for the build/simulation.
159170
Specifically, for ``CONFIG=RocketConfig`` the SoC top-level (``TOP``) Verilog file is ``ChipTop.sv`` while the (``Model``) file is ``TestHarness.sv``.

generators/chipyard/src/main/scala/ConfigFinder.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,28 @@ object ConfigFinder {
1717
}
1818
}
1919
}
20+
21+
/**
22+
* Lists only Chipyard configs suitable for use with make CONFIG=<Class>.
23+
* Filters to classes in the `chipyard` package hierarchy that extend Config.
24+
*/
25+
object ChipyardConfigFinder {
26+
def main(args: Array[String]) = {
27+
val reflections = new Reflections()
28+
val classes = reflections.get(SubTypes.of(classOf[Config]).asClass()).asScala
29+
val chipyardOnly = classes
30+
.map(_.getName)
31+
.filter { n =>
32+
val isChipyard = n.startsWith("chipyard.")
33+
val notExamples = !n.startsWith("chipyard.example.")
34+
val notHarness = !n.startsWith("chipyard.harness.")
35+
val notIOBinders = !n.startsWith("chipyard.iobinders.")
36+
val notConfigPkg = !n.startsWith("chipyard.config.")
37+
val endsWithConfig = n.split("\\.").lastOption.exists(_.endsWith("Config"))
38+
isChipyard && notExamples && notHarness && notIOBinders && notConfigPkg && endsWithConfig
39+
}
40+
.map(n => n.stripPrefix("chipyard."))
41+
val sorted = SortedSet[String]() ++ chipyardOnly
42+
sorted.foreach(println)
43+
}
44+
}

0 commit comments

Comments
 (0)