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

Subversion Repositories qaz_libs

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

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

powered by: WebSVN 2.1.0

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