/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Author: Eyal Hochberg ////
|
//// Author: Eyal Hochberg ////
|
//// eyal@provartec.com ////
|
//// eyal@provartec.com ////
|
//// ////
|
//// ////
|
//// Downloaded from: http://www.opencores.org ////
|
//// Downloaded from: http://www.opencores.org ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2010 Provartec LTD ////
|
//// Copyright (C) 2010 Provartec LTD ////
|
//// www.provartec.com ////
|
//// www.provartec.com ////
|
//// info@provartec.com ////
|
//// info@provartec.com ////
|
//// ////
|
//// ////
|
//// 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.////
|
//// ////
|
//// ////
|
//// 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. http://www.gnu.org/licenses/lgpl.html ////
|
//// details. http://www.gnu.org/licenses/lgpl.html ////
|
//// ////
|
//// ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
|
|
OUTFILE PREFIX_stall.v
|
OUTFILE PREFIX_stall.v
|
|
|
INCLUDE def_axi_master.txt
|
INCLUDE def_axi_master.txt
|
|
|
module PREFIX_stall(PORTS);
|
module PREFIX_stall(PORTS);
|
|
|
`include "prgen_rand.v"
|
`include "prgen_rand.v"
|
|
|
input clk;
|
input clk;
|
input reset;
|
input reset;
|
|
|
input rd_hold;
|
input rd_hold;
|
input wr_hold;
|
input wr_hold;
|
|
|
input ARVALID_pre;
|
input ARVALID_pre;
|
input RREADY_pre;
|
input RREADY_pre;
|
input AWVALID_pre;
|
input AWVALID_pre;
|
input WVALID_pre;
|
input WVALID_pre;
|
input BREADY_pre;
|
input BREADY_pre;
|
|
|
input ARREADY;
|
input ARREADY;
|
input AWREADY;
|
input AWREADY;
|
input WREADY;
|
input WREADY;
|
|
|
output ARVALID;
|
output ARVALID;
|
output RREADY;
|
output RREADY;
|
output AWVALID;
|
output AWVALID;
|
output WVALID;
|
output WVALID;
|
output BREADY;
|
output BREADY;
|
|
|
|
|
reg stall_enable = 1;
|
reg stall_enable = 1;
|
|
|
integer burst_chance = 1;
|
integer burst_chance = 1;
|
integer burst_len = 10;
|
integer burst_len = 10;
|
integer burst_val = 90;
|
integer burst_val = 90;
|
|
|
integer ar_stall_chance = 10;
|
integer ar_stall_chance = 10;
|
integer r_stall_chance = 10;
|
integer r_stall_chance = 10;
|
integer aw_stall_chance = 10;
|
integer aw_stall_chance = 10;
|
integer w_stall_chance = 10;
|
integer w_stall_chance = 10;
|
integer b_stall_chance = 10;
|
integer b_stall_chance = 10;
|
|
|
|
|
integer burst_type;
|
integer burst_type;
|
reg burst_stall;
|
reg burst_stall;
|
integer ar_stall_chance_valid;
|
integer ar_stall_chance_valid;
|
integer r_stall_chance_valid;
|
integer r_stall_chance_valid;
|
integer aw_stall_chance_valid;
|
integer aw_stall_chance_valid;
|
integer w_stall_chance_valid;
|
integer w_stall_chance_valid;
|
integer b_stall_chance_valid;
|
integer b_stall_chance_valid;
|
|
|
|
|
reg ARSTALL_pre = 0;
|
reg ARSTALL_pre = 0;
|
reg RSTALL_pre = 0;
|
reg RSTALL_pre = 0;
|
reg AWSTALL_pre = 0;
|
reg AWSTALL_pre = 0;
|
reg WSTALL_pre = 0;
|
reg WSTALL_pre = 0;
|
reg BSTALL_pre = 0;
|
reg BSTALL_pre = 0;
|
reg ARSTALL;
|
reg ARSTALL;
|
reg RSTALL;
|
reg RSTALL;
|
reg AWSTALL;
|
reg AWSTALL;
|
reg WSTALL;
|
reg WSTALL;
|
reg BSTALL;
|
reg BSTALL;
|
|
|
|
|
|
|
assign ARVALID = ARVALID_pre & (~ARSTALL) & (~rd_hold);
|
assign ARVALID = ARVALID_pre & (~ARSTALL) & (~rd_hold);
|
assign RREADY = RREADY_pre & (~RSTALL);
|
assign RREADY = RREADY_pre & (~RSTALL);
|
assign AWVALID = AWVALID_pre & (~AWSTALL) & (~wr_hold);
|
assign AWVALID = AWVALID_pre & (~AWSTALL) & (~wr_hold);
|
assign WVALID = WVALID_pre & (~WSTALL);
|
assign WVALID = WVALID_pre & (~WSTALL);
|
assign BREADY = BREADY_pre & (~BSTALL);
|
assign BREADY = BREADY_pre & (~BSTALL);
|
|
|
|
|
task set_stall;
|
task set_stall;
|
reg stall;
|
reg stall;
|
begin
|
begin
|
ar_stall_chance_valid = ar_stall_chance;
|
ar_stall_chance_valid = ar_stall_chance;
|
r_stall_chance_valid = r_stall_chance;
|
r_stall_chance_valid = r_stall_chance;
|
aw_stall_chance_valid = aw_stall_chance;
|
aw_stall_chance_valid = aw_stall_chance;
|
w_stall_chance_valid = w_stall_chance;
|
w_stall_chance_valid = w_stall_chance;
|
b_stall_chance_valid = b_stall_chance;
|
b_stall_chance_valid = b_stall_chance;
|
end
|
end
|
endtask
|
endtask
|
|
|
initial
|
initial
|
begin
|
begin
|
#FFD;
|
#FFD;
|
set_stall;
|
set_stall;
|
|
|
if (burst_chance > 0)
|
if (burst_chance > 0)
|
forever
|
forever
|
begin
|
begin
|
burst_stall = rand_chance(burst_chance);
|
burst_stall = rand_chance(burst_chance);
|
|
|
if (burst_stall)
|
if (burst_stall)
|
begin
|
begin
|
#FFD;
|
#FFD;
|
burst_type = rand(1, 5);
|
burst_type = rand(1, 5);
|
|
|
case (burst_type)
|
case (burst_type)
|
1 : ar_stall_chance_valid = burst_val;
|
1 : ar_stall_chance_valid = burst_val;
|
2 : r_stall_chance_valid = burst_val;
|
2 : r_stall_chance_valid = burst_val;
|
3 : aw_stall_chance_valid = burst_val;
|
3 : aw_stall_chance_valid = burst_val;
|
4 : w_stall_chance_valid = burst_val;
|
4 : w_stall_chance_valid = burst_val;
|
5 : b_stall_chance_valid = burst_val;
|
5 : b_stall_chance_valid = burst_val;
|
endcase
|
endcase
|
|
|
repeat (burst_len) @(posedge clk);
|
repeat (burst_len) @(posedge clk);
|
set_stall;
|
set_stall;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
@(posedge clk);
|
@(posedge clk);
|
end
|
end
|
end
|
end
|
end
|
end
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
begin
|
begin
|
#FFD;
|
#FFD;
|
ARSTALL_pre = rand_chance(ar_stall_chance_valid);
|
ARSTALL_pre = rand_chance(ar_stall_chance_valid);
|
RSTALL_pre = rand_chance(r_stall_chance_valid);
|
RSTALL_pre = rand_chance(r_stall_chance_valid);
|
AWSTALL_pre = rand_chance(aw_stall_chance_valid);
|
AWSTALL_pre = rand_chance(aw_stall_chance_valid);
|
WSTALL_pre = rand_chance(w_stall_chance_valid);
|
WSTALL_pre = rand_chance(w_stall_chance_valid);
|
BSTALL_pre = rand_chance(b_stall_chance_valid);
|
BSTALL_pre = rand_chance(b_stall_chance_valid);
|
end
|
end
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
begin
|
begin
|
ARSTALL <= #FFD 1'b0;
|
ARSTALL <= #FFD 1'b0;
|
RSTALL <= #FFD 1'b0;
|
RSTALL <= #FFD 1'b0;
|
AWSTALL <= #FFD 1'b0;
|
AWSTALL <= #FFD 1'b0;
|
WSTALL <= #FFD 1'b0;
|
WSTALL <= #FFD 1'b0;
|
BSTALL <= #FFD 1'b0;
|
BSTALL <= #FFD 1'b0;
|
end
|
end
|
else if (stall_enable)
|
else if (stall_enable)
|
begin
|
begin
|
ARSTALL <= #FFD ARSTALL_pre & ARREADY;
|
ARSTALL <= #FFD ARSTALL_pre & ARREADY; //keep VALID signal stable while ~READY
|
RSTALL <= #FFD RSTALL_pre;
|
RSTALL <= #FFD RSTALL_pre;
|
AWSTALL <= #FFD AWSTALL_pre & AWREADY;
|
AWSTALL <= #FFD AWSTALL_pre & AWREADY; //keep VALID signal stable while ~READY
|
WSTALL <= #FFD WSTALL_pre & WREADY;
|
WSTALL <= #FFD WSTALL_pre & WREADY; //keep VALID signal stable while ~READY
|
BSTALL <= #FFD BSTALL_pre;
|
BSTALL <= #FFD BSTALL_pre;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
ARSTALL <= #FFD 1'b0;
|
ARSTALL <= #FFD 1'b0;
|
RSTALL <= #FFD 1'b0;
|
RSTALL <= #FFD 1'b0;
|
AWSTALL <= #FFD 1'b0;
|
AWSTALL <= #FFD 1'b0;
|
WSTALL <= #FFD 1'b0;
|
WSTALL <= #FFD 1'b0;
|
BSTALL <= #FFD 1'b0;
|
BSTALL <= #FFD 1'b0;
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|