From 1b612a75e734084196deadb929dffc9181472b08 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Thu, 21 Jul 2022 13:00:09 -0400 Subject: [PATCH] autogenerate mode tests --- tests/Makefile | 6 +++-- tests/mode00.cpp | 3 --- tests/mode00.v | 34 ----------------------------- tests/mode01.cpp | 3 --- tests/mode01.v | 34 ----------------------------- tests/mode10.cpp | 3 --- tests/mode11.cpp | 3 --- tests/mode11.v | 34 ----------------------------- tests/mode_template.cpp | 3 +++ tests/{mode10.v => mode_template.v} | 8 +++---- tests/run_mode.makefile | 11 +++++----- 11 files changed, 16 insertions(+), 126 deletions(-) delete mode 100644 tests/mode00.cpp delete mode 100644 tests/mode00.v delete mode 100644 tests/mode01.cpp delete mode 100644 tests/mode01.v delete mode 100644 tests/mode10.cpp delete mode 100644 tests/mode11.cpp delete mode 100644 tests/mode11.v create mode 100644 tests/mode_template.cpp rename tests/{mode10.v => mode_template.v} (85%) diff --git a/tests/Makefile b/tests/Makefile index 3101b65..3148632 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,9 @@ +MODES=00 01 10 11 + all: - for i in 00 01 10 11; do \ + for i in ${MODES}; do \ make -f run_mode.makefile MODE="$$i"; \ done clean: - rm -rf obj_dir + rm -rf obj_dir mode[01][01]* diff --git a/tests/mode00.cpp b/tests/mode00.cpp deleted file mode 100644 index 4ba98dd..0000000 --- a/tests/mode00.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Vmode00.h" -using TopModule = Vmode00; -#include "write_read.cpp" diff --git a/tests/mode00.v b/tests/mode00.v deleted file mode 100644 index 2a037cf..0000000 --- a/tests/mode00.v +++ /dev/null @@ -1,34 +0,0 @@ -/* (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 mode00 ( - input clk, - input [23:0] data_ctrl, - input activate, - input ss, - input rdy, - output master_finished -); - -spi_write_read -#( - .POLARITY(0), - .PHASE(0) -) base ( - .clk(clk), - .data_ctrl(data_ctrl), - .activate(activate), - .master_finished(master_finished), - .ss(ss), - .rdy(rdy) -); - -initial begin - $dumpfile("mode00.vcd"); - $dumpvars(); -end - -endmodule diff --git a/tests/mode01.cpp b/tests/mode01.cpp deleted file mode 100644 index 4b5ea78..0000000 --- a/tests/mode01.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Vmode01.h" -using TopModule = Vmode01; -#include "write_read.cpp" diff --git a/tests/mode01.v b/tests/mode01.v deleted file mode 100644 index 4fb9e52..0000000 --- a/tests/mode01.v +++ /dev/null @@ -1,34 +0,0 @@ -/* (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 mode01 ( - input clk, - input [23:0] data_ctrl, - input activate, - input ss, - input rdy, - output master_finished -); - -spi_write_read -#( - .POLARITY(0), - .PHASE(1) -) base ( - .clk(clk), - .data_ctrl(data_ctrl), - .activate(activate), - .master_finished(master_finished), - .ss(ss), - .rdy(rdy) -); - -initial begin - $dumpfile("mode01.vcd"); - $dumpvars(); -end - -endmodule diff --git a/tests/mode10.cpp b/tests/mode10.cpp deleted file mode 100644 index 17350d5..0000000 --- a/tests/mode10.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Vmode10.h" -using TopModule = Vmode10; -#include "write_read.cpp" diff --git a/tests/mode11.cpp b/tests/mode11.cpp deleted file mode 100644 index 07c6bfe..0000000 --- a/tests/mode11.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Vmode11.h" -using TopModule = Vmode11; -#include "write_read.cpp" diff --git a/tests/mode11.v b/tests/mode11.v deleted file mode 100644 index 3621681..0000000 --- a/tests/mode11.v +++ /dev/null @@ -1,34 +0,0 @@ -/* (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 mode11 ( - input clk, - input [23:0] data_ctrl, - input activate, - input ss, - input rdy, - output master_finished -); - -spi_write_read -#( - .POLARITY(1), - .PHASE(1) -) base ( - .clk(clk), - .data_ctrl(data_ctrl), - .activate(activate), - .master_finished(master_finished), - .ss(ss), - .rdy(rdy) -); - -initial begin - $dumpfile("mode11.vcd"); - $dumpvars(); -end - -endmodule diff --git a/tests/mode_template.cpp b/tests/mode_template.cpp new file mode 100644 index 0000000..4b46fb4 --- /dev/null +++ b/tests/mode_template.cpp @@ -0,0 +1,3 @@ +#include "Vmode@MODE@.h" +using TopModule = Vmode@MODE@; +#include "write_read.cpp" diff --git a/tests/mode10.v b/tests/mode_template.v similarity index 85% rename from tests/mode10.v rename to tests/mode_template.v index 7405ae4..1df59b8 100644 --- a/tests/mode10.v +++ b/tests/mode_template.v @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -module mode10 ( +module mode@MODE@ ( input clk, input [23:0] data_ctrl, input activate, @@ -15,8 +15,8 @@ module mode10 ( spi_write_read #( - .POLARITY(1), - .PHASE(0) + .POLARITY(@POLARITY@), + .PHASE(@PHASE@) ) base ( .clk(clk), .data_ctrl(data_ctrl), @@ -27,7 +27,7 @@ spi_write_read ); initial begin - $dumpfile("mode10.vcd"); + $dumpfile("mode@MODE@.vcd"); $dumpvars(); end diff --git a/tests/run_mode.makefile b/tests/run_mode.makefile index b03da8e..96fd05f 100644 --- a/tests/run_mode.makefile +++ b/tests/run_mode.makefile @@ -11,15 +11,14 @@ WAVEFILE=${TESTBENCH_BASE}.vcd FILES=${TESTBENCH_BASE}.v ${AUXFILES} ${CPP_TESTBENCH} -all: obj_dir/V${TESTBENCH_BASE} +${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} obj_dir/V${TESTBENCH_BASE}: obj_dir/V${TESTBENCH_BASE}.mk make -C obj_dir -f V${TESTBENCH_BASE}.mk - -run: - ./obj_dir/V${TESTBENCH_CASE} -clean: - $(RM) obj_dir/* +${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 +${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