/* $Id: aemb2.v,v 1.3 2007-12-28 21:44:50 sybreon Exp $
|
/* $Id: aemb2.v,v 1.3 2007-12-28 21:44:50 sybreon Exp $
|
**
|
**
|
** AEMB2 TEST BENCH
|
** AEMB2 TEST BENCH
|
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
|
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
|
**
|
**
|
** This file is part of AEMB.
|
** This file is part of AEMB.
|
**
|
**
|
** AEMB is free software: you can redistribute it and/or modify it
|
** AEMB is free software: you can redistribute it and/or modify it
|
** under the terms of the GNU Lesser General Public License as
|
** under the terms of the GNU Lesser General Public License as
|
** published by the Free Software Foundation, either version 3 of the
|
** published by the Free Software Foundation, either version 3 of the
|
** License, or (at your option) any later version.
|
** License, or (at your option) any later version.
|
**
|
**
|
** AEMB is distributed in the hope that it will be useful, but WITHOUT
|
** AEMB is distributed in the hope that it will be useful, but WITHOUT
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
** Public License for more details.
|
** Public License for more details.
|
**
|
**
|
** You should have received a copy of the GNU Lesser General Public
|
** You should have received a copy of the GNU Lesser General Public
|
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
|
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
|
*/
|
*/
|
|
|
module aemb2 ();
|
module aemb2 ();
|
parameter IWB=16;
|
parameter IWB=16;
|
parameter DWB=16;
|
parameter DWB=16;
|
|
|
parameter TXE = 0; ///< thread execution enable
|
parameter TXE = 0; ///< thread execution enable
|
|
|
parameter MUL = 1; ///< enable hardware multiplier
|
parameter MUL = 1; ///< enable hardware multiplier
|
parameter BSF = 1; ///< enable barrel shifter
|
parameter BSF = 1; ///< enable barrel shifter
|
parameter FSL = 1; ///< enable FSL bus
|
parameter FSL = 1; ///< enable FSL bus
|
parameter DIV = 0; ///< enable hardware divider
|
parameter DIV = 0; ///< enable hardware divider
|
|
|
`include "random.v"
|
`include "random.v"
|
|
|
/*AUTOWIRE*/
|
/*AUTOWIRE*/
|
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
wire [6:2] cwb_adr_o; // From dut of aeMB2_sim.v
|
wire [6:2] cwb_adr_o; // From dut of aeMB2_sim.v
|
wire [31:0] cwb_dat_o; // From dut of aeMB2_sim.v
|
wire [31:0] cwb_dat_o; // From dut of aeMB2_sim.v
|
wire [3:0] cwb_sel_o; // From dut of aeMB2_sim.v
|
wire [3:0] cwb_sel_o; // From dut of aeMB2_sim.v
|
wire cwb_stb_o; // From dut of aeMB2_sim.v
|
wire cwb_stb_o; // From dut of aeMB2_sim.v
|
wire [1:0] cwb_tga_o; // From dut of aeMB2_sim.v
|
wire [1:0] cwb_tga_o; // From dut of aeMB2_sim.v
|
wire cwb_wre_o; // From dut of aeMB2_sim.v
|
wire cwb_wre_o; // From dut of aeMB2_sim.v
|
wire [DWB-1:2] dwb_adr_o; // From dut of aeMB2_sim.v
|
wire [DWB-1:2] dwb_adr_o; // From dut of aeMB2_sim.v
|
wire dwb_cyc_o; // From dut of aeMB2_sim.v
|
wire dwb_cyc_o; // From dut of aeMB2_sim.v
|
wire [31:0] dwb_dat_o; // From dut of aeMB2_sim.v
|
wire [31:0] dwb_dat_o; // From dut of aeMB2_sim.v
|
wire [3:0] dwb_sel_o; // From dut of aeMB2_sim.v
|
wire [3:0] dwb_sel_o; // From dut of aeMB2_sim.v
|
wire dwb_stb_o; // From dut of aeMB2_sim.v
|
wire dwb_stb_o; // From dut of aeMB2_sim.v
|
wire dwb_tga_o; // From dut of aeMB2_sim.v
|
wire dwb_tga_o; // From dut of aeMB2_sim.v
|
wire dwb_wre_o; // From dut of aeMB2_sim.v
|
wire dwb_wre_o; // From dut of aeMB2_sim.v
|
wire [IWB-1:2] iwb_adr_o; // From dut of aeMB2_sim.v
|
wire [IWB-1:2] iwb_adr_o; // From dut of aeMB2_sim.v
|
wire iwb_stb_o; // From dut of aeMB2_sim.v
|
wire iwb_stb_o; // From dut of aeMB2_sim.v
|
wire iwb_tga_o; // From dut of aeMB2_sim.v
|
wire iwb_tga_o; // From dut of aeMB2_sim.v
|
wire iwb_wre_o; // From dut of aeMB2_sim.v
|
wire iwb_wre_o; // From dut of aeMB2_sim.v
|
// End of automatics
|
// End of automatics
|
/*AUTOREGINPUT*/
|
/*AUTOREGINPUT*/
|
// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)
|
// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)
|
reg cwb_ack_i; // To dut of aeMB2_sim.v
|
reg cwb_ack_i; // To dut of aeMB2_sim.v
|
reg dwb_ack_i; // To dut of aeMB2_sim.v
|
reg dwb_ack_i; // To dut of aeMB2_sim.v
|
reg iwb_ack_i; // To dut of aeMB2_sim.v
|
reg iwb_ack_i; // To dut of aeMB2_sim.v
|
reg sys_clk_i; // To dut of aeMB2_sim.v
|
reg sys_clk_i; // To dut of aeMB2_sim.v
|
reg sys_int_i; // To dut of aeMB2_sim.v
|
reg sys_int_i; // To dut of aeMB2_sim.v
|
reg sys_rst_i; // To dut of aeMB2_sim.v
|
reg sys_rst_i; // To dut of aeMB2_sim.v
|
// End of automatics
|
// End of automatics
|
|
|
// INITIAL SETUP //////////////////////////////////////////////////////
|
// INITIAL SETUP //////////////////////////////////////////////////////
|
|
|
//reg sys_clk_i, sys_rst_i, sys_int_i, sys_exc_i;
|
//reg sys_clk_i, sys_rst_i, sys_int_i, sys_exc_i;
|
reg svc;
|
reg svc;
|
integer inttime;
|
integer inttime;
|
integer seed;
|
integer seed;
|
integer theend;
|
integer theend;
|
|
|
always #5 sys_clk_i = ~sys_clk_i;
|
always #5 sys_clk_i = ~sys_clk_i;
|
|
|
initial begin
|
initial begin
|
//$dumpfile("dump.vcd");
|
//$dumpfile("dump.vcd");
|
//$dumpvars(1,dut, dut.bpcu);
|
//$dumpvars(1,dut, dut.bpcu);
|
end
|
end
|
|
|
initial begin
|
initial begin
|
seed = randseed;
|
seed = randseed;
|
theend = 0;
|
theend = 0;
|
svc = 0;
|
svc = 0;
|
sys_clk_i = $random(seed);
|
sys_clk_i = $random(seed);
|
sys_rst_i = 1;
|
sys_rst_i = 1;
|
sys_int_i = 0;
|
sys_int_i = 0;
|
#50 sys_rst_i = 0;
|
#50 sys_rst_i = 0;
|
#3500000 $finish;
|
#3500000 $finish;
|
end
|
end
|
|
|
// FAKE MEMORY ////////////////////////////////////////////////////////
|
// FAKE MEMORY ////////////////////////////////////////////////////////
|
|
|
reg [31:0] rom [0:65535];
|
reg [31:0] rom [0:65535];
|
reg [31:0] ram[0:65535];
|
reg [31:0] ram[0:65535];
|
reg [31:0] dwblat;
|
reg [31:0] dwblat;
|
reg [15:2] dadr, iadr;
|
reg [15:2] dadr, iadr;
|
|
|
wire [31:0] dwb_dat_t = ram[dwb_adr_o];
|
wire [31:0] dwb_dat_t = ram[dwb_adr_o];
|
wire [31:0] iwb_dat_i = rom[iadr];
|
wire [31:0] iwb_dat_i = rom[iadr];
|
wire [31:0] dwb_dat_i = ram[dadr];
|
wire [31:0] dwb_dat_i = ram[dadr];
|
wire [31:0] cwb_dat_i = cwb_adr_o;
|
wire [31:0] cwb_dat_i = cwb_adr_o;
|
|
|
`ifdef POSEDGE
|
`ifdef POSEDGE
|
`else // !`ifdef POSEDGE
|
`else // !`ifdef POSEDGE
|
|
|
always @(negedge sys_clk_i)
|
always @(negedge sys_clk_i)
|
if (sys_rst_i) begin
|
if (sys_rst_i) begin
|
/*AUTORESET*/
|
/*AUTORESET*/
|
// Beginning of autoreset for uninitialized flops
|
// Beginning of autoreset for uninitialized flops
|
cwb_ack_i <= 1'h0;
|
cwb_ack_i <= 1'h0;
|
dwb_ack_i <= 1'h0;
|
dwb_ack_i <= 1'h0;
|
iwb_ack_i <= 1'h0;
|
iwb_ack_i <= 1'h0;
|
// End of automatics
|
// End of automatics
|
end else begin
|
end else begin
|
iwb_ack_i <= #1 iwb_stb_o;
|
iwb_ack_i <= #1 iwb_stb_o;
|
dwb_ack_i <= #1 dwb_stb_o;
|
dwb_ack_i <= #1 dwb_stb_o;
|
cwb_ack_i <= #1 cwb_stb_o;
|
cwb_ack_i <= #1 cwb_stb_o;
|
end // else: !if(sys_rst_i)
|
end // else: !if(sys_rst_i)
|
|
|
always @(negedge sys_clk_i) begin
|
always @(negedge sys_clk_i) begin
|
iadr <= #1 iwb_adr_o;
|
iadr <= #1 iwb_adr_o;
|
dadr <= #1 dwb_adr_o;
|
dadr <= #1 dwb_adr_o;
|
|
|
if (dwb_wre_o & dwb_stb_o) begin
|
if (dwb_wre_o & dwb_stb_o) begin
|
case (dwb_sel_o)
|
case (dwb_sel_o)
|
4'h1: ram[dwb_adr_o] <= {dwb_dat_t[31:8], dwb_dat_o[7:0]};
|
4'h1: ram[dwb_adr_o] <= {dwb_dat_t[31:8], dwb_dat_o[7:0]};
|
4'h2: ram[dwb_adr_o] <= {dwb_dat_t[31:16], dwb_dat_o[15:8], dwb_dat_t[7:0]};
|
4'h2: ram[dwb_adr_o] <= {dwb_dat_t[31:16], dwb_dat_o[15:8], dwb_dat_t[7:0]};
|
4'h4: ram[dwb_adr_o] <= {dwb_dat_t[31:24], dwb_dat_o[23:16], dwb_dat_t[15:0]};
|
4'h4: ram[dwb_adr_o] <= {dwb_dat_t[31:24], dwb_dat_o[23:16], dwb_dat_t[15:0]};
|
4'h8: ram[dwb_adr_o] <= {dwb_dat_o[31:24], dwb_dat_t[23:0]};
|
4'h8: ram[dwb_adr_o] <= {dwb_dat_o[31:24], dwb_dat_t[23:0]};
|
4'h3: ram[dwb_adr_o] <= {dwb_dat_t[31:16], dwb_dat_o[15:0]};
|
4'h3: ram[dwb_adr_o] <= {dwb_dat_t[31:16], dwb_dat_o[15:0]};
|
4'hC: ram[dwb_adr_o] <= {dwb_dat_o[31:16], dwb_dat_t[15:0]};
|
4'hC: ram[dwb_adr_o] <= {dwb_dat_o[31:16], dwb_dat_t[15:0]};
|
4'hF: ram[dwb_adr_o] <= {dwb_dat_o};
|
4'hF: ram[dwb_adr_o] <= {dwb_dat_o};
|
endcase // case (dwb_sel_o)
|
endcase // case (dwb_sel_o)
|
end // if (dwb_we_o & dwb_stb_o)
|
end // if (dwb_we_o & dwb_stb_o)
|
end // always @ (negedge sys_clk_i)
|
end // always @ (negedge sys_clk_i)
|
|
|
`endif // !`ifdef POSEDGE
|
`endif // !`ifdef POSEDGE
|
|
|
|
|
integer i;
|
integer i;
|
initial begin
|
initial begin
|
for (i=0;i<65535;i=i+1) begin
|
for (i=0;i<65535;i=i+1) begin
|
ram[i] <= $random;
|
ram[i] <= $random;
|
end
|
end
|
#1 $readmemh("dump.vmem",rom);
|
#1 $readmemh("dump.vmem",rom);
|
#1 $readmemh("dump.vmem",ram);
|
#1 $readmemh("dump.vmem",ram);
|
end
|
end
|
|
|
// DISPLAY OUTPUTS ///////////////////////////////////////////////////
|
// DISPLAY OUTPUTS ///////////////////////////////////////////////////
|
|
|
integer rnd;
|
integer rnd;
|
|
|
always @(posedge sys_clk_i) begin
|
always @(posedge sys_clk_i) begin
|
|
|
// Interrupt Monitors
|
// Interrupt Monitors
|
if (!dut.sim.rMSR_IE) begin
|
if (!dut.sim.rMSR_IE) begin
|
rnd = $random % 30;
|
rnd = $random % 30;
|
inttime = $stime + 1000 + (rnd*rnd * 10);
|
inttime = $stime + 1000 + (rnd*rnd * 10);
|
end
|
end
|
if ($stime > inttime) begin
|
if ($stime > inttime) begin
|
sys_int_i = 1;
|
sys_int_i = 1;
|
svc = 0;
|
svc = 0;
|
end
|
end
|
if (($stime > inttime + 500) && !svc) begin
|
if (($stime > inttime + 500) && !svc) begin
|
$display("\n\t*** INTERRUPT TIMEOUT ***", inttime);
|
$display("\n\t*** INTERRUPT TIMEOUT ***", inttime);
|
$finish;
|
$finish;
|
end
|
end
|
if (dwb_wre_o & (dwb_dat_o == "RTNI")) sys_int_i = 0;
|
if (dwb_wre_o & (dwb_dat_o == "RTNI")) sys_int_i = 0;
|
/*
|
/*
|
if (dut.regf.fRDWE && (dut.rRD == 5'h0e) && !svc && dut.gena) begin
|
if (dut.regf.fRDWE && (dut.rRD == 5'h0e) && !svc && dut.gena) begin
|
svc = 1;
|
svc = 1;
|
//$display("\nLATENCY: ", ($stime - inttime)/10);
|
//$display("\nLATENCY: ", ($stime - inttime)/10);
|
end
|
end
|
*/
|
*/
|
|
|
// Pass/Fail Monitors
|
// Pass/Fail Monitors
|
if (dwb_wre_o & (dwb_dat_o == "FAIL")) begin
|
if (dwb_wre_o & (dwb_dat_o == "FAIL")) begin
|
$display("\n\tFAIL");
|
$display("\n\tFAIL");
|
$finish;
|
$finish;
|
end
|
end
|
|
|
if (iwb_dat_i == 32'hb8000000) begin
|
if (iwb_dat_i == 32'hb8000000) begin
|
theend = theend + 1;
|
theend = theend + 1;
|
end
|
end
|
|
|
if (theend == 5) begin
|
if (theend == 5) begin
|
$display("\n\t*** PASSED ALL TESTS ***");
|
$display("\n\t*** PASSED ALL TESTS ***");
|
$finish;
|
$finish;
|
end
|
end
|
|
|
end // always @ (posedge sys_clk_i)
|
end // always @ (posedge sys_clk_i)
|
|
|
// INTERNAL WIRING ////////////////////////////////////////////////////
|
// INTERNAL WIRING ////////////////////////////////////////////////////
|
|
|
aeMB2_sim
|
aeMB2_sim
|
#(/*AUTOINSTPARAM*/
|
#(/*AUTOINSTPARAM*/
|
// Parameters
|
// Parameters
|
.IWB (IWB),
|
.IWB (IWB),
|
.DWB (DWB),
|
.DWB (DWB),
|
.TXE (TXE),
|
.TXE (TXE),
|
.MUL (MUL),
|
.MUL (MUL),
|
.BSF (BSF),
|
.BSF (BSF),
|
.FSL (FSL),
|
.FSL (FSL),
|
.DIV (DIV))
|
.DIV (DIV))
|
dut (/*AUTOINST*/
|
dut (/*AUTOINST*/
|
// Outputs
|
// Outputs
|
.cwb_adr_o (cwb_adr_o[6:2]),
|
.cwb_adr_o (cwb_adr_o[6:2]),
|
.cwb_dat_o (cwb_dat_o[31:0]),
|
.cwb_dat_o (cwb_dat_o[31:0]),
|
.cwb_sel_o (cwb_sel_o[3:0]),
|
.cwb_sel_o (cwb_sel_o[3:0]),
|
.cwb_stb_o (cwb_stb_o),
|
.cwb_stb_o (cwb_stb_o),
|
.cwb_tga_o (cwb_tga_o[1:0]),
|
.cwb_tga_o (cwb_tga_o[1:0]),
|
.cwb_wre_o (cwb_wre_o),
|
.cwb_wre_o (cwb_wre_o),
|
.dwb_adr_o (dwb_adr_o[DWB-1:2]),
|
.dwb_adr_o (dwb_adr_o[DWB-1:2]),
|
.dwb_cyc_o (dwb_cyc_o),
|
.dwb_cyc_o (dwb_cyc_o),
|
.dwb_dat_o (dwb_dat_o[31:0]),
|
.dwb_dat_o (dwb_dat_o[31:0]),
|
.dwb_sel_o (dwb_sel_o[3:0]),
|
.dwb_sel_o (dwb_sel_o[3:0]),
|
.dwb_stb_o (dwb_stb_o),
|
.dwb_stb_o (dwb_stb_o),
|
.dwb_tga_o (dwb_tga_o),
|
.dwb_tga_o (dwb_tga_o),
|
.dwb_wre_o (dwb_wre_o),
|
.dwb_wre_o (dwb_wre_o),
|
.iwb_adr_o (iwb_adr_o[IWB-1:2]),
|
.iwb_adr_o (iwb_adr_o[IWB-1:2]),
|
.iwb_stb_o (iwb_stb_o),
|
.iwb_stb_o (iwb_stb_o),
|
.iwb_tga_o (iwb_tga_o),
|
.iwb_tga_o (iwb_tga_o),
|
.iwb_wre_o (iwb_wre_o),
|
.iwb_wre_o (iwb_wre_o),
|
// Inputs
|
// Inputs
|
.cwb_ack_i (cwb_ack_i),
|
.cwb_ack_i (cwb_ack_i),
|
.cwb_dat_i (cwb_dat_i[31:0]),
|
.cwb_dat_i (cwb_dat_i[31:0]),
|
.dwb_ack_i (dwb_ack_i),
|
.dwb_ack_i (dwb_ack_i),
|
.dwb_dat_i (dwb_dat_i[31:0]),
|
.dwb_dat_i (dwb_dat_i[31:0]),
|
.iwb_ack_i (iwb_ack_i),
|
.iwb_ack_i (iwb_ack_i),
|
.iwb_dat_i (iwb_dat_i[31:0]),
|
.iwb_dat_i (iwb_dat_i[31:0]),
|
.sys_clk_i (sys_clk_i),
|
.sys_clk_i (sys_clk_i),
|
.sys_int_i (sys_int_i),
|
.sys_int_i (sys_int_i),
|
.sys_rst_i (sys_rst_i));
|
.sys_rst_i (sys_rst_i));
|
|
|
endmodule // edk32
|
endmodule // edk32
|
|
|
/* $Log $ */
|
/* $Log $ */
|
|
|
// Local Variables:
|
// Local Variables:
|
// verilog-library-directories:("." "../../rtl/verilog/")
|
// verilog-library-directories:("." "../../rtl/verilog/")
|
// verilog-library-files:("")
|
// verilog-library-files:("")
|
// End:
|
// End:
|
|
|