ice40/Makefile

46 lines
853 B
Makefile
Raw Normal View History

2021-07-02 00:35:20 -06:00
PROJ = top
PIN_DEF = pins.pcf
DEVICE = hx8k
PACKAGE = ct256
2021-07-02 00:58:43 -06:00
BUILD_DIR = build
2021-07-02 00:35:20 -06:00
2021-07-02 00:58:43 -06:00
SOURCE_V = $(wildcard hdl/*.v)
TESTBENCH_V = $(wildcard hdl/tb/*.v)
2021-07-02 00:41:37 -06:00
2021-07-02 00:58:43 -06:00
all: $(BUILD_DIR)/$(PROJ).rpt $(BUILD_DIR)/$(PROJ).bin
2021-07-02 00:35:20 -06:00
2021-07-02 00:58:43 -06:00
$(BUILD_DIR)/%.blif: hdl/%.v
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 $@ $<
prog: $(PROJ).bin
iceprog $<
sudo-prog: $(PROJ).bin
@echo 'Executing prog as root!!!'
sudo iceprog $<
2021-07-02 00:58:43 -06:00
$(BUILD_DIR):
mkdir $(BUILD_DIR)
$(BUILD_DIR)/tb.out: $(BUILD_DIR) $(SOURCE_V) $(TESTBENCH_V)
2021-07-02 00:35:20 -06:00
iverilog $^ -o $@
2021-07-02 00:58:43 -06:00
sim: $(BUILD_DIR)/tb.out
$(BUILD_DIR)/tb.out
2021-07-02 00:35:20 -06:00
clean:
2021-07-02 00:58:43 -06:00
rm -rf $(BUILD_DIR)
2021-07-02 00:35:20 -06:00
.SECONDARY:
.PHONY: all prog clean sim