ice40/Makefile

54 lines
1.2 KiB
Makefile
Raw Normal View History

2021-07-02 00:35:20 -06:00
PROJ = top
DEVICE = hx8k
PACKAGE = ct256
# 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
# 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
all: $(BUILD_DIR)/$(PROJ).rpt $(BUILD_DIR)/$(PROJ).bin
2021-07-02 01:12:29 -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 $@ $<
# 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 $<
tb: $(TB_VCD)
2021-07-02 00:35:20 -06:00
clean:
rm -rf $(BUILD_DIR) $(TB_VCD) $(TB_VCD:.vcd=.out)
2021-07-02 00:35:20 -06:00
.SECONDARY:
.PHONY: all prog clean tb