aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile77
-rwxr-xr-xscripts/gen-deps54
-rwxr-xr-xscripts/gen-report18
-rwxr-xr-xscripts/gen-rv64-fw23
-rw-r--r--scripts/makefile81
-rw-r--r--scripts/makefile.tests6
-rw-r--r--src/bfly/source.mk2
-rw-r--r--src/bus/source.mk2
-rw-r--r--src/cpu/riscv/source.mk2
-rw-r--r--src/main.c15
-rw-r--r--src/mem/source.mk2
-rw-r--r--src/mesh/source.mk2
-rw-r--r--src/source.mk3
-rw-r--r--src/torus3d/source.mk2
-rw-r--r--src/uart/source.mk2
-rw-r--r--tests/simple_fat_bfly/sim.c4
-rw-r--r--tests/simple_fat_bfly/source.mk25
-rw-r--r--tests/simple_ideal_alloc/source.mk12
-rw-r--r--tests/simple_ideal_noc/sim.c4
-rw-r--r--tests/simple_ideal_noc/source.mk25
-rw-r--r--tests/simple_mem/source.mk30
-rw-r--r--tests/simple_mesh1d/sim.c4
-rw-r--r--tests/simple_mesh1d/source.mk26
-rw-r--r--tests/simple_mesh2d/sim.c4
-rw-r--r--tests/simple_mesh2d/source.mk25
-rw-r--r--tests/simple_mesh3d/sim.c4
-rw-r--r--tests/simple_mesh3d/source.mk25
-rw-r--r--tests/simple_riscv64/source.mk11
-rw-r--r--tests/simple_torus3d/sim.c58
-rw-r--r--tests/simple_torus3d/source.mk25
-rw-r--r--tests/simple_uart/source.mk10
-rw-r--r--tests/starved_mesh/source.mk11
33 files changed, 338 insertions, 259 deletions
diff --git a/.gitignore b/.gitignore
index afd1562..393c2ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
deps.mk
docs/output
build
-gran
+reports
+libgran.a
!include/gran
pdf
diff --git a/Makefile b/Makefile
index cc02b8d..b8c9144 100644
--- a/Makefile
+++ b/Makefile
@@ -1,69 +1,64 @@
-DO != echo -n > deps.mk
+.PHONY: all
+all: setup
+ $(MAKE) -f scripts/makefile
-DEBUGFLAGS != [ $(RELEASE) ] && echo "-flto=auto -O2 -DNODEBUG" || echo "-O0 -g -DDEBUG"
-CFLAGS = -Wall -Wextra -g
-DEPFLAGS = -MT $@ -MMD -MP -MF $@.d
-LINTFLAGS = -fsyntax-only
-INCLUDEFLAGS = -Iinclude -Ideps/conts/include
-COMPILEFLAGS =
-LINKFLAGS =
+# this kicks all unrecognised targets to the client script.
+# note that trying to compile individual files, e.g.
+#
+# make kernel.elf
+#
+# will not work, you would need
+#
+# make -f scripts/makefile kernel.elf
+#
+# instead
+.DEFAULT: setup
+ $(MAKE) -f scripts/makefile $<
-all: gran
+.PHONY: analyze
+analyze: setup
+ CFLAGS="$$CFLAGS -fanalyzer" SKIP_ANALYZER='-fno-analyzer' $(MAKE)
-# default values
-CROSS_COMPILE ?=
+.PHONY: setup
+setup:
+ @echo -n > deps.mk
+ @./scripts/gen-deps -p GRAN -c COMPILE_GRAN -b gran "$(GRAN_SOURCES)"
-# common programs
-CC = gcc
-
-SOURCES :=
+CLEANUP := build reports deps.mk libgran.a
+CLEANUP_CMD :=
+GRAN_SOURCES :=
include src/source.mk
-COMPILE = $(CROSS_COMPILE)$(CC) $(DEBUGFLAGS)\
- $(CFLAGS) $(DEPFLAGS) $(COMPILEFLAGS) $(INCLUDEFLAGS)
-
-LINT = $(COMPILE) $(LINTFLAGS)
-
-OBJS != ./scripts/gen-deps --sources "$(SOURCES)"
-MAIN_OBJ != ./scripts/gen-deps --sources "$(MAIN_SRC)"
-
-include tests/source.mk
-include deps.mk
-
-.PHONY: lint
-lint: $(OBJS:.o=.o.l)
+.PHONY: check
+check: all
+ $(MAKE) -f scripts/makefile -k check CHECK=$(CHECK)
.PHONY: format
format:
- find src include tests -iname '*.[ch]' |\
- xargs -n 10 -P 0 uncrustify -c uncrustify.conf --no-backup -F -
+ find src include -iname '*.[ch]' |\
+ xargs uncrustify -c uncrustify.conf --no-backup -F -
.PHONY: license
license:
- find src include tests -iname '*.[ch]' |\
- xargs -n 10 -P 0 ./scripts/license
+ find src include -iname '*.[ch]' |\
+ xargs ./scripts/license
.PHONY: docs
docs:
find src include -iname '*.[ch]' |\
- xargs -n 10 -P 0 ./scripts/warn-undocumented
+ xargs ./scripts/warn-undocumented
doxygen docs/doxygen.conf
-.PHONY: check
-check: $(TEST_PROGS)
- ./tests/check.sh
-
-gran: $(MAIN_OBJ) $(OBJS)
- $(COMPILE) $(MAIN_OBJ) $(OBJS) -o $@
+RM = rm
.PHONY: clean
clean:
- $(RM) -r build gran deps.mk
+ $(RM) -rf $(CLEANUP)
.PHONY: clean_docs
clean_docs:
- $(RM) -r docs/output
+ $(RM) -rf docs/output
.PHONY: clean_all
clean_all: clean clean_docs
diff --git a/scripts/gen-deps b/scripts/gen-deps
index 0feed7e..1238a94 100755
--- a/scripts/gen-deps
+++ b/scripts/gen-deps
@@ -1,35 +1,37 @@
#!/bin/sh
-gencommon () {
- lint="build/${s%.*}${1}.l"
- dep="build/${s%.*}${1}.d"
- obj="build/${s%.*}${1}"
+PREFIX=
+COMPILE=COMPILE
+LINT=LINT
+BUILD=build
- echo "${dep}:" >> deps.mk
- echo "include ${dep}" >> deps.mk
- echo "${obj}: ${s}" >> deps.mk
-}
-
-genobjs () {
- gencommon ".o"
- echo "${obj}: ${s}" >> deps.mk
- echo " \$(COMPILE) -c $< -o \$@" >> deps.mk
-
- echo "${lint}: ${s}" >> deps.mk
- echo " \$(LINT) -c ${s} -o /dev/null" >> deps.mk
-}
+while getopts "p:c:b:l:" opt; do
+ case "$opt" in
+ p) PREFIX="$OPTARG"_;;
+ c) COMPILE="$OPTARG";;
+ l) LINT="$OPTARG";;
+ b) BUILD=build/"$OPTARG";;
+ *) echo "unrecognised option -$OPTARG" >&2; exit 1;;
+ esac
+done
-case "${1}" in
- --sources)
- func=genobjs
- ;;
-esac
+shift $((OPTIND - 1))
# create all subdirectories
-mkdir -p $(echo "${2}" | xargs dirname | uniq | sed 's|^|build/|g')
+mkdir -p $(echo "${@}" | tr ' ' '\n' | sed "s|[^/]*$||;s|^|${BUILD}/|" | uniq)
-for s in ${2}
+for s in ${@}
do
- ${func} ${suffix}
- echo ${obj}
+ obj="${BUILD}/${s%.*}.o"
+ lint="${obj}.l"
+ dep="${obj}.d"
+
+ echo "${PREFIX}OBJS += ${obj}" >> deps.mk
+ echo "${PREFIX}LINTS += ${lint}" >> deps.mk
+ echo "${dep}:" >> deps.mk
+ echo "-include ${dep}" >> deps.mk
+ echo "${obj}: ${s}" >> deps.mk
+ echo " \$(${COMPILE}) -c ${s} -o ${obj}" >> deps.mk
+ echo "${lint}: ${s}" >> deps.mk
+ echo " \$(${LINT}) -c ${s} -o /dev/null" >> deps.mk
done
diff --git a/scripts/gen-report b/scripts/gen-report
new file mode 100755
index 0000000..38e4a47
--- /dev/null
+++ b/scripts/gen-report
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+BUILD=build
+
+while getopts "d:" opt; do
+ case "$opt" in
+ d) BUILD="$OPTARG";;
+ *) echo "unregonised option -$OPTARG" >&2; exit 1;;
+ esac
+done
+
+shift $((OPTIND - 1))
+
+for p in "$@"; do
+ mkdir -p "reports/${p}"
+ timeout --foreground 30s valgrind -q --error-exitcode=1 \
+ "./${BUILD}/${p}" > "reports/${p}/log"
+done
diff --git a/scripts/gen-rv64-fw b/scripts/gen-rv64-fw
new file mode 100755
index 0000000..831071d
--- /dev/null
+++ b/scripts/gen-rv64-fw
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+BUILD=build
+NAME=
+
+while getopts "d:o:" opt; do
+ case "$opt" in
+ d) BUILD="$OPTARG";;
+ o) NAME="$OPTARG";;
+ *) echo "unrecognised option -$OPTARG" >&2; exit 1;
+ esac
+done
+
+shift $((OPTIND - 1))
+
+# might try to figure out how to support llvm as well in tests, but good enough
+# for now
+riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
+ -march=rv64i -mabi=lp64 -fno-delete-null-pointer-checks \
+ -o "${BUILD}/${NAME}.elf" "${@}"
+
+riscv64-unknown-elf-objcopy -Obinary "${BUILD}/${NAME}.elf" "${BUILD}/${NAME}.bin"
+xxd -i "${BUILD}/${NAME}.bin" > "${BUILD}/${NAME}"
diff --git a/scripts/makefile b/scripts/makefile
new file mode 100644
index 0000000..dc094fa
--- /dev/null
+++ b/scripts/makefile
@@ -0,0 +1,81 @@
+# this could be done better
+RELEASE ?= 0
+OPTFLAGS != [ "$(RELEASE)" != "0" ] \
+ && echo "-O2 -flto=auto" \
+ || echo "-O0"
+
+DEBUG ?= 1
+DEBUGFLAGS != [ "$(DEBUG)" != "0" ] \
+ && echo "-DDEBUG=1" \
+ || echo "-DNDEBUG=1"
+
+ASSERT ?= 1
+ASSERTFLAGS != [ "$(ASSERT)" != "0" ] \
+ && echo "-DASSERT=1" \
+ || echo
+
+DEP_FLAGS = -MT $@ -MMD -MP -MF $@.d
+LINT_FLAGS := -fsyntax-only
+PREPROCESS := -E
+
+LLVM ?= 0
+BUILD := build
+
+all: libgran.a
+
+# default values, overwrite if/when needed
+CROSS_COMPILE :=
+
+OBJCOPY != [ "$(LLVM)" != "0" ] \
+ && echo llvm-objcopy \
+ || echo $(CROSS_COMPILE)objcopy
+
+COMPILER != [ -n "$(CROSS_COMPILE)" ] \
+ && { \
+ [ "$(LLVM)" != "0" ] \
+ && echo clang --target="$(CROSS_COMPILE)" \
+ || echo $(CROSS_COMPILE)gcc \
+ ; \
+ } \
+ || echo $(CC)
+
+
+OBFLAGS := -g
+WARNFLAGS := -Wall -Wextra
+
+COMPILE_FLAGS := $(CFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(OBFLAGS) $(ASSERTFLAGS) \
+ $(DEBUGFLAGS)
+
+INCLUDE_FLAGS := -I include -I deps/conts/include
+
+LINT = $(COMPILER) \
+ $(COMPILE_FLAGS) $(LIN_TFLAGS) $(INCLUDE_FLAGS)
+
+UBSAN ?= 0
+SANITIZE_FLAGS != [ "$(UBSAN)" != "0" ] \
+ && echo -fsanitize=undefined \
+ || echo
+
+# don't use dep trick for tests
+COMPILE_TEST := $(COMPILER) $(COMPILE_FLAGS) \
+ $(INCLUDE_FLAGS) $(SANITIZE_FLAGS)
+
+# dep flags use delayed expansion trick so we can't use := here
+COMPILE_GRAN = $(COMPILER) $(COMPILE_FLAGS) \
+ $(DEP_FLAGS) $(INCLUDE_FLAGS) $(SANITIZE_FLAGS)
+
+TESTS != [ -n "$(CHECK)" ] && echo "$(CHECK)" || echo check
+
+-include deps.mk
+
+libgran.a: $(GRAN_OBJS)
+ $(AR) rcs $@ $(GRAN_OBJS)
+
+
+# might lint some common things twice
+.PHONY:
+lint: $(GRAN_LINTS)
+
+.PHONY: check
+check:
+ $(MAKE) -f scripts/makefile.tests -k $(TESTS) COMPILE_TEST="$(COMPILE_TEST)"
diff --git a/scripts/makefile.tests b/scripts/makefile.tests
new file mode 100644
index 0000000..600a819
--- /dev/null
+++ b/scripts/makefile.tests
@@ -0,0 +1,6 @@
+TESTS :=
+
+include tests/*/source.mk
+
+.PHONY: check
+check: $(TESTS)
diff --git a/src/bfly/source.mk b/src/bfly/source.mk
index f09a33d..2db4dd4 100644
--- a/src/bfly/source.mk
+++ b/src/bfly/source.mk
@@ -1 +1 @@
-SOURCES += src/bfly/fat_bfly.c
+GRAN_SOURCES += src/bfly/fat_bfly.c
diff --git a/src/bus/source.mk b/src/bus/source.mk
index e812785..1128fe4 100644
--- a/src/bus/source.mk
+++ b/src/bus/source.mk
@@ -1 +1 @@
-SOURCES += src/bus/simple_bus.c
+GRAN_SOURCES += src/bus/simple_bus.c
diff --git a/src/cpu/riscv/source.mk b/src/cpu/riscv/source.mk
index aa11801..57e0bf9 100644
--- a/src/cpu/riscv/source.mk
+++ b/src/cpu/riscv/source.mk
@@ -1 +1 @@
-SOURCES += src/cpu/riscv/simple_riscv64.c
+GRAN_SOURCES += src/cpu/riscv/simple_riscv64.c
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 5b7a45e..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: copyleft-next-0.3.1 */
-/* Copyright 2023 Kim Kuparinen < kimi.h.kuparinen@gmail.com > */
-
-/**
- * @file main.c
- *
- * Empty main file, fill up with your simulator if you'd like.
- * Although I really think gran should just be a library, why
- * haven't I done this that way?
- */
-
-int main(int argc, char **argv)
-{
-
-}
diff --git a/src/mem/source.mk b/src/mem/source.mk
index 264d8bc..6c4919e 100644
--- a/src/mem/source.mk
+++ b/src/mem/source.mk
@@ -1 +1 @@
-SOURCES += src/mem/simple_mem.c src/mem/ideal_alloc.c
+GRAN_SOURCES += src/mem/simple_mem.c src/mem/ideal_alloc.c
diff --git a/src/mesh/source.mk b/src/mesh/source.mk
index 23d6014..1b1c741 100644
--- a/src/mesh/source.mk
+++ b/src/mesh/source.mk
@@ -1 +1 @@
-SOURCES += src/mesh/node1d.c src/mesh/node2d.c src/mesh/node3d.c
+GRAN_SOURCES += src/mesh/node1d.c src/mesh/node2d.c src/mesh/node3d.c
diff --git a/src/source.mk b/src/source.mk
index 7ec3b9e..aa9c817 100644
--- a/src/source.mk
+++ b/src/source.mk
@@ -1,4 +1,3 @@
include src/*/source.mk
-SOURCES += src/root.c src/clock_domain.c src/ideal_noc.c src/common.c
-MAIN_SRC += src/main.c
+GRAN_SOURCES += src/root.c src/clock_domain.c src/ideal_noc.c src/common.c
diff --git a/src/torus3d/source.mk b/src/torus3d/source.mk
index 4770dad..30f8e87 100644
--- a/src/torus3d/source.mk
+++ b/src/torus3d/source.mk
@@ -1 +1 @@
-SOURCES += src/torus3d/node.c
+GRAN_SOURCES += src/torus3d/node.c
diff --git a/src/uart/source.mk b/src/uart/source.mk
index cdc0bc9..ae769f4 100644
--- a/src/uart/source.mk
+++ b/src/uart/source.mk
@@ -1 +1 @@
-SOURCES += src/uart/simple_uart.c
+GRAN_SOURCES += src/uart/simple_uart.c
diff --git a/tests/simple_fat_bfly/sim.c b/tests/simple_fat_bfly/sim.c
index 98aa359..1d5e2b8 100644
--- a/tests/simple_fat_bfly/sim.c
+++ b/tests/simple_fat_bfly/sim.c
@@ -23,8 +23,8 @@ static stat build_ideal_noc(struct clock_domain *clk, uint32_t x)
struct component *imem = create_simple_mem(4096);
init_simple_mem(imem, 0,
- build_tests_simple_fat_bfly_test_bin_len,
- build_tests_simple_fat_bfly_test_bin);
+ build_tests_simple_fat_bfly_test_inc_bin_len,
+ build_tests_simple_fat_bfly_test_inc_bin);
uint64_t rcv = fat_bfly_addr(i, 0);
struct component *rv64 = create_simple_riscv64(rcv, 0,
diff --git a/tests/simple_fat_bfly/source.mk b/tests/simple_fat_bfly/source.mk
index 9aae373..f8c357d 100644
--- a/tests/simple_fat_bfly/source.mk
+++ b/tests/simple_fat_bfly/source.mk
@@ -1,18 +1,11 @@
-FAT_BFLY_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_fat_bfly/sim.c"
-TEST_PROGS += build/tests/simple_fat_bfly/sim
+SIMPLE_BAT_FLY := tests/simple_fat_bfly
+SIMPLE_BAT_FLY_SIM := $(SIMPLE_BAT_FLY)/sim.c
-build/tests/simple_fat_bfly/test.inc: tests/simple_fat_bfly/test.c
- riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
- -march=rv64i -mabi=lp64 \
- -o build/tests/simple_fat_bfly/test \
- tests/simple_fat_bfly/test.c
- riscv64-unknown-elf-objcopy -Obinary \
- build/tests/simple_fat_bfly/test \
- build/tests/simple_fat_bfly/test.bin
- xxd -i build/tests/simple_fat_bfly/test.bin \
- > build/tests/simple_fat_bfly/test.inc
+TESTS += $(SIMPLE_BAT_FLY)/sim
-build/tests/simple_fat_bfly/sim.o: build/tests/simple_fat_bfly/test.inc
-
-build/tests/simple_fat_bfly/sim: $(FAT_BFLY_TEST_OBJ) $(OBJS)
- $(COMPILE) $(FAT_BFLY_TEST_OBJ) $(OBJS) -o $@
+.PHONY: $(SIMPLE_BAT_FLY)/sim
+$(SIMPLE_BAT_FLY)/sim: $(SIMPLE_BAT_FLY_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_BAT_FLY)
+ ./scripts/gen-rv64-fw -d build -o $(SIMPLE_BAT_FLY)/test.inc $(SIMPLE_BAT_FLY)/test.c
+ $(COMPILE_TEST) $(SIMPLE_BAT_FLY_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_ideal_alloc/source.mk b/tests/simple_ideal_alloc/source.mk
index f797cdd..450c866 100644
--- a/tests/simple_ideal_alloc/source.mk
+++ b/tests/simple_ideal_alloc/source.mk
@@ -1,7 +1,9 @@
-ALLOC_TB_OBJ != ./scripts/gen-deps --sources "tests/simple_ideal_alloc/testbench.c"
-IDEAL_ALLOC_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_ideal_alloc/sim.c"
+SIMPLE_IDEAL_ALLOC := tests/simple_ideal_alloc
+SIMPLE_IDEAL_ALLOC_SIM := $(SIMPLE_IDEAL_ALLOC)/testbench.c $(SIMPLE_IDEAL_ALLOC)/sim.c
-TEST_PROGS += build/tests/simple_ideal_alloc/sim
+TESTS += $(SIMPLE_IDEAL_ALLOC)/sim
-build/tests/simple_ideal_alloc/sim: $(ALLOC_TB_OBJ) $(IDEAL_ALLOC_TEST_OBJ) $(OBJS)
- $(COMPILE) $(ALLOC_TB_OBJ) $(IDEAL_ALLOC_TEST_OBJ) $(TEST_OBJS) $(OBJS) -o $@
+$(SIMPLE_IDEAL_ALLOC)/sim: $(SIMPLE_IDEAL_ALLOC_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_IDEAL_ALLOC)
+ $(COMPILE_TEST) $(SIMPLE_IDEAL_ALLOC_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_ideal_noc/sim.c b/tests/simple_ideal_noc/sim.c
index eb8f475..dd93375 100644
--- a/tests/simple_ideal_noc/sim.c
+++ b/tests/simple_ideal_noc/sim.c
@@ -24,8 +24,8 @@ static stat build_ideal_noc(struct clock_domain *clk, uint32_t x)
struct component *imem = create_simple_mem(4096);
init_simple_mem(imem, 0,
- build_tests_simple_ideal_noc_test_bin_len,
- build_tests_simple_ideal_noc_test_bin);
+ build_tests_simple_ideal_noc_test_inc_bin_len,
+ build_tests_simple_ideal_noc_test_inc_bin);
uint64_t rcv = ideal_noc_addr(i, 0);
struct component *rv64 = create_simple_riscv64(rcv, 0,
diff --git a/tests/simple_ideal_noc/source.mk b/tests/simple_ideal_noc/source.mk
index 2cf271b..d8c3f27 100644
--- a/tests/simple_ideal_noc/source.mk
+++ b/tests/simple_ideal_noc/source.mk
@@ -1,18 +1,11 @@
-IDEAL_NOC_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_ideal_noc/sim.c"
-TEST_PROGS += build/tests/simple_ideal_noc/sim
+SIMPLE_IDEAL_NOC := tests/simple_ideal_noc
+SIMPLE_IDEAL_NOC_SIM := $(SIMPLE_IDEAL_NOC)/sim.c
-build/tests/simple_ideal_noc/test.inc: tests/simple_ideal_noc/test.c
- riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
- -march=rv64i -mabi=lp64 \
- -o build/tests/simple_ideal_noc/test \
- tests/simple_ideal_noc/test.c
- riscv64-unknown-elf-objcopy -Obinary \
- build/tests/simple_ideal_noc/test \
- build/tests/simple_ideal_noc/test.bin
- xxd -i build/tests/simple_ideal_noc/test.bin \
- > build/tests/simple_ideal_noc/test.inc
+TESTS += $(SIMPLE_IDEAL_NOC)/sim
-build/tests/simple_ideal_noc/sim.o: build/tests/simple_ideal_noc/test.inc
-
-build/tests/simple_ideal_noc/sim: $(IDEAL_NOC_TEST_OBJ) $(OBJS)
- $(COMPILE) $(IDEAL_NOC_TEST_OBJ) $(OBJS) -o $@
+.PHONY: $(SIMPLE_IDEAL_NOC)/sim
+$(SIMPLE_IDEAL_NOC)/sim: $(SIMPLE_IDEAL_NOC_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_IDEAL_NOC)
+ ./scripts/gen-rv64-fw -d build -o $(SIMPLE_IDEAL_NOC)/test.inc $(SIMPLE_IDEAL_NOC)/test.c
+ $(COMPILE_TEST) $(SIMPLE_IDEAL_NOC_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_mem/source.mk b/tests/simple_mem/source.mk
index 3a65965..48cff7a 100644
--- a/tests/simple_mem/source.mk
+++ b/tests/simple_mem/source.mk
@@ -1,17 +1,21 @@
-TRAFFIC_OBJ != ./scripts/gen-deps --sources "tests/simple_mem/traffic_gen.c"
-NO_BUS_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_mem/no_bus.c"
-BUS_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_mem/bus.c"
-MANY_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_mem/many.c"
+SIMPLE_MEM := tests/simple_mem
+SIMPLE_MEM_NO_BUS := $(SIMPLE_MEM)/traffic_gen.c $(SIMPLE_MEM)/no_bus.c
+SIMPLE_MEM_BUS := $(SIMPLE_MEM)/traffic_gen.c $(SIMPLE_MEM)/bus.c
+SIMPLE_MEM_MANY := $(SIMPLE_MEM)/traffic_gen.c $(SIMPLE_MEM)/many.c
-TEST_PROGS += build/tests/simple_mem/no_bus \
- build/tests/simple_mem/bus \
- build/tests/simple_mem/many
+TESTS += $(SIMPLE_MEM)/no_bus $(SIMPLE_MEM)/bus $(SIMPLE_MEM)/many
-build/tests/simple_mem/no_bus: $(NO_BUS_TEST_OBJ) $(TRAFFIC_OBJ) $(OBJS)
- $(COMPILE) $(NO_BUS_TEST_OBJ) $(TRAFFIC_OBJ) $(OBJS) -o $@
+build/$(SIMPLE_MEM):
+ mkdir -p $@
-build/tests/simple_mem/bus: $(BUS_TEST_OBJ) $(TRAFFIC_OBJ) $(OBJS)
- $(COMPILE) $(BUS_TEST_OBJ) $(TRAFFIC_OBJ) $(OBJS) -o $@
+$(SIMPLE_MEM)/no_bus: build/$(SIMPLE_MEM) $(SIMPLE_MEM_NO_BUS) libgran.a
+ $(COMPILE_TEST) $(SIMPLE_MEM_NO_BUS) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
-build/tests/simple_mem/many: $(MANY_TEST_OBJ) $(TRAFFIC_OBJ) $(OBJS)
- $(COMPILE) $(MANY_TEST_OBJ) $(TRAFFIC_OBJ) $(OBJS) -o $@
+$(SIMPLE_MEM)/bus: build/$(SIMPLE_MEM) $(SIMPLE_MEM_BUS) libgran.a
+ $(COMPILE_TEST) $(SIMPLE_MEM_BUS) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
+
+$(SIMPLE_MEM)/many: build/$(SIMPLE_MEM) $(SIMPLE_MEM_MANY) libgran.a
+ $(COMPILE_TEST) $(SIMPLE_MEM_MANY) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_mesh1d/sim.c b/tests/simple_mesh1d/sim.c
index 7479a27..48197a1 100644
--- a/tests/simple_mesh1d/sim.c
+++ b/tests/simple_mesh1d/sim.c
@@ -22,8 +22,8 @@ static stat build_node1d(struct clock_domain *clk, uint16_t x, uint16_t y)
for (int j = 0; j < y; ++j) {
struct component *imem = create_simple_mem(4096);
init_simple_mem(imem, 0,
- build_tests_simple_mesh1d_test_bin_len,
- build_tests_simple_mesh1d_test_bin);
+ build_tests_simple_mesh1d_test_inc_bin_len,
+ build_tests_simple_mesh1d_test_inc_bin);
uint64_t rcv = mesh1d_addr(i, j, 0);
struct component *rv64 = create_simple_riscv64(rcv, 0,
diff --git a/tests/simple_mesh1d/source.mk b/tests/simple_mesh1d/source.mk
index 5013c6e..f2792c9 100644
--- a/tests/simple_mesh1d/source.mk
+++ b/tests/simple_mesh1d/source.mk
@@ -1,19 +1,11 @@
-MESH1D_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_mesh1d/sim.c"
-TEST_PROGS += build/tests/simple_mesh1d/sim
+SIMPLE_MESH1D := tests/simple_mesh1d
+SIMPLE_MESH1D_SIM := $(SIMPLE_MESH1D)/sim.c
-build/tests/simple_mesh1d/test.inc: tests/simple_mesh1d/test.c
- riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
- -march=rv64i -mabi=lp64 \
- -fno-delete-null-pointer-checks \
- -o build/tests/simple_mesh1d/test \
- tests/simple_mesh1d/test.c
- riscv64-unknown-elf-objcopy -Obinary \
- build/tests/simple_mesh1d/test \
- build/tests/simple_mesh1d/test.bin
- xxd -i build/tests/simple_mesh1d/test.bin \
- > build/tests/simple_mesh1d/test.inc
+TESTS += $(SIMPLE_MESH1D)/sim
-build/tests/simple_mesh1d/sim.o: build/tests/simple_mesh1d/test.inc
-
-build/tests/simple_mesh1d/sim: $(MESH1D_TEST_OBJ) $(OBJS)
- $(COMPILE) $(MESH1D_TEST_OBJ) $(OBJS) -o $@
+.PHONY: $(SIMPLE_MESH1D)/sim
+$(SIMPLE_MESH1D)/sim: $(SIMPLE_MESH1D_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_MESH1D)
+ ./scripts/gen-rv64-fw -d build -o $(SIMPLE_MESH1D)/test.inc $(SIMPLE_MESH1D)/test.c
+ $(COMPILE_TEST) $(SIMPLE_MESH1D_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_mesh2d/sim.c b/tests/simple_mesh2d/sim.c
index cbce9f3..f3e213d 100644
--- a/tests/simple_mesh2d/sim.c
+++ b/tests/simple_mesh2d/sim.c
@@ -73,8 +73,8 @@ static stat build_mesh(struct clock_domain *clk, uint16_t x, uint16_t y)
struct component *imem = create_simple_mem(4096);
init_simple_mem(imem, 0,
- build_tests_simple_mesh2d_test_bin_len,
- build_tests_simple_mesh2d_test_bin);
+ build_tests_simple_mesh2d_test_inc_bin_len,
+ build_tests_simple_mesh2d_test_inc_bin);
uint64_t rcv = mesh2d_addr(i, j, 0, 0);
struct component *rv64 = create_simple_riscv64(rcv, 0,
diff --git a/tests/simple_mesh2d/source.mk b/tests/simple_mesh2d/source.mk
index 525efa3..af80ab1 100644
--- a/tests/simple_mesh2d/source.mk
+++ b/tests/simple_mesh2d/source.mk
@@ -1,18 +1,11 @@
-MESH2D_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_mesh2d/sim.c"
-TEST_PROGS += build/tests/simple_mesh2d/sim
+SIMPLE_MESH2D := tests/simple_mesh2d
+SIMPLE_MESH2D_SIM := $(SIMPLE_MESH2D)/sim.c
-build/tests/simple_mesh2d/test.inc: tests/simple_mesh2d/test.c
- riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
- -march=rv64i -mabi=lp64 \
- -o build/tests/simple_mesh2d/test \
- tests/simple_mesh2d/test.c
- riscv64-unknown-elf-objcopy -Obinary \
- build/tests/simple_mesh2d/test \
- build/tests/simple_mesh2d/test.bin
- xxd -i build/tests/simple_mesh2d/test.bin \
- > build/tests/simple_mesh2d/test.inc
+TESTS += $(SIMPLE_MESH2D)/sim
-build/tests/simple_mesh2d/sim.o: build/tests/simple_mesh2d/test.inc
-
-build/tests/simple_mesh2d/sim: $(MESH2D_TEST_OBJ) $(OBJS)
- $(COMPILE) $(MESH2D_TEST_OBJ) $(OBJS) -o $@
+.PHONY: $(SIMPLE_MESH2D)/sim
+$(SIMPLE_MESH2D)/sim: $(SIMPLE_MESH2D_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_MESH2D)
+ ./scripts/gen-rv64-fw -d build -o $(SIMPLE_MESH2D)/test.inc $(SIMPLE_MESH2D)/test.c
+ $(COMPILE_TEST) $(SIMPLE_MESH2D_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_mesh3d/sim.c b/tests/simple_mesh3d/sim.c
index f1663ef..768e9ef 100644
--- a/tests/simple_mesh3d/sim.c
+++ b/tests/simple_mesh3d/sim.c
@@ -82,8 +82,8 @@ static stat build_mesh3d(struct clock_domain *clk, uint8_t x, uint8_t y,
struct component *imem =
create_simple_mem(4096);
init_simple_mem(imem, 0,
- build_tests_simple_mesh3d_test_bin_len,
- build_tests_simple_mesh3d_test_bin);
+ build_tests_simple_mesh3d_test_inc_bin_len,
+ build_tests_simple_mesh3d_test_inc_bin);
uint64_t rcv = mesh3d_addr(i, j, k, 0, 0);
struct component *rv64 = create_simple_riscv64(rcv, 0,
diff --git a/tests/simple_mesh3d/source.mk b/tests/simple_mesh3d/source.mk
index 30aea2c..36c2556 100644
--- a/tests/simple_mesh3d/source.mk
+++ b/tests/simple_mesh3d/source.mk
@@ -1,18 +1,11 @@
-MESH3D_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_mesh3d/sim.c"
-TEST_PROGS += build/tests/simple_mesh3d/sim
+SIMPLE_MESH3D := tests/simple_mesh3d
+SIMPLE_MESH3D_SIM := $(SIMPLE_MESH3D)/sim.c
-build/tests/simple_mesh3d/test.inc: tests/simple_mesh3d/test.c
- riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
- -march=rv64i -mabi=lp64 \
- -o build/tests/simple_mesh3d/test \
- tests/simple_mesh3d/test.c
- riscv64-unknown-elf-objcopy -Obinary \
- build/tests/simple_mesh3d/test \
- build/tests/simple_mesh3d/test.bin
- xxd -i build/tests/simple_mesh3d/test.bin \
- > build/tests/simple_mesh3d/test.inc
+TESTS += $(SIMPLE_MESH3D)/sim
-build/tests/simple_mesh3d/sim.o: build/tests/simple_mesh3d/test.inc
-
-build/tests/simple_mesh3d/sim: $(MESH3D_TEST_OBJ) $(OBJS)
- $(COMPILE) $(MESH3D_TEST_OBJ) $(OBJS) -o $@
+.PHONY: $(SIMPLE_MESH3D)/sim
+$(SIMPLE_MESH3D)/sim: $(SIMPLE_MESH3D_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_MESH3D)
+ ./scripts/gen-rv64-fw -d build -o $(SIMPLE_MESH3D)/test.inc $(SIMPLE_MESH3D)/test.c
+ $(COMPILE_TEST) $(SIMPLE_MESH3D_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_riscv64/source.mk b/tests/simple_riscv64/source.mk
index fbc541d..e61d511 100644
--- a/tests/simple_riscv64/source.mk
+++ b/tests/simple_riscv64/source.mk
@@ -1,6 +1,9 @@
-RV64_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_riscv64/sim.c"
+SIMPLE_RV64 := tests/simple_riscv64
+SIMPLE_RV64_SIM := $(SIMPLE_RV64)/sim.c
-TEST_PROGS += build/tests/simple_riscv64/sim
+TESTS += $(SIMPLE_RV64)/sim
-build/tests/simple_riscv64/sim: $(RV64_TEST_OBJ) $(TEST_OBJS) $(OBJS)
- $(COMPILE) $(RV64_TEST_OBJ) $(TEST_OBJS) $(OBJS) -o $@
+$(SIMPLE_RV64)/sim: $(SIMPLE_RV64_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_RV64)
+ $(COMPILE_TEST) $(SIMPLE_RV64_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_torus3d/sim.c b/tests/simple_torus3d/sim.c
index c996c42..c53eed6 100644
--- a/tests/simple_torus3d/sim.c
+++ b/tests/simple_torus3d/sim.c
@@ -41,42 +41,40 @@ static stat build_torus3d(struct clock_domain *clk, uint8_t x, uint8_t y,
assert(pes);
for (size_t i = 0; i < x; ++i)
- for (size_t j = 0; j < y; ++j)
- for (size_t k = 0; k < z; ++k) {
- struct component *node = create_torus3d_node(i,
- j,
- k);
- clock_domain_add(clk, node);
- grid[idx_1d(i, j, k, x, y, z)] = node;
+ for (size_t j = 0; j < y; ++j)
+ for (size_t k = 0; k < z; ++k) {
+ struct component *node = create_torus3d_node(i, j, k);
+ clock_domain_add(clk, node);
+ grid[idx_1d(i, j, k, x, y, z)] = node;
- if (i == 0 && j == 0 && k == 0)
- continue;
+ if (i == 0 && j == 0 && k == 0)
+ continue;
- if (i == 0 && j == 0 && k == 1)
- continue;
+ if (i == 0 && j == 0 && k == 1)
+ continue;
- struct component *imem =
- create_simple_mem(4096);
- init_simple_mem(imem, 0,
- build_tests_simple_torus3d_test_bin_len,
- build_tests_simple_torus3d_test_bin);
+ struct component *imem =
+ create_simple_mem(4096);
+ init_simple_mem(imem, 0,
+ build_tests_simple_torus3d_test_inc_bin_len,
+ build_tests_simple_torus3d_test_inc_bin);
- uint64_t rcv = torus3d_addr(i, j, k, 0);
- struct component *rv64 =
- create_simple_riscv64(rcv, 0, imem,
- node);
- simple_riscv64_set_reg(rv64, 10, i); /* a0 */
- simple_riscv64_set_reg(rv64, 11, j); /* a1 */
- simple_riscv64_set_reg(rv64, 12, k); /* a2 */
- simple_riscv64_set_reg(rv64, 13, x); /* a3 */
- simple_riscv64_set_reg(rv64, 14, y); /* a4 */
- simple_riscv64_set_reg(rv64, 15, z); /* a5 */
+ uint64_t rcv = torus3d_addr(i, j, k, 0);
+ struct component *rv64 =
+ create_simple_riscv64(rcv, 0, imem,
+ node);
+ simple_riscv64_set_reg(rv64, 10, i); /* a0 */
+ simple_riscv64_set_reg(rv64, 11, j); /* a1 */
+ simple_riscv64_set_reg(rv64, 12, k); /* a2 */
+ simple_riscv64_set_reg(rv64, 13, x); /* a3 */
+ simple_riscv64_set_reg(rv64, 14, y); /* a4 */
+ simple_riscv64_set_reg(rv64, 15, z); /* a5 */
- clock_domain_add(clk, rv64);
- clock_domain_add(clk, imem);
+ clock_domain_add(clk, rv64);
+ clock_domain_add(clk, imem);
- pes[idx_1d(i, j, k, x, y, z)] = rv64;
- }
+ pes[idx_1d(i, j, k, x, y, z)] = rv64;
+ }
struct component *uart = create_simple_uart();
clock_domain_add(clk, uart);
diff --git a/tests/simple_torus3d/source.mk b/tests/simple_torus3d/source.mk
index e045a3c..d376d05 100644
--- a/tests/simple_torus3d/source.mk
+++ b/tests/simple_torus3d/source.mk
@@ -1,18 +1,11 @@
-TORUS3D_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_torus3d/sim.c"
-TEST_PROGS += build/tests/simple_torus3d/sim
+SIMPLE_TORUS3D := tests/simple_torus3d
+SIMPLE_TORUS3D_SIM := $(SIMPLE_TORUS3D)/sim.c
-build/tests/simple_torus3d/test.inc: tests/simple_torus3d/test.c
- riscv64-unknown-elf-gcc -O2 -Wall -Wextra -ffreestanding -nostdlib \
- -march=rv64i -mabi=lp64 \
- -o build/tests/simple_torus3d/test \
- tests/simple_torus3d/test.c
- riscv64-unknown-elf-objcopy -Obinary \
- build/tests/simple_torus3d/test \
- build/tests/simple_torus3d/test.bin
- xxd -i build/tests/simple_torus3d/test.bin \
- > build/tests/simple_torus3d/test.inc
+TESTS += $(SIMPLE_TORUS3D)/sim
-build/tests/simple_torus3d/sim.o: build/tests/simple_torus3d/test.inc
-
-build/tests/simple_torus3d/sim: $(TORUS3D_TEST_OBJ) $(OBJS)
- $(COMPILE) $(TORUS3D_TEST_OBJ) $(OBJS) -o $@
+.PHONY: $(SIMPLE_TORUS3D)/sim
+$(SIMPLE_TORUS3D)/sim: $(SIMPLE_TORUS3D_SIM) libgran.a
+ mkdir -p build/$(SIMPLE_TORUS3D)
+ ./scripts/gen-rv64-fw -d build -o $(SIMPLE_TORUS3D)/test.inc $(SIMPLE_TORUS3D)/test.c
+ $(COMPILE_TEST) $(SIMPLE_TORUS3D_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/simple_uart/source.mk b/tests/simple_uart/source.mk
index a42a447..70f26a7 100644
--- a/tests/simple_uart/source.mk
+++ b/tests/simple_uart/source.mk
@@ -1,6 +1,8 @@
-UART_TEST_OBJ != ./scripts/gen-deps --sources "tests/simple_uart/sim.c"
+SIMPLE_UART := tests/simple_uart
+SIMPLE_UART_SIM := $(SIMPLE_UART)/sim.c
-TEST_PROGS += build/tests/simple_uart/sim
+TEST += $(SIMPLE_UART)/sim
-build/tests/simple_uart/sim: $(UART_TEST_OBJ) $(OBJS)
- $(COMPILE) $(UART_TEST_OBJ) $(TEST_OBJS) $(OBJS) -o $@
+$(SIMPLE_UART)/sim: $(SIMPLE_UART_SIM) libgran.a
+ $(COMPILE_TEST) $(SIMPLE_UART_SIM) libran.a -o build/$@
+ ./scripts/gen-report -d build $@
diff --git a/tests/starved_mesh/source.mk b/tests/starved_mesh/source.mk
index 2d3a6e8..0874aa5 100644
--- a/tests/starved_mesh/source.mk
+++ b/tests/starved_mesh/source.mk
@@ -1,6 +1,9 @@
-STARVED_TEST_OBJ != ./scripts/gen-deps --sources "tests/starved_mesh/sim.c"
+STARVED_MESH := tests/starved_mesh
+STARVED_MESH_SIM := $(STARVED_MESH)/sim.c
-TEST_PROGS += build/tests/starved_mesh/sim
+TESTS += $(STARVED_MESH)/sim
-build/tests/starved_mesh/sim: $(STARVED_TEST_OBJ) $(OBJS)
- $(COMPILE) $(STARVED_TEST_OBJ) $(OBJS) -o $@
+$(STARVED_MESH)/sim: $(STARVED_MESH_SIM) libgran.a
+ mkdir -p build/$(STARVED_MESH)
+ $(COMPILE_TEST) $(STARVED_MESH_SIM) libgran.a -o build/$@
+ ./scripts/gen-report -d build $@