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_rd_slicer.v
|
35 |
|
|
//---------------------------------------------------------
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
module dma_ahb64_core0_ch_rd_slicer (clk,reset,fifo_rd,fifo_rdata,fifo_rsize,rd_align,rd_ptr,rd_line_remain,wr_incr,wr_single,slice_rd,slice_rdata,slice_rsize,slice_rd_ptr,slice_rd_valid);
|
41 |
|
|
|
42 |
|
|
input clk;
|
43 |
|
|
input reset;
|
44 |
|
|
|
45 |
|
|
input fifo_rd;
|
46 |
|
|
input [64-1:0] fifo_rdata;
|
47 |
|
|
input [4-1:0] fifo_rsize;
|
48 |
|
|
input [3-1:0] rd_align;
|
49 |
|
|
input [5-1:0] rd_ptr;
|
50 |
|
|
input [4-1:0] rd_line_remain;
|
51 |
|
|
input wr_incr;
|
52 |
|
|
input wr_single;
|
53 |
|
|
|
54 |
|
|
output slice_rd;
|
55 |
|
|
output [64-1:0] slice_rdata;
|
56 |
|
|
output [4-1:0] slice_rsize;
|
57 |
|
|
output [5-1:0] slice_rd_ptr;
|
58 |
|
|
output slice_rd_valid;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
wire slice_rd_pre;
|
63 |
|
|
wire slice_rd;
|
64 |
|
|
wire [5-1:0] slice_rd_ptr;
|
65 |
|
|
reg [64-1:0] slice_rdata;
|
66 |
|
|
wire [4-1:0] slice_rsize;
|
67 |
|
|
|
68 |
|
|
wire fifo_rd_d;
|
69 |
|
|
wire slice_rd_d;
|
70 |
|
|
wire [3-1:0] rd_align_valid_pre;
|
71 |
|
|
reg [3-1:0] rd_align_valid;
|
72 |
|
|
reg [3-1:0] rd_align_d;
|
73 |
|
|
|
74 |
|
|
reg [64-1:0] next_rdata_pre;
|
75 |
|
|
reg [64-1:0] next_rdata;
|
76 |
|
|
|
77 |
|
|
reg [4-1:0] actual_rsize;
|
78 |
|
|
wire [4-1:0] actual_rsize_pre;
|
79 |
|
|
reg [4-1:0] next_rsize_reg;
|
80 |
|
|
wire [4-1:0] next_rsize;
|
81 |
|
|
wire next_rd;
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
//RDATA
|
85 |
|
|
prgen_delay #(1) delay_fifo_rd0 (.clk(clk), .reset(reset), .din(fifo_rd), .dout(fifo_rd_d));
|
86 |
|
|
prgen_delay #(2) delay_fifo_rd_valid (.clk(clk), .reset(reset), .din(fifo_rd_d), .dout(slice_rd_valid));
|
87 |
|
|
prgen_delay #(1) delay_fifo_rd1 (.clk(clk), .reset(reset), .din(slice_rd_pre), .dout(slice_rd));
|
88 |
|
|
prgen_delay #(1) delay_fifo_rd2 (.clk(clk), .reset(reset), .din(slice_rd), .dout(slice_rd_d));
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
assign rd_align_valid_pre =
|
92 |
|
|
(~wr_incr) & wr_single ? rd_align - rd_ptr[3-1:0] :
|
93 |
|
|
rd_align;
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
always @(posedge clk or posedge reset)
|
97 |
|
|
if (reset)
|
98 |
|
|
begin
|
99 |
|
|
rd_align_valid <= #1 {3{1'b0}};
|
100 |
|
|
rd_align_d <= #1 {3{1'b0}};
|
101 |
|
|
end
|
102 |
|
|
else
|
103 |
|
|
begin
|
104 |
|
|
rd_align_valid <= #1 rd_align_valid_pre;
|
105 |
|
|
rd_align_d <= #1 rd_align_valid;
|
106 |
|
|
end
|
107 |
|
|
|
108 |
|
|
always @(/*AUTOSENSE*/fifo_rdata or next_rdata or rd_align_d)
|
109 |
|
|
begin
|
110 |
|
|
case(rd_align_d[3-1:0])
|
111 |
|
|
3'd0 : slice_rdata = next_rdata[63:0];
|
112 |
|
|
3'd1 : slice_rdata = {fifo_rdata[55:0], next_rdata[7:0]};
|
113 |
|
|
3'd2 : slice_rdata = {fifo_rdata[47:0], next_rdata[15:0]};
|
114 |
|
|
3'd3 : slice_rdata = {fifo_rdata[39:0], next_rdata[23:0]};
|
115 |
|
|
3'd4 : slice_rdata = {fifo_rdata[31:0], next_rdata[31:0]};
|
116 |
|
|
3'd5 : slice_rdata = {fifo_rdata[23:0], next_rdata[39:0]};
|
117 |
|
|
3'd6 : slice_rdata = {fifo_rdata[15:0], next_rdata[47:0]};
|
118 |
|
|
3'd7 : slice_rdata = {fifo_rdata[7:0], next_rdata[55:0]};
|
119 |
|
|
endcase
|
120 |
|
|
end
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
always @(/*AUTOSENSE*/fifo_rdata or rd_align_valid)
|
124 |
|
|
begin
|
125 |
|
|
case(rd_align_valid[3-1:0])
|
126 |
|
|
3'd0 : next_rdata_pre = fifo_rdata[63:0];
|
127 |
|
|
3'd1 : next_rdata_pre = {{56{1'b0}}, fifo_rdata[63:56]};
|
128 |
|
|
3'd2 : next_rdata_pre = {{48{1'b0}}, fifo_rdata[63:48]};
|
129 |
|
|
3'd3 : next_rdata_pre = {{40{1'b0}}, fifo_rdata[63:40]};
|
130 |
|
|
3'd4 : next_rdata_pre = {{32{1'b0}}, fifo_rdata[63:32]};
|
131 |
|
|
3'd5 : next_rdata_pre = {{24{1'b0}}, fifo_rdata[63:24]};
|
132 |
|
|
3'd6 : next_rdata_pre = {{16{1'b0}}, fifo_rdata[63:16]};
|
133 |
|
|
3'd7 : next_rdata_pre = {{8{1'b0}}, fifo_rdata[63:8]};
|
134 |
|
|
endcase
|
135 |
|
|
end
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
always @(posedge clk or posedge reset)
|
140 |
|
|
if (reset)
|
141 |
|
|
next_rdata <= #1 {64{1'b0}};
|
142 |
|
|
else if (slice_rd_d)
|
143 |
|
|
next_rdata <= #1 next_rdata_pre;
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
//RSIZE
|
147 |
|
|
assign actual_rsize_pre = next_rsize + ({4{fifo_rd}} & fifo_rsize);
|
148 |
|
|
|
149 |
|
|
always @(posedge clk or posedge reset)
|
150 |
|
|
if (reset)
|
151 |
|
|
actual_rsize <= #1 {4{1'b0}};
|
152 |
|
|
else if (fifo_rd | (|next_rsize))
|
153 |
|
|
actual_rsize <= #1 actual_rsize_pre;
|
154 |
|
|
|
155 |
|
|
prgen_min2 #(4) min_rsize(
|
156 |
|
|
.a(rd_line_remain),
|
157 |
|
|
.b(actual_rsize),
|
158 |
|
|
.min(slice_rsize)
|
159 |
|
|
);
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
always @(posedge clk or posedge reset)
|
163 |
|
|
if (reset)
|
164 |
|
|
next_rsize_reg <= #1 {4{1'b0}};
|
165 |
|
|
else if (next_rd)
|
166 |
|
|
next_rsize_reg <= #1 {4{1'b0}};
|
167 |
|
|
else if (fifo_rd | slice_rd)
|
168 |
|
|
next_rsize_reg <= #1 next_rsize + ({4{fifo_rd}} & fifo_rsize);
|
169 |
|
|
|
170 |
|
|
assign next_rsize = next_rsize_reg - ({4{fifo_rd_d}} & slice_rsize);
|
171 |
|
|
|
172 |
|
|
//CMD
|
173 |
|
|
assign next_rd = (~fifo_rd) & (|next_rsize);
|
174 |
|
|
|
175 |
|
|
assign slice_rd_pre = fifo_rd | next_rd;
|
176 |
|
|
|
177 |
|
|
assign slice_rd_ptr = rd_ptr;
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
endmodule
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|