2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-08-16 07:03:03 +02:00
|
|
|
|
2016-09-22 03:28:30 +02:00
|
|
|
`ifndef RESET_DELAY
|
|
|
|
`define RESET_DELAY 777.7
|
|
|
|
`endif
|
|
|
|
|
2016-08-16 07:03:03 +02:00
|
|
|
module TestDriver;
|
|
|
|
|
2016-09-22 01:16:47 +02:00
|
|
|
reg clock = 1'b0;
|
2016-08-16 07:03:03 +02:00
|
|
|
reg reset = 1'b1;
|
|
|
|
|
2016-09-22 05:02:01 +02:00
|
|
|
always #(`CLOCK_PERIOD/2.0) clock = ~clock;
|
2016-09-22 03:28:30 +02:00
|
|
|
initial #(`RESET_DELAY) reset = 0;
|
2016-08-16 07:03:03 +02:00
|
|
|
|
|
|
|
// Read input arguments and initialize
|
|
|
|
reg verbose = 1'b0;
|
|
|
|
wire printf_cond = verbose && !reset;
|
|
|
|
reg [63:0] max_cycles = 0;
|
2017-03-31 20:37:37 +02:00
|
|
|
reg [63:0] dump_start = 0;
|
2016-08-16 07:03:03 +02:00
|
|
|
reg [63:0] trace_count = 0;
|
2018-01-09 18:54:34 +01:00
|
|
|
reg [1023:0] fsdbfile = 0;
|
2016-08-16 07:03:03 +02:00
|
|
|
reg [1023:0] vcdplusfile = 0;
|
|
|
|
reg [1023:0] vcdfile = 0;
|
2016-10-04 01:57:23 +02:00
|
|
|
int unsigned rand_value;
|
2016-08-16 07:03:03 +02:00
|
|
|
initial
|
|
|
|
begin
|
2016-10-18 00:44:24 +02:00
|
|
|
void'($value$plusargs("max-cycles=%d", max_cycles));
|
2017-03-31 20:37:37 +02:00
|
|
|
void'($value$plusargs("dump-start=%d", dump_start));
|
2016-08-16 07:03:03 +02:00
|
|
|
verbose = $test$plusargs("verbose");
|
2016-10-04 01:57:23 +02:00
|
|
|
|
2016-10-19 22:18:17 +02:00
|
|
|
// do not delete the lines below.
|
2016-10-04 01:57:23 +02:00
|
|
|
// $random function needs to be called with the seed once to affect all
|
|
|
|
// the downstream $random functions within the Chisel-generated Verilog
|
|
|
|
// code.
|
|
|
|
// $urandom is seeded via cmdline (+ntb_random_seed in VCS) but that
|
|
|
|
// doesn't seed $random.
|
2016-10-19 22:18:17 +02:00
|
|
|
rand_value = $urandom;
|
|
|
|
rand_value = $random(rand_value);
|
2016-10-04 01:57:23 +02:00
|
|
|
if (verbose) begin
|
2016-10-24 21:36:29 +02:00
|
|
|
`ifdef VCS
|
|
|
|
$fdisplay(stderr, "testing $random %0x seed %d", rand_value, unsigned'($get_initial_random_seed));
|
|
|
|
`else
|
2016-10-04 01:57:23 +02:00
|
|
|
$fdisplay(stderr, "testing $random %0x", rand_value);
|
2016-10-24 21:36:29 +02:00
|
|
|
`endif
|
2016-10-04 01:57:23 +02:00
|
|
|
end
|
|
|
|
|
2016-08-16 07:03:03 +02:00
|
|
|
`ifdef DEBUG
|
Fix Cadence Incisive compile errors; VCD-Plus is a VCS-only format
This fixes the following compile warnings and simulation errors:
Compile-time warnings:
$vcdplusfile(vcdplusfile);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): Unrecognized system task or function: $vcdplusfile (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdpluson(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): Unrecognized system task or function: $vcdpluson (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdplusmemon(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): Unrecognized system task or function: $vcdplusmemon (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
`VCDPLUSCLOSE
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): Unrecognized system task or function: $vcdplusclose (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
Which then become simulation-time errors:
$vcdplusfile(vcdplusfile);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): User Defined system task or function ($vcdplusfile) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdpluson(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): User Defined system task or function ($vcdpluson) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdplusmemon(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): User Defined system task or function ($vcdplusmemon) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,97|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
2016-10-19 22:11:18 +02:00
|
|
|
|
2016-08-16 07:03:03 +02:00
|
|
|
if ($value$plusargs("vcdplusfile=%s", vcdplusfile))
|
|
|
|
begin
|
Fix Cadence Incisive compile errors; VCD-Plus is a VCS-only format
This fixes the following compile warnings and simulation errors:
Compile-time warnings:
$vcdplusfile(vcdplusfile);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): Unrecognized system task or function: $vcdplusfile (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdpluson(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): Unrecognized system task or function: $vcdpluson (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdplusmemon(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): Unrecognized system task or function: $vcdplusmemon (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
`VCDPLUSCLOSE
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): Unrecognized system task or function: $vcdplusclose (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
Which then become simulation-time errors:
$vcdplusfile(vcdplusfile);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): User Defined system task or function ($vcdplusfile) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdpluson(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): User Defined system task or function ($vcdpluson) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdplusmemon(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): User Defined system task or function ($vcdplusmemon) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,97|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
2016-10-19 22:11:18 +02:00
|
|
|
`ifdef VCS
|
2016-08-16 07:03:03 +02:00
|
|
|
$vcdplusfile(vcdplusfile);
|
Fix Cadence Incisive compile errors; VCD-Plus is a VCS-only format
This fixes the following compile warnings and simulation errors:
Compile-time warnings:
$vcdplusfile(vcdplusfile);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): Unrecognized system task or function: $vcdplusfile (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdpluson(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): Unrecognized system task or function: $vcdpluson (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdplusmemon(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): Unrecognized system task or function: $vcdplusmemon (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
`VCDPLUSCLOSE
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): Unrecognized system task or function: $vcdplusclose (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
Which then become simulation-time errors:
$vcdplusfile(vcdplusfile);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): User Defined system task or function ($vcdplusfile) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdpluson(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): User Defined system task or function ($vcdpluson) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdplusmemon(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): User Defined system task or function ($vcdplusmemon) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,97|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
2016-10-19 22:11:18 +02:00
|
|
|
`else
|
2018-01-13 22:35:52 +01:00
|
|
|
$fdisplay(stderr, "Error: +vcdplusfile is VCS-only; use +vcdfile instead or recompile with VCS=1");
|
Fix Cadence Incisive compile errors; VCD-Plus is a VCS-only format
This fixes the following compile warnings and simulation errors:
Compile-time warnings:
$vcdplusfile(vcdplusfile);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): Unrecognized system task or function: $vcdplusfile (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdpluson(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): Unrecognized system task or function: $vcdpluson (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdplusmemon(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): Unrecognized system task or function: $vcdplusmemon (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
`VCDPLUSCLOSE
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): Unrecognized system task or function: $vcdplusclose (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
Which then become simulation-time errors:
$vcdplusfile(vcdplusfile);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): User Defined system task or function ($vcdplusfile) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdpluson(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): User Defined system task or function ($vcdpluson) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdplusmemon(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): User Defined system task or function ($vcdplusmemon) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,97|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
2016-10-19 22:11:18 +02:00
|
|
|
$fatal;
|
|
|
|
`endif
|
2016-08-16 07:03:03 +02:00
|
|
|
end
|
|
|
|
|
2018-01-09 18:54:34 +01:00
|
|
|
if ($value$plusargs("fsdbfile=%s", fsdbfile))
|
|
|
|
begin
|
|
|
|
`ifdef FSDB
|
|
|
|
$fsdbDumpfile(fsdbfile);
|
|
|
|
$fsdbDumpvars("+all");
|
|
|
|
//$fsdbDumpSVA;
|
|
|
|
`else
|
2018-01-13 22:35:52 +01:00
|
|
|
$fdisplay(stderr, "Error: +fsdbfile is FSDB-only; use +vcdfile/+vcdplus instead or recompile with FSDB=1");
|
2018-01-09 18:54:34 +01:00
|
|
|
$fatal;
|
|
|
|
`endif
|
|
|
|
end
|
|
|
|
|
2016-08-16 07:03:03 +02:00
|
|
|
if ($value$plusargs("vcdfile=%s", vcdfile))
|
|
|
|
begin
|
|
|
|
$dumpfile(vcdfile);
|
|
|
|
$dumpvars(0, testHarness);
|
|
|
|
end
|
2018-01-09 18:54:34 +01:00
|
|
|
|
|
|
|
`ifdef FSDB
|
|
|
|
`define VCDPLUSON $fsdbDumpon;
|
|
|
|
`define VCDPLUSCLOSE $fsdbDumpoff;
|
|
|
|
`elsif VCS
|
2017-03-31 20:37:37 +02:00
|
|
|
`define VCDPLUSON $vcdpluson(0); $vcdplusmemon(0);
|
2016-08-16 07:03:03 +02:00
|
|
|
`define VCDPLUSCLOSE $vcdplusclose; $dumpoff;
|
|
|
|
`else
|
2017-03-31 20:37:37 +02:00
|
|
|
`define VCDPLUSON $dumpon;
|
Fix Cadence Incisive compile errors; VCD-Plus is a VCS-only format
This fixes the following compile warnings and simulation errors:
Compile-time warnings:
$vcdplusfile(vcdplusfile);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): Unrecognized system task or function: $vcdplusfile (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdpluson(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): Unrecognized system task or function: $vcdpluson (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
$vcdplusmemon(0);
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): Unrecognized system task or function: $vcdplusmemon (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
`VCDPLUSCLOSE
|
ncelab: *W,MISSYST (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): Unrecognized system task or function: $vcdplusclose (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
Which then become simulation-time errors:
$vcdplusfile(vcdplusfile);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,42|17): User Defined system task or function ($vcdplusfile) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdpluson(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,43|15): User Defined system task or function ($vcdpluson) registered during elaboration and used within the simulation has not been registered during simulation.
$vcdplusmemon(0);
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,44|18): User Defined system task or function ($vcdplusmemon) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,89|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
`VCDPLUSCLOSE
|
ncsim: *E,MSSYSTF (/home/scottj/rocket-chip/vsrc/TestDriver.v,97|20): User Defined system task or function ($vcdplusclose) registered during elaboration and used within the simulation has not been registered during simulation.
2016-10-19 22:11:18 +02:00
|
|
|
`define VCDPLUSCLOSE $dumpoff;
|
|
|
|
`endif
|
|
|
|
`else
|
2016-10-24 23:45:34 +02:00
|
|
|
// No +define+DEBUG
|
2017-03-31 20:37:37 +02:00
|
|
|
`define VCDPLUSON
|
2016-08-16 07:03:03 +02:00
|
|
|
`define VCDPLUSCLOSE
|
2016-10-24 23:45:34 +02:00
|
|
|
|
2018-01-09 18:54:34 +01:00
|
|
|
if ($test$plusargs("vcdplusfile=") || $test$plusargs("vcdfile=") || $test$plusargs("fsdbfile="))
|
2016-10-24 23:45:34 +02:00
|
|
|
begin
|
2018-01-09 18:54:34 +01:00
|
|
|
$fdisplay(stderr, "Error: +vcdfile, +vcdplusfile, or +fsdbfile requested but compile did not have +define+DEBUG enabled");
|
2016-10-24 23:45:34 +02:00
|
|
|
$fatal;
|
|
|
|
end
|
|
|
|
|
2016-08-16 07:03:03 +02:00
|
|
|
`endif
|
|
|
|
end
|
|
|
|
|
2016-08-20 02:14:54 +02:00
|
|
|
`ifdef TESTBENCH_IN_UVM
|
|
|
|
// UVM library has its own way to manage end-of-simulation.
|
|
|
|
// A UVM-based testbench will raise an objection, watch this signal until this goes 1, then drop the objection.
|
|
|
|
reg finish_request = 1'b0;
|
|
|
|
`endif
|
2016-08-16 07:03:03 +02:00
|
|
|
reg [255:0] reason = "";
|
|
|
|
reg failure = 1'b0;
|
|
|
|
wire success;
|
|
|
|
integer stderr = 32'h80000002;
|
2016-09-22 01:16:47 +02:00
|
|
|
always @(posedge clock)
|
2016-08-16 07:03:03 +02:00
|
|
|
begin
|
2016-08-13 01:58:22 +02:00
|
|
|
`ifdef GATE_LEVEL
|
|
|
|
if (verbose)
|
|
|
|
begin
|
2016-08-13 02:03:21 +02:00
|
|
|
$fdisplay(stderr, "C: %10d", trace_count);
|
2016-08-13 01:58:22 +02:00
|
|
|
end
|
|
|
|
`endif
|
2017-03-31 20:37:37 +02:00
|
|
|
if (trace_count == dump_start)
|
|
|
|
begin
|
|
|
|
`VCDPLUSON
|
|
|
|
end
|
2016-08-13 02:03:21 +02:00
|
|
|
|
|
|
|
trace_count = trace_count + 1;
|
2016-08-16 07:03:03 +02:00
|
|
|
if (!reset)
|
|
|
|
begin
|
|
|
|
if (max_cycles > 0 && trace_count > max_cycles)
|
|
|
|
begin
|
|
|
|
reason = " (timeout)";
|
|
|
|
failure = 1'b1;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (failure)
|
|
|
|
begin
|
|
|
|
$fdisplay(stderr, "*** FAILED ***%s after %d simulation cycles", reason, trace_count);
|
|
|
|
`VCDPLUSCLOSE
|
|
|
|
$fatal;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
begin
|
|
|
|
if (verbose)
|
|
|
|
$fdisplay(stderr, "Completed after %d simulation cycles", trace_count);
|
|
|
|
`VCDPLUSCLOSE
|
2016-08-20 02:14:54 +02:00
|
|
|
`ifdef TESTBENCH_IN_UVM
|
|
|
|
finish_request = 1;
|
|
|
|
`else
|
2016-08-16 07:03:03 +02:00
|
|
|
$finish;
|
2016-08-20 02:14:54 +02:00
|
|
|
`endif
|
2016-08-16 07:03:03 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-15 20:53:05 +02:00
|
|
|
TestHarness testHarness(
|
2016-09-22 01:16:47 +02:00
|
|
|
.clock(clock),
|
2016-08-16 07:03:03 +02:00
|
|
|
.reset(reset),
|
|
|
|
.io_success(success)
|
|
|
|
);
|
|
|
|
|
|
|
|
endmodule
|