//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
/// ////
|
/// ////
|
/// ORPSoC testbench ////
|
/// ORPSoC testbench ////
|
/// ////
|
/// ////
|
/// Instantiate ORPSoC, monitors, provide stimulus ////
|
/// Instantiate ORPSoC, monitors, provide stimulus ////
|
/// ////
|
/// ////
|
/// Julius Baxter, julius@opencores.org ////
|
/// Julius Baxter, julius@opencores.org ////
|
/// ////
|
/// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
`include "orpsoc-defines.v"
|
`include "orpsoc-defines.v"
|
`include "orpsoc-testbench-defines.v"
|
`include "orpsoc-testbench-defines.v"
|
`include "test-defines.v"
|
`include "test-defines.v"
|
|
|
`include "timescale.v"
|
`include "timescale.v"
|
|
|
module orpsoc_testbench;
|
module orpsoc_testbench;
|
|
|
reg clk = 0;
|
reg clk = 0;
|
reg rst_n = 1; // Active LOW
|
reg rst_n = 1; // Active LOW
|
|
|
always
|
always
|
#((`BOARD_CLOCK_PERIOD_NS)/2) clk <= ~clk;
|
#((`BOARD_CLOCK_PERIOD)/2) clk <= ~clk;
|
|
|
// Reset, ACTIVE LOW
|
// Reset, ACTIVE LOW
|
initial
|
initial
|
begin
|
begin
|
#1;
|
#1;
|
repeat (32) @(negedge clk)
|
repeat (32) @(negedge clk)
|
rst_n <= 1;
|
rst_n <= 1;
|
repeat (32) @(negedge clk)
|
repeat (32) @(negedge clk)
|
rst_n <= 0;
|
rst_n <= 0;
|
repeat (32) @(negedge clk)
|
repeat (32) @(negedge clk)
|
rst_n <= 1;
|
rst_n <= 1;
|
end
|
end
|
|
|
`include "orpsoc-params.v"
|
`include "orpsoc-params.v"
|
|
|
`ifdef JTAG_DEBUG
|
`ifdef JTAG_DEBUG
|
wire tdo_pad_o;
|
wire tdo_pad_o;
|
wire tck_pad_i;
|
wire tck_pad_i;
|
wire tms_pad_i;
|
wire tms_pad_i;
|
wire tdi_pad_i;
|
wire tdi_pad_i;
|
`endif
|
`endif
|
`ifdef UART0
|
`ifdef UART0
|
wire uart0_stx_pad_o;
|
wire uart0_stx_pad_o;
|
wire uart0_srx_pad_i;
|
wire uart0_srx_pad_i;
|
`endif
|
`endif
|
|
|
orpsoc_top dut
|
orpsoc_top dut
|
(
|
(
|
.clk_pad_i (clk),
|
.clk_pad_i (clk),
|
`ifdef JTAG_DEBUG
|
`ifdef JTAG_DEBUG
|
.tms_pad_i (tms_pad_i),
|
.tms_pad_i (tms_pad_i),
|
.tck_pad_i (tck_pad_i),
|
.tck_pad_i (tck_pad_i),
|
.tdi_pad_i (tdi_pad_i),
|
.tdi_pad_i (tdi_pad_i),
|
.tdo_pad_o (tdo_pad_o),
|
.tdo_pad_o (tdo_pad_o),
|
`endif
|
`endif
|
`ifdef UART0
|
`ifdef UART0
|
.uart0_stx_pad_o (uart0_stx_pad_o),
|
.uart0_stx_pad_o (uart0_stx_pad_o),
|
.uart0_srx_pad_i (uart0_srx_pad_i),
|
.uart0_srx_pad_i (uart0_srx_pad_i),
|
`endif
|
`endif
|
.rst_n_pad_i (rst_n)
|
.rst_n_pad_i (rst_n)
|
);
|
);
|
|
|
//
|
//
|
// Instantiate OR1200 monitor
|
// Instantiate OR1200 monitor
|
//
|
//
|
or1200_monitor monitor();
|
or1200_monitor monitor();
|
|
|
`ifndef SIM_QUIET
|
`ifndef SIM_QUIET
|
`define CPU_ic_top or1200_ic_top
|
`define CPU_ic_top or1200_ic_top
|
`define CPU_dc_top or1200_dc_top
|
`define CPU_dc_top or1200_dc_top
|
wire ic_en = orpsoc_testbench.dut.or1200_top.or1200_ic_top.ic_en;
|
wire ic_en = orpsoc_testbench.dut.or1200_top0.or1200_ic_top.ic_en;
|
always @(posedge ic_en)
|
always @(posedge ic_en)
|
$display("Or1200 IC enabled at %t", $time);
|
$display("Or1200 IC enabled at %t", $time);
|
|
|
wire dc_en = orpsoc_testbench.dut.or1200_top.or1200_dc_top.dc_en;
|
wire dc_en = orpsoc_testbench.dut.or1200_top0.or1200_dc_top.dc_en;
|
always @(posedge dc_en)
|
always @(posedge dc_en)
|
$display("Or1200 DC enabled at %t", $time);
|
$display("Or1200 DC enabled at %t", $time);
|
`endif
|
`endif
|
|
|
|
|
`ifdef JTAG_DEBUG
|
`ifdef JTAG_DEBUG
|
`ifdef VPI_DEBUG
|
`ifdef VPI_DEBUG
|
// Debugging interface
|
// Debugging interface
|
vpi_debug_module vpi_dbg
|
vpi_debug_module vpi_dbg
|
(
|
(
|
.tms(tms_pad_i),
|
.tms(tms_pad_i),
|
.tck(tck_pad_i),
|
.tck(tck_pad_i),
|
.tdi(tdi_pad_i),
|
.tdi(tdi_pad_i),
|
.tdo(tdo_pad_o)
|
.tdo(tdo_pad_o)
|
);
|
);
|
`else
|
`else
|
// If no VPI debugging, tie off JTAG inputs
|
// If no VPI debugging, tie off JTAG inputs
|
assign tdi_pad_i = 1;
|
assign tdi_pad_i = 1;
|
assign tck_pad_i = 0;
|
assign tck_pad_i = 0;
|
assign tms_pad_i = 1;
|
assign tms_pad_i = 1;
|
`endif // !`ifdef VPI_DEBUG_ENABLE
|
`endif // !`ifdef VPI_DEBUG_ENABLE
|
`endif // `ifdef JTAG_DEBUG
|
`endif // `ifdef JTAG_DEBUG
|
|
|
|
|
initial
|
initial
|
begin
|
begin
|
`ifndef SIM_QUIET
|
`ifndef SIM_QUIET
|
$display("\n* Starting simulation of design RTL.\n* Test: %s\n",
|
$display("\n* Starting simulation of ORPSoC RTL.\n* Test: %s\n",
|
`TEST_NAME_STRING );
|
`TEST_NAME_STRING );
|
`endif
|
`endif
|
|
|
`ifdef VCD
|
`ifdef VCD
|
`ifdef VCD_DELAY
|
`ifdef VCD_DELAY
|
#(`VCD_DELAY);
|
#(`VCD_DELAY);
|
`endif
|
`endif
|
|
|
// Delay by x insns
|
// Delay by x insns
|
`ifdef VCD_DELAY_INSNS
|
`ifdef VCD_DELAY_INSNS
|
#10; // Delay until after the value becomes valid
|
#10; // Delay until after the value becomes valid
|
while (monitor.insns < `VCD_DELAY_INSNS)
|
while (monitor.insns < `VCD_DELAY_INSNS)
|
@(posedge clk);
|
@(posedge clk);
|
`endif
|
`endif
|
|
|
`ifdef SIMULATOR_MODELSIM
|
`ifdef SIMULATOR_MODELSIM
|
// Modelsim can GZip VCDs on the fly if given in the suffix
|
// Modelsim can GZip VCDs on the fly if given in the suffix
|
`define VCD_SUFFIX ".vcd.gz"
|
`define VCD_SUFFIX ".vcd.gz"
|
`else
|
`else
|
`define VCD_SUFFIX ".vcd"
|
`define VCD_SUFFIX ".vcd"
|
`endif
|
`endif
|
|
|
`ifndef SIM_QUIET
|
`ifndef SIM_QUIET
|
$display("* VCD in %s\n", {"../out/",`TEST_NAME_STRING,`VCD_SUFFIX});
|
$display("* VCD in %s\n", {"../out/",`TEST_NAME_STRING,`VCD_SUFFIX});
|
`endif
|
`endif
|
$dumpfile({"../out/",`TEST_NAME_STRING,`VCD_SUFFIX});
|
$dumpfile({"../out/",`TEST_NAME_STRING,`VCD_SUFFIX});
|
`ifndef VCD_DEPTH
|
`ifndef VCD_DEPTH
|
`define VCD_DEPTH 0
|
`define VCD_DEPTH 0
|
`endif
|
`endif
|
$dumpvars(`VCD_DEPTH);
|
$dumpvars(`VCD_DEPTH);
|
`endif
|
`endif
|
|
|
end // initial begin
|
end // initial begin
|
|
|
`ifdef END_TIME
|
`ifdef END_TIME
|
initial begin
|
initial begin
|
#(`END_TIME);
|
#(`END_TIME);
|
`ifndef SIM_QUIET
|
`ifndef SIM_QUIET
|
$display("* Finish simulation due to END_TIME being set at %t", $time);
|
$display("* Finish simulation due to END_TIME being set at %t", $time);
|
`endif
|
`endif
|
$finish;
|
$finish;
|
end
|
end
|
`endif
|
`endif
|
|
|
`ifdef END_INSNS
|
`ifdef END_INSNS
|
initial begin
|
initial begin
|
#10
|
#10
|
while (monitor.insns < `END_INSNS)
|
while (monitor.insns < `END_INSNS)
|
@(posedge clk);
|
@(posedge clk);
|
`ifndef SIM_QUIET
|
`ifndef SIM_QUIET
|
$display("* Finish simulation due to END_INSNS count (%d) reached at %t",
|
$display("* Finish simulation due to END_INSNS count (%d) reached at %t",
|
`END_INSNS, $time);
|
`END_INSNS, $time);
|
`endif
|
`endif
|
$finish;
|
$finish;
|
end
|
end
|
`endif
|
`endif
|
|
|
`ifdef UART0
|
`ifdef UART0
|
//
|
//
|
// UART0 decoder
|
// UART0 decoder
|
//
|
//
|
uart_decoder
|
uart_decoder
|
#(
|
#(
|
.uart_baudrate_period_ns(8680) // 115200 baud = period 8.68uS
|
.uart_baudrate_period_ns(8680) // 115200 baud = period 8.68uS
|
)
|
)
|
uart0_decoder
|
uart0_decoder
|
(
|
(
|
.clk(clk),
|
.clk(clk),
|
.uart_tx(uart0_stx_pad_o)
|
.uart_tx(uart0_stx_pad_o)
|
);
|
);
|
|
|
// UART0 stimulus
|
// UART0 stimulus
|
/*
|
/*
|
uart_stim
|
uart_stim
|
#(
|
#(
|
.uart_baudrate_period_ns(8680) // 115200 baud = period 8.68uS
|
.uart_baudrate_period_ns(8680) // 115200 baud = period 8.68uS
|
)
|
)
|
uart0_stim
|
uart0_stim
|
(
|
(
|
.clk(clk),
|
.clk(clk),
|
.uart_rx(uart0_srx_pad_i)
|
.uart_rx(uart0_srx_pad_i)
|
);
|
);
|
*/
|
*/
|
// UART0 is looped back for now
|
// UART0 is looped back for now
|
assign uart0_srx_pad_i = uart0_stx_pad_o;
|
assign uart0_srx_pad_i = uart0_stx_pad_o;
|
|
|
`endif // `ifdef UART0
|
`endif // `ifdef UART0
|
|
|
endmodule // orpsoc_testbench
|
endmodule // orpsoc_testbench
|
|
|
// Local Variables:
|
// Local Variables:
|
// verilog-library-directories:("." "../../rtl/verilog/orpsoc_top")
|
// verilog-library-directories:("." "../../rtl/verilog/orpsoc_top")
|
// verilog-library-files:()
|
// verilog-library-files:()
|
// verilog-library-extensions:(".v" ".h")
|
// verilog-library-extensions:(".v" ".h")
|
// End:
|
// End:
|
|
|
|
|