-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (52 loc) · 2.32 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# FPGA variables
PROJECT = fpga/encoder_pwm
SOURCES= src/rgb_mixer.v src/encoder.v src/debounce.v src/pwm.v
ICEBREAKER_DEVICE = up5k
ICEBREAKER_PIN_DEF = fpga/icebreaker.pcf
ICEBREAKER_PACKAGE = sg48
SEED = 1
# COCOTB variables
export COCOTB_REDUCED_LOG_FMT=1
all: test_encoder test_debounce test_pwm test_rgb_mixer
# if you run rules with NOASSERT=1 it will set PYTHONOPTIMIZE, which turns off assertions in the tests
test_top:
echo "the top module was renamed to rgb_mixer. Please run make test_rgb_mixer instead"
test_rgb_mixer:
rm -rf sim_build/
mkdir sim_build/
iverilog -o sim_build/sim.vvp -s rgb_mixer -s dump -g2012 src/rgb_mixer.v test/dump_rgb_mixer.v src/ src/encoder.v src/debounce.v src/pwm.v
PYTHONOPTIMIZE=${NOASSERT} MODULE=test.test_rgb_mixer vvp -M $$(cocotb-config --prefix)/cocotb/libs -m libcocotbvpi_icarus sim_build/sim.vvp
test_encoder:
rm -rf sim_build/
mkdir sim_build/
iverilog -o sim_build/sim.vvp -s encoder -s dump -g2012 test/dump_encoder.v src/encoder.v
PYTHONOPTIMIZE=${NOASSERT} MODULE=test.test_encoder vvp -M $$(cocotb-config --prefix)/cocotb/libs -m libcocotbvpi_icarus sim_build/sim.vvp
test_pwm:
rm -rf sim_build/
mkdir sim_build/
iverilog -o sim_build/sim.vvp -s pwm -s dump -g2012 src/pwm.v test/dump_pwm.v
PYTHONOPTIMIZE=${NOASSERT} MODULE=test.test_pwm vvp -M $$(cocotb-config --prefix)/cocotb/libs -m libcocotbvpi_icarus sim_build/sim.vvp
test_debounce:
rm -rf sim_build/
mkdir sim_build/
iverilog -o sim_build/sim.vvp -s debounce -s dump -g2012 src/debounce.v test/dump_debounce.v
PYTHONOPTIMIZE=${NOASSERT} MODULE=test.test_debounce vvp -M $$(cocotb-config --prefix)/cocotb/libs -m libcocotbvpi_icarus sim_build/sim.vvp
show_%: %.vcd %.gtkw
gtkwave $^
# FPGA recipes
show_synth_%: src/%.v
yosys -p "read_verilog $<; proc; opt; show -colors 2 -width -signed"
%.json: $(SOURCES)
yosys -l fpga/yosys.log -p 'synth_ice40 -top rgb_mixer -json $(PROJECT).json' $(SOURCES)
%.asc: %.json $(ICEBREAKER_PIN_DEF)
nextpnr-ice40 -l fpga/nextpnr.log --seed $(SEED) --freq 20 --package $(ICEBREAKER_PACKAGE) --$(ICEBREAKER_DEVICE) --asc $@ --pcf $(ICEBREAKER_PIN_DEF) --json $<
%.bin: %.asc
icepack $< $@
prog: $(PROJECT).bin
iceprog $<
# general recipes
lint:
verible-verilog-lint src/*v --rules_config verible.rules
clean:
rm -rf *vcd sim_build fpga/*log fpga/*bin test/__pycache__
.PHONY: clean