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