Skip to content

Instantly share code, notes, and snippets.

@tanitanin
Created May 23, 2014 06:48
Show Gist options
  • Save tanitanin/04d7ef132cd0ae18c0c6 to your computer and use it in GitHub Desktop.
Save tanitanin/04d7ef132cd0ae18c0c6 to your computer and use it in GitHub Desktop.
Verilog simulation by using iVerilog
# Makefile for iVerilog testing
SRC_DIR := src
TEST_DIR := test
SIM_DIR := sim
TESTS := $(sort $(patsubst $(TEST_DIR)/%.v,$(SIM_DIR)/%.vcd,$(wildcard $(TEST_DIR)/test_*.v)))
VERILOGS := $(sort $(wildcard $(SRC_DIR)/*.v))
.PHONY: $(SIM_DIR)/test_%.sim
$(SIM_DIR)/test_%.sim: $(TEST_DIR)/test_%.v
iverilog -o $@ -s test_$* $< $(VERILOGS)
.PHONY: $(SIM_DIR)/test_%.vcd
$(SIM_DIR)/test_%.vcd: $(SIM_DIR)/test_%.sim
vvp -l $(patsubst %.sim,%.log,$<) $<
.PHONY: all
all: test
.PHONY: test
test: $(TESTS)
.PHONY: wave
%: $(SIM_DIR)/test_%.vcd
gtkwave $< &
.PHONY: clean
clean:
rm -rf sim/*.sim sim/test_*.vcd sim/*.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment