ice40/Makefile

45 lines
905 B
Makefile
Raw Normal View History

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