From b5e7d3a236aed0dca18556c6166f25544d336089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Thu, 20 Jul 2023 09:44:02 +0200 Subject: [PATCH] feat: add Makefile template --- .gitignore | 4 ++++ LICENSE | 21 +++++++++++++++++ Makefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++ src/.gitkeep | 0 testbench/.gitkeep | 0 5 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 src/.gitkeep create mode 100644 testbench/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..c5ad88b21a273c17c682aa3f01ac6ea12e6a4cd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +_impactbatch.log +work/ +sim/ +bin/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..03971e7b0fe97852c8636d41b11f3a2e18bfeb5b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 František Boháček + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..ecde0a1d6e6c74807f04438f0a9bc3041fdd318b --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +SIMDIR := sim +BINDIR := bin +SRCDIR := src +TBDIR := testbench +WORKDIR := work +VHDLEX := vhd + +WORKFILE := $(WORKDIR)/work-obj93.cf + +##################################################### +# # +# Top level entity # +# # +##################################################### +TOP_ENTITY := spi +TESTBENCH ?= $(TOP_ENTITY)_tb # default + +WAVEFORM_VIEWER := gtkwave + +COMPILER := ghdl +COMPILER_FLAGS := --std=08 --ieee=standard --workdir=$(WORKDIR) + +STOP_TIME ?= 1000ns +RUN_FLAGS := --stop-time=$(STOP_TIME) --stats + +TBSOURCES := $(wildcard $(TBDIR)/*.$(VHDLEX) $(TBDIR)/**/*.$(VHDLEX)) +SOURCES := $(wildcard $(SRCDIR)/*.$(VHDLEX) $(SRCDIR)/**/*.$(VHDLEX)) +ALL_SOURCES := $(SOURCES) $(TBSOURCES) + +.PHONY: all clean + +all: $(SIMDIR)/$(TESTBENCH).ghw + +$(BINDIR)/%_tb.out: $(TBDIR)/%_tb.$(VHDLEX) $(WORKFILE) $(BINDIR) + @$(COMPILER) -m -o $@ $(COMPILER_FLAGS) $(notdir $(basename $@)) + +$(BINDIR)/%.out: $(SRCDIR)/%.$(VHDLEX) $(WORKFILE) $(BINDIR) + @$(COMPILER) -m -o $@ $(COMPILER_FLAGS) $(notdir $(basename $@)) + +$(SIMDIR)/%.ghw: $(BINDIR)/%.out + $< $(RUN_FLAGS) --wave=$@ + gsettings set com.geda.gtkwave reload 1 + gsettings set com.geda.gtkwave reload 0 + pgrep $(WAVEFORM_VIEWER) || $(WAVEFORM_VIEWER) $@ & + +$(WORKFILE): $(WORKDIR) $(ALL_SOURCES) + @$(COMPILER) -i $(COMPILER_FLAGS) $(ALL_SOURCES) + +$(BINDIR) $(WORKDIR) $(SIMDIR): + @mkdir $@ + +clean: + @$(RM) -rf $(SIMDIR) $(WORKDIR) $(BINDIR) + @$(MAKE) -C ax309 clean + +$(ALL_SOURCES): diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/testbench/.gitkeep b/testbench/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391