2021-07-02 00:35:20 -06:00
|
|
|
PROJ = top
|
|
|
|
DEVICE = hx8k
|
|
|
|
PACKAGE = ct256
|
2022-08-21 11:40:12 -06:00
|
|
|
# Synthesis outputs go here. Testbench outputs go with their testbenches
|
2021-07-02 00:58:43 -06:00
|
|
|
BUILD_DIR = build
|
2021-07-02 01:12:29 -06:00
|
|
|
PIN_DEF = constraints/pins.pcf
|
2022-08-21 11:40:12 -06:00
|
|
|
# NOTE: this should work fine with .sv files too
|
|
|
|
# Synthesis files
|
|
|
|
SOURCE_V = $(wildcard rtl/*.v)
|
|
|
|
# Testbench files
|
|
|
|
TB_V = $(wildcard tb/**/tb_*.v)
|
|
|
|
# Testbench resources shared by all testbenches
|
|
|
|
TB_COMMON_V = $(wildcard tb/common/*.v)
|
|
|
|
|
|
|
|
TB_VCD = $(patsubst %.sv,%.vcd,$(TB_V:.v=.vcd))
|
2021-07-02 00:41:37 -06:00
|
|
|
|
2021-07-02 01:15:35 -06:00
|
|
|
all: $(BUILD_DIR)/$(PROJ).rpt $(BUILD_DIR)/$(PROJ).bin
|
2021-07-02 01:12:29 -06:00
|
|
|
|
2022-08-21 11:40:12 -06:00
|
|
|
$(BUILD_DIR)/%.blif: rtl/%.v
|
2021-07-02 01:12:29 -06:00
|
|
|
mkdir -p $(BUILD_DIR)
|
2021-07-02 00:41:37 -06:00
|
|
|
yosys -p 'synth_ice40 -top top -blif $@' $(SOURCE_V)
|
2021-07-02 00:35:20 -06:00
|
|
|
# yosys -p 'synth_ice40 -top top -blif $@' $<
|
|
|
|
|
|
|
|
%.asc: $(PIN_DEF) %.blif
|
|
|
|
arachne-pnr -d $(subst hx,,$(subst lp,,$(DEVICE))) -P $(PACKAGE) -o $@ -p $^
|
|
|
|
|
|
|
|
%.bin: %.asc
|
|
|
|
icepack $< $@
|
|
|
|
|
|
|
|
%.rpt: %.asc
|
|
|
|
icetime -d $(DEVICE) -mtr $@ $<
|
|
|
|
|
2022-08-21 11:40:12 -06:00
|
|
|
# Simulation files
|
|
|
|
%.out: %.v $(SOURCE_V) $(TB_COMMON_V)
|
|
|
|
iverilog $^ -o $@
|
|
|
|
|
|
|
|
%.vcd: %.out
|
|
|
|
cd $(dir $@) && $(abspath $^)
|
|
|
|
|
2021-07-02 00:35:20 -06:00
|
|
|
prog: $(PROJ).bin
|
|
|
|
iceprog $<
|
|
|
|
|
|
|
|
sudo-prog: $(PROJ).bin
|
|
|
|
@echo 'Executing prog as root!!!'
|
|
|
|
sudo iceprog $<
|
|
|
|
|
2022-08-21 11:40:12 -06:00
|
|
|
tb: $(TB_VCD)
|
2021-07-02 00:35:20 -06:00
|
|
|
|
|
|
|
clean:
|
2022-08-21 11:40:12 -06:00
|
|
|
rm -rf $(BUILD_DIR) $(TB_VCD) $(TB_VCD:.vcd=.out)
|
2021-07-02 00:35:20 -06:00
|
|
|
|
|
|
|
.SECONDARY:
|
2022-08-21 11:40:12 -06:00
|
|
|
.PHONY: all prog clean tb
|