OpenCores
URL https://opencores.org/ocsvn/axi_master/axi_master/trunk

Subversion Repositories axi_master

[/] [axi_master/] [trunk/] [src/] [base/] [axi_master_stall.v] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 eyalhoc
<##//////////////////////////////////////////////////////////////////
2 2 eyalhoc
////                                                             ////
3
////  Author: Eyal Hochberg                                      ////
4
////          eyal@provartec.com                                 ////
5
////                                                             ////
6
////  Downloaded from: http://www.opencores.org                  ////
7
/////////////////////////////////////////////////////////////////////
8
////                                                             ////
9
//// Copyright (C) 2010 Provartec LTD                            ////
10
//// www.provartec.com                                           ////
11
//// info@provartec.com                                          ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
//// This source file is free software; you can redistribute it  ////
19
//// and/or modify it under the terms of the GNU Lesser General  ////
20
//// Public License as published by the Free Software Foundation.////
21
////                                                             ////
22
//// This source is distributed in the hope that it will be      ////
23
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
24
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
25
//// PURPOSE.  See the GNU Lesser General Public License for more////
26
//// details. http://www.gnu.org/licenses/lgpl.html              ////
27
////                                                             ////
28 21 eyalhoc
//////////////////////////////////////////////////////////////////##>
29 18 eyalhoc
 
30
OUTFILE PREFIX_stall.v
31
 
32
INCLUDE def_axi_master.txt
33
 
34
module PREFIX_stall(PORTS);
35
 
36
`include "prgen_rand.v"
37
 
38
   input                      clk;
39
   input                      reset;
40
 
41
   input                      rd_hold;
42
   input                      wr_hold;
43
 
44
   input                      ARVALID_pre;
45
   input                      RREADY_pre;
46
   input                      AWVALID_pre;
47
   input                      WVALID_pre;
48
   input                      BREADY_pre;
49
 
50
   input                      ARREADY;
51
   input                      AWREADY;
52
   input                      WREADY;
53
 
54
   output                     ARVALID;
55
   output                     RREADY;
56
   output                     AWVALID;
57
   output                     WVALID;
58
   output                     BREADY;
59
 
60
 
61
   reg                        stall_enable = 1;
62
 
63
   integer                    burst_chance    = 1;
64
   integer                    burst_len       = 10;
65
   integer                    burst_val       = 90;
66
 
67
   integer                    ar_stall_chance = 10;
68
   integer                    r_stall_chance  = 10;
69
   integer                    aw_stall_chance = 10;
70
   integer                    w_stall_chance  = 10;
71
   integer                    b_stall_chance  = 10;
72
 
73
 
74
   integer                    burst_type;
75
   reg                        burst_stall;
76
   integer                    ar_stall_chance_valid;
77
   integer                    r_stall_chance_valid;
78
   integer                    aw_stall_chance_valid;
79
   integer                    w_stall_chance_valid;
80
   integer                    b_stall_chance_valid;
81
 
82
 
83
   reg                        ARSTALL_pre = 0;
84
   reg                        RSTALL_pre  = 0;
85
   reg                        AWSTALL_pre = 0;
86
   reg                        WSTALL_pre  = 0;
87
   reg                        BSTALL_pre  = 0;
88
   reg                        ARSTALL;
89
   reg                        RSTALL;
90
   reg                        AWSTALL;
91
   reg                        WSTALL;
92
   reg                        BSTALL;
93
 
94
 
95
 
96
   assign                     ARVALID = ARVALID_pre & (~ARSTALL) & (~rd_hold);
97
   assign                     RREADY  = RREADY_pre  & (~RSTALL);
98
   assign                     AWVALID = AWVALID_pre & (~AWSTALL) & (~wr_hold);
99
   assign                     WVALID  = WVALID_pre  & (~WSTALL);
100
   assign                     BREADY  = BREADY_pre  & (~BSTALL);
101
 
102
 
103
   task set_stall;
104
      reg stall;
105
      begin
106
         ar_stall_chance_valid = ar_stall_chance;
107
         r_stall_chance_valid  = r_stall_chance;
108
         aw_stall_chance_valid = aw_stall_chance;
109
         w_stall_chance_valid  = w_stall_chance;
110
         b_stall_chance_valid  = b_stall_chance;
111
      end
112
   endtask
113
 
114
   initial
115
     begin
116
        #FFD;
117
        set_stall;
118
 
119
        if (burst_chance > 0)
120
          forever
121
            begin
122
               burst_stall = rand_chance(burst_chance);
123
 
124
               if (burst_stall)
125
                 begin
126
                    #FFD;
127
                    burst_type = rand(1, 5);
128
 
129
                    case (burst_type)
130
                      1 : ar_stall_chance_valid = burst_val;
131
                      2 : r_stall_chance_valid  = burst_val;
132
                      3 : aw_stall_chance_valid = burst_val;
133
                      4 : w_stall_chance_valid  = burst_val;
134
                      5 : b_stall_chance_valid  = burst_val;
135
                    endcase
136
 
137
                    repeat (burst_len) @(posedge clk);
138
                    set_stall;
139
                 end
140
               else
141
                 begin
142
                    @(posedge clk);
143
                 end
144
            end
145
     end
146
 
147
   always @(posedge clk)
148
     begin
149
        #FFD;
150
        ARSTALL_pre = rand_chance(ar_stall_chance_valid);
151
        RSTALL_pre  = rand_chance(r_stall_chance_valid);
152
        AWSTALL_pre = rand_chance(aw_stall_chance_valid);
153
        WSTALL_pre  = rand_chance(w_stall_chance_valid);
154
        BSTALL_pre  = rand_chance(b_stall_chance_valid);
155
     end
156
 
157
   always @(posedge clk or posedge reset)
158
     if (reset)
159
       begin
160
          ARSTALL <= #FFD 1'b0;
161
          RSTALL  <= #FFD 1'b0;
162
          AWSTALL <= #FFD 1'b0;
163
          WSTALL  <= #FFD 1'b0;
164
          BSTALL  <= #FFD 1'b0;
165
       end
166
     else if (stall_enable)
167
       begin
168
          ARSTALL <= #FFD ARSTALL_pre & ARREADY; //keep VALID signal stable while ~READY
169
          RSTALL  <= #FFD RSTALL_pre;
170
          AWSTALL <= #FFD AWSTALL_pre & AWREADY; //keep VALID signal stable while ~READY
171
          WSTALL  <= #FFD WSTALL_pre & WREADY; //keep VALID signal stable while ~READY
172
          BSTALL  <= #FFD BSTALL_pre;
173
       end
174
     else
175
       begin
176
          ARSTALL <= #FFD 1'b0;
177
          RSTALL  <= #FFD 1'b0;
178
          AWSTALL <= #FFD 1'b0;
179
          WSTALL  <= #FFD 1'b0;
180
          BSTALL  <= #FFD 1'b0;
181
       end
182
 
183
endmodule
184
 
185
 
186
 
187
 
188
 
189
 
190
 
191
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.