aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2022-07-21 13:51:55 -0400
committerGravatar Peter McGoron 2022-07-21 13:52:51 -0400
commit34bb170241e1c2643cc8b6f3d5a2fee59d1226f2 (patch)
treeeea9ee1ec48e60084eabcb2d31b2b29aedf6b07f /tests
parentautogenerate mode tests (diff)
add read only master with tests
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile3
-rw-r--r--tests/read_only_mode_template.cpp4
-rw-r--r--tests/read_only_mode_template.v57
-rw-r--r--tests/run_mode.makefile10
-rw-r--r--tests/write_read.cpp4
5 files changed, 72 insertions, 6 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 3148632..085cd92 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -3,7 +3,8 @@ MODES=00 01 10 11
all:
for i in ${MODES}; do \
make -f run_mode.makefile MODE="$$i"; \
+ make -f run_mode.makefile MODE="$$i" PREFIX="read_only_" MASTER_TYPE="_no_write" SLAVE_TYPE="_no_read"; \
done
clean:
- rm -rf obj_dir mode[01][01]*
+ rm -rf obj_dir mode[01][01]* read_only_mode[01][01]*
diff --git a/tests/read_only_mode_template.cpp b/tests/read_only_mode_template.cpp
new file mode 100644
index 0000000..d09a0be
--- /dev/null
+++ b/tests/read_only_mode_template.cpp
@@ -0,0 +1,4 @@
+#include "Vread_only_mode@MODE@.h"
+using TopModule = Vread_only_mode@MODE@;
+#define READ_ONLY
+#include "write_read.cpp"
diff --git a/tests/read_only_mode_template.v b/tests/read_only_mode_template.v
new file mode 100644
index 0000000..cd10c7d
--- /dev/null
+++ b/tests/read_only_mode_template.v
@@ -0,0 +1,57 @@
+/* (c) Peter McGoron 2022
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v.2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ */
+
+module read_only_mode@MODE@ (
+ input clk,
+ input activate,
+ input ss,
+ input rdy,
+ output master_finished
+);
+
+wire miso;
+wire sck;
+wire ss_L = !ss;
+reg [23:0] from_slave_data;
+reg finished;
+reg err;
+
+spi_master_no_write
+#(
+ .POLARITY(@POLARITY@),
+ .PHASE(@PHASE@)
+) master (
+ .clk(clk),
+ .from_slave(from_slave_data),
+ .miso(miso),
+ .sck_wire(sck),
+ .finished(master_finished),
+ .arm(activate)
+);
+
+reg [23:0] to_master = 24'hF4325F;
+
+spi_slave_no_read
+#(
+ .POLARITY(@POLARITY@),
+ .PHASE(@PHASE@)
+) slave (
+ .clk(clk),
+ .sck(sck),
+ .ss_L(ss_L),
+ .to_master(to_master),
+ .miso(miso),
+ .finished(finished),
+ .rdy(rdy),
+ .err(finished)
+);
+
+initial begin
+ $dumpfile("read_only_mode@MODE@.vcd");
+ $dumpvars();
+end
+
+endmodule
diff --git a/tests/run_mode.makefile b/tests/run_mode.makefile
index 96fd05f..2b48053 100644
--- a/tests/run_mode.makefile
+++ b/tests/run_mode.makefile
@@ -3,8 +3,8 @@
# License, v.2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-TESTBENCH_BASE=mode${MODE}
-AUXFILES=../spi_master.v ../spi_slave.v
+TESTBENCH_BASE=${PREFIX}mode${MODE}
+AUXFILES=../spi_master${MASTER_TYPE}.v ../spi_slave${SLAVE_TYPE}.v
CPP_TESTBENCH=${TESTBENCH_BASE}.cpp
WAVEFILE=${TESTBENCH_BASE}.vcd
@@ -15,10 +15,10 @@ ${WAVEFILE}: obj_dir/V${TESTBENCH_BASE}
./obj_dir/V${TESTBENCH_BASE}
obj_dir/V${TESTBENCH_BASE}.mk: ${FILES}
- verilator -CFLAGS -Wall -Wno-unused -Wpedantic --trace --cc --exe ${FILES} --top ${TESTBENCH_BASE}
+ verilator -I.. -Wall -Wno-unused -Wpedantic --trace --cc --exe ${FILES} --top ${TESTBENCH_BASE}
obj_dir/V${TESTBENCH_BASE}: obj_dir/V${TESTBENCH_BASE}.mk
make -C obj_dir -f V${TESTBENCH_BASE}.mk
${TESTBENCH_BASE}.v: mode_template.v
- sed "s/@PHASE@/`echo ${MODE} | cut -c 2`/g; s/@POLARITY@/`echo ${MODE} | cut -c 1`/g; s/@MODE@/${MODE}/g" mode_template.v > ${TESTBENCH_BASE}.v
+ sed "s/@PHASE@/`echo ${MODE} | cut -c 2`/g; s/@POLARITY@/`echo ${MODE} | cut -c 1`/g; s/@MODE@/${MODE}/g" ${PREFIX}mode_template.v > ${TESTBENCH_BASE}.v
${TESTBENCH_BASE}.cpp: mode_template.cpp
- sed "s/@PHASE@/`echo ${MODE} | cut -c 2`/g; s/@POLARITY@/`echo ${MODE} | cut -c 1`/g; s/@MODE@/${MODE}/g" mode_template.cpp > ${TESTBENCH_BASE}.cpp
+ sed "s/@PHASE@/`echo ${MODE} | cut -c 2`/g; s/@POLARITY@/`echo ${MODE} | cut -c 1`/g; s/@MODE@/${MODE}/g" ${PREFIX}mode_template.cpp > ${TESTBENCH_BASE}.cpp
diff --git a/tests/write_read.cpp b/tests/write_read.cpp
index 457180a..45bdc5a 100644
--- a/tests/write_read.cpp
+++ b/tests/write_read.cpp
@@ -30,7 +30,9 @@ int main(int argc, char **argv) {
sim->rdy = 1;
progress();
+#ifndef READ_ONLY
sim->data_ctrl = 0b110011011111001100011111;
+#endif
sim->activate = 1;
while (!sim->master_finished)
@@ -41,6 +43,7 @@ int main(int argc, char **argv) {
sim->rdy = 0;
progress_n(5);
+#ifndef READ_ONLY
sim->data_ctrl = 0xFE3456;
sim->activate = 1;
sim->ss = 1;
@@ -52,6 +55,7 @@ int main(int argc, char **argv) {
sim->ss = 0;
sim->rdy = 0;
progress_n(5);
+#endif
sim->final();
delete sim;