use separate build directory

This commit is contained in:
2021-07-02 00:58:43 -06:00
parent 0ec0c32d87
commit d850556bb7
4 changed files with 1847 additions and 8 deletions

45
Makefile Normal file
View File

@@ -0,0 +1,45 @@
PROJ = top
PIN_DEF = pins.pcf
DEVICE = hx8k
PACKAGE = ct256
BUILD_DIR = build
SOURCE_V = $(wildcard hdl/*.v)
TESTBENCH_V = $(wildcard hdl/tb/*.v)
all: $(BUILD_DIR)/$(PROJ).rpt $(BUILD_DIR)/$(PROJ).bin
$(BUILD_DIR)/%.blif: hdl/%.v
yosys -p 'synth_ice40 -top top -blif $@' $(SOURCE_V)
# 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 $<
$(BUILD_DIR):
mkdir $(BUILD_DIR)
$(BUILD_DIR)/tb.out: $(BUILD_DIR) $(SOURCE_V) $(TESTBENCH_V)
iverilog $^ -o $@
sim: $(BUILD_DIR)/tb.out
$(BUILD_DIR)/tb.out
clean:
rm -rf $(BUILD_DIR)
.SECONDARY:
.PHONY: all prog clean sim