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

Subversion Repositories dma_axi

[/] [dma_axi/] [trunk/] [src/] [dma_axi32/] [dma_axi32_core0_ch_calc_size.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 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 2 eyalhoc
//---------------------------------------------------------
30
//-- File generated by RobustVerilog parser
31
//-- Version: 1.0
32
//-- Invoked Fri Mar 25 23:34:53 2011
33
//--
34
//-- Source file: dma_ch_calc_size.v
35
//---------------------------------------------------------
36
 
37
 
38
 
39
module  dma_axi32_core0_ch_calc_size (clk,reset,ch_update,ch_update_d,ch_update_d2,ch_update_d3,ch_end,ch_end_flush,load_in_prog,load_req_in_prog,joint_line_req_clr,wr_cmd_pending,outs_empty,burst_start,burst_addr,burst_max_size,x_remain,fifo_wr_ready,fifo_remain,burst_last,burst_size,burst_ready,joint_ready_in,joint_ready_out,joint,joint_line_req_in,joint_line_req_out,joint_burst_req_in,joint_burst_req_out,page_cross,joint_cross,joint_flush,joint_flush_in);
40
 
41
   parameter               READ          = 0;
42
 
43
   input                   clk;
44
   input            reset;
45
 
46
   input            ch_update;
47
   input            ch_update_d;
48
   input            ch_update_d2;
49
   input            ch_update_d3;
50
   input            ch_end;
51
   input            ch_end_flush;
52
 
53
   input            load_in_prog;
54
   input            load_req_in_prog;
55
 
56
   input            joint_line_req_clr;
57
   input            wr_cmd_pending;
58
   input            outs_empty;
59
   input            burst_start;
60
   input [32-1:0]   burst_addr;
61
   input [7-1:0]  burst_max_size;
62
   input [10-1:0]   x_remain;
63
   input            fifo_wr_ready;
64
   input [5:0]        fifo_remain;
65
 
66
   output            burst_last;
67
   output [7-1:0] burst_size;
68
   output            burst_ready;
69
   input            joint_ready_in;
70
   output            joint_ready_out;
71
   input            joint;
72
   input            joint_line_req_in;
73
   output            joint_line_req_out;
74
   input            joint_burst_req_in;
75
   output            joint_burst_req_out;
76
   input            page_cross;
77
   input            joint_cross;
78
   output            joint_flush;
79
   input            joint_flush_in;
80
 
81
 
82
   parameter            CMD_SIZE       = 16; //4*32 bit
83
 
84
 
85
   wire [7-1:0]   burst_size_pre;
86
   wire [7-1:0]   x_remain_fifo;
87
   wire [7-1:0]   max_burst_align;
88
   wire [7-1:0]   burst_size_pre2;
89
   reg [7-1:0]    burst_size;
90
   reg                burst_ready;
91
   wire            fifo_not_ready_pre;
92
   wire            fifo_not_ready;
93
 
94
   wire            joint_update;
95
   wire            joint_ready_out;
96
   wire            joint_line_req_out;
97
   wire            joint_burst_req_out;
98
   wire            joint_wait;
99
   reg [1:0]            joint_burst_req_reg;
100
   wire [1:0]            joint_burst_req;
101
   wire [7-1:0]   joint_burst_req_size;
102
   reg                joint_line_req_reg;
103
   wire            joint_line_req;
104
   wire [7-1:0]   joint_line_req_size;
105
   wire            joint_buffer_small;
106
   wire            release_fifo;
107
 
108
 
109
 
110
   assign            x_remain_fifo = |x_remain[10-1:7] ? {1'b1, {7-1{1'b0}}} : x_remain[7-1:0];
111
 
112
 
113
   prgen_min3 #(7) min3(
114
                   .clk(clk),
115
                   .reset(reset),
116
                   .a(max_burst_align), //address constraint
117
                   .b(burst_max_size),  //sw constraint
118
                   .c(x_remain_fifo),   //buffer constraint
119
                   .min(burst_size_pre)
120
                );
121
 
122
   //   
123
   //address align, do not cross 16 bit or 32 bit boundary
124
   assign            max_burst_align =
125
                          burst_addr[0] ? 'd1 : // byte
126
                          burst_addr[1] ? 'd2 : // 16 bit
127
                          {1'b1, {7-1{1'b0}}}; //no restriction
128
 
129
 
130
   assign            burst_size_pre2 =
131
               |burst_size_pre[7-1:2] ? {burst_size_pre[7-1:2], 2'b00} : //burst
132
 
133
               burst_size_pre[1]               ? 'd2 :
134
               burst_size_pre[0]               ? 'd1 : 'd0;
135
 
136
 
137
 
138
 
139
   assign            fifo_not_ready_pre = (fifo_remain < burst_size_pre2) & (~release_fifo);
140
 
141
   prgen_delay #(1) delay_fifo_not_ready (.clk(clk), .reset(reset), .din(fifo_not_ready_pre), .dout(fifo_not_ready));
142
 
143
   assign            burst_last = burst_size == x_remain;
144
 
145
   always @(posedge clk or posedge reset)
146
     if (reset)
147
       burst_ready <= #1 1'b0;
148
     else if (ch_update | ch_update_d | ch_update_d2 | ch_update_d3)
149
       burst_ready <= #1 1'b0;
150
     else if (load_req_in_prog)
151
       burst_ready <= #1 1'b1;
152
     else if (|joint_burst_req)
153
       burst_ready <= #1 1'b1;
154
     else if (joint_line_req & (~joint_buffer_small))
155
       burst_ready <= #1 1'b1;
156
     else if (load_in_prog | fifo_not_ready_pre | joint_wait | (page_cross & (burst_size != burst_size_pre2)))
157
       burst_ready <= #1 1'b0;
158
     else
159
       burst_ready <= #1 |burst_size_pre2;
160
 
161
   always @(posedge clk or posedge reset)
162
     if (reset)
163
       burst_size  <= #1 {7{1'b0}};
164
     else if (load_req_in_prog)
165
       burst_size  <= #1 CMD_SIZE;
166
     else if (|joint_burst_req)
167
       burst_size  <= #1 joint_burst_req_size;
168
     else if (joint_line_req & (~joint_buffer_small))
169
       burst_size  <= #1 joint_line_req_size;
170
     else
171
       burst_size  <= #1 burst_size_pre2;
172
 
173
 
174
 
175
   assign            joint_update = ch_update | ch_update_d | ch_update_d2;
176
 
177
   always @(posedge clk or posedge reset)
178
     if (reset)
179
       joint_burst_req_reg <= #1 2'b00;
180
     else if (joint_update | joint_flush | joint_flush_in)
181
       joint_burst_req_reg <= #1 2'b00;
182
     else if (joint_burst_req_reg & burst_start)
183
       joint_burst_req_reg <= #1 2'b00;
184
     else if (joint_burst_req_in)
185
       joint_burst_req_reg <= #1 joint_burst_req_reg[0] ? 2'b11 : 2'b01;
186
 
187
   assign            joint_burst_req = joint_burst_req_reg;
188
 
189
   always @(posedge clk or posedge reset)
190
     if (reset)
191
       joint_line_req_reg <= #1 1'b0;
192
     else if (joint_update | joint_flush | joint_flush_in)
193
       joint_line_req_reg <= #1 1'b0;
194
     else if (joint_line_req_reg & burst_start)
195
       joint_line_req_reg <= #1 1'b0;
196
     else if (joint_line_req_in)
197
       joint_line_req_reg <= #1 1'b1;
198
 
199
   assign            joint_line_req = joint_line_req_reg;
200
 
201
   assign            joint_line_req_size =
202
               burst_addr[2:0] == 3'd0 ? 3'd4 :
203
               burst_addr[1:0] == 2'd0 ? 'd4 :
204
               burst_addr[0]   == 1'd0 ? 'd2 : 'd1;
205
 
206
   assign            joint_burst_req_size =
207
                          burst_addr[0]             ? 'd1  :
208
                          burst_addr[1]             ? 'd2  :
209
                          burst_addr[2] & (!1) ? 'd4  :
210
                          joint_burst_req[1]        ? 'd32 : 'd16;
211
 
212
   dma_axi32_core0_ch_calc_joint #(READ)
213
   dma_axi32_core0_ch_calc_joint (
214
                   .clk(clk),
215
                   .reset(reset),
216
                   .joint_update(joint_update),
217
                   .ch_end(ch_end),
218
                   .ch_end_flush(ch_end_flush),
219
                   .joint_line_req_clr(joint_line_req_clr),
220
                   .burst_size_pre2(burst_size_pre2),
221
                   .burst_max_size(burst_max_size),
222
                   .fifo_not_ready(fifo_not_ready),
223
                   .wr_cmd_pending(wr_cmd_pending),
224
                   .outs_empty(outs_empty),
225
                   .x_remain(x_remain),
226
                   .fifo_wr_ready(fifo_wr_ready),
227
                   .fifo_remain(fifo_remain),
228
                   .joint(joint),
229
                   .joint_ready_in(joint_ready_in),
230
                   .joint_ready_out(joint_ready_out),
231
                   .joint_line_req(joint_line_req_out),
232
                   .joint_burst_req(joint_burst_req_out),
233
                   .joint_wait(joint_wait),
234
                   .page_cross(page_cross),
235
                   .joint_cross(joint_cross),
236
                   .joint_flush(joint_flush),
237
                   .joint_flush_in(joint_flush_in),
238
                   .joint_buffer_small(joint_buffer_small)
239
                   );
240
 
241
   assign            release_fifo         =  joint_ready_in & joint_ready_out & (~joint_cross);
242
 
243
 
244
 
245
 
246
endmodule
247
 
248
 

powered by: WebSVN 2.1.0

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