From f122fa70e30a7d7744b38fa22bd1d5aa949e8277 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Thu, 24 Dec 2020 09:22:34 +0100 Subject: prepare makefile infrastructure for writing examples --- Makefile.util | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'Makefile.util') diff --git a/Makefile.util b/Makefile.util index 02ad5a3..4abddca 100644 --- a/Makefile.util +++ b/Makefile.util @@ -1,4 +1,31 @@ -FILE_LINES = `grep -E '^[[:space:]]*[^[:space:]/]' -c $(1)` +ifndef PROJ_DIR +PROJ_DIR := ./ +endif + +include $(PROJ_DIR)/Makefile.config + +IVFLAGS += -I$(PROJ_DIR)/include/ + +vpath %.v $(PROJ_DIR)/design/:$(PROJ_DIR)/models/:$(PROJ_DIR)/examples/:. +vpath %.vh $(PROJ_DIR)/include:. +vpath %.pcf $(PROJ_DIR):. + +FILE_LINES = $(shell grep -E '^[[:space:]]*[^[:space:]/]' -c $(1)) + +design.json yosys.log : design.v + $(YOSYS) -p 'read_verilog -defer $<' \ + -p 'synth_ice40 -top $(TOPMODULE) -json design.json' \ + > yosys.log 2>&1 + +design.asc pnr.log: $(PCF) design.json + $(PNR) --hx8k --asc design.asc --pcf $< --json design.json \ + --package ct256 > pnr.log 2>&1 + +design.bin : design.asc + $(ICEPACK) $< $@ + +prog : design.bin + sudo iceprogduino $< %.mem : $(PROJ_DIR)/tclasm.tcl %.s.tcl tclsh $^ > $@ @@ -8,3 +35,36 @@ FILE_LINES = `grep -E '^[[:space:]]*[^[:space:]/]' -c $(1)` %.wasm : %.wat $(WAT2WASM) $< -o $@ + +include $(PROJ_DIR)/tools/Makefile.tools + +TOOLS_TARGETS = $(addprefix $(PROJ_DIR)/tools/,$(TOOLS)) + +$(TOOLS_TARGETS) : $(PROJ_DIR)/tools/% : + $(MAKE) -C $(dir $@) $* + +FIND_TCLASM_BASE_NAMES = \ + $(basename $(basename $(shell find $(1) -name "*.s.tcl"))) + +FIND_WAT_BASE_NAMES = \ + $(basename $(shell find $(1) -name "*.wat")) + +FIND_MEMV_BASE_NAMES = \ + $(basename $(shell find $(1) -name "*.memv")) + +FIND_GENERATED_MEM_BASE_NAMES = \ + $(call FIND_TCLASM_BASE_NAMES,$(1)) \ + $(call FIND_WAT_BASE_NAMES,$(1)) \ + $(call FIND_MEMV_BASE_NAMES,$(1)) + +FIND_GENERATED_MEM_FILES = \ + $(addsuffix .mem,$(call FIND_GENERATED_MEM_BASE_NAMES,$(1))) + +FIND_GENERATED_WASM_FILES = \ + $(addsuffix .wasm,$(call FIND_WAT_BASE_NAMES,$(1))) + +FIND_GENERATED_FILES = \ + $(call FIND_GENERATED_MEM_FILES,$(1)) \ + $(call FIND_GENERATED_WASM_FILES,$(1)) + +.PHONY : prog -- cgit v1.2.3