-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.mk
61 lines (41 loc) · 1.43 KB
/
main.mk
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
all: $(PROJ).rpt $(PROJ).bin
%.blif: %.v $(ADD_SRC) $(ADD_DEPS)
yosys -ql $*.log $(if $(USE_ARACHNEPNR),-DUSE_ARACHNEPNR) -p 'synth_ice40 -top top -blif $@' $< $(ADD_SRC)
%.json: %.v $(ADD_SRC) $(ADD_DEPS)
yosys -ql $*.log $(if $(USE_ARACHNEPNR),-DUSE_ARACHNEPNR) -p 'synth_ice40 -top top -json $@' $< $(ADD_SRC)
ifeq ($(USE_ARACHNEPNR),)
%.asc: $(PIN_DEF) %.json
nextpnr-ice40 --$(DEVICE) $(if $(PACKAGE),--package $(PACKAGE)) $(if $(FREQ),--freq $(FREQ)) --json $(filter-out $<,$^) --pcf $< --asc $@
else
%.asc: $(PIN_DEF) %.blif
arachne-pnr -d $(subst up,,$(subst hx,,$(subst lp,,$(DEVICE)))) $(if $(PACKAGE),-P $(PACKAGE)) -o $@ -p $^
endif
%.bin: %.asc
icepack $< $@
%.rpt: %.asc
icetime $(if $(FREQ),-c $(FREQ)) -d $(DEVICE) -mtr $@ $<
%_tb: %_tb.v %.v $(ADD_SRC)
iverilog $(SIM_FLAGS) -o $@ $^ $(TST_SRC)
%_tb.vcd: %_tb
vvp -N $< +df=$@
%_tb.lxt: %_tb
vvp -N $< +df=$@ -lxt2
%_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: $(PROJ)_tb.lxt
# @echo "Now run: $$ gtkwave $<"
gtkwave $< &
prog: $(PROJ).bin
iceprog $<
sudo-prog: $(PROJ).bin
@echo 'Executing prog as root!!!'
sudo iceprog $<
clean:
rm -f $(PROJ).blif $(PROJ).asc $(PROJ).rpt $(PROJ).bin $(PROJ).json $(PROJ).log $(ADD_CLEAN)
rm -f $(PROJ)_tb.vcd $(PROJ)_tb.lxt $(PROJ)_tb
.SECONDARY:
.PHONY: all prog sim clean