summaryrefslogtreecommitdiff
path: root/tb
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-02-16 22:36:57 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2025-02-16 22:36:57 +0200
commit373edb42380875eafc8b9de54d80b939d263d041 (patch)
tree8edf513e9052b9b4b514fc28d118abf9eb823586 /tb
parent82dec45fd786831f791b17b84aedb4d99b5ca25d (diff)
downloadttarv32-373edb42380875eafc8b9de54d80b939d263d041.tar.gz
ttarv32-373edb42380875eafc8b9de54d80b939d263d041.zip
add some kind of toplevelHEADmaster
Diffstat (limited to 'tb')
-rw-r--r--tb/Makefile10
-rw-r--r--tb/ttarv32_tb.sv45
2 files changed, 54 insertions, 1 deletions
diff --git a/tb/Makefile b/tb/Makefile
index a76747f..f34cb5e 100644
--- a/tb/Makefile
+++ b/tb/Makefile
@@ -1,4 +1,4 @@
-all: rv2insn sched
+all: rv2insn sched ttarv32
.PHONY: sched
sched: sched_tb.sv ../src/sched.sv ../src/common.svh
@@ -12,3 +12,11 @@ rv2insn: rv2insn_tb.sv ../src/rv2insn.sv ../src/common.svh
riscv32-unknown-elf-objcopy -O verilog rv2insn rv2insn.hex
verilator --Mdir rv2insn_objdir --assert --trace --binary -I../src rv2insn_tb.sv
./rv2insn_objdir/Vrv2insn_tb
+
+.PHONY: ttarv32
+ttarv32: ttarv32_tb.sv ../src/ttarv32.sv ../src/rv2insn.sv ../src/sched.sv ../src/common.svh
+ riscv32-unknown-elf-gcc -ffreestanding -nostdlib -march=rv32i -mabi=ilp32 \
+ -Wl,-Ttext=0 data/rv2insn.S -o ttarv32
+ riscv32-unknown-elf-objcopy -O verilog rv2insn ttarv32.hex
+ verilator --Mdir ttarv32_objdir --assert --trace --binary -I../src ttarv32_tb.sv
+ ./ttarv32_objdir/Vttarv32_tb
diff --git a/tb/ttarv32_tb.sv b/tb/ttarv32_tb.sv
new file mode 100644
index 0000000..6277f02
--- /dev/null
+++ b/tb/ttarv32_tb.sv
@@ -0,0 +1,45 @@
+`include "common.svh"
+
+module ttarv32_tb;
+
+function automatic rv_t[3:0] unp2p(logic[7:0] in[4*4]);
+ logic [15:0][7:0] conversion;
+ for (int i = 0; i < 4 * 4; ++i) begin
+ conversion[i] = in[i];
+ end
+ return conversion;
+endfunction
+
+xlen_t pc;
+logic[7:0] rv[4*4];
+
+logic clk;
+logic rst_n;
+
+ttarv32 #(
+ .SLOT_COUNT(4),
+ .SLOT_DEPTH(3),
+ .ALU_COUNT(2)
+) ttarv32 (
+ .clk_i(clk),
+ .rst_ni(rst_n),
+ .rv_i(unp2p(rv)),
+ .pc_o(pc)
+);
+
+initial begin
+ $dumpfile("ttarv32_tb.vcd");
+ $dumpvars();
+ $readmemh("ttarv32.hex", rv);
+
+ clk = 0;
+ rst_n = 0;
+
+ #10 rst_n = 1;
+ clk = 1;
+
+ #10
+ $finish;
+end
+
+endmodule