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

Subversion Repositories dma_axi

[/] [dma_axi/] [trunk/] [src/] [dma_axi32/] [dma_axi32_core0_axim_cmd.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:34:52 2011
33
//--
34
//-- Source file: dma_core_axim_cmd.v
35
//---------------------------------------------------------
36
 
37
 
38
 
39
module dma_axi32_core0_axim_cmd(clk,reset,ch_num,burst_start,burst_addr,burst_size,end_line_cmd,extra_bit,cmd_port,joint_req,joint_pending,cmd_pending,cmd_full,cmd_split,cmd_num,cmd_line,page_cross,AID,AADDR,APORT,ALEN,ASIZE,AVALID,AREADY,AWVALID,AJOINT,axim_timeout_num,axim_timeout);
40
 
41
   parameter                  AXI_WORD_SIZE = 1 ? 2'b10 : 2'b11;
42
   parameter                  AXI_2 = 1 ? 2 : 3;
43
 
44
   input               clk;
45
   input               reset;
46
 
47
   input [2:0]               ch_num;
48
 
49
   input               burst_start;
50
   input [32-1:0]      burst_addr;
51
   input [7-1:0]     burst_size;
52
   input               end_line_cmd;
53
   input               extra_bit;
54
   input               cmd_port;
55
   input               joint_req;
56
 
57
   output               joint_pending;
58
   output               cmd_pending;
59
   input               cmd_full;
60
   output               cmd_split;
61
   output [2:0]           cmd_num;
62
   output               cmd_line;
63
 
64
   output               page_cross;
65
 
66
   output [`CMD_BITS-1:0]     AID;
67
   output [32-1:0]     AADDR;
68
   output               APORT;
69
   output [`LEN_BITS-1:0]     ALEN;
70
   output [1:0]           ASIZE;
71
   output               AVALID;
72
   input               AREADY;
73
   input               AWVALID;
74
   output               AJOINT;
75
 
76
   output [2:0]           axim_timeout_num;
77
   output               axim_timeout;
78
 
79
 
80
 
81
   reg [`CMD_BITS-1:0]           AID;
82
   reg [`CMD_BITS-1:0]           AID_reg;
83
   reg [32-1:0]           AADDR;
84
   reg                   APORT;
85
   reg [`LEN_BITS-1:0]           ALEN;
86
   reg [1:0]               ASIZE;
87
   reg                   AVALID_reg;
88
   reg                   AJOINT;
89
 
90
 
91
   wire [`CMD_BITS-1:0]       AID_pre;
92
   wire [32-1:0]       AADDR_pre;
93
   wire [1:0]               ASIZE_pre;
94
   wire [`LEN_BITS-1:0]       ALEN_pre;
95
   wire [7-1:0]      burst_length;
96
 
97
   wire               cmd;
98
   reg                   cmd_pending;
99
   wire               cmd_line_pre;
100
   wire               cmd_line;
101
 
102
   wire               high_addr_pre;
103
   wire               high_addr;
104
   wire [8:0]               burst_reach_pre;
105
   reg [8:0]               burst_reach;
106
   reg                   joint_cross;
107
   wire               page_cross_pre;
108
   wire               page_cross;
109
   wire               cross_start;
110
   wire               cross_start_d;
111
   wire [8:0]               max_burst;
112
   reg [8:0]               max_burst_d;
113
   reg                   next_burst;
114
   reg [7-1:0]       next_burst_size;
115
   wire               next_burst_start;
116
 
117
 
118
 
119
 
120
   assign               high_addr_pre    = burst_addr[11:8] == 4'hf;
121
   assign               burst_reach_pre  = burst_addr[7:0] + burst_size;
122
   assign               page_cross       = high_addr & (burst_reach > {1'b1, {8{1'b0}}});
123
   assign               max_burst        = {1'b1, {8{1'b0}}} - burst_addr[7:0];
124
   assign               next_burst_start = next_burst & (~AVALID_reg) & (~cmd_full);
125
   assign               cross_start      = burst_start & page_cross;
126
 
127
 
128
   prgen_delay #(1) delay_high_addr (.clk(clk), .reset(reset), .din(high_addr_pre), .dout(high_addr));
129
   prgen_delay #(1) delay_cross_start (.clk(clk), .reset(reset), .din(cross_start), .dout(cross_start_d));
130
 
131
 
132
   always @(posedge clk or posedge reset)
133
     if (reset)
134
       burst_reach <= #1 {9{1'b0}};
135
     else if (high_addr_pre)
136
       burst_reach <= #1 burst_reach_pre;
137
 
138
   always @(posedge clk or posedge reset)
139
     if (reset)
140
       next_burst <= #1 1'b0;
141
     else if (next_burst_start)
142
       next_burst <= #1 1'b0;
143
     else if (cross_start)
144
       next_burst <= #1 1'b1;
145
 
146
   always @(posedge clk or posedge reset)
147
     if (reset)
148
       max_burst_d <= #1 {9{1'b0}};
149
     else if (cross_start)
150
       max_burst_d <= #1 max_burst;
151
 
152
   always @(posedge clk or posedge reset)
153
     if (reset)
154
       next_burst_size <= #1 {7{1'b0}};
155
     else if (cross_start)
156
       next_burst_size <= #1 burst_size;
157
     else if (cross_start_d)
158
       next_burst_size <= #1 next_burst_size - max_burst_d;
159
 
160
   assign               cmd_split       = cross_start_d;
161
 
162
   assign               cmd             = AVALID & AREADY;
163
   assign               cmd_num         = AID[2:0];
164
   assign               cmd_line_pre    = cmd & AID[6];
165
 
166
   assign               joint_pending   = AVALID & (~AREADY) & AJOINT;
167
 
168
   always @(posedge clk or posedge reset)
169
     if (reset)
170
       cmd_pending <= #1 1'b0;
171
     else if (burst_start)
172
       cmd_pending <= #1 1'b1;
173
     else if (cmd & (~next_burst))
174
       cmd_pending <= #1 1'b0;
175
 
176
 
177
   prgen_delay #(1) delay_cmd_line (.clk(clk), .reset(reset), .din(cmd_line_pre), .dout(cmd_line));
178
 
179
   assign               AID_pre = {
180
                     end_line_cmd,   //[6]
181
                     ASIZE_pre[1:0], //[5:4]
182
                     extra_bit,      //[3]
183
                     ch_num[2:0]     //[2:0]
184
                     };
185
 
186
   assign               AADDR_pre = burst_addr;
187
 
188
   assign               ASIZE_pre =
189
                  burst_size == 'd1 ? 2'b00 :
190
                  burst_size == 'd2 ? 2'b01 :
191
                  burst_size == 'd4 ? 2'b10 :
192
                  AXI_WORD_SIZE;
193
 
194
   assign               burst_length =
195
                  next_burst    ? next_burst_size :
196
                  page_cross    ? max_burst       : burst_size;
197
 
198
   assign               ALEN_pre =
199
                  burst_length[7-1:AXI_2] == 'd0 ? {`LEN_BITS{1'b0}} :
200
                  burst_length[7-1:AXI_2] - 1'b1;
201
 
202
 
203
   always @(posedge clk or posedge reset)
204
     if (reset)
205
       begin
206
      ASIZE  <= #1 {2{1'b0}};
207
      AJOINT <= #1 1'b0;
208
       end
209
     else if (burst_start)
210
       begin
211
      ASIZE  <= #1 ASIZE_pre;
212
      AJOINT <= #1 joint_req;
213
       end
214
 
215
   always @(posedge clk or posedge reset)
216
     if (reset)
217
       AID_reg <= #1 {`CMD_BITS{1'b0}};
218
     else if (burst_start)
219
       AID_reg <= #1 AID_pre;
220
 
221
   always @(AID_reg or next_burst)
222
     begin
223
    AID               = AID_reg;
224
    AID[`ID_END_LINE] = AID_reg[`ID_END_LINE] & (~next_burst);
225
    AID[`ID_LAST]     = AID_reg[`ID_LAST] & (~next_burst);
226
     end
227
 
228
   always @(posedge clk or posedge reset)
229
     if (reset)
230
       AADDR  <= #1 {32{1'b0}};
231
     else if (next_burst_start)
232
       AADDR  <= #1 {AADDR[32-1:12], {12{1'b1}}} + 1'b1;
233
     else if (burst_start)
234
       AADDR  <= #1 AADDR_pre;
235
 
236
   always @(posedge clk or posedge reset)
237
     if (reset)
238
       APORT <= #1 1'b0;
239
     else if (burst_start)
240
       APORT <= #1 cmd_port;
241
 
242
   always @(posedge clk or posedge reset)
243
     if (reset)
244
       ALEN   <= #1 {`LEN_BITS{1'b0}};
245
     else if (burst_start | next_burst_start)
246
       ALEN   <= #1 ALEN_pre;
247
 
248
   always @(posedge clk or posedge reset)
249
     if (reset)
250
       AVALID_reg <= #1 1'b0;
251
     else if (AVALID & AREADY)
252
       AVALID_reg <= #1 1'b0;
253
     else if ((burst_start & (burst_size > 'd0)) | next_burst_start)
254
       AVALID_reg <= #1 1'b1;
255
 
256
   assign AVALID = AJOINT ? AVALID_reg & (~AWVALID) : AVALID_reg;
257
 
258
   dma_axi32_core0_axim_timeout  dma_axi32_axim_timeout (
259
                         .clk(clk),
260
                         .reset(reset),
261
                         .VALID(AVALID),
262
                         .READY(AREADY),
263
                         .ID(AID),
264
                         .axim_timeout_num(axim_timeout_num),
265
                         .axim_timeout(axim_timeout)
266
                         );
267
 
268
 
269
endmodule
270
 
271
 
272
 
273
 
274
 

powered by: WebSVN 2.1.0

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