tb: Make trng selftesting

- Exit with the right error code
This commit is contained in:
Daniel Jobson 2024-11-21 15:28:20 +01:00
parent ac853c87ec
commit c637c745cc
No known key found for this signature in database
GPG Key ID: 3707A9DBF4BB8F1A

View File

@ -177,7 +177,7 @@ module tb_trng ();
// the word read will be available in the global variable // the word read will be available in the global variable
// read_data. // read_data.
//---------------------------------------------------------------- //----------------------------------------------------------------
task read_word(input [ 7 : 0] address, input [31 : 0] expected); task read_word(input [7 : 0] address, input [31 : 0] expected);
begin : read_word begin : read_word
reg [31 : 0] read_data; reg [31 : 0] read_data;
@ -221,6 +221,22 @@ module tb_trng ();
end end
endtask // test1 endtask // test1
//----------------------------------------------------------------
// exit_with_error_code()
//
// Exit with the right error code
//----------------------------------------------------------------
task exit_with_error_code;
begin
if (error_ctr == 0) begin
$finish(0);
end
else begin
$fatal(1);
end
end
endtask // exit_with_error_code
//---------------------------------------------------------------- //----------------------------------------------------------------
// trng_test // trng_test
@ -240,7 +256,7 @@ module tb_trng ();
$display(" -= Testbench for trng completed =-"); $display(" -= Testbench for trng completed =-");
$display(" =============================="); $display(" ==============================");
$display(""); $display("");
$finish; exit_with_error_code();
end // trng_test end // trng_test
endmodule // tb_trng endmodule // tb_trng