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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lib/] [src/] [axi4_s_to_read_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_read_fifos
30
  #(
31
    A     = 32, // address bus width
32
    N     = 8,  // data bus width in bytes
33
    I     = 1,  // ID width
34
    R_D   = 32,
35
    AR_D  = 2,
36
    USE_ADVANCED_PROTOCOL = 0
37
  )
38
  (
39
    axi4_if axi4_s,
40
    axi4_if axi4_read_fifo,
41
 
42
    output  ar_rd_empty,
43
    input   ar_rd_en,
44
    output  r_wr_full,
45
    input   r_wr_en,
46
 
47
    input   aclk,
48
    input   aresetn
49
  );
50
 
51
  // --------------------------------------------------------------------
52
  //
53
  localparam R_W =
54
    8*N + //  logic [(8*N)-1:0]  rdata;
55
    I +   //  logic [(I-1):0]    rid;
56
    1 +   //  logic              rlast;
57
    2;    //  logic [1:0]        rresp;
58
 
59
  localparam AX_BASIC_W =
60
    A +  // logic [(A-1):0]    axaddr;
61
    2 +  // logic [1:0]        axburst;
62
    I +  // logic [(I-1):0]    axid;
63
    8 +  // logic [7:0]        axlen;
64
    3;   // logic [2:0]        axsize;
65
 
66
  localparam AX_ADVANCED_W =
67
    4 +   // logic [3:0]        axcache;
68
    1 +   // logic              axlock;
69
    3 +   // logic [2:0]        axprot;
70
    4 +   // logic [3:0]        axqos;
71
    4;    // logic [3:0]        axregion;
72
 
73
  localparam AR_W = USE_ADVANCED_PROTOCOL ? AX_BASIC_W + AX_ADVANCED_W : AX_BASIC_W;
74
 
75
 
76
  // --------------------------------------------------------------------
77
  //
78
  wire [AR_W-1:0] ar_rd_data;
79
  wire [AR_W-1:0] ar_wr_data;
80
 
81
  generate
82
    begin: ar_data_gen
83
      if(USE_ADVANCED_PROTOCOL)
84
      begin
85
        assign ar_wr_data =
86
          {
87
            axi4_s.araddr,
88
            axi4_s.arburst,
89
            axi4_s.arid,
90
            axi4_s.arlen,
91
            axi4_s.arsize,
92
            axi4_s.arcache,
93
            axi4_s.arlock,
94
            axi4_s.arprot,
95
            axi4_s.arqos,
96
            axi4_s.arregion
97
          };
98
 
99
        assign
100
          {
101
            axi4_read_fifo.araddr,
102
            axi4_read_fifo.arburst,
103
            axi4_read_fifo.arid,
104
            axi4_read_fifo.arlen,
105
            axi4_read_fifo.arsize,
106
            axi4_read_fifo.arcache,
107
            axi4_read_fifo.arlock,
108
            axi4_read_fifo.arprot,
109
            axi4_read_fifo.arqos,
110
            axi4_read_fifo.arregion
111
          } = ar_rd_data;
112
      end
113
      else
114
      begin
115
        assign ar_wr_data =
116
          {
117
            axi4_s.araddr,
118
            axi4_s.arburst,
119
            axi4_s.arid,
120
            axi4_s.arlen,
121
            axi4_s.arsize
122
          };
123
 
124
        assign
125
          {
126
            axi4_read_fifo.araddr,
127
            axi4_read_fifo.arburst,
128
            axi4_read_fifo.arid,
129
            axi4_read_fifo.arlen,
130
            axi4_read_fifo.arsize
131
          } = ar_rd_data;
132
      end
133
    end
134
  endgenerate
135
 
136
 
137
  // --------------------------------------------------------------------
138
  //
139
  wire ar_wr_full;
140
  wire ar_wr_en = axi4_s.arready & axi4_s.arvalid;
141
  assign axi4_s.arready = ~ar_wr_full;
142
 
143
  sync_fifo #(.W(AR_W), .D(AR_D))
144
    ar_fifo
145
    (
146
      .wr_full(ar_wr_full),
147
      .wr_data(ar_wr_data),
148
      .wr_en(ar_wr_en),
149
      .rd_empty(ar_rd_empty),
150
      .rd_data(ar_rd_data),
151
      .rd_en(ar_rd_en),
152
      .count(),
153
      .clk(aclk),
154
      .reset(~aresetn)
155
    );
156
 
157
 
158
  // --------------------------------------------------------------------
159
  //
160
  wire [R_W-1:0] r_rd_data;
161
  wire [R_W-1:0] r_wr_data;
162
 
163
  assign r_wr_data =
164
    {
165
      axi4_read_fifo.rdata,
166
      axi4_read_fifo.rid,
167
      axi4_read_fifo.rlast,
168
      axi4_read_fifo.rresp
169
    };
170
 
171
  assign
172
    {
173
      axi4_s.rdata,
174
      axi4_s.rid,
175
      axi4_s.rlast,
176
      axi4_s.rresp
177
    } = r_rd_data;
178
 
179
 
180
  // --------------------------------------------------------------------
181
  //
182
  wire r_rd_empty;
183
  wire r_rd_en = axi4_s.rready & axi4_s.rvalid;
184
  assign axi4_s.rvalid = ~r_rd_empty;
185
 
186
  sync_fifo #(.W(R_W), .D(R_D))
187
    r_fifo
188
    (
189
      .wr_full(r_wr_full),
190
      .wr_data(r_wr_data),
191
      .wr_en(r_wr_en),
192
      .rd_empty(r_rd_empty),
193
      .rd_data(r_rd_data),
194
      .rd_en(r_rd_en),
195
      .count(),
196
      .clk(aclk),
197
      .reset(~aresetn)
198
    );
199
 
200
 
201
// --------------------------------------------------------------------
202
//
203
 
204
endmodule
205
 

powered by: WebSVN 2.1.0

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