|
1 | 1 | SHELL=/bin/bash |
2 | 2 | SED ?= sed |
3 | 3 |
|
4 | | -ifndef RISCV |
5 | | -$(error RISCV is unset. Did you source the Chipyard auto-generated env file (which activates the default conda environment)?) |
6 | | -else |
7 | | -$(info Running with RISCV=$(RISCV)) |
8 | | -endif |
| 4 | +# Note: Individual rules that use RISCV or external tools perform local checks to avoid |
| 5 | +# blocking unrelated targets. Use $(require_riscv) and $(call require_cmd,<tool>) inside recipes. |
| 6 | + |
| 7 | +define require_riscv |
| 8 | + @if [ -z "$(RISCV)" ]; then \ |
| 9 | + echo "RISCV is unset. Source env.sh (which activates the default conda env) before building sims." 1>&2; \ |
| 10 | + exit 1; \ |
| 11 | + fi |
| 12 | +endef |
| 13 | + |
| 14 | +# Verify a tool is present in PATH; usage: $(call require_cmd,verilator) |
| 15 | +define require_cmd |
| 16 | + @command -v $(1) >/dev/null 2>&1 \ |
| 17 | + || { echo "Error: $(1) not found in PATH. Set up your tool environment before building this target." >&2; exit 1; } |
| 18 | +endef |
9 | 19 |
|
10 | 20 | ######################################################################################### |
11 | 21 | # specify user-interface variables |
@@ -184,27 +194,23 @@ else |
184 | 194 | endif |
185 | 195 |
|
186 | 196 | $(SFC_MFC_TARGETS) &: $(FIRRTL_FILE) $(FINAL_ANNO_FILE) $(MFC_LOWERING_OPTIONS) |
187 | | - @# Ensure firtool is available before invoking CIRCT to emit Verilog |
188 | | - @command -v firtool >/dev/null 2>&1 || { \ |
189 | | - echo "Error: firtool (CIRCT) not found in PATH. Install/activate CIRCT before running this target." >&2; \ |
190 | | - exit 1; \ |
191 | | - } |
| 197 | + $(call require_cmd,firtool) |
192 | 198 | rm -rf $(GEN_COLLATERAL_DIR) |
193 | 199 | (set -o pipefail && firtool \ |
194 | | - --format=fir \ |
195 | | - --export-module-hierarchy \ |
196 | | - --verify-each=true \ |
197 | | - --warn-on-unprocessed-annotations \ |
198 | | - --disable-annotation-classless \ |
199 | | - --disable-annotation-unknown \ |
200 | | - --mlir-timing \ |
201 | | - --lowering-options=$(shell cat $(MFC_LOWERING_OPTIONS)) \ |
202 | | - --repl-seq-mem \ |
203 | | - --repl-seq-mem-file=$(MFC_SMEMS_CONF) \ |
204 | | - --annotation-file=$(FINAL_ANNO_FILE) \ |
205 | | - --split-verilog \ |
206 | | - -o $(GEN_COLLATERAL_DIR) \ |
207 | | - $(FIRRTL_FILE) |& tee $(FIRTOOL_LOG_FILE)) |
| 200 | + --format=fir \ |
| 201 | + --export-module-hierarchy \ |
| 202 | + --verify-each=true \ |
| 203 | + --warn-on-unprocessed-annotations \ |
| 204 | + --disable-annotation-classless \ |
| 205 | + --disable-annotation-unknown \ |
| 206 | + --mlir-timing \ |
| 207 | + --lowering-options=$(shell cat $(MFC_LOWERING_OPTIONS)) \ |
| 208 | + --repl-seq-mem \ |
| 209 | + --repl-seq-mem-file=$(MFC_SMEMS_CONF) \ |
| 210 | + --annotation-file=$(FINAL_ANNO_FILE) \ |
| 211 | + --split-verilog \ |
| 212 | + -o $(GEN_COLLATERAL_DIR) \ |
| 213 | + $(FIRRTL_FILE) |& tee $(FIRTOOL_LOG_FILE)) |
208 | 214 | $(SED) -i 's/.*/& /' $(MFC_SMEMS_CONF) # need trailing space for SFC macrocompiler |
209 | 215 | touch $(MFC_BB_MODS_FILELIST) # if there are no BB's then the file might not be generated, instead always generate it |
210 | 216 | # DOC include end: FirrtlCompiler |
@@ -395,8 +401,10 @@ run-binary-fast-hex: override SIM_FLAGS += +loadmem=$(BINARY) |
395 | 401 | $(output_dir): |
396 | 402 | mkdir -p $@ |
397 | 403 |
|
| 404 | +ifdef RISCV |
398 | 405 | $(output_dir)/%: $(RISCV)/riscv64-unknown-elf/share/riscv-tests/isa/% | $(output_dir) |
399 | 406 | ln -sf $< $@ |
| 407 | +endif |
400 | 408 |
|
401 | 409 | $(output_dir)/%.run: $(output_dir)/% $(SIM_PREREQ) |
402 | 410 | (set -o pipefail && $(NUMA_PREFIX) $(sim) $(PERMISSIVE_ON) $(call get_common_sim_flags,$<) $(PERMISSIVE_OFF) $< </dev/null | tee $<.log) && touch $@ |
|
0 commit comments