beepo/tests/adding/top.v
2023-11-21 06:08:22 -05:00

73 lines
1.9 KiB
Verilog

`include "../src/beepo.v"
`timescale 100us/10ns
`define assert(signal, value) \
if (signal !== value) begin \
$display("ASSERTION FAILED in %m: signal != value"); \
$finish; \
end
module tb_beepo();
localparam T_LI = 0;
localparam T_ADD = 1;
localparam T_ADDI = 2;
reg r_clk = 0;
reg r_resume = 0;
reg [1:0] r_test = 0;
wire w_breakpoint;
Beepo #(
.FREQ(1)
) bep (
.i_clk(r_clk),
.i_resume(r_resume),
.o_breakpoint(w_breakpoint)
);
localparam CLK_PERIOD = 1.0;
always #(CLK_PERIOD/2) r_clk=~r_clk;
initial begin
$dumpfile("adding/build/dump.vcd");
$dumpvars(0, tb_beepo,
bep.r_arg_regs[0], bep.r_arg_regs[1],
bep.r_arg_regs[2], bep.r_arg_regs[3],
bep.r_registers[1], bep.r_registers[3]
);
end
// should probably do more granular tests
always @(posedge w_breakpoint) begin
$display("BREAK");
case (r_test)
T_LI: begin
`assert(bep.r_registers[1], 64'h10);
`assert(bep.r_registers[2], 64'h1010);
`assert(bep.r_registers[3], 64'h10101010);
`assert(bep.r_registers[4], 64'h1010101010101010);
$display("[ADDING] LI tests passed");
end
T_ADD: begin
`assert(bep.r_registers[1], 64'h1010101020203050);
$display("[ADDING] ADD test passed");
end
T_ADDI: begin
`assert(bep.r_registers[1], 64'h2020202040406090);
$display("[ADDING] ADDI test passed");
$display("[ADDING] All tests passed");
$finish;
end
endcase
r_test <= r_test + 1;
r_resume = 1;
#2 r_resume = 0;
end
initial #100000 begin
$display("[ADDING] Timeout");
$finish;
end
endmodule