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

Subversion Repositories usb_fpga_2_13

[/] [usb_fpga_2_13/] [trunk/] [examples/] [usb-fpga-1.11/] [1.11a/] [memtest/] [fpga/] [memtest.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
library ieee;
2
use IEEE.std_logic_1164.all;
3
use IEEE.std_logic_arith.all;
4
use IEEE.std_logic_unsigned.all;
5
 
6
entity memtest is
7
    port(
8
        FXCLK         : in std_logic;
9
        RESET_IN      : in std_logic;
10
        IFCLK         : in std_logic;
11
 
12
        -- FX2 FIFO
13
        FD            : out std_logic_vector(15 downto 0);
14
 
15
        SLOE          : out std_logic;
16
        SLRD          : out std_logic;
17
        SLWR          : out std_logic;
18
        FIFOADR0      : out std_logic;
19
        FIFOADR1      : out std_logic;
20
        PKTEND        : out std_logic;
21
 
22
        FLAGB         : in std_logic;
23
        PA3           : in std_logic;
24
 
25
        -- errors ...
26
        PC            : out std_logic_vector(7 downto 0);
27
 
28
        -- DDR-SDRAM
29
        mcb3_dram_dq    : inout std_logic_vector(15 downto 0);
30
        mcb3_rzq        : inout std_logic;
31
        mcb3_zio        : inout std_logic;
32
        mcb3_dram_udqs  : inout std_logic;
33
        mcb3_dram_dqs   : inout std_logic;
34
        mcb3_dram_a     : out std_logic_vector(12 downto 0);
35
        mcb3_dram_ba    : out std_logic_vector(1 downto 0);
36
        mcb3_dram_cke   : out std_logic;
37
        mcb3_dram_ras_n : out std_logic;
38
        mcb3_dram_cas_n : out std_logic;
39
        mcb3_dram_we_n  : out std_logic;
40
        mcb3_dram_dm    : out std_logic;
41
        mcb3_dram_udm   : out std_logic;
42
        mcb3_dram_ck    : out std_logic;
43
        mcb3_dram_ck_n  : out std_logic
44
    );
45
end memtest;
46
 
47
architecture RTL of memtest is
48
 
49
component dcm0
50
    port (
51
        -- Clock in ports
52
        CLK_IN1           : in     std_logic;
53
        -- Clock out ports
54
        CLK_OUT1          : out    std_logic;
55
        CLK_OUT2          : out    std_logic;
56
        -- Status and control signals
57
        RESET             : in     std_logic;
58
        LOCKED            : out    std_logic;
59
        CLK_VALID         : out    std_logic
60
    );
61
end component;
62
 
63
component mem0
64
    generic (
65
        C3_P0_MASK_SIZE       : integer := 4;
66
        C3_P0_DATA_PORT_SIZE  : integer := 32;
67
        C3_P1_MASK_SIZE       : integer := 4;
68
        C3_P1_DATA_PORT_SIZE  : integer := 32;
69
        C3_MEMCLK_PERIOD      : integer := 5000;
70
        C3_INPUT_CLK_TYPE     : string := "SINGLE_ENDED";
71
        C3_RST_ACT_LOW        : integer := 0;
72
        C3_CALIB_SOFT_IP      : string := "FALSE";
73
        C3_MEM_ADDR_ORDER     : string := "ROW_BANK_COLUMN";
74
        C3_NUM_DQ_PINS        : integer := 16;
75
        C3_MEM_ADDR_WIDTH     : integer := 13;
76
        C3_MEM_BANKADDR_WIDTH : integer := 2
77
    );
78
 
79
   port (
80
        mcb3_dram_dq         : inout std_logic_vector(C3_NUM_DQ_PINS-1 downto 0);
81
        mcb3_dram_a          : out std_logic_vector(C3_MEM_ADDR_WIDTH-1 downto 0);
82
        mcb3_dram_ba         : out std_logic_vector(C3_MEM_BANKADDR_WIDTH-1 downto 0);
83
        mcb3_dram_cke        : out std_logic;
84
        mcb3_dram_ras_n      : out std_logic;
85
        mcb3_dram_cas_n      : out std_logic;
86
        mcb3_dram_we_n       : out std_logic;
87
        mcb3_dram_dm         : out std_logic;
88
        mcb3_dram_udqs       : inout std_logic;
89
        mcb3_rzq             : inout std_logic;
90
        mcb3_dram_udm        : out std_logic;
91
        mcb3_dram_dqs        : inout std_logic;
92
        mcb3_dram_ck         : out std_logic;
93
        mcb3_dram_ck_n       : out std_logic;
94
 
95
        c3_sys_clk           : in std_logic;
96
        c3_sys_rst_n         : in std_logic;
97
 
98
        c3_calib_done        : out std_logic;
99
        c3_clk0              : out std_logic;
100
        c3_rst0              : out std_logic;
101
 
102
        c3_p0_cmd_clk        : in std_logic;
103
        c3_p0_cmd_en         : in std_logic;
104
        c3_p0_cmd_instr      : in std_logic_vector(2 downto 0);
105
        c3_p0_cmd_bl         : in std_logic_vector(5 downto 0);
106
        c3_p0_cmd_byte_addr  : in std_logic_vector(29 downto 0);
107
        c3_p0_cmd_empty      : out std_logic;
108
        c3_p0_cmd_full       : out std_logic;
109
        c3_p0_wr_clk         : in std_logic;
110
        c3_p0_wr_en          : in std_logic;
111
        c3_p0_wr_mask        : in std_logic_vector(C3_P0_MASK_SIZE - 1 downto 0);
112
        c3_p0_wr_data        : in std_logic_vector(C3_P0_DATA_PORT_SIZE - 1 downto 0);
113
        c3_p0_wr_full        : out std_logic;
114
        c3_p0_wr_empty       : out std_logic;
115
        c3_p0_wr_count       : out std_logic_vector(6 downto 0);
116
        c3_p0_wr_underrun    : out std_logic;
117
        c3_p0_wr_error       : out std_logic;
118
        c3_p0_rd_clk         : in std_logic;
119
        c3_p0_rd_en          : in std_logic;
120
        c3_p0_rd_data        : out std_logic_vector(C3_P0_DATA_PORT_SIZE - 1 downto 0);
121
        c3_p0_rd_full        : out std_logic;
122
        c3_p0_rd_empty       : out std_logic;
123
        c3_p0_rd_count       : out std_logic_vector(6 downto 0);
124
        c3_p0_rd_overflow    : out std_logic;
125
        c3_p0_rd_error       : out std_logic;
126
 
127
        c3_p1_cmd_clk        : in std_logic;
128
        c3_p1_cmd_en         : in std_logic;
129
        c3_p1_cmd_instr      : in std_logic_vector(2 downto 0);
130
        c3_p1_cmd_bl         : in std_logic_vector(5 downto 0);
131
        c3_p1_cmd_byte_addr  : in std_logic_vector(29 downto 0);
132
        c3_p1_cmd_empty      : out std_logic;
133
        c3_p1_cmd_full       : out std_logic;
134
        c3_p1_wr_clk         : in std_logic;
135
        c3_p1_wr_en          : in std_logic;
136
        c3_p1_wr_mask        : in std_logic_vector(C3_P1_MASK_SIZE - 1 downto 0);
137
        c3_p1_wr_data        : in std_logic_vector(C3_P1_DATA_PORT_SIZE - 1 downto 0);
138
        c3_p1_wr_full        : out std_logic;
139
        c3_p1_wr_empty       : out std_logic;
140
        c3_p1_wr_count       : out std_logic_vector(6 downto 0);
141
        c3_p1_wr_underrun    : out std_logic;
142
        c3_p1_wr_error       : out std_logic;
143
        c3_p1_rd_clk         : in std_logic;
144
        c3_p1_rd_en          : in std_logic;
145
        c3_p1_rd_data        : out std_logic_vector(C3_P1_DATA_PORT_SIZE - 1 downto 0);
146
        c3_p1_rd_full        : out std_logic;
147
        c3_p1_rd_empty       : out std_logic;
148
        c3_p1_rd_count       : out std_logic_vector(6 downto 0);
149
        c3_p1_rd_overflow    : out std_logic;
150
        c3_p1_rd_error       : out std_logic;
151
 
152
        c3_p2_cmd_clk        : in std_logic;
153
        c3_p2_cmd_en         : in std_logic;
154
        c3_p2_cmd_instr      : in std_logic_vector(2 downto 0);
155
        c3_p2_cmd_bl         : in std_logic_vector(5 downto 0);
156
        c3_p2_cmd_byte_addr  : in std_logic_vector(29 downto 0);
157
        c3_p2_cmd_empty      : out std_logic;
158
        c3_p2_cmd_full       : out std_logic;
159
        c3_p2_wr_clk         : in std_logic;
160
        c3_p2_wr_en          : in std_logic;
161
        c3_p2_wr_mask        : in std_logic_vector(3 downto 0);
162
        c3_p2_wr_data        : in std_logic_vector(31 downto 0);
163
        c3_p2_wr_full        : out std_logic;
164
        c3_p2_wr_empty       : out std_logic;
165
        c3_p2_wr_count       : out std_logic_vector(6 downto 0);
166
        c3_p2_wr_underrun    : out std_logic;
167
        c3_p2_wr_error       : out std_logic;
168
 
169
        c3_p3_cmd_clk        : in std_logic;
170
        c3_p3_cmd_en         : in std_logic;
171
        c3_p3_cmd_instr      : in std_logic_vector(2 downto 0);
172
        c3_p3_cmd_bl         : in std_logic_vector(5 downto 0);
173
        c3_p3_cmd_byte_addr  : in std_logic_vector(29 downto 0);
174
        c3_p3_cmd_empty      : out std_logic;
175
        c3_p3_cmd_full       : out std_logic;
176
        c3_p3_rd_clk         : in std_logic;
177
        c3_p3_rd_en          : in std_logic;
178
        c3_p3_rd_data        : out std_logic_vector(31 downto 0);
179
        c3_p3_rd_full        : out std_logic;
180
        c3_p3_rd_empty       : out std_logic;
181
        c3_p3_rd_count       : out std_logic_vector(6 downto 0);
182
        c3_p3_rd_overflow    : out std_logic;
183
        c3_p3_rd_error       : out std_logic;
184
 
185
        c3_p4_cmd_clk        : in std_logic;
186
        c3_p4_cmd_en         : in std_logic;
187
        c3_p4_cmd_instr      : in std_logic_vector(2 downto 0);
188
        c3_p4_cmd_bl         : in std_logic_vector(5 downto 0);
189
        c3_p4_cmd_byte_addr  : in std_logic_vector(29 downto 0);
190
        c3_p4_cmd_empty      : out std_logic;
191
        c3_p4_cmd_full       : out std_logic;
192
        c3_p4_wr_clk         : in std_logic;
193
        c3_p4_wr_en          : in std_logic;
194
        c3_p4_wr_mask        : in std_logic_vector(3 downto 0);
195
        c3_p4_wr_data        : in std_logic_vector(31 downto 0);
196
        c3_p4_wr_full        : out std_logic;
197
        c3_p4_wr_empty       : out std_logic;
198
        c3_p4_wr_count       : out std_logic_vector(6 downto 0);
199
        c3_p4_wr_underrun    : out std_logic;
200
        c3_p4_wr_error       : out std_logic;
201
 
202
        c3_p5_cmd_clk        : in std_logic;
203
        c3_p5_cmd_en         : in std_logic;
204
        c3_p5_cmd_instr      : in std_logic_vector(2 downto 0);
205
        c3_p5_cmd_bl         : in std_logic_vector(5 downto 0);
206
        c3_p5_cmd_byte_addr  : in std_logic_vector(29 downto 0);
207
        c3_p5_cmd_empty      : out std_logic;
208
        c3_p5_cmd_full       : out std_logic;
209
        c3_p5_rd_clk         : in std_logic;
210
        c3_p5_rd_en          : in std_logic;
211
        c3_p5_rd_data        : out std_logic_vector(31 downto 0);
212
        c3_p5_rd_full        : out std_logic;
213
        c3_p5_rd_empty       : out std_logic;
214
        c3_p5_rd_count       : out std_logic_vector(6 downto 0);
215
        c3_p5_rd_overflow    : out std_logic;
216
        c3_p5_rd_error       : out std_logic
217
);
218
end component;
219
 
220
signal CLK : std_logic;
221
signal RESET0 : std_logic;      -- released after dcm0 is ready
222
signal RESET : std_logic;       -- released after MCB is ready
223
 
224
signal DCM0_LOCKED : std_logic;
225
signal DCM0_CLK_VALID : std_logic;
226
 
227
----------------------------
228
-- test pattern generator --
229
----------------------------
230
signal GEN_CNT : std_logic_vector(29 downto 0);
231
signal GEN_PATTERN : std_logic_vector(29 downto 0);
232
 
233
signal FIFO_WORD : std_logic;
234
 
235
-----------------------
236
-- memory controller --
237
-----------------------
238
signal MEM_CLK : std_logic;
239
signal C3_CALIB_DONE : std_logic;
240
signal C3_RST0 : std_logic;
241
 
242
---------------
243
-- DRAM FIFO --
244
---------------
245
signal WR_CLK       : std_logic;
246
signal WR_CMD_EN    : std_logic_vector(2 downto 0);
247
type WR_CMD_ADDR_ARRAY is array(2 downto 0) of std_logic_vector(29 downto 0);
248
signal WR_CMD_ADDR  : WR_CMD_ADDR_ARRAY;
249
signal WR_ADDR      : std_logic_vector(17 downto 0);   -- in 256 bytes burst blocks
250
signal WR_EN        : std_logic_vector(2 downto 0);
251
signal WR_EN_TMP    : std_logic_vector(2 downto 0);
252
signal WR_DATA      : std_logic_vector(31 downto 0);
253
signal WR_EMPTY     : std_logic_vector(2 downto 0);
254
signal WR_UNDERRUN  : std_logic_vector(2 downto 0);
255
signal WR_ERROR     : std_logic_vector(2 downto 0);
256
type WR_COUNT_ARRAY is array(2 downto 0) of std_logic_vector(6 downto 0);
257
signal WR_COUNT     : WR_COUNT_ARRAY;
258
signal WR_PORT      : std_logic_vector(1 downto 0);
259
 
260
signal RD_CLK       : std_logic;
261
signal RD_CMD_EN    : std_logic_vector(2 downto 0);
262
type RD_CMD_ADDR_ARRAY is array(2 downto 0) of std_logic_vector(29 downto 0);
263
signal RD_CMD_ADDR  : WR_CMD_ADDR_ARRAY;
264
signal RD_ADDR      : std_logic_vector(17 downto 0); -- in 256 bytes burst blocks
265
signal RD_EN        : std_logic_vector(2 downto 0);
266
type RD_DATA_ARRAY is array(2 downto 0) of std_logic_vector(31 downto 0);
267
signal RD_DATA      : RD_DATA_ARRAY;
268
signal RD_EMPTY     : std_logic_vector(2 downto 0);
269
signal RD_OVERFLOW  : std_logic_vector(2 downto 0);
270
signal RD_ERROR     : std_logic_vector(2 downto 0);
271
signal RD_PORT      : std_logic_vector(1 downto 0);
272
type RD_COUNT_ARRAY is array(2 downto 0) of std_logic_vector(6 downto 0);
273
signal RD_COUNT     : RD_COUNT_ARRAY;
274
 
275
signal FD_TMP        : std_logic_vector(15 downto 0);
276
 
277
signal RD_ADDR2      : std_logic_vector(17 downto 0);   -- 256 bytes burst block currently beeing read
278
signal RD_ADDR2_BAK1 : std_logic_vector(17 downto 0);   -- backup for synchronization
279
signal RD_ADDR2_BAK2 : std_logic_vector(17 downto 0);   -- backup for synchronization
280
signal WR_ADDR2      : std_logic_vector(17 downto 0);   -- 256 bytes burst block currently beeing written
281
signal WR_ADDR2_BAK1 : std_logic_vector(17 downto 0);   -- backup for synchronization
282
signal WR_ADDR2_BAK2 : std_logic_vector(17 downto 0);   -- backup for synchronization
283
 
284
signal RD_STOP       : std_logic;
285
 
286
begin
287
 
288
    inst_dcm0 : dcm0 port map(
289
        -- Clock in ports
290
        CLK_IN1            => FXCLK,
291
        -- Clock out ports
292
        CLK_OUT1           => MEM_CLK,
293
        CLK_OUT2           => CLK,
294
        -- Status and control signals
295
        RESET              => RESET_IN,
296
        LOCKED             => DCM0_LOCKED,
297
        CLK_VALID          => DCM0_CLK_VALID
298
    );
299
 
300
    inst_mem0 : mem0 port map (
301
        mcb3_dram_dq    =>  mcb3_dram_dq,
302
        mcb3_dram_a     =>  mcb3_dram_a,
303
        mcb3_dram_ba    =>  mcb3_dram_ba,
304
        mcb3_dram_ras_n =>  mcb3_dram_ras_n,
305
        mcb3_dram_cas_n =>  mcb3_dram_cas_n,
306
        mcb3_dram_we_n  =>  mcb3_dram_we_n,
307
        mcb3_dram_cke   =>  mcb3_dram_cke,
308
        mcb3_dram_ck    =>  mcb3_dram_ck,
309
        mcb3_dram_ck_n  =>  mcb3_dram_ck_n,
310
        mcb3_dram_dqs   =>  mcb3_dram_dqs,
311
        mcb3_dram_udqs  =>  mcb3_dram_udqs,    -- for X16 parts           
312
        mcb3_dram_udm   =>  mcb3_dram_udm,     -- for X16 parts
313
        mcb3_dram_dm    =>  mcb3_dram_dm,
314
        mcb3_rzq        =>  mcb3_rzq,
315
 
316
        c3_sys_clk      =>  MEM_CLK,
317
        c3_sys_rst_n    =>  RESET0,
318
 
319
        c3_clk0         =>  open,
320
        c3_rst0         =>  C3_RST0,
321
        c3_calib_done   =>  C3_CALIB_DONE,
322
 
323
        c3_p0_cmd_clk        =>  WR_CLK,
324
        c3_p0_cmd_en         =>  WR_CMD_EN(0),
325
        c3_p0_cmd_instr      =>  "000",
326
        c3_p0_cmd_bl         =>  ( others => '1' ),
327
        c3_p0_cmd_byte_addr  =>  WR_CMD_ADDR(0),
328
        c3_p0_cmd_empty      =>  open,
329
        c3_p0_cmd_full       =>  open,
330
        c3_p0_wr_clk         =>  WR_CLK,
331
        c3_p0_wr_en          =>  WR_EN(0),
332
        c3_p0_wr_mask        =>  ( others => '0' ),
333
        c3_p0_wr_data        =>  WR_DATA,
334
        c3_p0_wr_full        =>  open,
335
        c3_p0_wr_empty       =>  WR_EMPTY(0),
336
        c3_p0_wr_count       =>  open,
337
        c3_p0_wr_underrun    =>  WR_UNDERRUN(0),
338
        c3_p0_wr_error       =>  WR_ERROR(0),
339
        c3_p0_rd_clk         =>  WR_CLK,
340
        c3_p0_rd_en          =>  '0',
341
        c3_p0_rd_data        =>  open,
342
        c3_p0_rd_full        =>  open,
343
        c3_p0_rd_empty       =>  open,
344
        c3_p0_rd_count       =>  open,
345
        c3_p0_rd_overflow    =>  open,
346
        c3_p0_rd_error       =>  open,
347
 
348
        c3_p2_cmd_clk        =>  WR_CLK,
349
        c3_p2_cmd_en         =>  WR_CMD_EN(1),
350
        c3_p2_cmd_instr      =>  "000",
351
        c3_p2_cmd_bl         =>  ( others => '1' ),
352
        c3_p2_cmd_byte_addr  =>  WR_CMD_ADDR(1),
353
        c3_p2_cmd_empty      =>  open,
354
        c3_p2_cmd_full       =>  open,
355
        c3_p2_wr_clk         =>  WR_CLK,
356
        c3_p2_wr_en          =>  WR_EN(1),
357
        c3_p2_wr_mask        =>  ( others => '0' ),
358
        c3_p2_wr_data        =>  WR_DATA,
359
        c3_p2_wr_full        =>  open,
360
        c3_p2_wr_empty       =>  WR_EMPTY(1),
361
        c3_p2_wr_count       =>  open,
362
        c3_p2_wr_underrun    =>  WR_UNDERRUN(1),
363
        c3_p2_wr_error       =>  WR_ERROR(1),
364
 
365
        c3_p4_cmd_clk        =>  WR_CLK,
366
        c3_p4_cmd_en         =>  WR_CMD_EN(2),
367
        c3_p4_cmd_instr      =>  "000",
368
        c3_p4_cmd_bl         =>  ( others => '1' ),
369
        c3_p4_cmd_byte_addr  =>  WR_CMD_ADDR(2),
370
        c3_p4_cmd_empty      =>  open,
371
        c3_p4_cmd_full       =>  open,
372
        c3_p4_wr_clk         =>  WR_CLK,
373
        c3_p4_wr_en          =>  WR_EN(2),
374
        c3_p4_wr_mask        =>  ( others => '0' ),
375
        c3_p4_wr_data        =>  WR_DATA,
376
        c3_p4_wr_full        =>  open,
377
        c3_p4_wr_empty       =>  WR_EMPTY(2),
378
        c3_p4_wr_count       =>  open,
379
        c3_p4_wr_underrun    =>  WR_UNDERRUN(2),
380
        c3_p4_wr_error       =>  WR_ERROR(2),
381
 
382
        c3_p1_cmd_clk        =>  RD_CLK,
383
        c3_p1_cmd_en         =>  RD_CMD_EN(0),
384
        c3_p1_cmd_instr      =>  "001",
385
        c3_p1_cmd_bl         =>  ( others => '1' ),
386
        c3_p1_cmd_byte_addr  =>  RD_CMD_ADDR(0),
387
        c3_p1_cmd_empty      =>  open,
388
        c3_p1_cmd_full       =>  open,
389
        c3_p1_wr_clk         =>  RD_CLK,
390
        c3_p1_wr_en          =>  '0',
391
        c3_p1_wr_mask        =>  ( others => '0' ),
392
        c3_p1_wr_data        =>  ( others => '0' ),
393
        c3_p1_wr_full        =>  open,
394
        c3_p1_wr_empty       =>  open,
395
        c3_p1_wr_count       =>  open,
396
        c3_p1_wr_underrun    =>  open,
397
        c3_p1_wr_error       =>  open,
398
        c3_p1_rd_clk         =>  RD_CLK,
399
        c3_p1_rd_en          =>  RD_EN(0),
400
        c3_p1_rd_data        =>  RD_DATA(0),
401
        c3_p1_rd_full        =>  open,
402
        c3_p1_rd_empty       =>  RD_EMPTY(0),
403
        c3_p1_rd_count       =>  open,
404
        c3_p1_rd_overflow    =>  RD_OVERFLOW(0),
405
        c3_p1_rd_error       =>  RD_ERROR(0),
406
 
407
        c3_p3_cmd_clk        =>  RD_CLK,
408
        c3_p3_cmd_en         =>  RD_CMD_EN(1),
409
        c3_p3_cmd_instr      =>  "001",
410
        c3_p3_cmd_bl         =>  ( others => '1' ),
411
        c3_p3_cmd_byte_addr  =>  RD_CMD_ADDR(1),
412
        c3_p3_cmd_empty      =>  open,
413
        c3_p3_cmd_full       =>  open,
414
        c3_p3_rd_clk         =>  RD_CLK,
415
        c3_p3_rd_en          =>  RD_EN(1),
416
        c3_p3_rd_data        =>  RD_DATA(1),
417
        c3_p3_rd_full        =>  open,
418
        c3_p3_rd_empty       =>  RD_EMPTY(1),
419
        c3_p3_rd_count       =>  open,
420
        c3_p3_rd_overflow    =>  RD_OVERFLOW(1),
421
        c3_p3_rd_error       =>  RD_ERROR(1),
422
 
423
        c3_p5_cmd_clk        =>  RD_CLK,
424
        c3_p5_cmd_en         =>  RD_CMD_EN(2),
425
        c3_p5_cmd_instr      =>  "001",
426
        c3_p5_cmd_bl         =>  ( others => '1' ),
427
        c3_p5_cmd_byte_addr  =>  RD_CMD_ADDR(2),
428
        c3_p5_cmd_empty      =>  open,
429
        c3_p5_cmd_full       =>  open,
430
        c3_p5_rd_clk         =>  RD_CLK,
431
        c3_p5_rd_en          =>  RD_EN(2),
432
        c3_p5_rd_data        =>  RD_DATA(2),
433
        c3_p5_rd_full        =>  open,
434
        c3_p5_rd_empty       =>  RD_EMPTY(2),
435
        c3_p5_rd_count       =>  open,
436
        c3_p5_rd_overflow    =>  RD_OVERFLOW(2),
437
        c3_p5_rd_error       =>  RD_ERROR(2)
438
);
439
 
440
    SLOE <= '1';
441
    SLRD <= '1';
442
    FIFOADR0 <= '0';
443
    FIFOADR1 <= '0';
444
    PKTEND <= '1';
445
 
446
    WR_CLK <= CLK;
447
    RD_CLK <= IFCLK;
448
 
449
    RESET0 <= RESET_IN or (not DCM0_LOCKED) or (not DCM0_CLK_VALID);
450
    RESET <= RESET0 or (not C3_CALIB_DONE) or C3_RST0;
451
 
452
    PC(0) <= WR_UNDERRUN(0) or WR_UNDERRUN(1) or WR_UNDERRUN(2);
453
    PC(1) <= WR_ERROR(0) or WR_ERROR(1) or WR_ERROR(2);
454
    PC(2) <= RD_OVERFLOW(0) or RD_OVERFLOW(1) or RD_OVERFLOW(2);
455
    PC(3) <= RD_ERROR(0) or RD_ERROR(1) or RD_ERROR(2);
456
    PC(4) <= C3_CALIB_DONE;
457
    PC(5) <= C3_RST0;
458
    PC(6) <= RESET0;
459
    PC(7) <= RESET;
460
 
461
    dpCLK: process (CLK, RESET)
462
    begin
463
-- reset
464
        if RESET = '1'
465
        then
466
            GEN_CNT <= ( others => '0' );
467
            GEN_PATTERN <= "100101010101010101010101010101";
468
 
469
            WR_CMD_EN      <= ( others => '0' );
470
            WR_CMD_ADDR(0) <= ( others => '0' );
471
            WR_CMD_ADDR(1) <= ( others => '0' );
472
            WR_CMD_ADDR(2) <= ( others => '0' );
473
            WR_ADDR        <= conv_std_logic_vector(3,18);
474
            WR_EN          <= ( others => '0' );
475
            WR_COUNT(0)    <= ( others => '0' );
476
            WR_COUNT(1)    <= ( others => '0' );
477
            WR_COUNT(2)    <= ( others => '0' );
478
            WR_PORT        <= ( others => '0' );
479
 
480
            WR_ADDR2       <= ( others => '0' );
481
            RD_ADDR2_BAK1  <= ( others => '0' );
482
            RD_ADDR2_BAK2  <= ( others => '0' );
483
 
484
-- CLK
485
        elsif CLK'event and CLK = '1'
486
        then
487
            WR_CMD_EN <= ( others => '0' );
488
            WR_EN <= ( others => '0' );
489
            WR_CMD_ADDR(conv_integer(WR_PORT))(25 downto 8) <= WR_ADDR;
490
 
491
            if ( WR_COUNT(conv_integer(WR_PORT)) = conv_std_logic_vector(64,7) )
492
                then
493
                -- FF flag = 1
494
                if ( RD_ADDR2_BAK1 = RD_ADDR2_BAK2 ) and ( RD_ADDR2_BAK2 /= WR_ADDR )
495
                then
496
                    WR_CMD_EN(conv_integer(WR_PORT)) <= '1';
497
                    WR_COUNT(conv_integer(WR_PORT)) <= ( others => '0' );
498
                    if WR_PORT = "10"
499
                    then
500
                        WR_PORT <= "00";
501
                    else
502
                        WR_PORT <= WR_PORT + 1;
503
                    end if;
504
                    WR_ADDR <= WR_ADDR + 1;
505
                    WR_ADDR2 <= WR_ADDR2 + 1;
506
                end if;
507
            elsif ( WR_COUNT(conv_integer(WR_PORT)) = conv_std_logic_vector(0,7)) and (WR_EMPTY(conv_integer(WR_PORT)) = '0' )  -- write port fifo not empty 
508
            then
509
                -- FF flag = 1 
510
            else
511
                WR_EN(conv_integer(WR_PORT)) <= '1';
512
                WR_DATA(31) <= '1';
513
                WR_DATA(15) <= '0';
514
                if PA3 = '1'
515
                then
516
                    WR_DATA(30 downto 16) <= GEN_PATTERN(29 downto 15);
517
                    WR_DATA(14 downto 0) <= GEN_PATTERN(14 downto 0);
518
                else
519
                    WR_DATA(30 downto 16) <= GEN_CNT(29 downto 15);
520
                    WR_DATA(14 downto 0) <= GEN_CNT(14 downto 0);
521
                end if;
522
                GEN_CNT <= GEN_CNT + 1;
523
                GEN_PATTERN(29) <= GEN_PATTERN(0);
524
                GEN_PATTERN(28 downto 0) <= GEN_PATTERN(29 downto 1);
525
--              if ( WR_COUNT(conv_integer(WR_PORT)) = conv_std_logic_vector(63,7) ) and ( RD_ADDR2_BAK1 = RD_ADDR2_BAK2 ) and ( RD_ADDR2_BAK2 /= WR_ADDR )
526
--                Add code from above here. This saves one clock cylcle and is required for uninterrupred input.
527
--              then
528
--              else
529
                    WR_COUNT(conv_integer(WR_PORT)) <= WR_COUNT(conv_integer(WR_PORT)) + 1;
530
--              end if;
531
            end if;
532
 
533
            RD_ADDR2_BAK1 <= RD_ADDR2;
534
            RD_ADDR2_BAK2 <= RD_ADDR2_BAK1;
535
 
536
        end if;
537
    end process dpCLK;
538
 
539
 
540
    dpIFCLK: process (IFCLK, RESET)
541
    begin
542
-- reset
543
        if RESET = '1'
544
        then
545
            FIFO_WORD <= '0';
546
            SLWR <= '1';
547
 
548
            RD_CMD_EN      <= ( others => '0' );
549
            RD_CMD_ADDR(0) <= ( others => '0' );
550
            RD_CMD_ADDR(1) <= ( others => '0' );
551
            RD_CMD_ADDR(2) <= ( others => '0' );
552
            RD_ADDR        <= conv_std_logic_vector(3,18);
553
            RD_EN          <= ( others => '0' );
554
            RD_COUNT(0)    <= conv_std_logic_vector(64,7);
555
            RD_COUNT(1)    <= conv_std_logic_vector(64,7);
556
            RD_COUNT(2)    <= conv_std_logic_vector(64,7);
557
            RD_PORT        <= ( others => '0' );
558
 
559
            RD_ADDR2       <= ( others => '0' );
560
            WR_ADDR2_BAK1  <= ( others => '0' );
561
            WR_ADDR2_BAK2  <= ( others => '0' );
562
 
563
            RD_STOP        <= '1';
564
 
565
-- IFCLK
566
        elsif IFCLK'event and IFCLK = '1'
567
        then
568
 
569
            RD_CMD_EN <= ( others => '0' );
570
            RD_CMD_ADDR(conv_integer(RD_PORT))(25 downto 8) <= RD_ADDR;
571
            RD_EN(conv_integer(RD_PORT)) <= '0';
572
 
573
            if FLAGB = '1'
574
            then
575
                if ( RD_EMPTY(conv_integer(RD_PORT)) = '1' ) or ( RD_COUNT(conv_integer(RD_PORT)) = conv_std_logic_vector(64,7) )
576
                then
577
                    SLWR <= '1';
578
                    if ( RD_COUNT(conv_integer(RD_PORT)) = conv_std_logic_vector(64,7) ) and ( RD_EMPTY(conv_integer(RD_PORT)) = '1' ) and ( WR_ADDR2_BAK2 = WR_ADDR2_BAK1 ) and ( WR_ADDR2_BAK2 /= RD_ADDR ) and ( RD_STOP = '0' )
579
                    then
580
                        RD_CMD_EN(conv_integer(RD_PORT)) <= '1';
581
                        RD_COUNT(conv_integer(RD_PORT)) <= ( others => '0' );
582
                        if RD_PORT = "10"
583
                        then
584
                            RD_PORT <= "00";
585
                        else
586
                            RD_PORT <= RD_PORT + 1;
587
                        end if;
588
                        RD_ADDR <= RD_ADDR + 1;
589
                        RD_ADDR2 <= RD_ADDR2 + 1;
590
                    end if;
591
                else
592
                    SLWR <= '0';
593
                    if FIFO_WORD = '0'
594
                    then
595
                        FD(15 downto 0) <= RD_DATA(conv_integer(RD_PORT))(15 downto 0);
596
                        FD_TMP <= RD_DATA(conv_integer(RD_PORT))(31 downto 16);
597
                        RD_EN(conv_integer(RD_PORT)) <= '1';
598
                    else
599
                        FD(15 downto 0) <= FD_TMP;
600
                        RD_COUNT(conv_integer(RD_PORT)) <= RD_COUNT(conv_integer(RD_PORT)) + 1;
601
                    end if;
602
                    FIFO_WORD <= not FIFO_WORD;
603
                end if;
604
            end if;
605
 
606
            WR_ADDR2_BAK1 <= WR_ADDR2;
607
            WR_ADDR2_BAK2 <= WR_ADDR2_BAK1;
608
 
609
            if ( WR_ADDR2_BAK1 = WR_ADDR2_BAK2 ) and ( WR_ADDR2_BAK2(3) = '1')
610
            then
611
                RD_STOP <= '0';
612
            end if;
613
 
614
        end if;
615
    end process dpIFCLK;
616
 
617
end RTL;

powered by: WebSVN 2.1.0

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