aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-09-08 17:27:48 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-09-08 17:27:48 +0200
commitcbc2686373a5fe81b6b28f845edc323d4cae56e5 (patch)
treef53d38cbb32f441450f8d33ff315566f1e98ce5f
parent0a49a2c1496888f0014cf09feb425d9cc47a75ba (diff)
downloadAGH-engineering-thesis-cbc2686373a5fe81b6b28f845edc323d4cae56e5.tar.gz
AGH-engineering-thesis-cbc2686373a5fe81b6b28f845edc323d4cae56e5.zip
modernize the build (test) system
-rw-r--r--Makefile231
-rw-r--r--Makefile.config16
-rw-r--r--Makefile.test73
-rw-r--r--Makefile.util10
-rwxr-xr-x[-rw-r--r--]tclasm.tcl7
-rw-r--r--tests/div/Makefile7
-rw-r--r--tests/embedded_bram_slave/Makefile9
-rw-r--r--tests/intercon/Makefile10
-rw-r--r--tests/interface_wrapper/Makefile7
-rw-r--r--tests/master_arbiter/Makefile10
-rw-r--r--tests/self/Makefile7
-rw-r--r--tests/self_32bit_word/Makefile7
-rw-r--r--tests/slave_dispatcher/Makefile7
-rw-r--r--tests/soc_simple_display/Makefile9
-rw-r--r--[-rwxr-xr-x]tests/soc_simple_display/instructions.s.tcl4
-rw-r--r--tests/sram_slave/Makefile7
l---------tests/stack_machine_add/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_add/instructions.s.tcl4
l---------tests/stack_machine_cond_jump/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_cond_jump/instructions.s.tcl6
l---------tests/stack_machine_div/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_div/instructions.s.tcl4
l---------tests/stack_machine_jump/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_jump/instructions.s.tcl4
l---------tests/stack_machine_load_store/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_load_store/instructions.s.tcl4
l---------tests/stack_machine_mul/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_mul/instructions.s.tcl4
l---------tests/stack_machine_multiinstructions_load_store/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_multiinstructions_load_store/instructions.s.tcl4
-rw-r--r--tests/stack_machine_store/Makefile10
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_store/instructions.s.tcl4
l---------tests/stack_machine_sub/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_sub/instructions.s.tcl4
l---------tests/stack_machine_swap/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_swap/instructions.s.tcl4
l---------tests/stack_machine_tee/Makefile1
-rw-r--r--[-rwxr-xr-x]tests/stack_machine_tee/instructions.s.tcl4
-rw-r--r--tests/vga/Makefile9
-rw-r--r--tests/wrapped_stack_machine_cond_jump/Makefile10
40 files changed, 250 insertions, 256 deletions
diff --git a/Makefile b/Makefile
index a4c7b69..677053a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,87 +1,17 @@
-CC = gcc
-CFLAGS = -std=c89 -pedantic -Wall -Werror -O2
-
-IV = iverilog
-
-YOSYS = git-yosys
-PNR = git-nextpnr-ice40
-ICEPACK = git-icepack
-ICETIME = git-icetime
-
-TOPMODULE = soc
-
-PCF = design/pins.pcf
-
-IVFLAGS = -Iinclude/ -DSIMULATION
-# The macroassembly header file is somewhat different thing, but I don't know
-# what place would be more suitable for it than include/ dir
-MACROASM_FLAGS := -Iinclude/ -E
-
-# It made sense to just list all of those in this variable
-# and then prepend stack_machine_ to each element
-STACK_MACHINE_TESTS := \
- store \
- load_store \
- multiinstructions_load_store \
- tee \
- swap \
- add \
- sub \
- div \
- mul \
- jump \
- cond_jump
-
-# Add other tests here if You need
-TESTS := \
- self \
- self_32bit_word \
- div \
- vga \
- sram_slave \
- embedded_bram_slave \
- soc_simple_display \
- interface_wrapper \
- wrapped_stack_machine_cond_jump \
- intercon \
- slave_dispatcher \
- master_arbiter \
- $(addprefix stack_machine_,$(STACK_MACHINE_TESTS))
-
-# For each of these Makefile will attempt to generate VGAdump.ppm
-# and compare it to VGAdump_expected.ppm inside that test's directory
-TESTS_WITH_VGA := \
- vga \
- soc_simple_display
+include Makefile.config
+include Makefile.util
# Short C programs
TOOLS := VGAdump2ppm
-ifdef DEBUG
-IVFLAGS += -DDEBUG
-DBG&SAVE = tee "$(1)"
-else
-DBG&SAVE = cat > "$(1)" # putting cat through pipe - what an animal cruelty!
-endif
-
-TEST_TARGETS := $(addprefix test_,$(TESTS))
-VGA_TEST_TARGETS := $(addprefix test_,$(TESTS_WITH_VGA))
-NO_VGA_TEST_TARGETS := $(foreach TARGET,$(TEST_TARGETS), \
- $(if $(filter $(TARGET),$(VGA_TEST_TARGETS)),,$(TARGET)) \
- )
-
-TEST_LOGS := $(foreach TEST,$(TESTS),tests/$(TEST)/report.log)
+TEST_TARGETS := $(addprefix test_,$(shell ls tests))
TOOLS_TARGETS := $(addprefix tools/,$(TOOLS))
-GENERATED_MEM_FILES := $(shell find . -name "*.s.tcl")
+GENERATED_MEM_FILES := $(shell find design/ -name "*.s.tcl")
GENERATED_MEM_FILES := $(basename $(basename $(GENERATED_MEM_FILES)))
-GENERATED_MEM_FILES += $(basename $(shell find tests/ -name "*.memv"))
GENERATED_MEM_FILES := $(addsuffix .mem,$(GENERATED_MEM_FILES))
-# TODO: check if this function can be changed to use $(shell grep ...)
-FILE_LINES = `grep -E '^[[:space:]]*[^[:space:]/]' -c $(1)`
-
all : design.bin
@@ -105,130 +35,25 @@ prog : design.bin
sudo iceprogduino $<
-test : $(TEST_TARGETS)
-quicktest : $(NO_VGA_TEST_TARGETS) # VGA tests take loooong time
-
-
-tests/%.mem : tests/%.memv
- $(IV) $(MACROASM_FLAGS) $^ -o $@
-
-%.mem : %.s.tcl tclasm.tcl
- $< > $@
-
-tests/self/test.vvp : tests/self/operations.mem tests/self/test.v \
- models/slave.v models/master.v include/messages.vh
- $(IV) $(IVFLAGS) -s self_test \
- -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/self_32bit_word/test.vvp : tests/self_32bit_word/operations.mem \
- tests/self_32bit_word/test.v models/slave.v models/master.v \
- include/messages.vh
- $(IV) $(IVFLAGS) -s self_32bit_test \
- -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/sram_slave/test.vvp : tests/sram_slave/operations.mem \
- tests/sram_slave/test.v models/sram.v models/master.v \
- design/sram_slave.v include/messages.vh
- $(IV) $(IVFLAGS) -s sram_slave_test \
- -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/slave_dispatcher/test.vvp : tests/slave_dispatcher/operations.mem \
- tests/slave_dispatcher/test.v models/slave.v models/master.v \
- design/slave_dispatcher.v include/messages.vh
- $(IV) $(IVFLAGS) -s slave_dispatcher_test \
- -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/interface_wrapper/test.vvp : tests/interface_wrapper/operations.mem \
- tests/interface_wrapper/test.v models/slave.v models/master.v \
- design/interface_wrapper.v include/messages.vh
- $(IV) $(IVFLAGS) -s interface_wrapper_test \
- -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/master_arbiter/test.vvp : tests/master_arbiter/operations0.mem \
- tests/master_arbiter/operations1.mem \
- tests/master_arbiter/test.v models/slave.v models/master.v \
- design/master_arbiter.v include/messages.vh
- $(IV) $(IVFLAGS) -s master_arbiter_test \
- -DMASTER0_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- -DMASTER1_OPERATIONS_COUNT=$(call FILE_LINES,\
- $(filter %1.mem,$^)) \
- $(filter %.v,$^) -o $@
-
-tests/intercon/test.vvp : tests/intercon/operations0.mem \
- tests/intercon/operations1.mem tests/intercon/test.v \
- models/slave.v models/master.v design/intercon.v \
- design/slave_dispatcher.v design/master_arbiter.v \
- include/messages.vh
- $(IV) $(IVFLAGS) -s intercon_test \
- -DMASTER0_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- -DMASTER1_OPERATIONS_COUNT=$(call FILE_LINES,\
- $(filter %1.mem,$^)) \
- $(filter %.v,$^) -o $@
-
-tests/embedded_bram_slave/test.vvp : tests/embedded_bram_slave/operations.mem \
- tests/embedded_bram_slave/rom.mem \
- tests/embedded_bram_slave/test.v models/master.v \
- design/embedded_bram_slave.v include/messages.vh
- $(IV) $(IVFLAGS) -s embedded_bram_test \
- -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,$<) \
- -DROM_WORDS_COUNT=$(call FILE_LINES,$(filter %rom.mem,$^)) \
- $(filter %.v,$^) -o $@
-
-tests/div/test.vvp : tests/div/test.v design/div.v include/messages.vh
- $(IV) $(IVFLAGS) -s div_test $(filter %.v,$^) -o $@
-
-tests/vga/test.vvp : tests/vga/test.v design/vga.v models/vga_display.v \
- include/messages.vh
- $(IV) $(IVFLAGS) -s vga_test $^ -o $@
-
-tests/stack_machine_%/test.vvp : \
- tests/stack_machine_%/words_to_verify.mem \
- tests/stack_machine_%/instructions.mem \
- tests/stack_machine_%/test.v models/slave.v \
- design/stack_machine.v design/div.v include/messages.vh
- $(IV) $(IVFLAGS) -s stack_machine_test \
- -DINSTRUCTIONS_COUNT=$(call FILE_LINES,$(filter %ions.mem,$^)) \
- -DWORDS_TO_VERIFY_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/wrapped_stack_machine_%/test.vvp : \
- tests/wrapped_stack_machine_%/words_to_verify.mem \
- tests/wrapped_stack_machine_%/instructions.mem \
- tests/wrapped_stack_machine_%/test.v models/slave.v \
- design/wrapped_stack_machine.v design/stack_machine.v \
- design/interface_wrapper.v design/div.v include/messages.vh
- $(IV) $(IVFLAGS) -s wrapped_stack_machine_test \
- -DINSTRUCTIONS_COUNT=$(call FILE_LINES,$(filter %ions.mem,$^)) \
- -DWORDS_TO_VERIFY_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-tests/soc_simple_display/test.vvp : tests/soc_simple_display/instructions.mem \
- tests/soc_simple_display/test.v models/sram.v \
- models/vga_display.v design/*.v include/messages.vh
- $(IV) $(IVFLAGS) -s soc_test -DROM_WORDS_COUNT=$(call FILE_LINES,$<) \
- $(filter %.v,$^) -o $@
-
-
-$(foreach TEST,$(TESTS_WITH_VGA),tests/$(TEST)/report.log) \
-$(foreach TEST,$(TESTS_WITH_VGA),tests/$(TEST)/VGAdump.ppm) : design/font.mem
-
-tests/%/VGAdump.mem tests/%/report.log : tests/%/test.vvp
- cd $(dir $<) && vvp $(notdir $<) | $(call DBG&SAVE,report.log)
-
-tests/%/VGAdump.ppm : tests/%/VGAdump.mem tools/VGAdump2ppm
- grep -v // < $< | ./tools/VGAdump2ppm > $@
-
-$(VGA_TEST_TARGETS) : test_% : tests/%/VGAdump_expected.ppm tests/%/VGAdump.ppm
-$(TEST_TARGETS) : test_% : tests/%/report.log
- if grep error $<; then false; fi
- if [ "$(filter $@,$(VGA_TEST_TARGETS))" != "" ]; then \
- diff $(dir $<)VGAdump.ppm $(dir $<)VGAdump_expected.ppm; \
- fi
+CALL_TESTS = \
+ cd tests/; \
+ for TEST in *; do \
+ echo "** $$TEST "; \
+ if ! $(MAKE) -C $$TEST $(1) 3>&1 1>/dev/null 2>&3; then \
+ FAIL=true; \
+ fi; \
+ done; \
+ [ "$$FAIL" != true ]
+
+test :
+ $(call CALL_TESTS)
+
+# Will skip VGA tests, because they take loooong time
+quicktest :
+ $(call CALL_TESTS,QUICK_TEST=1)
+
+$(TEST_TARGETS) : test_% :
+ $(MAKE) -C tests/$*
tools : $(TOOLS_TARGETS)
@@ -236,12 +61,8 @@ $(TOOLS_TARGETS) : tools/% : tools/%.c
$(CC) $(CFLAGS) $^ -o $@
clean :
- -find tests/ -name "*.vvp" -delete
- -find tests/ -name "*.log" -delete
- -find tests/ -name "VGAdump.mem" -delete
- -find tests/ -name "VGAdump.ppm" -delete
- -rm $(GENERATED_MEM_FILES)
- -rm design.json design.v design.asc design.bin timing.rpt
- -rm $(TOOLS_TARGETS)
+ for TEST in tests/*; do $(MAKE) -C $$TEST clean >/dev/null; done
+ rm $(GENERATED_MEM_FILES) $(TOOLS_TARGETS) 2>/dev/null || true
+ rm $(addprefix design.,v json asc bin) timing.rpt 2>/dev/null || true
.PHONY : all tools test quicktest $(TEST_TARGETS)
diff --git a/Makefile.config b/Makefile.config
new file mode 100644
index 0000000..5c619c3
--- /dev/null
+++ b/Makefile.config
@@ -0,0 +1,16 @@
+CC = gcc
+CFLAGS = -std=c89 -pedantic -Wall -Werror -O2
+
+IV = iverilog
+
+YOSYS = git-yosys
+PNR = git-nextpnr-ice40
+ICEPACK = git-icepack
+ICETIME = git-icetime
+
+TOPMODULE = soc
+
+PCF = design/pins.pcf
+
+# Uncomment this line when needed
+#DEBUG=1
diff --git a/Makefile.test b/Makefile.test
new file mode 100644
index 0000000..fac2c14
--- /dev/null
+++ b/Makefile.test
@@ -0,0 +1,73 @@
+# This Makefile is to be included by Makefile of each test
+
+ifndef PROJ_DIR
+PROJ_DIR := ../../
+endif
+
+IVFLAGS += -I$(PROJ_DIR)/include/ -DSIMULATION
+# The macroassembly header file is somewhat different thing, but I don't know
+# what place would be more suitable for it than include/ dir
+MACROASM_FLAGS += -I$(PROJ_DIR)/include/ -E
+
+include $(PROJ_DIR)/Makefile.config
+include $(PROJ_DIR)/Makefile.util
+
+ifdef DEBUG
+IVFLAGS += -DDEBUG
+DBG&SAVE = tee "$(1)"
+else
+DBG&SAVE = cat > "$(1)" # putting cat through pipe - what an animal cruelty!
+endif
+
+vpath %.v $(PROJ_DIR):$(PROJ_DIR)/design/:$(PROJ_DIR)/models/:.
+vpath %.vh $(PROJ_DIR)/include:.
+
+ifdef QUICK_TEST
+ifdef VGA_TEST
+SKIPPING = 1
+endif
+endif
+
+ifdef SKIPPING
+test :
+ @echo Skipping >&2
+else
+ifdef VGA_TEST
+test : VGAdump.ppm VGAdump_expected.ppm
+endif
+test : report.log
+ ! grep error $< >&2
+ifdef VGA_TEST
+ diff VGAdump.ppm VGAdump_expected.ppm
+endif
+endif
+
+$(PROJ_DIR)/% :
+ $(MAKE) -C $(PROJ_DIR) $*
+
+%.mem : %.memv
+ $(IV) $(MACROASM_FLAGS) $^ -o $@
+
+%.vvp : %.v $(DEPENDS)
+ $(IV) $(IVFLAGS) -s $(TOP) $(filter %.v,$^) -o $@
+
+
+ifdef VGA_TEST
+report.log VGAdump.mem : $(PROJ_DIR)/design/font.mem
+endif
+report.log VGAdump.mem : test.vvp
+ vvp $< | $(call DBG&SAVE,report.log)
+
+VGAdump.ppm : $(PROJ_DIR)/tools/VGAdump2ppm VGAdump.mem
+ grep -v // < VGAdump.mem | $< > $@
+
+GENERATED_MEM_FILES := $(shell find . -name "*.s.tcl")
+GENERATED_MEM_FILES := $(basename $(basename $(GENERATED_MEM_FILES)))
+GENERATED_MEM_FILES += $(basename $(shell find . -name "*.memv"))
+GENERATED_MEM_FILES := $(addsuffix .mem,$(GENERATED_MEM_FILES))
+
+clean :
+ rm $(GENERATED_MEM_FILES) *.vvp report.log VGAdump.mem VGAdump.ppm \
+ 2>/dev/null || true
+
+.PHONY : test clean
diff --git a/Makefile.util b/Makefile.util
new file mode 100644
index 0000000..7bdc584
--- /dev/null
+++ b/Makefile.util
@@ -0,0 +1,10 @@
+FILE_LINES = `grep -E '^[[:space:]]*[^[:space:]/]' -c $(1)`
+
+ifdef PROJ_DIR
+vpath tclasm.tcl $(PROJ_DIR)
+endif
+
+vpath tclasm.tcl .
+
+%.mem : tclasm.tcl %.s.tcl
+ tclsh $^ > $@
diff --git a/tclasm.tcl b/tclasm.tcl
index cafe99f..5af74c4 100644..100755
--- a/tclasm.tcl
+++ b/tclasm.tcl
@@ -1,5 +1,4 @@
-#!/bin/grep this[ ]script
-# this script is to be sourced, not executed by itself
+#!/usr/bin/tclsh
# procedures starting with "__" are internal and not to be used in asm code;
# procedures starting with "_" are low-level procedures, that are not meant
@@ -204,3 +203,7 @@ proc _cond_jump {address_part} {
proc cond_jump {address} {
_with_im _cond_jump $address
}
+
+
+# translate instructions in the file given as command line argument
+source [lindex $argv 0]
diff --git a/tests/div/Makefile b/tests/div/Makefile
new file mode 100644
index 0000000..c49f160
--- /dev/null
+++ b/tests/div/Makefile
@@ -0,0 +1,7 @@
+DEPENDS = div.v messages.vh
+
+IVFLAGS =
+
+TOP = div_test
+
+include ../../Makefile.test
diff --git a/tests/embedded_bram_slave/Makefile b/tests/embedded_bram_slave/Makefile
new file mode 100644
index 0000000..6d5b79e
--- /dev/null
+++ b/tests/embedded_bram_slave/Makefile
@@ -0,0 +1,9 @@
+DEPENDS = operations.mem rom.mem master.v embedded_bram_slave.v messages.vh
+
+IVFLAGS = \
+ -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,operations.mem) \
+ -DROM_WORDS_COUNT=$(call FILE_LINES,rom.mem)
+
+TOP = embedded_bram_test
+
+include ../../Makefile.test
diff --git a/tests/intercon/Makefile b/tests/intercon/Makefile
new file mode 100644
index 0000000..d70c403
--- /dev/null
+++ b/tests/intercon/Makefile
@@ -0,0 +1,10 @@
+DEPENDS = operations0.mem operations1.mem slave.v master.v intercon.v \
+ slave_dispatcher.v master_arbiter.v messages.vh
+
+IVFLAGS = \
+ -DMASTER0_OPERATIONS_COUNT=$(call FILE_LINES,operations0.mem) \
+ -DMASTER1_OPERATIONS_COUNT=$(call FILE_LINES,operations1.mem)
+
+TOP = intercon_test
+
+include ../../Makefile.test
diff --git a/tests/interface_wrapper/Makefile b/tests/interface_wrapper/Makefile
new file mode 100644
index 0000000..473c887
--- /dev/null
+++ b/tests/interface_wrapper/Makefile
@@ -0,0 +1,7 @@
+DEPENDS = operations.mem slave.v master.v interface_wrapper.v messages.vh
+
+IVFLAGS = -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,operations.mem)
+
+TOP = interface_wrapper_test
+
+include ../../Makefile.test
diff --git a/tests/master_arbiter/Makefile b/tests/master_arbiter/Makefile
new file mode 100644
index 0000000..2c611d7
--- /dev/null
+++ b/tests/master_arbiter/Makefile
@@ -0,0 +1,10 @@
+DEPENDS = operations0.mem operations1.mem slave.v master.v master_arbiter.v \
+ messages.vh
+
+IVFLAGS = \
+ -DMASTER0_OPERATIONS_COUNT=$(call FILE_LINES,operations0.mem) \
+ -DMASTER1_OPERATIONS_COUNT=$(call FILE_LINES,operations1.mem)
+
+TOP = master_arbiter_test
+
+include ../../Makefile.test
diff --git a/tests/self/Makefile b/tests/self/Makefile
new file mode 100644
index 0000000..d408792
--- /dev/null
+++ b/tests/self/Makefile
@@ -0,0 +1,7 @@
+DEPENDS = operations.mem slave.v master.v messages.vh
+
+IVFLAGS = -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,operations.mem)
+
+TOP = self_test
+
+include ../../Makefile.test
diff --git a/tests/self_32bit_word/Makefile b/tests/self_32bit_word/Makefile
new file mode 100644
index 0000000..71c5f3e
--- /dev/null
+++ b/tests/self_32bit_word/Makefile
@@ -0,0 +1,7 @@
+DEPENDS = operations.mem slave.v master.v messages.vh
+
+IVFLAGS = -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,operations.mem)
+
+TOP = self_32bit_test
+
+include ../../Makefile.test
diff --git a/tests/slave_dispatcher/Makefile b/tests/slave_dispatcher/Makefile
new file mode 100644
index 0000000..72e68ca
--- /dev/null
+++ b/tests/slave_dispatcher/Makefile
@@ -0,0 +1,7 @@
+DEPENDS = operations.mem slave.v master.v slave_dispatcher.v messages.vh
+
+IVFLAGS = -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,operations.mem)
+
+TOP = slave_dispatcher_test
+
+include ../../Makefile.test
diff --git a/tests/soc_simple_display/Makefile b/tests/soc_simple_display/Makefile
new file mode 100644
index 0000000..4506ff7
--- /dev/null
+++ b/tests/soc_simple_display/Makefile
@@ -0,0 +1,9 @@
+VGA_TEST = 1
+
+DEPENDS = instructions.mem sram.v vga_display.v ../../design/*.v messages.vh
+
+IVFLAGS = -DROM_WORDS_COUNT=$(call FILE_LINES,instructions.mem)
+
+TOP = soc_test
+
+include ../../Makefile.test
diff --git a/tests/soc_simple_display/instructions.s.tcl b/tests/soc_simple_display/instructions.s.tcl
index 616c1bc..97e577e 100755..100644
--- a/tests/soc_simple_display/instructions.s.tcl
+++ b/tests/soc_simple_display/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
## also look at stack_machine_cond_jump test
## we're going to write numbers from 0 to 639 at addresses h100000 to h1009FC
diff --git a/tests/sram_slave/Makefile b/tests/sram_slave/Makefile
new file mode 100644
index 0000000..7619ccd
--- /dev/null
+++ b/tests/sram_slave/Makefile
@@ -0,0 +1,7 @@
+DEPENDS = operations.mem sram.v master.v sram_slave.v messages.vh
+
+IVFLAGS = -DMASTER_OPERATIONS_COUNT=$(call FILE_LINES,operations.mem)
+
+TOP = sram_slave_test
+
+include ../../Makefile.test
diff --git a/tests/stack_machine_add/Makefile b/tests/stack_machine_add/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_add/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_add/instructions.s.tcl b/tests/stack_machine_add/instructions.s.tcl
index c0a9449..0fe544e 100755..100644
--- a/tests/stack_machine_add/instructions.s.tcl
+++ b/tests/stack_machine_add/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### store 2 values to memory, load them back, add them and store the result
set_sp 0
diff --git a/tests/stack_machine_cond_jump/Makefile b/tests/stack_machine_cond_jump/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_cond_jump/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_cond_jump/instructions.s.tcl b/tests/stack_machine_cond_jump/instructions.s.tcl
index d1d5809..fba496d 100755..100644
--- a/tests/stack_machine_cond_jump/instructions.s.tcl
+++ b/tests/stack_machine_cond_jump/instructions.s.tcl
@@ -1,8 +1,4 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
-## also look at stack_machine_jump test
+## also look at stack_machine_jump test
## we're going to write numbers from 0 to 7 to addresses h400 - h41C
diff --git a/tests/stack_machine_div/Makefile b/tests/stack_machine_div/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_div/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_div/instructions.s.tcl b/tests/stack_machine_div/instructions.s.tcl
index 7f09f20..be233a2 100755..100644
--- a/tests/stack_machine_div/instructions.s.tcl
+++ b/tests/stack_machine_div/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### store 2 values to memory, load them back, divide one by another and store
### the result (quotient); this is analogous to addition and substraction tests
diff --git a/tests/stack_machine_jump/Makefile b/tests/stack_machine_jump/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_jump/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_jump/instructions.s.tcl b/tests/stack_machine_jump/instructions.s.tcl
index fe3b297..381f083 100755..100644
--- a/tests/stack_machine_jump/instructions.s.tcl
+++ b/tests/stack_machine_jump/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
## Let there be 2 pieces of code - each one storing a different value in memory
## and halting afterwards. Jump instruction should cause the second piece of
## code to execute instead of the first. We'll verify that by checking, which
diff --git a/tests/stack_machine_load_store/Makefile b/tests/stack_machine_load_store/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_load_store/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_load_store/instructions.s.tcl b/tests/stack_machine_load_store/instructions.s.tcl
index 4d6da2a..a28816f 100755..100644
--- a/tests/stack_machine_load_store/instructions.s.tcl
+++ b/tests/stack_machine_load_store/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### set stack to 0, store 4 numbers (h2B, h3B, h4B and h5B) at addresses
### h000002, h000012, h000022 and h000032 and load them back to stack (only 2
### will really get written to stack's memory, other 2 will remain in r0 and
diff --git a/tests/stack_machine_mul/Makefile b/tests/stack_machine_mul/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_mul/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_mul/instructions.s.tcl b/tests/stack_machine_mul/instructions.s.tcl
index fae5ec6..df8228e 100755..100644
--- a/tests/stack_machine_mul/instructions.s.tcl
+++ b/tests/stack_machine_mul/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### store 4 values to memory; load 2 of them back, multiply them and store the
### result; load another 2, multiply them and store the result;
### this is similar to addition and substraction tests
diff --git a/tests/stack_machine_multiinstructions_load_store/Makefile b/tests/stack_machine_multiinstructions_load_store/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_multiinstructions_load_store/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl b/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl
index bd16f8a..6710c0c 100755..100644
--- a/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl
+++ b/tests/stack_machine_multiinstructions_load_store/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### set stack to h1FFE00, store 4 numbers (h11223344, h55667788, h8899AABB and
### hCCDDEEFF) at addresses h00002E, h00003E, h00004E and h00005E and load them
### back to stack (only 2 will really get written to stack's memory, other 2
diff --git a/tests/stack_machine_store/Makefile b/tests/stack_machine_store/Makefile
new file mode 100644
index 0000000..e662a5f
--- /dev/null
+++ b/tests/stack_machine_store/Makefile
@@ -0,0 +1,10 @@
+DEPENDS = instructions.mem words_to_verify.mem slave.v stack_machine.v div.v \
+ messages.vh
+
+IVFLAGS = \
+ -DINSTRUCTIONS_COUNT=$(call FILE_LINES,instructions.mem) \
+ -DWORDS_TO_VERIFY_COUNT=$(call FILE_LINES,words_to_verify.mem)
+
+TOP = stack_machine_test
+
+include ../../Makefile.test
diff --git a/tests/stack_machine_store/instructions.s.tcl b/tests/stack_machine_store/instructions.s.tcl
index f35461d..662912c 100755..100644
--- a/tests/stack_machine_store/instructions.s.tcl
+++ b/tests/stack_machine_store/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### simple test - write value hDEADBEEF to address h3ABCD;
### then, write value h900DDEED to address FFBCE, but use operand addressing
### (i.e. with hFFBBD in im and h00011 in r0)
diff --git a/tests/stack_machine_sub/Makefile b/tests/stack_machine_sub/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_sub/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_sub/instructions.s.tcl b/tests/stack_machine_sub/instructions.s.tcl
index e8485ee..28076fd 100755..100644
--- a/tests/stack_machine_sub/instructions.s.tcl
+++ b/tests/stack_machine_sub/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### store 2 values to memory, load them back,
### substract them and store the result
diff --git a/tests/stack_machine_swap/Makefile b/tests/stack_machine_swap/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_swap/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_swap/instructions.s.tcl b/tests/stack_machine_swap/instructions.s.tcl
index a44ecf9..69e7744 100755..100644
--- a/tests/stack_machine_swap/instructions.s.tcl
+++ b/tests/stack_machine_swap/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
set_sp 0
const h0000DEAD
diff --git a/tests/stack_machine_tee/Makefile b/tests/stack_machine_tee/Makefile
new file mode 120000
index 0000000..2c3c770
--- /dev/null
+++ b/tests/stack_machine_tee/Makefile
@@ -0,0 +1 @@
+../stack_machine_store/Makefile \ No newline at end of file
diff --git a/tests/stack_machine_tee/instructions.s.tcl b/tests/stack_machine_tee/instructions.s.tcl
index 98117c7..f51940a 100755..100644
--- a/tests/stack_machine_tee/instructions.s.tcl
+++ b/tests/stack_machine_tee/instructions.s.tcl
@@ -1,7 +1,3 @@
-#!/usr/bin/env tclsh
-
-source tclasm.tcl
-
### All three stores should write the hABCDEF
set_sp 0
diff --git a/tests/vga/Makefile b/tests/vga/Makefile
new file mode 100644
index 0000000..bc2da7f
--- /dev/null
+++ b/tests/vga/Makefile
@@ -0,0 +1,9 @@
+VGA_TEST = 1
+
+DEPENDS = vga.v vga_display.v messages.vh
+
+IVFLAGS =
+
+TOP = vga_test
+
+include ../../Makefile.test
diff --git a/tests/wrapped_stack_machine_cond_jump/Makefile b/tests/wrapped_stack_machine_cond_jump/Makefile
new file mode 100644
index 0000000..e39252e
--- /dev/null
+++ b/tests/wrapped_stack_machine_cond_jump/Makefile
@@ -0,0 +1,10 @@
+DEPENDS = instructions.mem words_to_verify.mem slave.v wrapped_stack_machine.v \
+ interface_wrapper.v stack_machine.v div.v messages.vh
+
+IVFLAGS = \
+ -DINSTRUCTIONS_COUNT=$(call FILE_LINES,instructions.mem) \
+ -DWORDS_TO_VERIFY_COUNT=$(call FILE_LINES,words_to_verify.mem)
+
+TOP = wrapped_stack_machine_test
+
+include ../../Makefile.test