Refactored after moving of VHDL make
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
LIB_PATH := $(VHDL_HOME)/lib
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
# -------------------------------------------------
|
||||
# User options
|
||||
# -------------------------------------------------
|
||||
# SRCS
|
||||
# WITH_VCD
|
||||
# WITH_GHW
|
||||
TARGET ?= default
|
||||
ENTITY ?= default
|
||||
WORK_LIB ?= work
|
||||
LANG_STD ?= 93c
|
||||
IEEE_STD ?= standard
|
||||
RUN_TIME ?= 1000ns
|
||||
WAVE_FORMAT ?= fst
|
||||
|
||||
# Build path
|
||||
BUILD_DIR ?= build/$(TARGET)
|
||||
WORK_DIR ?= $(BUILD_DIR)/$(WORK_LIB)
|
||||
|
||||
# Can be pre-initialized by user
|
||||
RUN_OPTS += --stop-time=$(RUN_TIME)
|
||||
GHDL_OPTS += --work=$(WORK_LIB) --workdir=$(WORK_DIR) --std=$(LANG_STD) --ieee=$(IEEE_STD)
|
||||
|
||||
# -------------------------------------------------
|
||||
# Make unique
|
||||
# -------------------------------------------------
|
||||
define uniq =
|
||||
$(eval seen :=)
|
||||
$(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_)))
|
||||
${seen}
|
||||
endef
|
||||
SRCS := $(abspath $(SRCS))
|
||||
SRCS := $(call uniq,$(SRCS))
|
||||
SRCS := $(filter-out ,$(SRCS))
|
||||
#$(info ----------------------)
|
||||
#$(info $(SRCS))
|
||||
#$(info ----------------------)
|
||||
|
||||
# -------------------------------------------------
|
||||
# GHDL binary
|
||||
# -------------------------------------------------
|
||||
GHDL := ghdl
|
||||
GHDL_GCC := ghdl-gcc
|
||||
|
||||
# Wave format selection
|
||||
SIM_FILE-vcd := $(BUILD_DIR)/$(TARGET).vcd
|
||||
GTK_OPTS-vcd := --vcd=$(SIM_FILE-vcd)
|
||||
|
||||
SIM_FILE-fst := $(BUILD_DIR)/$(TARGET).fst
|
||||
GTK_OPTS-fst := --fst=$(SIM_FILE-fst)
|
||||
|
||||
SIM_FILE-ghw := $(BUILD_DIR)/$(TARGET).ghw
|
||||
GTK_OPTS-ghw := --wave=$(SIM_FILE-ghw)
|
||||
|
||||
SIM_FILE := $(SIM_FILE-$(WAVE_FORMAT))
|
||||
GTK_OPTS := $(GTK_OPTS-$(WAVE_FORMAT))
|
||||
|
||||
# -------------------------------------------------
|
||||
# Targets
|
||||
# -------------------------------------------------
|
||||
|
||||
all: analyze
|
||||
|
||||
$(WORK_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
syntax:
|
||||
$(GHDL) -s $(GHDL_OPTS) $(SRCS)
|
||||
|
||||
import:
|
||||
$(GHDL) -i $(GHDL_OPTS) $(SRCS)
|
||||
|
||||
analyze: $(WORK_DIR) $(SRCS)
|
||||
$(GHDL) -a $(GHDL_OPTS) $(SRCS)
|
||||
|
||||
html: $(WORK_DIR) $(SRCS)
|
||||
$(GHDL) --pp-html $(GHDL_OPTS) $(SRCS) >$(BUILD_DIR)/$(TARGET).html
|
||||
|
||||
anaborate: $(WORK_DIR) $(SRCS)
|
||||
$(GHDL) -c $(GHDL_OPTS) -o $(BUILD_DIR)/$(TARGET) $(SRCS) -e $(ENTITY)
|
||||
|
||||
makeunit: analyze
|
||||
$(GHDL) -m $(GHDL_OPTS) $(ENTITY)
|
||||
|
||||
elaborate: analyze
|
||||
$(GHDL) -e $(GHDL_OPTS) $(ENTITY)
|
||||
|
||||
run: analyze
|
||||
$(GHDL) -r $(GHDL_OPTS) $(ENTITY) $(RUN_OPTS)
|
||||
|
||||
run_wave: analyze
|
||||
$(GHDL) -r $(GHDL_OPTS) $(ENTITY) $(RUN_OPTS) $(GTK_OPTS) >$(BUILD_DIR)/$(TARGET).log
|
||||
|
||||
synth: analyze
|
||||
$(GHDL) --synth $(GHDL_OPTS) $(ENTITY)
|
||||
|
||||
wave: run_wave
|
||||
exec gtkwave -f $(SIM_FILE) -a $(TARGET).gtkw &
|
||||
|
||||
result:
|
||||
exec gtkwave -f $(SIM_FILE) -a $(TARGET).gtkw &
|
||||
|
||||
tree: analyze
|
||||
$(GHDL) -r $(GHDL_OPTS) $(ENTITY) $(RUN_OPTS) --no-run --disp-tree=inst
|
||||
|
||||
|
||||
.PHONY: list
|
||||
INSTR = $(foreach number,$(SRCS),echo $(number);)
|
||||
list:
|
||||
@$(INSTR)
|
||||
|
||||
clean:
|
||||
rm -rf $(WORK_DIR)
|
||||
rm -f $(BUILD_DIR)/$(TARGET)*.vcd
|
||||
rm -f $(BUILD_DIR)/$(TARGET)*.fst
|
||||
rm -f $(BUILD_DIR)/$(TARGET)*.ghw
|
||||
rm -f $(BUILD_DIR)/$(TARGET)*.log
|
||||
rm -f $(BUILD_DIR)/$(TARGET)*.o
|
||||
|
||||
mrproper:
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
.PHONY: clean
|
||||
all: bit
|
||||
|
||||
netlist: $(PRJ).ngc
|
||||
translate: $(PRJ).ngd
|
||||
map: $(PRJ)_map.ncd
|
||||
par: $(PRJ).ncd
|
||||
bit: $(PRJ).bit
|
||||
prom : $(PRJ).mcs
|
||||
timing : $(PRJ).twr
|
||||
|
||||
NETLIST_DIR ?= ./
|
||||
MAP_EFFORT ?= high
|
||||
PAR_EFFORT ?= high
|
||||
|
||||
BUILD_DIR := ./
|
||||
XST_DIR := $(BUILD_DIR)/xst/tmp
|
||||
DIRS := $(XST_DIR)
|
||||
|
||||
# Netlist
|
||||
$(PRJ).ngc: $(DIRS) $(PREQ) ./project/$(PRJ).ucf
|
||||
xst -intstyle xflow -ifn ./project/$(PRJ).xst
|
||||
|
||||
# Translate
|
||||
$(PRJ).ngd: $(NETLISTS) $(PRJ).ngc ./project/$(PRJ).ucf
|
||||
ngdbuild -p $(DEVICE) -sd $(NETLIST_DIR) -dd _ngo -nt timestamp -uc ./project/$(PRJ).ucf $(PRJ).ngc $(PRJ).ngd
|
||||
|
||||
# Map
|
||||
$(PRJ)_map.ncd: $(PRJ).ngd
|
||||
map -intstyle xflow -p $(DEVICE) -timing -logic_opt on -ol $(MAP_EFFORT) -t 1 -register_duplication -cm area -ignore_keep_hierarchy -pr off -k 4 -power off -o $(PRJ)_map.ncd $(PRJ).ngd $(PRJ).pcf
|
||||
|
||||
# PAR
|
||||
$(PRJ).ncd: $(PRJ)_map.ncd
|
||||
par -w -intstyle xflow -ol $(PAR_EFFORT) -t 1 $(PRJ)_map.ncd $(PRJ).ncd $(PRJ).pcf
|
||||
|
||||
# Timing
|
||||
$(PRJ).twr: $(PRJ).ncd $(PRJ).pcf ./project/$(PRJ).ucf
|
||||
trce -intstyle xflow -v 3 $(PRJ).ncd -ucf ./project/$(PRJ).ucf -o $(PRJ).twr $(PRJ).pcf
|
||||
|
||||
# Bitgen
|
||||
$(PRJ).bit: $(PRJ).ncd ./project/$(PRJ).ut
|
||||
bitgen -intstyle xflow -f ./project/$(PRJ).ut $(PRJ).ncd
|
||||
|
||||
# Promgen
|
||||
$(PRJ).mcs: $(PRJ).bit
|
||||
promgen -w -p mcs -c FF -o $(PRJ) -ver 0 $(PRJ).bit -x xcf32p
|
||||
|
||||
$(DIRS):
|
||||
mkdir -p $(DIRS)
|
||||
|
||||
clean:
|
||||
rm -rf ./_ngo
|
||||
rm -rf ./xst
|
||||
rm -rf ./xlnx_auto_0_xdb
|
||||
rm -f xlnx_auto_0.ise
|
||||
rm -f smartpreview.twr
|
||||
rm -f $(PRJ)*.*
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# -----------------------------------------------------------
|
||||
include $(VHDL_HOME)/make/defs.mk
|
||||
# -----------------------------------------------------------
|
||||
include package_other.inc
|
||||
|
||||
# -----------------------------------------------------------
|
||||
PKG_NAME := PACKAGE_NEW
|
||||
|
||||
# -----------------------------------------------------------
|
||||
$(PKG_NAME)_SRCS += $(PKG_OTHER_SRC)
|
||||
$(PKG_NAME)_SRCS += $(LIB_PATH)/pkg_new.vhd
|
||||
|
||||
# -----------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# -----------------------------------------------------------
|
||||
include $(VHDL_HOME)/make/defs.mk
|
||||
# -----------------------------------------------------------
|
||||
include package1.inc
|
||||
include package2.inc
|
||||
|
||||
# -----------------------------------------------------------
|
||||
SRCS := $(PACKAGE1_SRCS)
|
||||
SRCS += $(PACKAGE2_SRCS)
|
||||
SRCS += $(LIB_PATH)/tb_new.vhd
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Compile
|
||||
TARGET := tb_new
|
||||
ENTITY := tb_new
|
||||
WITH_VCD := y
|
||||
RUN_TIME := 1us
|
||||
|
||||
include $(VHDL_HOME)/make/ghdl.mk
|
||||
# -----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user