aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/ppu-stm-integration-demo/data2test.awk15
-rw-r--r--test/ppu-stm-integration-demo/makefile8
2 files changed, 17 insertions, 6 deletions
diff --git a/test/ppu-stm-integration-demo/data2test.awk b/test/ppu-stm-integration-demo/data2test.awk
new file mode 100755
index 0000000..286a388
--- /dev/null
+++ b/test/ppu-stm-integration-demo/data2test.awk
@@ -0,0 +1,15 @@
+#!/bin/awk -f
+BEGIN {
+ print "#pragma once"
+ print "#include <stdint.h>"
+ printf("const uint8_t HH_PPUINTDEMO_ARR[] = { ")
+}
+
+length($1) == 4 && length($2) == 4 {
+ printf "0x"substr($1,1,2)", 0x"substr($1,3,2)", 0x"substr($2,1,2)", 0x"substr($2,3,2)", "
+}
+
+END {
+ printf("};\n") # close array
+ printf("#define HH_PPUINTDEMO_LENGTH %d\n", NR*4) # calculate array length
+}
diff --git a/test/ppu-stm-integration-demo/makefile b/test/ppu-stm-integration-demo/makefile
index 7d7a7c8..2f4b6f4 100644
--- a/test/ppu-stm-integration-demo/makefile
+++ b/test/ppu-stm-integration-demo/makefile
@@ -4,12 +4,8 @@ TARGETS := test-background-color.h test-image.h test-image.tb.vhd
all: $(TARGETS)
-%.h: %.txt
- echo "#pragma once" > $@
- echo "#include <stdint.h>" >> $@
- (printf "#define HH_PPUINTDEMO_LENGTH "; wc -l < $<) >> $@
- tr -d ':' < $< | awk 'BEGIN { printf "const uint16_t HH_PPUINTDEMO_ADDR[] = { " } 1 { printf "0x"$$1", " } END { print "};" }' >> $@
- tr -d ':' < $< | awk 'BEGIN { printf "const uint16_t HH_PPUINTDEMO_DATA[] = { " } 1 { printf "0x"$$2", " } END { print "};" }' >> $@
+%.h: %.txt ./data2test.awk
+ tr -d ':' < $< | ./data2test.awk > $@
test-%.tb.vhd: test-%.txt ./data2vhdltb.awk
tr -d ':' < $< | ./data2vhdltb.awk > $@