-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
58 lines (40 loc) · 1.3 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
PROJ = chip
SIMPROJ = simulate
PIN_DEF = upduino_v2.pcf
DEVICE = 5k
TIME_DEVICE = up5k
PROJ_SOURCE = $(shell ls -1 *.v | egrep -v '($(SIMPROJ)|$(PROJ))' )
all: $(PROJ).rpt $(PROJ).bin
%.blif: %.v $(SIMPROJ).v $(PROJ_SOURCE)
yosys -p 'read_verilog -noautowire $^; tribuf; hierarchy; opt; proc; opt; fsm; opt; clean; synth_ice40 -top chip -blif $@; tribuf -logic'
%.asc: $(PIN_DEF) %.blif
arachne-pnr -d $(subst hx,,$(subst lp,,$(DEVICE))) -o $@ -p $^
%.bin: %.asc
icepack $< $@
%.rpt: %.asc
icetime -d $(TIME_DEVICE) -mtr $@ $<
%_tb: %_tb.v $(SIMPROJ).v $^ $(PROJ_SOURCE)
iverilog -o $@ $^
%_tb.vcd: %_tb
vvp -N $< +vcd=$@
%_syn.v: %.blif
yosys -p 'read_blif -wideports $^; write_verilog $@'
%_syntb: %_tb.v %_syn.v
iverilog -o $@ $^ `yosys-config --datdir/ice40/cells_sim.v`
%_syntb.vcd: %_syntb
vvp -N $< +vcd=$@
sim: $(SIMPROJ)_tb.vcd
gtkwave: $(SIMPROJ)_tb.vcd default.gtkw
gtkwave $^
flash: $(PROJ).bin
iceprog $<
show: chip.blif
yosys -p "synth_ice40; show" chip.blif
clean:
# Remove the synthesis files
$(RM) $(SIMPROJ).blif $(SIMPROJ).asc $(SIMPROJ).rpt $(SIMPROJ).bin
$(RM) $(PROJ).blif $(PROJ).asc $(PROJ).rpt $(PROJ).bin
# Removing the simulation files
$(RM) $(SIMPROJ)_syntb $(SIMPROJ)_syntb.vcd $(SIMPROJ)_tb.vcd $(SIMPROJ)_tb $(SIMPROJ)_syn.v
.SECONDARY:
.PHONY: all flash clean sim