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

Subversion Repositories axi_slave

[/] [axi_slave/] [trunk/] [src/] [base/] [axi_slave_busy.v] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 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 13 eyalhoc
//////////////////////////////////////////////////////////////////##>
29 6 eyalhoc
 
30
OUTFILE PREFIX_busy.v
31
 
32
INCLUDE def_axi_slave.txt
33
 
34
module PREFIX_busy(PORTS);
35
 
36
CREATE prgen_rand.v DEFCMD(DEFINE NOT_IN_LIST)
37
`include "prgen_rand.v"
38
 
39
   input                      clk;
40
   input                      reset;
41
 
42 10 eyalhoc
   output                     ARBUSY;
43 6 eyalhoc
   output                     RBUSY;
44 10 eyalhoc
   output                     AWBUSY;
45
   output                     WBUSY;
46 6 eyalhoc
   output                     BBUSY;
47
 
48
 
49
   reg                        stall_enable    = 1;
50
 
51
   integer                    burst_chance    = 1;
52
   integer                    burst_len       = 10;
53
   integer                    burst_val       = 90;
54
 
55
   integer                    ar_stall_chance = 10;
56
   integer                    r_stall_chance  = 10;
57
   integer                    aw_stall_chance = 10;
58
   integer                    w_stall_chance  = 10;
59
   integer                    b_stall_chance  = 10;
60
 
61
 
62
   integer                    burst_type;
63
   reg                        burst_stall;
64
   integer                    ar_stall_chance_valid;
65
   integer                    r_stall_chance_valid;
66
   integer                    aw_stall_chance_valid;
67
   integer                    w_stall_chance_valid;
68
   integer                    b_stall_chance_valid;
69
 
70
 
71
   reg                        ARBUSY_pre = 0;
72
   reg                        RBUSY_pre = 0;
73
   reg                        AWBUSY_pre = 0;
74
   reg                        WBUSY_pre = 0;
75
   reg                        BBUSY_pre = 0;
76
   reg                        ARBUSY;
77
   reg                        RBUSY;
78
   reg                        AWBUSY;
79
   reg                        WBUSY;
80
   reg                        BBUSY;
81
 
82
 
83
   task set_stall;
84
      reg stall;
85
      begin
86
         ar_stall_chance_valid = ar_stall_chance;
87
         r_stall_chance_valid  = r_stall_chance;
88
         aw_stall_chance_valid = aw_stall_chance;
89
         w_stall_chance_valid  = w_stall_chance;
90
         b_stall_chance_valid  = b_stall_chance;
91
      end
92
   endtask
93
 
94
   initial
95
     begin
96
        #FFD;
97
        set_stall;
98
 
99
        if (burst_chance > 0)
100
          forever
101
            begin
102
               burst_stall = rand_chance(burst_chance);
103
 
104
               if (burst_stall)
105
                 begin
106
                    #FFD;
107
                    burst_type = rand(1, 5);
108
 
109
                    case (burst_type)
110
                      1 : ar_stall_chance_valid = burst_val;
111
                      2 : r_stall_chance_valid  = burst_val;
112
                      3 : aw_stall_chance_valid = burst_val;
113
                      4 : w_stall_chance_valid  = burst_val;
114
                      5 : b_stall_chance_valid  = burst_val;
115
                    endcase
116
 
117
                    repeat (burst_len) @(posedge clk);
118
                    set_stall;
119
                 end
120
               else
121
                 begin
122
                    @(posedge clk);
123
                 end
124
            end
125
     end
126
 
127
   always @(posedge clk)
128
     begin
129
        #FFD;
130
        ARBUSY_pre = rand_chance(ar_stall_chance_valid);
131
        RBUSY_pre  = rand_chance(r_stall_chance_valid);
132
        AWBUSY_pre = rand_chance(aw_stall_chance_valid);
133
        WBUSY_pre  = rand_chance(w_stall_chance_valid);
134
        BBUSY_pre  = rand_chance(b_stall_chance_valid);
135
     end
136
 
137
   always @(posedge clk or posedge reset)
138
     if (reset)
139
       begin
140
          ARBUSY <= #FFD 1'b0;
141
          RBUSY  <= #FFD 1'b0;
142
          AWBUSY <= #FFD 1'b0;
143
          WBUSY  <= #FFD 1'b0;
144
          BBUSY  <= #FFD 1'b0;
145
       end
146
     else if (stall_enable)
147
       begin
148
          ARBUSY <= #FFD ARBUSY_pre;
149
          RBUSY  <= #FFD RBUSY_pre;
150
          AWBUSY <= #FFD AWBUSY_pre;
151
          WBUSY  <= #FFD WBUSY_pre;
152
          BBUSY  <= #FFD BBUSY_pre;
153
       end
154
     else
155
       begin
156
          ARBUSY <= #FFD 1'b0;
157
          RBUSY  <= #FFD 1'b0;
158
          AWBUSY <= #FFD 1'b0;
159
          WBUSY  <= #FFD 1'b0;
160
          BBUSY  <= #FFD 1'b0;
161
       end
162
 
163
endmodule
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 

powered by: WebSVN 2.1.0

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