2014-09-12 19:15:04 +02:00
|
|
|
// See LICENSE for license details.
|
2014-09-01 05:26:55 +02:00
|
|
|
|
2016-06-23 09:17:29 +02:00
|
|
|
extern "A" void debug_tick
|
2014-09-01 05:26:55 +02:00
|
|
|
(
|
2016-06-23 09:17:29 +02:00
|
|
|
output reg debug_req_valid,
|
|
|
|
input reg debug_req_ready,
|
|
|
|
output reg [ 4:0] debug_req_bits_addr,
|
|
|
|
output reg [ 1:0] debug_req_bits_op,
|
|
|
|
output reg [33:0] debug_req_bits_data,
|
|
|
|
|
|
|
|
input reg debug_resp_valid,
|
|
|
|
output reg debug_resp_ready,
|
|
|
|
input reg [ 1:0] debug_resp_bits_resp,
|
|
|
|
input reg [33:0] debug_resp_bits_data,
|
|
|
|
|
|
|
|
output reg [31:0] exit
|
2014-09-01 05:26:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
extern "A" void memory_tick
|
|
|
|
(
|
2015-10-31 05:14:33 +01:00
|
|
|
input reg [31:0] channel,
|
|
|
|
|
2015-10-14 20:33:18 +02:00
|
|
|
input reg ar_valid,
|
|
|
|
output reg ar_ready,
|
|
|
|
input reg [`MEM_ADDR_BITS-1:0] ar_addr,
|
|
|
|
input reg [`MEM_ID_BITS-1:0] ar_id,
|
|
|
|
input reg [2:0] ar_size,
|
|
|
|
input reg [7:0] ar_len,
|
|
|
|
|
|
|
|
input reg aw_valid,
|
|
|
|
output reg aw_ready,
|
|
|
|
input reg [`MEM_ADDR_BITS-1:0] aw_addr,
|
|
|
|
input reg [`MEM_ID_BITS-1:0] aw_id,
|
|
|
|
input reg [2:0] aw_size,
|
|
|
|
input reg [7:0] aw_len,
|
|
|
|
|
|
|
|
input reg w_valid,
|
|
|
|
output reg w_ready,
|
|
|
|
input reg [`MEM_STRB_BITS-1:0] w_strb,
|
|
|
|
input reg [`MEM_DATA_BITS-1:0] w_data,
|
|
|
|
input reg w_last,
|
|
|
|
|
|
|
|
output reg r_valid,
|
|
|
|
input reg r_ready,
|
|
|
|
output reg [1:0] r_resp,
|
|
|
|
output reg [`MEM_ID_BITS-1:0] r_id,
|
|
|
|
output reg [`MEM_DATA_BITS-1:0] r_data,
|
|
|
|
output reg r_last,
|
|
|
|
|
|
|
|
output reg b_valid,
|
|
|
|
input reg b_ready,
|
|
|
|
output reg [1:0] b_resp,
|
|
|
|
output reg [`MEM_ID_BITS-1:0] b_id
|
2014-09-01 05:26:55 +02:00
|
|
|
);
|
2015-10-14 20:33:18 +02:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
module rocketTestHarness;
|
|
|
|
|
|
|
|
reg [31:0] seed;
|
|
|
|
initial seed = $get_initial_random_seed();
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// Instantiate the processor
|
|
|
|
|
2015-10-14 20:33:18 +02:00
|
|
|
reg clk = 1'b0;
|
|
|
|
reg reset = 1'b1;
|
2016-06-08 19:03:53 +02:00
|
|
|
reg r_reset = 1'b1;
|
2015-10-14 20:33:18 +02:00
|
|
|
reg start = 1'b0;
|
2014-09-01 05:26:55 +02:00
|
|
|
|
|
|
|
always #`CLOCK_PERIOD clk = ~clk;
|
|
|
|
|
2015-10-31 05:14:33 +01:00
|
|
|
reg [ 31:0] n_mem_channel = `N_MEM_CHANNELS;
|
|
|
|
reg [ 31:0] mem_width = `MEM_DATA_BITS;
|
|
|
|
reg [ 63:0] max_cycles = 0;
|
|
|
|
reg [ 63:0] trace_count = 0;
|
|
|
|
reg [1023:0] loadmem = 0;
|
|
|
|
reg [1023:0] vcdplusfile = 0;
|
|
|
|
reg [1023:0] vcdfile = 0;
|
|
|
|
reg verbose = 0;
|
2016-04-02 01:40:13 +02:00
|
|
|
wire printf_cond = verbose && !reset;
|
2015-10-31 05:14:33 +01:00
|
|
|
integer stderr = 32'h80000002;
|
2014-09-01 05:26:55 +02:00
|
|
|
|
2015-10-31 05:14:33 +01:00
|
|
|
`include `TBVFRAG
|
2014-09-01 05:26:55 +02:00
|
|
|
|
2015-10-31 05:14:33 +01:00
|
|
|
always @(posedge clk)
|
2014-09-01 05:26:55 +02:00
|
|
|
begin
|
|
|
|
r_reset <= reset;
|
|
|
|
end
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
reg [31:0] exit = 0;
|
2014-09-01 05:26:55 +02:00
|
|
|
|
2016-06-23 09:17:29 +02:00
|
|
|
always @(posedge clk)
|
2014-09-01 05:26:55 +02:00
|
|
|
begin
|
|
|
|
if (reset || r_reset)
|
|
|
|
begin
|
2016-06-23 09:17:29 +02:00
|
|
|
debug_req_valid <= 0;
|
|
|
|
debug_resp_ready <= 0;
|
2014-09-01 05:26:55 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2016-06-23 09:17:29 +02:00
|
|
|
debug_tick
|
2014-09-01 05:26:55 +02:00
|
|
|
(
|
2016-06-23 09:17:29 +02:00
|
|
|
debug_req_valid,
|
|
|
|
debug_req_ready,
|
|
|
|
debug_req_bits_addr,
|
|
|
|
debug_req_bits_op,
|
|
|
|
debug_req_bits_data,
|
|
|
|
debug_resp_valid,
|
|
|
|
debug_resp_ready,
|
|
|
|
debug_resp_bits_resp,
|
|
|
|
debug_resp_bits_data,
|
2014-09-01 05:26:55 +02:00
|
|
|
exit
|
|
|
|
);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
// Start the simulation
|
|
|
|
|
|
|
|
// Read input arguments and initialize
|
|
|
|
initial
|
|
|
|
begin
|
|
|
|
$value$plusargs("max-cycles=%d", max_cycles);
|
|
|
|
verbose = $test$plusargs("verbose");
|
|
|
|
`ifdef DEBUG
|
|
|
|
if ($value$plusargs("vcdplusfile=%s", vcdplusfile))
|
|
|
|
begin
|
|
|
|
$vcdplusfile(vcdplusfile);
|
2016-04-27 23:57:54 +02:00
|
|
|
$vcdpluson(0);
|
|
|
|
$vcdplusmemon(0);
|
2014-09-01 05:26:55 +02:00
|
|
|
end
|
2016-04-27 23:57:54 +02:00
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
if ($value$plusargs("vcdfile=%s", vcdfile))
|
|
|
|
begin
|
|
|
|
$dumpfile(vcdfile);
|
|
|
|
$dumpvars(0, dut);
|
2016-04-27 23:57:54 +02:00
|
|
|
$dumpon;
|
2014-09-01 05:26:55 +02:00
|
|
|
end
|
2016-04-27 23:57:54 +02:00
|
|
|
`define VCDPLUSCLOSE $vcdplusclose; $dumpoff;
|
|
|
|
`else
|
|
|
|
`define VCDPLUSCLOSE
|
2014-09-01 05:26:55 +02:00
|
|
|
`endif
|
|
|
|
|
|
|
|
// Strobe reset
|
|
|
|
#777.7 reset = 0;
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
reg [255:0] reason = 0;
|
|
|
|
always @(posedge clk)
|
|
|
|
begin
|
|
|
|
if (max_cycles > 0 && trace_count > max_cycles)
|
|
|
|
reason = "timeout";
|
|
|
|
if (exit > 1)
|
|
|
|
$sformat(reason, "tohost = %d", exit >> 1);
|
|
|
|
|
|
|
|
if (reason)
|
|
|
|
begin
|
|
|
|
$fdisplay(stderr, "*** FAILED *** (%s) after %d simulation cycles", reason, trace_count);
|
|
|
|
`VCDPLUSCLOSE
|
2016-06-24 05:54:07 +02:00
|
|
|
$fatal;
|
2014-09-01 05:26:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if (exit == 1)
|
|
|
|
begin
|
2016-06-14 01:24:01 +02:00
|
|
|
if (verbose)
|
|
|
|
$fdisplay(stderr, "Completed after %d simulation cycles", trace_count);
|
2014-09-01 05:26:55 +02:00
|
|
|
`VCDPLUSCLOSE
|
2016-06-24 05:54:07 +02:00
|
|
|
$finish;
|
2014-09-01 05:26:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge clk)
|
|
|
|
begin
|
|
|
|
trace_count = trace_count + 1;
|
|
|
|
`ifdef GATE_LEVEL
|
|
|
|
if (verbose)
|
|
|
|
begin
|
|
|
|
$fdisplay(stderr, "C: %10d", trace_count-1);
|
|
|
|
end
|
|
|
|
`endif
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|