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

Subversion Repositories axi_slave

[/] [axi_slave/] [trunk/] [src/] [base/] [axi_slave_ram.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 eyalhoc
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Author: Eyal Hochberg                                      ////
4
////          eyal@provartec.com                                 ////
5
////                                                             ////
6
////  Downloaded from: http://www.opencores.org                  ////
7
/////////////////////////////////////////////////////////////////////
8
////                                                             ////
9
//// Copyright (C) 2010 Provartec LTD                            ////
10
//// www.provartec.com                                           ////
11
//// info@provartec.com                                          ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
//// This source file is free software; you can redistribute it  ////
19
//// and/or modify it under the terms of the GNU Lesser General  ////
20
//// Public License as published by the Free Software Foundation.////
21
////                                                             ////
22
//// This source is distributed in the hope that it will be      ////
23
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
24
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
25
//// PURPOSE.  See the GNU Lesser General Public License for more////
26
//// details. http://www.gnu.org/licenses/lgpl.html              ////
27
////                                                             ////
28
/////////////////////////////////////////////////////////////////////
29
 
30
OUTFILE PREFIX_ram.v
31
 
32
INCLUDE def_axi_slave.txt
33
 
34
module PREFIX_ram(PORTS);
35
 
36
   input                      clk;
37
   input                      reset;
38
 
39
   revport                    GROUP_STUB_AXI;
40
 
41
   port                       GROUP_STUB_MEM;
42
 
43
 
44
   //busy
45
   wire                       ARREADY_pre;
46
   wire                       RVALID_pre;
47
   wire                       AWREADY_pre;
48
   wire                       WREADY_pre;
49
   wire                       BVALID_pre;
50
   wire                       RBUSY;
51
   wire                       BBUSY;
52
 
53
   //wcmd fifo
54
   wire [ADDR_BITS-1:0]       wcmd_addr;
55
   wire [ID_BITS-1:0]          wcmd_id;
56
   wire [1:0]                  wcmd_size;
57
   wire [LEN_BITS-1:0]        wcmd_len;
58
   wire [1:0]                  wcmd_resp;
59
   wire                       wcmd_timeout;
60
   wire                       wcmd_ready;
61
   wire                       wcmd_empty;
62
   wire                       wcmd_full;
63
 
64
   //rcmd fifo
65
   wire [ADDR_BITS-1:0]       rcmd_addr;
66
   wire [ID_BITS-1:0]          rcmd_id;
67
   wire [1:0]                  rcmd_size;
68
   wire [LEN_BITS-1:0]        rcmd_len;
69
   wire [1:0]                  rcmd_resp;
70
   wire                       rcmd_timeout;
71
   wire                       rcmd_ready;
72
   wire                       rcmd_full;
73
 
74
   wire [ID_BITS-1:0]          rcmd_id2;
75
   wire [LEN_BITS-1:0]        rcmd_len2;
76
 
77
   wire                       wresp_empty;
78
   wire                       wresp_pending;
79
   wire                       wresp_timeout;
80
 
81
   reg [ADDR_BITS-1:0]         TIMEOUT_AR_addr = {ADDR_BITS{1'b1}};
82
   reg [ADDR_BITS-1:0]         TIMEOUT_AW_addr = {ADDR_BITS{1'b1}};
83
   wire                       AR_stall = ARVALID & (TIMEOUT_AR_addr == ARADDR);
84
   wire                       AW_stall = AWVALID & (TIMEOUT_AW_addr == AWADDR);
85
 
86
   wire                       RD_last;
87
 
88
   assign                     RID   = rcmd_id2;
89
 
90
 
91
   assign                     ARREADY_pre = (~rcmd_full) & (~AR_stall);
92
   assign                     AWREADY_pre = (~wcmd_full) & (~AW_stall);
93
   assign                     BVALID_pre  = (~wresp_timeout) & (wresp_pending ? (~wresp_empty) : (~wresp_empty) & (~BBUSY));
94
 
95
   CREATE axi_slave_busy.v
96
   PREFIX_busy
97
     PREFIX_busy (
98
                   .clk(clk),
99
                   .reset(reset),
100
                   .ARREADY_pre(ARREADY_pre),
101
                   .RVALID_pre(RVALID_pre),
102
                   .AWREADY_pre(AWREADY_pre),
103
                   .WREADY_pre(WREADY_pre),
104
                   .BVALID_pre(BVALID_pre),
105
                   .ARREADY(ARREADY),
106
                   .RVALID(RVALID),
107
                   .AWREADY(AWREADY),
108
                   .WREADY(WREADY),
109
                   .BVALID(BVALID),
110
                   .RBUSY(RBUSY),
111
                   .BBUSY(BBUSY)
112
                   );
113
 
114
   CREATE axi_slave_cmd_fifo.v
115
   PREFIX_cmd_fifo #(WCMD_DEPTH)
116
   PREFIX_wcmd_fifo (
117
                      .clk(clk),
118
                      .reset(reset),
119
                      .AADDR(AWADDR),
120
                      .AID(AWID),
121
                      .ASIZE(AWSIZE),
122
                      .ALEN(AWLEN),
123
                      .AVALID(AWVALID),
124
                      .AREADY(AWREADY),
125
                      .VALID(WVALID),
126
                      .READY(WREADY),
127
                      .LAST(WLAST),
128
                      .cmd_addr(wcmd_addr),
129
                      .cmd_id(wcmd_id), //not used
130
                      .cmd_size(wcmd_size),
131
                      .cmd_len(wcmd_len), //not used
132
                      .cmd_resp(),
133
                      .cmd_timeout(wcmd_timeout),
134
                      .cmd_ready(wcmd_ready),
135
                      .cmd_empty(wcmd_empty),
136
                      .cmd_full(wcmd_full)
137
                      );
138
 
139
 
140
   PREFIX_cmd_fifo #(RCMD_DEPTH)
141
   PREFIX_rcmd_fifo (
142
                      .clk(clk),
143
                      .reset(reset),
144
                      .AADDR(ARADDR),
145
                      .AID(ARID),
146
                      .ASIZE(ARSIZE),
147
                      .ALEN(ARLEN),
148
                      .AVALID(ARVALID),
149
                      .AREADY(ARREADY),
150
                      .VALID(RD_last),
151
                      .READY(1'b1),
152
                      .LAST(1'b1),
153
                      .cmd_addr(rcmd_addr),
154
                      .cmd_id(rcmd_id),
155
                      .cmd_size(rcmd_size),
156
                      .cmd_len(rcmd_len),
157
                      .cmd_resp(rcmd_resp),
158
                      .cmd_timeout(rcmd_timeout),
159
                      .cmd_ready(rcmd_ready),
160
                      .cmd_empty(),
161
                      .cmd_full()
162
                      );
163
 
164
   PREFIX_cmd_fifo #(RCMD_DEPTH)
165
   PREFIX_rcmd_fifo2 (
166
                       .clk(clk),
167
                       .reset(reset),
168
                       .AADDR(ARADDR),
169
                       .AID(ARID),
170
                       .ASIZE(ARSIZE),
171
                       .ALEN(ARLEN),
172
                       .AVALID(ARVALID),
173
                       .AREADY(ARREADY),
174
                       .VALID(RVALID),
175
                       .READY(RREADY),
176
                       .LAST(RLAST),
177
                       .cmd_addr(),
178
                       .cmd_id(rcmd_id2),
179
                       .cmd_size(),
180
                       .cmd_len(rcmd_len2),
181
                       .cmd_resp(),
182
                       .cmd_timeout(),
183
                       .cmd_ready(),
184
                       .cmd_empty(),
185
                       .cmd_full(rcmd_full)
186
                       );
187
 
188
   CREATE axi_slave_wresp_fifo.v
189
   PREFIX_wresp_fifo #(WCMD_DEPTH)
190
     PREFIX_wresp_fifo (
191
                         .clk(clk),
192
                         .reset(reset),
193
                         .AWVALID(AWVALID),
194
                         .AWREADY(AWREADY),
195
                         .AWADDR(AWADDR),
196
                         .WVALID(WVALID),
197
                         .WREADY(WREADY),
198
                         .WLAST(WLAST),
199
                         .WID(WID),
200
                         .BID(BID),
201
                         .BRESP(BRESP),
202
                         .BVALID(BVALID),
203
                         .BREADY(BREADY),
204
                         .empty(wresp_empty),
205
                         .pending(wresp_pending),
206
                         .timeout(wresp_timeout)
207
                         );
208
 
209
   CREATE axi_slave_addr_gen.v
210
   PREFIX_addr_gen
211
     PREFIX_addr_gen_wr (
212
                          .clk(clk),
213
                          .reset(reset),
214
                          .cmd_addr(wcmd_addr),
215
                          .cmd_size(wcmd_size),
216
                          .advance(WVALID & WREADY & (~WLAST)),
217
                          .restart(WVALID & WREADY & WLAST),
218
                          .ADDR(ADDR_WR)
219
                          );
220
 
221
 
222
   PREFIX_addr_gen
223
     PREFIX_addr_gen_rd (
224
                          .clk(clk),
225
                          .reset(reset),
226
                          .cmd_addr(rcmd_addr),
227
                          .cmd_size(rcmd_size),
228
                          .advance(RD),
229
                          .restart(RD_last),
230
                          .ADDR(ADDR_RD)
231
                          );
232
 
233
   CREATE axi_slave_rd_buff.v
234
   PREFIX_rd_buff #(DATA_BITS, ID_BITS)
235
   PREFIX_rd_buff(
236
                   .clk(clk),
237
                   .reset(reset),
238
                   .RD(RD),
239
                   .DOUT(DOUT),
240
                   .rcmd_len(rcmd_len),
241
                   .rcmd_len2(rcmd_len2),
242
                   .rcmd_resp(rcmd_resp),
243
                   .rcmd_timeout(rcmd_timeout),
244
                   .rcmd_ready(rcmd_ready),
245
                   .RVALID(RVALID_pre),
246
                   .RREADY(RREADY),
247
                   .RLAST(RLAST),
248
                   .RDATA(RDATA),
249
                   .RD_last(RD_last),
250
                   .RRESP(RRESP),
251
                   .RBUSY(RBUSY)
252
                   );
253
 
254
   //wr_buff
255
   assign                     WREADY_pre = (~wcmd_timeout) & (~wcmd_empty);
256
   assign                     WR         = WVALID & WREADY & (~wcmd_empty);
257
   assign                     DIN        = WDATA;
258
   assign                     BSEL       = WSTRB;
259
 
260
 
261
endmodule
262
 
263
 

powered by: WebSVN 2.1.0

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