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 2

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:34:53 2011
5
//--
6
//-- Source file: dma_ch_calc_size.v
7
//---------------------------------------------------------
8
 
9
 
10
 
11
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);
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 [7-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 [7-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       = 16; //4*32 bit
55
 
56
 
57
   wire [7-1:0]   burst_size_pre;
58
   wire [7-1:0]   x_remain_fifo;
59
   wire [7-1:0]   max_burst_align;
60
   wire [7-1:0]   burst_size_pre2;
61
   reg [7-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 [7-1:0]   joint_burst_req_size;
74
   reg                joint_line_req_reg;
75
   wire            joint_line_req;
76
   wire [7-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:7] ? {1'b1, {7-1{1'b0}}} : x_remain[7-1:0];
83
 
84
 
85
   prgen_min3 #(7) 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
   //address align, do not cross 16 bit or 32 bit boundary
96
   assign            max_burst_align =
97
                          burst_addr[0] ? 'd1 : // byte
98
                          burst_addr[1] ? 'd2 : // 16 bit
99
                          {1'b1, {7-1{1'b0}}}; //no restriction
100
 
101
 
102
   assign            burst_size_pre2 =
103
               |burst_size_pre[7-1:2] ? {burst_size_pre[7-1:2], 2'b00} : //burst
104
 
105
               burst_size_pre[1]               ? 'd2 :
106
               burst_size_pre[0]               ? 'd1 : 'd0;
107
 
108
 
109
 
110
 
111
   assign            fifo_not_ready_pre = (fifo_remain < burst_size_pre2) & (~release_fifo);
112
 
113
   prgen_delay #(1) delay_fifo_not_ready (.clk(clk), .reset(reset), .din(fifo_not_ready_pre), .dout(fifo_not_ready));
114
 
115
   assign            burst_last = burst_size == x_remain;
116
 
117
   always @(posedge clk or posedge reset)
118
     if (reset)
119
       burst_ready <= #1 1'b0;
120
     else if (ch_update | ch_update_d | ch_update_d2 | ch_update_d3)
121
       burst_ready <= #1 1'b0;
122
     else if (load_req_in_prog)
123
       burst_ready <= #1 1'b1;
124
     else if (|joint_burst_req)
125
       burst_ready <= #1 1'b1;
126
     else if (joint_line_req & (~joint_buffer_small))
127
       burst_ready <= #1 1'b1;
128
     else if (load_in_prog | fifo_not_ready_pre | joint_wait | (page_cross & (burst_size != burst_size_pre2)))
129
       burst_ready <= #1 1'b0;
130
     else
131
       burst_ready <= #1 |burst_size_pre2;
132
 
133
   always @(posedge clk or posedge reset)
134
     if (reset)
135
       burst_size  <= #1 {7{1'b0}};
136
     else if (load_req_in_prog)
137
       burst_size  <= #1 CMD_SIZE;
138
     else if (|joint_burst_req)
139
       burst_size  <= #1 joint_burst_req_size;
140
     else if (joint_line_req & (~joint_buffer_small))
141
       burst_size  <= #1 joint_line_req_size;
142
     else
143
       burst_size  <= #1 burst_size_pre2;
144
 
145
 
146
 
147
   assign            joint_update = ch_update | ch_update_d | ch_update_d2;
148
 
149
   always @(posedge clk or posedge reset)
150
     if (reset)
151
       joint_burst_req_reg <= #1 2'b00;
152
     else if (joint_update | joint_flush | joint_flush_in)
153
       joint_burst_req_reg <= #1 2'b00;
154
     else if (joint_burst_req_reg & burst_start)
155
       joint_burst_req_reg <= #1 2'b00;
156
     else if (joint_burst_req_in)
157
       joint_burst_req_reg <= #1 joint_burst_req_reg[0] ? 2'b11 : 2'b01;
158
 
159
   assign            joint_burst_req = joint_burst_req_reg;
160
 
161
   always @(posedge clk or posedge reset)
162
     if (reset)
163
       joint_line_req_reg <= #1 1'b0;
164
     else if (joint_update | joint_flush | joint_flush_in)
165
       joint_line_req_reg <= #1 1'b0;
166
     else if (joint_line_req_reg & burst_start)
167
       joint_line_req_reg <= #1 1'b0;
168
     else if (joint_line_req_in)
169
       joint_line_req_reg <= #1 1'b1;
170
 
171
   assign            joint_line_req = joint_line_req_reg;
172
 
173
   assign            joint_line_req_size =
174
               burst_addr[2:0] == 3'd0 ? 3'd4 :
175
               burst_addr[1:0] == 2'd0 ? 'd4 :
176
               burst_addr[0]   == 1'd0 ? 'd2 : 'd1;
177
 
178
   assign            joint_burst_req_size =
179
                          burst_addr[0]             ? 'd1  :
180
                          burst_addr[1]             ? 'd2  :
181
                          burst_addr[2] & (!1) ? 'd4  :
182
                          joint_burst_req[1]        ? 'd32 : 'd16;
183
 
184
   dma_axi32_core0_ch_calc_joint #(READ)
185
   dma_axi32_core0_ch_calc_joint (
186
                   .clk(clk),
187
                   .reset(reset),
188
                   .joint_update(joint_update),
189
                   .ch_end(ch_end),
190
                   .ch_end_flush(ch_end_flush),
191
                   .joint_line_req_clr(joint_line_req_clr),
192
                   .burst_size_pre2(burst_size_pre2),
193
                   .burst_max_size(burst_max_size),
194
                   .fifo_not_ready(fifo_not_ready),
195
                   .wr_cmd_pending(wr_cmd_pending),
196
                   .outs_empty(outs_empty),
197
                   .x_remain(x_remain),
198
                   .fifo_wr_ready(fifo_wr_ready),
199
                   .fifo_remain(fifo_remain),
200
                   .joint(joint),
201
                   .joint_ready_in(joint_ready_in),
202
                   .joint_ready_out(joint_ready_out),
203
                   .joint_line_req(joint_line_req_out),
204
                   .joint_burst_req(joint_burst_req_out),
205
                   .joint_wait(joint_wait),
206
                   .page_cross(page_cross),
207
                   .joint_cross(joint_cross),
208
                   .joint_flush(joint_flush),
209
                   .joint_flush_in(joint_flush_in),
210
                   .joint_buffer_small(joint_buffer_small)
211
                   );
212
 
213
   assign            release_fifo         =  joint_ready_in & joint_ready_out & (~joint_cross);
214
 
215
 
216
 
217
 
218
endmodule
219
 
220
 

powered by: WebSVN 2.1.0

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