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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lib/] [src/] [axi4_to_write_fifos.sv] - Blame information for rev 30

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

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

powered by: WebSVN 2.1.0

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