Adds a way to simulate the programs with spike, to compare PCs and debug

This commit is contained in:
2025-11-15 00:57:30 +01:00
parent ca03b29774
commit 0c377a1380
8 changed files with 77 additions and 76 deletions

View File

@@ -70,6 +70,7 @@ $(MEM_DIR):
@mkdir -p $@/programs
@mkdir -p $@/programs_rust
.PRECIOUS: $(MEM_DIR)/programs_rust/%.elf
$(MEM_DIR)/programs_rust/%.elf: bench/programs_rust/% force $(MEM_DIR)/crt.o |$(MEM_DIR)
cd bench/programs_rust && cargo build --release --bin=$(basename $(notdir $@))
cp -f bench/programs_rust/target/riscv64i/release/$(basename $(notdir $@)) $@
@@ -100,6 +101,7 @@ PATH_SRC := src/main/scala/$(TOP_REP)
TOP_TEST := $(addsuffix Spec, $(TOP))
CYCLES=500
INSTRUCTIONS=1000
# Pour filtrer les tests dans une simulation
ifdef PROG
FILTRE_TEST:= -- -z "$(PROG)"
@@ -120,11 +122,16 @@ testall: mill compile ##! Lance la simulation automatique pour tous les tests en
$(PROG): $(MEM_DIR)/$(PROG).mem
simulation: mill $(PROG) ##! Lance gtkwave sur le test fourni dans PROG
simulation: mill $(PROG) ##! Lance gtkwave sur le test fourni dans PROG et produit le log du pc
@$(call check_vars,PROG)
@PROOT=$(PWD) PROG=$(PROG) CYCLES=$(CYCLES) ./mill TPchisel.test.testOnly $(TOP_REP).$(TOP_TEST) -- -DemitVcd=1 -z "gtkwave"
@cp -f ./build/chiselsim/ZzTopSpec/Simulation-pour-gtkwave/workdir-verilator/core_pc.log .
@gtkwave -a common/config.gtkw ./build/chiselsim/ZzTopSpec/Simulation-pour-gtkwave/workdir-verilator/trace.vcd
spike-simulation: mill $(PROG) ##! Simule INSTRUCTIONS instructions de PROG avec spike et produit un log du PC dans spike_pc.log
spike --log spike.log --instructions=$$(($(INSTRUCTIONS) + 5)) -m0x10000:0x20000,0x80000000:0x00020000 -l $(MEM_DIR)/$(PROG).elf
cat spike.log | sed "/>>>>/d" | awk '{print $$3}' | tail -n $(INSTRUCTIONS) > spike_pc.log
###############################################################################