tb: add tests type macro

Signed-off-by: liangkangnan <liangkangnan@163.com>
pull/4/head
liangkangnan 2021-06-05 16:59:26 +08:00
parent d9a1f89fd2
commit b7b8572542
1 changed files with 47 additions and 23 deletions

View File

@ -14,6 +14,12 @@
limitations under the License.
*/
// 二选一,都不选时表示测试用户自定义程序
// tests/isa测试
//`define TEST_ISA 1
// tests/riscv-compliance测试
//`define TEST_RISCV_COMPLIANCE 1
module tb_top_verilator #(
) (
@ -23,9 +29,14 @@ module tb_top_verilator #(
wire halted;
wire[31:0] x3 = u_tinyriscv_soc_top.u_tinyriscv_core.u_gpr_reg.regs[3];
wire[31:0] x26 = u_tinyriscv_soc_top.u_tinyriscv_core.u_gpr_reg.regs[26];
wire[31:0] x27 = u_tinyriscv_soc_top.u_tinyriscv_core.u_gpr_reg.regs[27];
wire[31:0] end_flag = u_tinyriscv_soc_top.u_ram.u_gen_ram.ram[4];
wire[31:0] begin_signature = u_tinyriscv_soc_top.u_ram.u_gen_ram.ram[2];
wire[31:0] end_signature = u_tinyriscv_soc_top.u_ram.u_gen_ram.ram[3];
initial begin: load_prog
automatic logic [1023:0] firmware;
@ -38,6 +49,7 @@ module tb_top_verilator #(
end
end
integer r;
reg result_printed;
always @(posedge clk_i or negedge rst_ni) begin
@ -47,6 +59,14 @@ module tb_top_verilator #(
if (u_tinyriscv_soc_top.ndmreset) begin
result_printed <= 1'b0;
end else if (!result_printed) begin
`ifdef TEST_RISCV_COMPLIANCE
if (end_flag == 32'h1) begin
for (r = begin_signature; r < end_signature; r = r + 4) begin
$display("%x", u_tinyriscv_soc_top.u_rom.u_gen_ram.ram[r[31:2]]);
end
$finish;
end
`else
if (x26 == 32'b1) begin
if (x27 == 32'b1) begin
$display("~~~~~~~~~~~~~~~~~~~ TEST_PASS ~~~~~~~~~~~~~~~~~~~");
@ -68,9 +88,13 @@ module tb_top_verilator #(
$display("~~~~~~~~~~# # # # # ~~~~~~~~~~");
$display("~~~~~~~~~~# # # # ######~~~~~~~~~~");
$display("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
`ifdef TEST_ISA
$display("fail testnum = %2d", x3);
`endif
end
result_printed <= 1'b1;
end
`endif
end
end
end