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 3

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

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

powered by: WebSVN 2.1.0

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