From 4f6c8993af40207c0b06728e9055a94b3c6026e2 Mon Sep 17 00:00:00 2001 From: skfwe Date: Sun, 20 Apr 2025 12:41:05 +0800 Subject: [PATCH] Improve Makefile and add waveform viewing --- Makefile | 19 ++++++++++++++++--- README.md | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bc10f84..69809d8 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ .PHONY: test compile export LIBPYTHON_LOC=$(shell cocotb-config --libpython) +TOPLEVEL=gpu test_%: make compile - iverilog -o build/sim.vvp -s gpu -g2012 build/gpu.v + make iverilog_dump_$*.sv + iverilog -o build/sim.vvp -s gpu -g2012 build/gpu.v -s iverilog_dump_$* iverilog_dump_$*.sv MODULE=test.test_$* vvp -M $$(cocotb-config --prefix)/cocotb/libs -m libcocotbvpi_icarus build/sim.vvp compile: @@ -19,7 +21,18 @@ compile: compile_%: sv2v -w build/$*.v src/$*.sv -# TODO: Get gtkwave visualizaiton +iverilog_dump_%.sv: + echo 'module iverilog_dump_$*();' > $@ + echo 'initial begin' >> $@ + echo ' $$dumpfile("$*.vcd");' >> $@ + echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@ + echo 'end' >> $@ + echo 'endmodule' >> $@ -show_%: %.vcd %.gtkw +show_%: %.vcd gtkwave $^ + +clean: + rm -rf build/* + rm -f iverilog_dump* + rm -f *.vcd diff --git a/README.md b/README.md index c20afc4..78d261e 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,7 @@ tiny-gpu is setup to simulate the execution of both of the above kernels. Before - Run `mkdir build` in the root directory of this repository. Once you've installed the pre-requisites, you can run the kernel simulations with `make test_matadd` and `make test_matmul`. +You can also view the waveforms using `make show_matadd` and `make show_matmul`. Executing the simulations will output a log file in `test/logs` with the initial data memory state, complete execution trace of the kernel, and final data memory state.