Files
lab-rv32i-asm-control-flow/tests/task01_branch_compare_tb.sv
T

23 lines
880 B
Systemverilog

module tb;
logic [31:0] lhs, rhs;
logic [2:0] funct3;
logic taken, illegal;
integer checks = 0;
string trace_file;
branch_compare dut (.*);
task automatic check(input logic [2:0] function_code, input logic expected);
funct3 = function_code; #1;
if (taken !== expected || illegal) $fatal(1, "FAIL f=%b taken=%b illegal=%b", function_code, taken, illegal);
checks += 1;
endtask
initial begin
if ($value$plusargs("trace=%s", trace_file)) begin $dumpfile(trace_file); $dumpvars(0, tb); end
lhs = 32'hffffffff; rhs = 1;
check(0,0); check(1,1); check(4,1); check(5,0); check(6,0); check(7,1);
funct3 = 2; #1;
if (!illegal || taken) $fatal(1, "FAIL illegal");
$display("PASS task01 conditions=%0d signed_lt=1 unsigned_lt=0 illegal=1", checks);
$finish;
end
endmodule