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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lib/] [src/] [axi4_s_to_write_fifos.sv] - Blame information for rev 31

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_s_to_write_fifos
30
  #(
31
    A     = 32, // address bus width
32
    N     = 8,  // data bus width in bytes
33
    I     = 1,  // ID width
34
    W_D   = 32,
35
    B_D   = 2,
36
    AW_D  = 2,
37
 
38
    USE_ADVANCED_PROTOCOL = 0
39
  )
40
  (
41
    axi4_if axi4_s,
42
    axi4_if axi4_write_fifo,
43
 
44
    output  aw_rd_empty,
45
    input   aw_rd_en,
46
    output  w_rd_empty,
47
    input   w_rd_en,
48
    output  b_wr_full,
49
    input   b_wr_en,
50
 
51
    input   aclk,
52
    input   aresetn
53
  );
54
 
55
  // --------------------------------------------------------------------
56
  //
57
  localparam W_W =
58
    8*N + // logic [(8*N)-1:0]  wdata;
59
    I +   // logic [(I-1):0]    wid;
60
    1 +   // logic              wlast;
61
    N;    // logic [N-1:0]      wstrb;
62
 
63
  localparam B_W =
64
    I +   // logic [(I-1):0]    bid;
65
    2;    // logic [1:0]        bresp;
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 AW_W = USE_ADVANCED_PROTOCOL ? AX_BASIC_W + AX_ADVANCED_W : AX_BASIC_W;
82
 
83
 
84
  // --------------------------------------------------------------------
85
  //
86
  wire [AW_W-1:0] aw_rd_data;
87
  wire [AW_W-1:0] aw_wr_data;
88
 
89
  generate
90
    begin: aw_data_gen
91
      if(USE_ADVANCED_PROTOCOL)
92
      begin
93
        assign aw_wr_data =
94
          {
95
            axi4_s.awaddr,
96
            axi4_s.awburst,
97
            axi4_s.awid,
98
            axi4_s.awlen,
99
            axi4_s.awsize,
100
            axi4_s.awcache,
101
            axi4_s.awlock,
102
            axi4_s.awprot,
103
            axi4_s.awqos,
104
            axi4_s.awregion
105
          };
106
 
107
        assign
108
          {
109
            axi4_write_fifo.awaddr,
110
            axi4_write_fifo.awburst,
111
            axi4_write_fifo.awid,
112
            axi4_write_fifo.awlen,
113
            axi4_write_fifo.awsize,
114
            axi4_write_fifo.awcache,
115
            axi4_write_fifo.awlock,
116
            axi4_write_fifo.awprot,
117
            axi4_write_fifo.awqos,
118
            axi4_write_fifo.awregion
119
          } = aw_rd_data;
120
      end
121
      else
122
      begin
123
        assign aw_wr_data =
124
          {
125
            axi4_s.awaddr,
126
            axi4_s.awburst,
127
            axi4_s.awid,
128
            axi4_s.awlen,
129
            axi4_s.awsize
130
          };
131
 
132
        assign
133
          {
134
            axi4_write_fifo.awaddr,
135
            axi4_write_fifo.awburst,
136
            axi4_write_fifo.awid,
137
            axi4_write_fifo.awlen,
138
            axi4_write_fifo.awsize
139
          } = aw_rd_data;
140
      end
141
    end
142
  endgenerate
143
 
144
 
145
  // --------------------------------------------------------------------
146
  //
147
  wire aw_wr_full;
148
  wire aw_wr_en = axi4_s.awready & axi4_s.awvalid;
149
  assign axi4_s.awready = ~aw_wr_full;
150
 
151
  sync_fifo #(.W(AW_W), .D(AW_D))
152
    aw_fifo
153
    (
154
      .wr_full(aw_wr_full),
155
      .wr_data(aw_wr_data),
156
      .wr_en(aw_wr_en),
157
      .rd_empty(aw_rd_empty),
158
      .rd_data(aw_rd_data),
159
      .rd_en(aw_rd_en),
160
      .count(),
161
      .clk(aclk),
162
      .reset(~aresetn)
163
    );
164
 
165
 
166
  // --------------------------------------------------------------------
167
  //
168
  wire [W_W-1:0] w_rd_data;
169
  wire [W_W-1:0] w_wr_data;
170
 
171
  assign w_wr_data =
172
    {
173
      axi4_s.wdata,
174
      axi4_s.wid,
175
      axi4_s.wlast,
176
      axi4_s.wstrb
177
    };
178
 
179
  assign
180
    {
181
      axi4_write_fifo.wdata,
182
      axi4_write_fifo.wid,
183
      axi4_write_fifo.wlast,
184
      axi4_write_fifo.wstrb
185
    } = w_rd_data;
186
 
187
 
188
  // --------------------------------------------------------------------
189
  //
190
  wire w_wr_full;
191
  wire w_wr_en = axi4_s.wready & axi4_s.wvalid;
192
  assign axi4_s.wready = ~w_wr_full;
193
 
194
  sync_fifo #(.W(W_W), .D(W_D))
195
    w_fifo
196
    (
197
      .wr_full(w_wr_full),
198
      .wr_data(w_wr_data),
199
      .wr_en(w_wr_en),
200
      .rd_empty(w_rd_empty),
201
      .rd_data(w_rd_data),
202
      .rd_en(w_rd_en),
203
      .count(),
204
      .clk(aclk),
205
      .reset(~aresetn)
206
    );
207
 
208
 
209
  // --------------------------------------------------------------------
210
  //
211
  wire [B_W-1:0] b_rd_data;
212
  wire [B_W-1:0] b_wr_data;
213
 
214
  assign b_wr_data =
215
    {
216
      axi4_write_fifo.bid,
217
      axi4_write_fifo.bresp
218
    };
219
 
220
  assign
221
    {
222
      axi4_s.bid,
223
      axi4_s.bresp
224
    } = b_rd_data;
225
 
226
 
227
  // --------------------------------------------------------------------
228
  //
229
  wire b_rd_empty;
230
  wire b_rd_en = axi4_s.bready & axi4_s.bvalid;
231
  assign axi4_s.bvalid = ~b_rd_empty;
232
 
233
  sync_fifo #(.W(B_W), .D(B_D))
234
    b_fifo
235
    (
236
      .wr_full(b_wr_full),
237
      .wr_data(b_wr_data),
238
      .wr_en(b_wr_en),
239
      .rd_empty(b_rd_empty),
240
      .rd_data(b_rd_data),
241
      .rd_en(b_rd_en),
242
      .count(),
243
      .clk(aclk),
244
      .reset(~aresetn)
245
    );
246
 
247
 
248
// --------------------------------------------------------------------
249
//
250
 
251
endmodule
252
 

powered by: WebSVN 2.1.0

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