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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lib/] [src/] [axi4_m_to_read_fifos.sv] - Blame information for rev 43

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
module
29
  axi4_m_to_read_fifos
30
  #(
31 43 qaztronic
    A, // address bus width
32
    N,  // data bus width in bytes
33
    I,  // ID width
34
    R_D,
35
    AR_D,
36 31 qaztronic
    WATERMARK = 0,
37
    USE_ADVANCED_PROTOCOL = 0
38
  )
39
  (
40
    axi4_if     axi4_m,
41
    axi4_if     axi4_read_fifo,
42
 
43
    output      ar_wr_full,
44
    input       ar_wr_en,
45
    output      r_rd_empty,
46
    input       r_rd_en,
47
    output      r_topped_off,
48
    output      r_watermark,
49
 
50
    input       aclk,
51
    input       aresetn
52
  );
53
 
54
  // --------------------------------------------------------------------
55
  //
56
  localparam UB = $clog2(R_D);
57
 
58
 
59
  // --------------------------------------------------------------------
60
  //
61
  localparam R_W =
62
    8*N + //  logic [(8*N)-1:0]  rdata;
63
    I +   //  logic [(I-1):0]    rid;
64
    1 +   //  logic              rlast;
65
    2;    //  logic [1:0]        rresp;
66
 
67
  localparam AX_BASIC_W =
68
    A +  // logic [(A-1):0]    axaddr;
69
    2 +  // logic [1:0]        axburst;
70
    I +  // logic [(I-1):0]    axid;
71
    8 +  // logic [7:0]        axlen;
72
    3;   // logic [2:0]        axsize;
73
 
74
  localparam AX_ADVANCED_W =
75
    4 +   // logic [3:0]        axcache;
76
    1 +   // logic              axlock;
77
    3 +   // logic [2:0]        axprot;
78
    4 +   // logic [3:0]        axqos;
79
    4;    // logic [3:0]        axregion;
80
 
81
  localparam AR_W = USE_ADVANCED_PROTOCOL ? AX_BASIC_W + AX_ADVANCED_W : AX_BASIC_W;
82
 
83
 
84
  // --------------------------------------------------------------------
85
  //
86
  wire [AR_W-1:0] ar_rd_data;
87
  wire [AR_W-1:0] ar_wr_data;
88
 
89
  generate
90
    begin: ar_data_gen
91
      if(USE_ADVANCED_PROTOCOL)
92
      begin
93
        assign ar_wr_data =
94
          {
95
            axi4_read_fifo.araddr,
96
            axi4_read_fifo.arburst,
97
            axi4_read_fifo.arid,
98
            axi4_read_fifo.arlen,
99
            axi4_read_fifo.arsize,
100
            axi4_read_fifo.arcache,
101
            axi4_read_fifo.arlock,
102
            axi4_read_fifo.arprot,
103
            axi4_read_fifo.arqos,
104
            axi4_read_fifo.arregion
105
          };
106
 
107
        assign
108
          {
109
            axi4_m.araddr,
110
            axi4_m.arburst,
111
            axi4_m.arid,
112
            axi4_m.arlen,
113
            axi4_m.arsize,
114
            axi4_m.arcache,
115
            axi4_m.arlock,
116
            axi4_m.arprot,
117
            axi4_m.arqos,
118
            axi4_m.arregion
119
          } = ar_rd_data;
120
      end
121
      else
122
      begin
123
        assign ar_wr_data =
124
          {
125
            axi4_read_fifo.araddr,
126
            axi4_read_fifo.arburst,
127
            axi4_read_fifo.arid,
128
            axi4_read_fifo.arlen,
129
            axi4_read_fifo.arsize
130
          };
131
 
132
        assign axi4_read_fifo.arcache  = 0;
133
        assign axi4_read_fifo.arlock   = 0;
134
        assign axi4_read_fifo.arprot   = 0;
135
        assign axi4_read_fifo.arqos    = 0;
136
        assign axi4_read_fifo.arregion = 0;
137
 
138
        assign
139
          {
140
            axi4_m.araddr,
141
            axi4_m.arburst,
142
            axi4_m.arid,
143
            axi4_m.arlen,
144
            axi4_m.arsize
145
          } = ar_rd_data;
146
 
147
        assign axi4_m.arcache  = 0;
148
        assign axi4_m.arlock   = 0;
149
        assign axi4_m.arprot   = 0;
150
        assign axi4_m.arqos    = 0;
151
        assign axi4_m.arregion = 0;
152
 
153
      end
154
    end
155
  endgenerate
156
 
157
 
158
  // --------------------------------------------------------------------
159
  //
160
  wire ar_rd_empty;
161
  wire ar_rd_en = axi4_m.arready & axi4_m.arvalid;
162
  assign axi4_m.arvalid = ~ar_rd_empty;
163
 
164
  sync_fifo #(.W(AR_W), .D(AR_D))
165
    ar_fifo
166
    (
167
      .wr_full(ar_wr_full),
168
      .wr_data(ar_wr_data),
169
      .wr_en(ar_wr_en),
170
      .rd_empty(ar_rd_empty),
171
      .rd_data(ar_rd_data),
172
      .rd_en(ar_rd_en),
173
      .count(),
174
      .clk(aclk),
175
      .reset(~aresetn)
176
    );
177
 
178
 
179
  // --------------------------------------------------------------------
180
  //
181
  wire [R_W-1:0] r_rd_data;
182
  wire [R_W-1:0] r_wr_data;
183
 
184
  assign r_wr_data =
185
    {
186
      axi4_m.rid,
187 43 qaztronic
      axi4_m.rresp,
188 31 qaztronic
      axi4_m.rlast,
189 43 qaztronic
      axi4_m.rdata
190 31 qaztronic
    };
191
 
192
  assign
193
    {
194
      axi4_read_fifo.rid,
195 43 qaztronic
      axi4_read_fifo.rresp,
196 31 qaztronic
      axi4_read_fifo.rlast,
197 43 qaztronic
      axi4_read_fifo.rdata
198 31 qaztronic
    } = r_rd_data;
199
 
200
 
201
  // --------------------------------------------------------------------
202
  //
203
  wire [UB:0] r_count;
204
 
205
  generate
206
    begin: r_watermark_gen
207
      if(WATERMARK == 0)
208
      begin
209
        assign r_topped_off = 1;
210
        assign r_watermark = 0;
211
      end
212
      else
213
      begin
214
        reg r_topped_off_r;
215
        assign r_topped_off = r_topped_off_r;
216
        assign r_watermark = r_count > WATERMARK - 1;
217
 
218
        always_ff @(posedge aclk)
219
          if(~aresetn | r_rd_empty)
220
            r_topped_off_r <= 0;
221
          else if(r_watermark)
222
            r_topped_off_r <= 1;
223
      end
224
    end
225
  endgenerate
226
 
227
 
228
  // --------------------------------------------------------------------
229
  //
230
  wire r_wr_full;
231
  wire r_wr_en = axi4_m.rready & axi4_m.rvalid;
232
  assign axi4_m.rready = ~r_wr_full;
233
 
234
  sync_fifo #(.W(R_W), .D(R_D))
235
    r_fifo
236
    (
237
      .wr_full(r_wr_full),
238
      .wr_data(r_wr_data),
239
      .wr_en(r_wr_en),
240
      .rd_empty(r_rd_empty),
241
      .rd_data(r_rd_data),
242
      .rd_en(r_rd_en),
243
      .count(r_count),
244
      .clk(aclk),
245
      .reset(~aresetn)
246
    );
247
 
248
 
249
// --------------------------------------------------------------------
250
//
251
 
252
endmodule
253
 

powered by: WebSVN 2.1.0

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