@@ 1,21 @@
+MIT License
+
+Copyright (c) 2021 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.
@@ 1,63 @@
+export ROOT := $(shell pwd)
+SIMDIR := $(ROOT)/sim
+export SRCDIR := $(ROOT)/src
+TBDIR := $(ROOT)/testbench
+WORKDIR := $(ROOT)/work
+VHDLEX := vhd
+
+#####################################################
+# #
+# Top level entity #
+# #
+#####################################################
+export TOP_ENTITY := char_alignment
+export TOP_ENTITY_VHDL := $(SRCDIR)/$(TOP_ENTITY).$(VHDLEX)
+TESTBENCH ?= $(TOP_ENTITY)_tb # default
+
+WAVEFORM_VIEWER := gtkwave
+
+COMPILER := ghdl
+COMPILER_FLAGS := --workdir=$(WORKDIR)
+
+STOP_TIME ?= 1000ns
+WAVEFORM_FILE ?= $(SIMDIR)/out.gwh
+
+RUN_FLAGS := --stop-time=$(STOP_TIME) --vcd=$(WAVEFORM_FILE) --stats
+
+TBSOURCES := $(wildcard $(TBDIR)/*.$(VHDLEX)) $(wildcard $(TBDIR)/**/*.$(VHDLEX))
+export SOURCES := $(wildcard $(TBDIR)/*.$(VHDLEX)) $(wildcard $(SRCDIR)/**/*.$(VHDLEX))
+ALL_SOURCES := $(SOURCES) $(TBSOURCES)
+
+EXECUTABLE := $(SIMDIR)/$(TESTBENCH)
+
+.PHONY: all clean
+
+import: $(WORKDIR) $(ALL_SOURCES)
+ $(COMPILER) -i $(COMPILER_FLAGS) $(ALL_SOURCES)
+
+compile: $(SIMDIR) $(WORKDIR) $(ALL_SOURCES)
+ @$(COMPILER) -i $(COMPILER_FLAGS) $(ALL_SOURCES)
+ @$(COMPILER) -m -o $(EXECUTABLE) $(COMPILER_FLAGS) $(TESTBENCH)
+
+all: compile run view
+
+$(TBDIR)/$(TESTBENCH): compile
+
+$(WORKDIR):
+ @mkdir $(WORKDIR)
+
+$(SIMDIR):
+ @mkdir $(SIMDIR)
+
+run: $(TBDIR)/$(TESTBENCH) $(SIMDIR)
+ @$(EXECUTABLE) $(RUN_FLAGS)
+
+view:
+ gsettings set com.geda.gtkwave reload 1
+ gsettings set com.geda.gtkwave reload 0
+ pgrep $(WAVEFORM_VIEWER) || $(WAVEFORM_VIEWER) $(WAVEFORM_FILE) &
+
+clean:
+ @$(RM) -rf $(SIMDIR)
+ @$(RM) -rf $(WORKDIR)
+