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

Subversion Repositories dma_ahb

[/] [dma_ahb/] [trunk/] [src/] [dma_ahb64/] [dma_ahb64_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:33:02 2011
33
//--
34
//-- Source file: dma_ch_calc_size.v
35
//---------------------------------------------------------
36
 
37
 
38
 
39
module  dma_ahb64_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 [8-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 [8-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       = 32; //4 strobes
83
 
84
 
85
   wire [8-1:0]   burst_size_pre;
86
   wire [8-1:0]   x_remain_fifo;
87
   wire [8-1:0]   max_burst_align;
88
   wire [8-1:0]   burst_size_pre2;
89
   reg [8-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 [8-1:0]   joint_burst_req_size;
102
   reg                joint_line_req_reg;
103
   wire            joint_line_req;
104
   wire [8-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:8] ? {1'b1, {8-1{1'b0}}} : x_remain[8-1:0];
111
 
112
 
113
   prgen_min3 #(8) 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
   assign            max_burst_align =
124
                        burst_addr[6:0] == 7'd0 ? 'd128 : //INCR16 64bit
125
                        burst_addr[5:0] == 6'd0 ? 'd64 :  //INCR8  64bit
126
                        burst_addr[4:0] == 5'd0 ? 'd32 :  //INCR4  64bit
127
                        burst_addr[2:0] == 3'd0 ? 'd8 :   //SINGLE 64bit
128
                        burst_addr[1:0] == 2'd0 ? 'd4 :   //SINGLE 32bit
129
                        burst_addr[0]   == 1'd0 ? 'd2 :   //SINGLE 16bit
130
                        'd1;                              //SINGLE 8 bite
131
 
132
 
133
   assign            burst_size_pre2 =
134
               |burst_size_pre[8-1:7]  ? 'd128 :
135
               burst_size_pre[6]                ? 'd64 :
136
               burst_size_pre[5]                ? 'd32 :
137
               |burst_size_pre[4:3]             ? 'd8 :
138
               burst_size_pre[2]                ? 'd4 :
139
               burst_size_pre[1]                ? 'd2 :
140
               burst_size_pre[0]                ? 'd1 : 'd0;
141
 
142
 
143
 
144
 
145
 
146
 
147
   assign            fifo_not_ready_pre = (fifo_remain < burst_size_pre2) & (~release_fifo);
148
 
149
   prgen_delay #(1) delay_fifo_not_ready (.clk(clk), .reset(reset), .din(fifo_not_ready_pre), .dout(fifo_not_ready));
150
 
151
   assign            burst_last = burst_size == x_remain;
152
 
153
   always @(posedge clk or posedge reset)
154
     if (reset)
155
       burst_ready <= #1 1'b0;
156
     else if (ch_update | ch_update_d | ch_update_d2 | ch_update_d3)
157
       burst_ready <= #1 1'b0;
158
     else if (load_req_in_prog)
159
       burst_ready <= #1 1'b1;
160
     else if (|joint_burst_req)
161
       burst_ready <= #1 1'b1;
162
     else if (joint_line_req & (~joint_buffer_small))
163
       burst_ready <= #1 1'b1;
164
     else if (load_in_prog | fifo_not_ready_pre | joint_wait | (page_cross & (burst_size != burst_size_pre2)))
165
       burst_ready <= #1 1'b0;
166
     else
167
       burst_ready <= #1 |burst_size_pre2;
168
 
169
   always @(posedge clk or posedge reset)
170
     if (reset)
171
       burst_size  <= #1 {8{1'b0}};
172
     else if (load_req_in_prog)
173
       burst_size  <= #1 CMD_SIZE;
174
     else if (|joint_burst_req)
175
       burst_size  <= #1 joint_burst_req_size;
176
     else if (joint_line_req & (~joint_buffer_small))
177
       burst_size  <= #1 joint_line_req_size;
178
     else
179
       burst_size  <= #1 burst_size_pre2;
180
 
181
 
182
 
183
   assign            joint_update = ch_update | ch_update_d | ch_update_d2;
184
 
185
   always @(posedge clk or posedge reset)
186
     if (reset)
187
       joint_burst_req_reg <= #1 2'b00;
188
     else if (joint_update | joint_flush | joint_flush_in)
189
       joint_burst_req_reg <= #1 2'b00;
190
     else if (joint_burst_req_reg & burst_start)
191
       joint_burst_req_reg <= #1 2'b00;
192
     else if (joint_burst_req_in)
193
       joint_burst_req_reg <= #1 joint_burst_req_reg[0] ? 2'b11 : 2'b01;
194
 
195
   assign            joint_burst_req = joint_burst_req_reg;
196
 
197
   always @(posedge clk or posedge reset)
198
     if (reset)
199
       joint_line_req_reg <= #1 1'b0;
200
     else if (joint_update | joint_flush | joint_flush_in)
201
       joint_line_req_reg <= #1 1'b0;
202
     else if (joint_line_req_reg & burst_start)
203
       joint_line_req_reg <= #1 1'b0;
204
     else if (joint_line_req_in)
205
       joint_line_req_reg <= #1 1'b1;
206
 
207
   assign            joint_line_req = joint_line_req_reg;
208
 
209
   assign            joint_line_req_size =
210
               burst_addr[2:0] == 3'd0 ? 4'd8 :
211
               burst_addr[1:0] == 2'd0 ? 'd4 :
212
               burst_addr[0]   == 1'd0 ? 'd2 : 'd1;
213
 
214
   assign            joint_burst_req_size = joint_burst_req[1] ? 'd32 : (0 ? 'd16 : 'd8);
215
 
216
   dma_ahb64_core0_ch_calc_joint #(READ)
217
   dma_ahb64_core0_ch_calc_joint (
218
                   .clk(clk),
219
                   .reset(reset),
220
                   .joint_update(joint_update),
221
                   .ch_end(ch_end),
222
                   .ch_end_flush(ch_end_flush),
223
                   .joint_line_req_clr(joint_line_req_clr),
224
                   .burst_size_pre2(burst_size_pre2),
225
                   .burst_max_size(burst_max_size),
226
                   .fifo_not_ready(fifo_not_ready),
227
                   .wr_cmd_pending(wr_cmd_pending),
228
                   .outs_empty(outs_empty),
229
                   .x_remain(x_remain),
230
                   .fifo_wr_ready(fifo_wr_ready),
231
                   .fifo_remain(fifo_remain),
232
                   .joint(joint),
233
                   .joint_ready_in(joint_ready_in),
234
                   .joint_ready_out(joint_ready_out),
235
                   .joint_line_req(joint_line_req_out),
236
                   .joint_burst_req(joint_burst_req_out),
237
                   .joint_wait(joint_wait),
238
                   .page_cross(page_cross),
239
                   .joint_cross(joint_cross),
240
                   .joint_flush(joint_flush),
241
                   .joint_flush_in(joint_flush_in),
242
                   .joint_buffer_small(joint_buffer_small)
243
                   );
244
 
245
   assign            release_fifo         =  joint_ready_in & joint_ready_out & (~joint_cross);
246
 
247
 
248
 
249
 
250
endmodule
251
 
252
 

powered by: WebSVN 2.1.0

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