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 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 eyalhoc
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
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
/////////////////////////////////////////////////////////////////////
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
   input                      ARREADY_pre;
43
   input                      RVALID_pre;
44
   input                      AWREADY_pre;
45
   input                      WREADY_pre;
46
   input                      BVALID_pre;
47
 
48
   output                     ARREADY;
49
   output                     RVALID;
50
   output                     AWREADY;
51
   output                     WREADY;
52
   output                     BVALID;
53
 
54
   output                     RBUSY;
55
   output                     BBUSY;
56
 
57
 
58
   reg                        stall_enable    = 1;
59
 
60
   integer                    burst_chance    = 1;
61
   integer                    burst_len       = 10;
62
   integer                    burst_val       = 90;
63
 
64
   integer                    ar_stall_chance = 10;
65
   integer                    r_stall_chance  = 10;
66
   integer                    aw_stall_chance = 10;
67
   integer                    w_stall_chance  = 10;
68
   integer                    b_stall_chance  = 10;
69
 
70
 
71
   integer                    burst_type;
72
   reg                        burst_stall;
73
   integer                    ar_stall_chance_valid;
74
   integer                    r_stall_chance_valid;
75
   integer                    aw_stall_chance_valid;
76
   integer                    w_stall_chance_valid;
77
   integer                    b_stall_chance_valid;
78
 
79
 
80
   reg                        ARBUSY_pre = 0;
81
   reg                        RBUSY_pre = 0;
82
   reg                        AWBUSY_pre = 0;
83
   reg                        WBUSY_pre = 0;
84
   reg                        BBUSY_pre = 0;
85
   reg                        ARBUSY;
86
   reg                        RBUSY;
87
   reg                        AWBUSY;
88
   reg                        WBUSY;
89
   reg                        BBUSY;
90
 
91
 
92
 
93
   assign                     ARREADY = ARREADY_pre & (~ARBUSY);
94
   assign                     RVALID  = RVALID_pre; //in rd_buff
95
   assign                     AWREADY = AWREADY_pre & (~AWBUSY);
96
   assign                     WREADY  = WREADY_pre  & (~WBUSY);
97
   assign                     BVALID  = BVALID_pre; //in wresp
98
 
99
 
100
   task set_stall;
101
      reg stall;
102
      begin
103
         ar_stall_chance_valid = ar_stall_chance;
104
         r_stall_chance_valid  = r_stall_chance;
105
         aw_stall_chance_valid = aw_stall_chance;
106
         w_stall_chance_valid  = w_stall_chance;
107
         b_stall_chance_valid  = b_stall_chance;
108
      end
109
   endtask
110
 
111
   initial
112
     begin
113
        #FFD;
114
        set_stall;
115
 
116
        if (burst_chance > 0)
117
          forever
118
            begin
119
               burst_stall = rand_chance(burst_chance);
120
 
121
               if (burst_stall)
122
                 begin
123
                    #FFD;
124
                    burst_type = rand(1, 5);
125
 
126
                    case (burst_type)
127
                      1 : ar_stall_chance_valid = burst_val;
128
                      2 : r_stall_chance_valid  = burst_val;
129
                      3 : aw_stall_chance_valid = burst_val;
130
                      4 : w_stall_chance_valid  = burst_val;
131
                      5 : b_stall_chance_valid  = burst_val;
132
                    endcase
133
 
134
                    repeat (burst_len) @(posedge clk);
135
                    set_stall;
136
                 end
137
               else
138
                 begin
139
                    @(posedge clk);
140
                 end
141
            end
142
     end
143
 
144
   always @(posedge clk)
145
     begin
146
        #FFD;
147
        ARBUSY_pre = rand_chance(ar_stall_chance_valid);
148
        RBUSY_pre  = rand_chance(r_stall_chance_valid);
149
        AWBUSY_pre = rand_chance(aw_stall_chance_valid);
150
        WBUSY_pre  = rand_chance(w_stall_chance_valid);
151
        BBUSY_pre  = rand_chance(b_stall_chance_valid);
152
     end
153
 
154
   always @(posedge clk or posedge reset)
155
     if (reset)
156
       begin
157
          ARBUSY <= #FFD 1'b0;
158
          RBUSY  <= #FFD 1'b0;
159
          AWBUSY <= #FFD 1'b0;
160
          WBUSY  <= #FFD 1'b0;
161
          BBUSY  <= #FFD 1'b0;
162
       end
163
     else if (stall_enable)
164
       begin
165
          ARBUSY <= #FFD ARBUSY_pre;
166
          RBUSY  <= #FFD RBUSY_pre;
167
          AWBUSY <= #FFD AWBUSY_pre;
168
          WBUSY  <= #FFD WBUSY_pre;
169
          BBUSY  <= #FFD BBUSY_pre;
170
       end
171
     else
172
       begin
173
          ARBUSY <= #FFD 1'b0;
174
          RBUSY  <= #FFD 1'b0;
175
          AWBUSY <= #FFD 1'b0;
176
          WBUSY  <= #FFD 1'b0;
177
          BBUSY  <= #FFD 1'b0;
178
       end
179
 
180
endmodule
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
 

powered by: WebSVN 2.1.0

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