w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
fx2_3fifoctl_ic.vhd
Go to the documentation of this file.
1-- $Id: fx2_3fifoctl_ic.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2012-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: fx2_3fifoctl_ic - syn
7-- Description: Cypress EZ-USB FX2 controller (3 fifo; int clk)
8--
9-- Dependencies: vlib/xlib/iob_reg_o
10-- vlib/xlib/iob_reg_i_gen
11-- vlib/xlib/iob_reg_o_gen
12-- vlib/xlib/iob_reg_io_gen
13-- memlib/fifo_2c_dram
14--
15-- Test bench: -
16-- Target Devices: generic
17-- Tool versions: xst 13.3-14.7; ghdl 0.29-0.34
18--
19-- Synthesized (xst):
20-- Date Rev ise Target flop lutl lutm slic t peri
21-- 2017-04-30 888 14.7 131013 xc6slx16-2 207 207 48 125 s 6.9/5.8
22-- 2012-01-15 453 13.3 O76x xc3s1200e-4 157 265 96 243 s 7.7/7.4
23-- 2012-01-15 453 13.3 O76x xc3s1200e-4 156 259 96 238 s 7.9/7.5
24--
25-- Revision History:
26-- Date Rev Version Comment
27-- 2017-04-30 888 1.2 BUGFIX: resolve rx fifo threshold deadlock
28-- add fsm_* monitor lines
29-- 2013-01-04 469 1.1 BUGFIX: redo rx logic, now properly pipelined
30-- 2012-01-09 453 1.0 Initial version (derived from 2fifo_ic)
31--
32------------------------------------------------------------------------------
33
34library ieee;
35use ieee.std_logic_1164.all;
36use ieee.numeric_std.all;
37
38use work.slvtypes.all;
39use work.xlib.all;
40use work.memlib.all;
41use work.fx2lib.all;
42
43entity fx2_3fifoctl_ic is -- EZ-USB FX2 controller(3 fifo; int clk)
44 generic (
45 RXFAWIDTH : positive := 5; -- receive fifo address width
46 TXFAWIDTH : positive := 5; -- transmit fifo address width
47 PETOWIDTH : positive := 7; -- packet end time-out counter width
48 CCWIDTH : positive := 5; -- chunk counter width
49 RXAEMPTY_THRES : natural := 1; -- threshold for rx aempty flag
50 TXAFULL_THRES : natural := 1; -- threshold for tx afull flag
51 TX2AFULL_THRES : natural := 1); -- threshold for tx2 afull flag
52 port (
53 CLK : in slbit; -- clock
54 RESET : in slbit := '0'; -- reset
55 RXDATA : out slv8; -- receive data out
56 RXVAL : out slbit; -- receive data valid
57 RXHOLD : in slbit; -- receive data hold
58 RXAEMPTY : out slbit; -- receive almost empty flag
59 TXDATA : in slv8; -- transmit 1 data in
60 TXENA : in slbit; -- transmit 1 data enable
61 TXBUSY : out slbit; -- transmit 1 data busy
62 TXAFULL : out slbit; -- transmit 1 almost full flag
63 TX2DATA : in slv8; -- transmit 2 data in
64 TX2ENA : in slbit; -- transmit 2 data enable
65 TX2BUSY : out slbit; -- transmit 2 data busy
66 TX2AFULL : out slbit; -- transmit 2 almost full flag
67 MONI : out fx2ctl_moni_type; -- monitor port data
68 I_FX2_IFCLK : in slbit; -- fx2: interface clock
69 O_FX2_FIFO : out slv2; -- fx2: fifo address
70 I_FX2_FLAG : in slv4; -- fx2: fifo flags
71 O_FX2_SLRD_N : out slbit; -- fx2: read enable (act.low)
72 O_FX2_SLWR_N : out slbit; -- fx2: write enable (act.low)
73 O_FX2_SLOE_N : out slbit; -- fx2: output enable (act.low)
74 O_FX2_PKTEND_N : out slbit; -- fx2: packet end (act.low)
75 IO_FX2_DATA : inout slv8 -- fx2: data lines
76 );
78
79
80architecture syn of fx2_3fifoctl_ic is
81
82 constant c_rxfifo : slv2 := c_fifo_ep4;
83 constant c_txfifo : slv2 := c_fifo_ep6;
84 constant c_tx2fifo: slv2 := c_fifo_ep8;
85
86 constant c_flag_prog : integer := 0;
87 constant c_flag_tx_ff : integer := 1;
88 constant c_flag_rx_ef : integer := 2;
89 constant c_flag_tx2_ff : integer := 3;
90
91 type state_type is (
92 s_idle, -- s_idle: idle state
93 s_rxprep0, -- s_rxprep0: switch to rx-fifo
94 s_rxprep1, -- s_rxprep1: fifo addr setup
95 s_rxprep2, -- s_rxprep2: wait for flags
96 s_rxdisp, -- s_rxdisp: read, dispatch
97 s_rxpipe, -- s_rxpipe: read, pipe wait
98 s_txprep0, -- s_txprep0: switch to tx-fifo
99 s_txprep1, -- s_txprep1: fifo addr setup
100 s_txprep2, -- s_txprep2: wait for flags
101 s_txdisp, -- s_txdisp: write, dispatch
102 s_tx2prep0, -- s_tx2prep0: switch to tx2-fifo
103 s_tx2prep1, -- s_tx2prep1: fifo addr setup
104 s_tx2prep2, -- s_tx2prep2: wait for flags
105 s_tx2disp -- s_tx2disp: write, dispatch
106 );
107
108 type regs_type is record
109 state : state_type; -- state
110 petocnt : slv(PETOWIDTH-1 downto 0); -- pktend 1 time out counter
111 pe2tocnt : slv(PETOWIDTH-1 downto 0); -- pktend 2 time out counter
112 pepend : slbit; -- pktend 1 pending
113 pe2pend : slbit; -- pktend 2 pending
114 rxpipe1 : slbit; -- read pipe 1: iob capture stage
115 rxpipe2 : slbit; -- read pipe 2: fifo write stage
116 ccnt : slv(CCWIDTH-1 downto 0); -- chunk counter
117 moni_ep4_sel : slbit; -- ep4 (rx) select
118 moni_ep6_sel : slbit; -- ep6 (tx) select
119 moni_ep8_sel : slbit; -- ep8 (tx2) select
120 moni_ep4_pf : slbit; -- ep4 (rx) prog flag
121 moni_ep6_pf : slbit; -- ep6 (tx) prog flag
122 moni_ep8_pf : slbit; -- ep8 (tx2) prog flag
123 end record regs_type;
124
125 constant petocnt_init : slv(PETOWIDTH-1 downto 0) := (others=>'0');
126 constant ccnt_init : slv(CCWIDTH-1 downto 0) := (others=>'0');
127
128 constant regs_init : regs_type := (
129 s_idle, -- state
130 petocnt_init, -- petocnt
131 petocnt_init, -- pe2tocnt
132 '0','0', -- pepend,pe2pend
133 '0','0', -- rxpipe1, rxpipe2
134 ccnt_init, -- ccnt
135 '0','0','0', -- moni_ep(4|6|8)_sel
136 '0','0','0' -- moni_ep(4|6|8)_pf
137 );
138
139 constant rxfifo_thres : natural := 3; -- required free space in rx fifo to
140 -- start rx pipeline
141
142 signal R_REGS : regs_type := regs_init; -- state registers
143 signal N_REGS : regs_type := regs_init; -- next value state regs
144
145 signal FX2_FIFO : slv2 := (others=>'0');
146 signal FX2_FIFO_CE : slbit := '0';
147 signal FX2_FLAG_N : slv4 := (others=>'0');
148 signal FX2_SLRD_N : slbit := '1';
149 signal FX2_SLWR_N : slbit := '1';
150 signal FX2_SLOE_N : slbit := '1';
151 signal FX2_PKTEND_N : slbit := '1';
152 signal FX2_DATA_CEI : slbit := '0';
153 signal FX2_DATA_CEO : slbit := '0';
154 signal FX2_DATA_OE : slbit := '0';
155 signal FX2_DATA_DO : slv8 := (others=>'0');
156
157 signal RXFIFO_DI : slv8 := (others=>'0');
158 signal RXFIFO_ENA : slbit := '0';
159 signal RXFIFO_BUSY : slbit := '0';
160 signal RXSIZE_FX2 : slv(RXFAWIDTH-1 downto 0) := (others=>'0');
161 signal RXSIZE_USR : slv(RXFAWIDTH-1 downto 0) := (others=>'0');
162 signal TXFIFO_DO : slv8 := (others=>'0');
163 signal TXFIFO_VAL : slbit := '0';
164 signal TXFIFO_HOLD : slbit := '0';
165 signal TXSIZE_FX2 : slv(TXFAWIDTH-1 downto 0) := (others=>'0');
166 signal TXSIZE_USR : slv(TXFAWIDTH-1 downto 0) := (others=>'0');
167 signal TX2FIFO_DO : slv8 := (others=>'0');
168 signal TX2FIFO_VAL : slbit := '0';
169 signal TX2FIFO_HOLD : slbit := '0';
170 signal TX2SIZE_FX2 : slv(TXFAWIDTH-1 downto 0) := (others=>'0');
171 signal TX2SIZE_USR : slv(TXFAWIDTH-1 downto 0) := (others=>'0');
172
173 signal TXBUSY_L : slbit := '0';
174 signal TX2BUSY_L : slbit := '0';
175
176 signal R_MONI_C : fx2ctl_moni_type := fx2ctl_moni_init;
177 signal R_MONI_S : fx2ctl_moni_type := fx2ctl_moni_init;
178
179begin
180
181 assert RXAEMPTY_THRES<=2**RXFAWIDTH-1 and
182 TXAFULL_THRES<=2**TXFAWIDTH-1 and
184 report "assert((RXAEMPTY|TXAFULL|TX2AFULL)_THRES <= 2**(RX|TX)FAWIDTH)-1"
185 severity failure;
186
187
188 IOB_FX2_FIFO : iob_reg_o_gen
189 generic map (
190 DWIDTH => 2,
191 INIT => '0')
192 port map (
193 CLK => I_FX2_IFCLK,
194 CE => FX2_FIFO_CE,
195 DO => FX2_FIFO,
196 PAD => O_FX2_FIFO
197 );
198
199 IOB_FX2_FLAG : iob_reg_i_gen
200 generic map (
201 DWIDTH => 4,
202 INIT => '0')
203 port map (
204 CLK => I_FX2_IFCLK,
205 CE => '1',
206 DI => FX2_FLAG_N,
207 PAD => I_FX2_FLAG
208 );
209
210 IOB_FX2_SLRD : iob_reg_o
211 generic map (
212 INIT => '1')
213 port map (
214 CLK => I_FX2_IFCLK,
215 CE => '1',
216 DO => FX2_SLRD_N,
218 );
219
220 IOB_FX2_SLWR : iob_reg_o
221 generic map (
222 INIT => '1')
223 port map (
224 CLK => I_FX2_IFCLK,
225 CE => '1',
226 DO => FX2_SLWR_N,
228 );
229
230 IOB_FX2_SLOE : iob_reg_o
231 generic map (
232 INIT => '1')
233 port map (
234 CLK => I_FX2_IFCLK,
235 CE => '1',
236 DO => FX2_SLOE_N,
238 );
239
240 IOB_FX2_PKTEND : iob_reg_o
241 generic map (
242 INIT => '1')
243 port map (
244 CLK => I_FX2_IFCLK,
245 CE => '1',
246 DO => FX2_PKTEND_N,
248 );
249
250 IOB_FX2_DATA : iob_reg_io_gen
251 generic map (
252 DWIDTH => 8,
253 PULL => "KEEP")
254 port map (
255 CLK => I_FX2_IFCLK,
256 CEI => FX2_DATA_CEI,
257 CEO => FX2_DATA_CEO,
258 OE => FX2_DATA_OE,
259 DI => RXFIFO_DI, -- input data (read from pad)
260 DO => FX2_DATA_DO, -- output data (write to pad)
262 );
263
264 RXFIFO : fifo_2c_dram -- input fifo, 2 clock, dram based
265 generic map (
266 AWIDTH => RXFAWIDTH,
267 DWIDTH => 8)
268 port map (
269 CLKW => I_FX2_IFCLK,
270 CLKR => CLK,
271 RESETW => '0',
272 RESETR => RESET,
273 DI => RXFIFO_DI,
274 ENA => RXFIFO_ENA,
275 BUSY => RXFIFO_BUSY,
276 DO => RXDATA,
277 VAL => RXVAL,
278 HOLD => RXHOLD,
279 SIZEW => RXSIZE_FX2,
280 SIZER => RXSIZE_USR
281 );
282
283 TXFIFO : fifo_2c_dram -- output fifo, 2 clock, dram based
284 generic map (
285 AWIDTH => TXFAWIDTH,
286 DWIDTH => 8)
287 port map (
288 CLKW => CLK,
289 CLKR => I_FX2_IFCLK,
290 RESETW => RESET,
291 RESETR => '0',
292 DI => TXDATA,
293 ENA => TXENA,
294 BUSY => TXBUSY_L,
295 DO => TXFIFO_DO,
296 VAL => TXFIFO_VAL,
297 HOLD => TXFIFO_HOLD,
298 SIZEW => TXSIZE_USR,
299 SIZER => TXSIZE_FX2
300 );
301
302 TX2FIFO : fifo_2c_dram -- output 2 fifo, 2 clock, dram based
303 generic map (
304 AWIDTH => TXFAWIDTH,
305 DWIDTH => 8)
306 port map (
307 CLKW => CLK,
308 CLKR => I_FX2_IFCLK,
309 RESETW => RESET,
310 RESETR => '0',
311 DI => TX2DATA,
312 ENA => TX2ENA,
313 BUSY => TX2BUSY_L,
314 DO => TX2FIFO_DO,
315 VAL => TX2FIFO_VAL,
316 HOLD => TX2FIFO_HOLD,
317 SIZEW => TX2SIZE_USR,
318 SIZER => TX2SIZE_FX2
319 );
320
321 proc_regs: process (I_FX2_IFCLK)
322 begin
323
324 if rising_edge(I_FX2_IFCLK) then
325 if RESET = '1' then
326 R_REGS <= regs_init;
327 else
328 R_REGS <= N_REGS;
329 end if;
330 end if;
331
332 end process proc_regs;
333
334 proc_next: process (R_REGS, FX2_FLAG_N, TXFIFO_VAL, TX2FIFO_VAL,
336
337 variable r : regs_type := regs_init;
338 variable n : regs_type := regs_init;
339
340 variable ififo_ce : slbit := '0';
341 variable ififo : slv2 := "00";
342
343 variable irxfifo_ena : slbit := '0';
344 variable itxfifo_hold : slbit := '0';
345 variable itx2fifo_hold : slbit := '0';
346
347 variable islrd : slbit := '0';
348 variable islwr : slbit := '0';
349 variable isloe : slbit := '0';
350 variable ipktend : slbit := '0';
351
352 variable idata_cei : slbit := '0';
353 variable idata_ceo : slbit := '0';
354 variable idata_oe : slbit := '0';
355 variable idata_do : slv8 := (others=>'0');
356
357 variable slrxok : slbit := '0';
358 variable sltxok : slbit := '0';
359 variable sltx2ok : slbit := '0';
360 variable pipeok : slbit := '0';
361 variable rxfifook : slbit := '0';
362
363 variable cc_clr : slbit := '0';
364 variable cc_cnt : slbit := '0';
365 variable cc_done : slbit := '0';
366
367 begin
368
369 r := R_REGS;
370 n := R_REGS;
371
372 ififo_ce := '0';
373 ififo := "00";
374
375 irxfifo_ena := '0';
376 itxfifo_hold := '1';
377 itx2fifo_hold := '1';
378
379 islrd := '0';
380 islwr := '0';
381 isloe := '0';
382 ipktend := '0';
383
384 idata_cei := '0';
385 idata_ceo := '0';
386 idata_oe := '0';
387 idata_do := TXFIFO_DO;
388
389 slrxok := FX2_FLAG_N(c_flag_rx_ef); -- empty flag is act.low!
390 sltxok := FX2_FLAG_N(c_flag_tx_ff); -- full flag is act.low!
391 sltx2ok := FX2_FLAG_N(c_flag_tx2_ff); -- full flag is act.low!
392 pipeok := FX2_FLAG_N(c_flag_prog); -- almost flag is act.low!
393
394 rxfifook := '0';
395 if unsigned(RXSIZE_FX2)>rxfifo_thres then -- enough space in rx fifo ?
396 rxfifook := '1';
397 end if;
398
399 cc_clr := '0';
400 cc_cnt := '0';
401 if unsigned(r.ccnt) = 0 then
402 cc_done := '1';
403 else
404 cc_done := '0';
405 end if;
406
407 n.rxpipe1 := '0';
408
409 case r.state is
410 when s_idle => -- s_idle:
411 if slrxok='1' and rxfifook='1' then -- rx data and space in fifo
412 ififo_ce := '1';
413 ififo := c_rxfifo;
414 n.state := s_rxprep1;
415 elsif sltxok='1' and (TXFIFO_VAL='1' or r.pepend='1')then
416 ififo_ce := '1';
417 ififo := c_txfifo;
418 n.state := s_txprep1;
419 elsif sltx2ok='1' and (TX2FIFO_VAL='1' or r.pe2pend='1')then
420 ififo_ce := '1';
421 ififo := c_tx2fifo;
422 n.state := s_tx2prep1;
423 end if;
424
425 when s_rxprep0 => -- s_rxprep0: switch to rx-fifo
426 ififo_ce := '1';
427 ififo := c_rxfifo;
428 n.state := s_rxprep1;
429
430 when s_rxprep1 => -- s_rxprep1: fifo addr setup
431 cc_clr := '1';
432 n.state := s_rxprep2;
433
434 when s_rxprep2 => -- s_rxprep2: wait for flags
435 isloe := '1';
436 n.state := s_rxdisp;
437
438 when s_rxdisp => -- s_rxdisp: read, dispatch
439 isloe := '1';
440 -- if chunk done and tx or pe pending and possible
441 if cc_done='1' and sltxok='1' and (TXFIFO_VAL='1' or r.pepend='1') then
442 if r.rxpipe1='1' or r.rxpipe2='1' then -- rx pipe busy ?
443 n.state := s_rxdisp; -- wait
444 else
445 n.state := s_txprep0; -- otherwise switch to tx flow
446 end if;
447 -- if chunk done and tx2 or pe2 pending and possible
448 elsif cc_done='1' and sltx2ok='1' and (TX2FIFO_VAL='1' or r.pe2pend='1')
449 then
450 if r.rxpipe1='1' or r.rxpipe2='1' then -- rx pipe busy ?
451 n.state := s_rxdisp; -- wait
452 else
453 n.state := s_tx2prep0;
454 end if;
455 -- if more rx to do and possible
456 elsif slrxok='1' and rxfifook='1' then
457 islrd := '1';
458 cc_cnt := '1';
459 n.rxpipe1 := '1';
460 if pipeok='1' then
461 n.state := s_rxdisp; -- 1 cycle read
462 --n.state := s_rxprep2; -- 2 cycle read
463 else
464 n.state := s_rxpipe;
465 end if;
466 -- otherwise back to idle
467 else
468 if r.rxpipe1='1' or r.rxpipe2='1' then -- rx pipe busy ?
469 n.state := s_rxdisp; -- wait
470 else
471 n.state := s_idle; -- to idle
472 end if;
473 end if;
474
475 when s_rxpipe => -- s_rxpipe: read, pipe wait
476 isloe := '1';
477 n.state := s_rxprep2;
478
479 when s_txprep0 => -- s_txprep0: switch to tx-fifo
480 ififo_ce := '1';
481 ififo := c_txfifo;
482 n.state := s_txprep1;
483
484 when s_txprep1 => -- s_txprep1: fifo addr setup
485 cc_clr := '1';
486 n.state := s_txprep2;
487
488 when s_txprep2 => -- s_txprep2: wait for flags
489 n.state := s_txdisp;
490
491 when s_txdisp => -- s_txdisp: write, dispatch
492 -- if chunk done and tx2 or pe2 pending and possible
493 if cc_done='1' and sltx2ok='1' and (TX2FIFO_VAL='1' or r.pe2pend='1')
494 then
495 n.state := s_tx2prep0;
496 -- if chunk done and rx pending and possible
497 elsif cc_done='1' and slrxok='1' and rxfifook='1' then
498 n.state := s_rxprep0;
499 -- if pktend to do and possible
500 elsif sltxok = '1' and r.pepend = '1' then
501 ipktend := '1';
502 n.pepend := '0';
503 n.state := s_idle;
504 -- if more tx to do and possible
505 elsif sltxok = '1' and TXFIFO_VAL = '1' then
506 cc_cnt := '1'; -- inc chunk count
507 n.pepend := '0'; -- cancel pe (avoid back-2-back tx+pe)
508 itxfifo_hold := '0';
509 idata_do := TXFIFO_DO;
510 idata_ceo := '1';
511 idata_oe := '1';
512 islwr := '1';
513 if pipeok = '1' then -- if not almost full
514 n.state := s_txdisp; -- stream
515 else
516 n.state := s_txprep1; -- wait for full flag
517 end if;
518 -- otherwise back to idle
519 else
520 n.state := s_idle;
521 end if;
522
523 when s_tx2prep0 => -- s_tx2prep0: switch to tx2-fifo
524 ififo_ce := '1';
525 ififo := c_tx2fifo;
526 n.state := s_tx2prep1;
527
528 when s_tx2prep1 => -- s_tx2prep1: fifo addr setup
529 cc_clr := '1';
530 n.state := s_tx2prep2;
531
532 when s_tx2prep2 => -- s_tx2prep2: wait for flags
533 n.state := s_tx2disp;
534
535 when s_tx2disp => -- s_tx2disp: write, dispatch
536 -- if chunk done and rx pending and possible
537 if cc_done='1' and slrxok='1' and rxfifook='1' then
538 n.state := s_rxprep0;
539 -- if chunk done and tx or pe pending and possible
540 elsif cc_done='1' and sltxok='1' and (TXFIFO_VAL='1' or r.pepend='1')
541 then
542 n.state := s_txprep0;
543 -- if pktend 2 to do and possible
544 elsif sltx2ok = '1' and r.pe2pend = '1' then
545 ipktend := '1';
546 n.pe2pend := '0';
547 n.state := s_idle;
548 -- if more tx2 to do and possible
549 elsif sltx2ok = '1' and TX2FIFO_VAL = '1' then
550 cc_cnt := '1'; -- inc chunk count
551 n.pe2pend := '0'; -- cancel pe (avoid back-2-back tx+pe)
552 itx2fifo_hold := '0';
553 idata_do := TX2FIFO_DO;
554 idata_ceo := '1';
555 idata_oe := '1';
556 islwr := '1';
557 if pipeok = '1' then -- if not almost full
558 n.state := s_tx2disp; -- stream
559 else
560 n.state := s_tx2prep1; -- wait for full flag
561 end if;
562 -- otherwise back to idle
563 else
564 n.state := s_idle;
565 end if;
566
567 when others => null;
568 end case;
569
570 -- rx pipe handling
571 idata_cei := r.rxpipe1;
572 n.rxpipe2 := r.rxpipe1;
573 irxfifo_ena := r.rxpipe2;
574
575 -- chunk counter handling
576 if cc_clr = '1' then
577 n.ccnt := (others=>'1');
578 elsif cc_cnt='1' and unsigned(r.ccnt) > 0 then
579 n.ccnt := slv(unsigned(r.ccnt) - 1);
580 end if;
581
582 -- pktend time-out handling:
583 -- if tx fifo is non-empty, set counter to max
584 -- if tx fifo is empty, count down every ifclk cycle
585 -- on 1->0 transition queue pktend request
586 if TXFIFO_VAL = '1' then
587 n.petocnt := (others=>'1');
588 else
589 if unsigned(r.petocnt) /= 0 then
590 n.petocnt := slv(unsigned(r.petocnt) - 1);
591 if unsigned(r.petocnt) = 1 then
592 n.pepend := '1';
593 end if;
594 end if;
595 end if;
596 if TX2FIFO_VAL = '1' then
597 n.pe2tocnt := (others=>'1');
598 else
599 if unsigned(r.pe2tocnt) /= 0 then
600 n.pe2tocnt := slv(unsigned(r.pe2tocnt) - 1);
601 if unsigned(r.pe2tocnt) = 1 then
602 n.pe2pend := '1';
603 end if;
604 end if;
605 end if;
606
607 n.moni_ep4_sel := '0';
608 n.moni_ep6_sel := '0';
609 n.moni_ep8_sel := '0';
610 if r.state = s_rxdisp or r.state = s_rxpipe then
611 n.moni_ep4_sel := '1';
612 n.moni_ep4_pf := not FX2_FLAG_N(c_flag_prog);
613 elsif r.state = s_txdisp then
614 n.moni_ep6_sel := '1';
615 n.moni_ep6_pf := not FX2_FLAG_N(c_flag_prog);
616 elsif r.state = s_tx2disp then
617 n.moni_ep8_sel := '1';
618 n.moni_ep8_pf := not FX2_FLAG_N(c_flag_prog);
619 end if;
620
621 N_REGS <= n;
622
623 FX2_FIFO_CE <= ififo_ce;
624 FX2_FIFO <= ififo;
625
626 FX2_SLRD_N <= not islrd;
627 FX2_SLWR_N <= not islwr;
628 FX2_SLOE_N <= not isloe;
629 FX2_PKTEND_N <= not ipktend;
630
631 FX2_DATA_CEI <= idata_cei;
632 FX2_DATA_CEO <= idata_ceo;
633 FX2_DATA_OE <= idata_oe;
634 FX2_DATA_DO <= idata_do;
635
636 RXFIFO_ENA <= irxfifo_ena;
637 TXFIFO_HOLD <= itxfifo_hold;
638 TX2FIFO_HOLD <= itx2fifo_hold;
639
640 end process proc_next;
641
642 proc_moni: process (CLK)
643 begin
644
645 if rising_edge(CLK) then
646 if RESET = '1' then
647 R_MONI_C <= fx2ctl_moni_init;
648 R_MONI_S <= fx2ctl_moni_init;
649 else
650 R_MONI_C <= fx2ctl_moni_init;
651 R_MONI_C.fifo_ep4 <= R_REGS.moni_ep4_sel;
652 R_MONI_C.fifo_ep6 <= R_REGS.moni_ep6_sel;
653 R_MONI_C.fifo_ep8 <= R_REGS.moni_ep8_sel;
654 R_MONI_C.flag_ep4_empty <= not FX2_FLAG_N(c_flag_rx_ef);
655 R_MONI_C.flag_ep4_almost <= R_REGS.moni_ep4_pf;
656 R_MONI_C.flag_ep6_full <= not FX2_FLAG_N(c_flag_tx_ff);
657 R_MONI_C.flag_ep6_almost <= R_REGS.moni_ep6_pf;
658 R_MONI_C.flag_ep8_full <= not FX2_FLAG_N(c_flag_tx2_ff);
659 R_MONI_C.flag_ep8_almost <= R_REGS.moni_ep8_pf;
660 R_MONI_C.slrd <= not FX2_SLRD_N;
661 R_MONI_C.slwr <= not FX2_SLWR_N;
662 R_MONI_C.pktend <= not FX2_PKTEND_N;
663 case R_REGS.state is
664 when s_idle => R_MONI_C.fsm_idle <= '1';
665 when s_rxprep0 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_rx <= '1';
666 when s_rxprep1 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_rx <= '1';
667 when s_rxprep2 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_rx <= '1';
668 when s_rxdisp => R_MONI_C.fsm_disp <= '1'; R_MONI_C.fsm_rx <= '1';
669 when s_rxpipe => R_MONI_C.fsm_pipe <= '1'; R_MONI_C.fsm_rx <= '1';
670 when s_txprep0 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_tx <= '1';
671 when s_txprep1 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_tx <= '1';
672 when s_txprep2 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_tx <= '1';
673 when s_txdisp => R_MONI_C.fsm_disp <= '1'; R_MONI_C.fsm_tx <= '1';
674 when s_tx2prep0 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_tx2 <= '1';
675 when s_tx2prep1 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_tx2 <= '1';
676 when s_tx2prep2 => R_MONI_C.fsm_prep <= '1'; R_MONI_C.fsm_tx2 <= '1';
677 when s_tx2disp => R_MONI_C.fsm_disp <= '1'; R_MONI_C.fsm_tx2 <= '1';
678 when others => null;
679 end case;
680
682 end if;
683 end if;
684
685 end process proc_moni;
686
687 proc_almost: process (RXSIZE_USR, TXSIZE_USR, TX2SIZE_USR)
688 begin
689
690 -- rxsize_usr is the number of bytes to read
691 -- txsize_usr is the number of bytes to write
692
693 if unsigned(RXSIZE_USR) <= RXAEMPTY_THRES then
694 RXAEMPTY <= '1';
695 else
696 RXAEMPTY <= '0';
697 end if;
698
699 if unsigned(TXSIZE_USR) <= TXAFULL_THRES then
700 TXAFULL <= '1';
701 else
702 TXAFULL <= '0';
703 end if;
704
705 if unsigned(TX2SIZE_USR) <= TX2AFULL_THRES then
706 TX2AFULL <= '1';
707 else
708 TX2AFULL <= '0';
709 end if;
710
711 end process proc_almost;
712
713 TXBUSY <= TXBUSY_L;
715
716 MONI <= R_MONI_S;
717
718end syn;
slbit := '0' TXFIFO_HOLD
slv( TXFAWIDTH- 1 downto 0) :=( others => '0') TX2SIZE_USR
slv2 := c_fifo_ep4 c_rxfifo
slv( RXFAWIDTH- 1 downto 0) :=( others => '0') RXSIZE_USR
slv( TXFAWIDTH- 1 downto 0) :=( others => '0') TXSIZE_FX2
integer := 1 c_flag_tx_ff
slv( CCWIDTH- 1 downto 0) :=( others => '0') ccnt_init
slv( TXFAWIDTH- 1 downto 0) :=( others => '0') TX2SIZE_FX2
slbit := '0' TX2FIFO_HOLD
integer := 3 c_flag_tx2_ff
slv8 :=( others => '0') FX2_DATA_DO
regs_type := regs_init N_REGS
slbit := '0' TX2FIFO_VAL
slv8 :=( others => '0') TXFIFO_DO
slv8 :=( others => '0') TX2FIFO_DO
slbit := '0' FX2_FIFO_CE
slbit := '1' FX2_PKTEND_N
fx2ctl_moni_type := fx2ctl_moni_init R_MONI_C
integer := 0 c_flag_prog
slv( TXFAWIDTH- 1 downto 0) :=( others => '0') TXSIZE_USR
slbit := '0' FX2_DATA_OE
regs_type := regs_init R_REGS
slbit := '0' RXFIFO_BUSY
slv2 := c_fifo_ep8 c_tx2fifo
regs_type :=( s_idle, petocnt_init, petocnt_init, '0', '0', '0', '0', ccnt_init, '0', '0', '0', '0', '0', '0') regs_init
fx2ctl_moni_type := fx2ctl_moni_init R_MONI_S
(s_idle,s_rxprep0,s_rxprep1,s_rxprep2,s_rxdisp,s_rxpipe,s_txprep0,s_txprep1,s_txprep2,s_txdisp,s_tx2prep0,s_tx2prep1,s_tx2prep2,s_tx2disp) state_type
slv2 :=( others => '0') FX2_FIFO
slv2 := c_fifo_ep6 c_txfifo
natural := 3 rxfifo_thres
integer := 2 c_flag_rx_ef
slbit := '0' FX2_DATA_CEO
slv( PETOWIDTH- 1 downto 0) :=( others => '0') petocnt_init
slv8 :=( others => '0') RXFIFO_DI
slv( RXFAWIDTH- 1 downto 0) :=( others => '0') RXSIZE_FX2
slv4 :=( others => '0') FX2_FLAG_N
slbit := '0' FX2_DATA_CEI
inout IO_FX2_DATA slv8
TX2AFULL_THRES natural := 1
in I_FX2_IFCLK slbit
out TX2AFULL slbit
out O_FX2_PKTEND_N slbit
out TXAFULL slbit
out TX2BUSY slbit
RXAEMPTY_THRES natural := 1
CCWIDTH positive := 5
out O_FX2_SLWR_N slbit
out O_FX2_FIFO slv2
PETOWIDTH positive := 7
TXFAWIDTH positive := 5
RXFAWIDTH positive := 5
out MONI fx2ctl_moni_type
out RXAEMPTY slbit
in RESET slbit := '0'
TXAFULL_THRES natural := 1
out O_FX2_SLRD_N slbit
out O_FX2_SLOE_N slbit
in CE slbit := '1'
in PAD slv( DWIDTH- 1 downto 0)
INIT slbit := '0'
in CLK slbit
out DI slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
in CEO slbit := '1'
in CEI slbit := '1'
PULL string := "NONE"
inout PAD slv( DWIDTH- 1 downto 0)
in DO slv( DWIDTH- 1 downto 0)
out DI slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
in CE slbit := '1'
out PAD slv( DWIDTH- 1 downto 0)
INIT slbit := '0'
in CLK slbit
in DO slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
in CE slbit := '1'
Definition: iob_reg_o.vhd:30
out PAD slbit
Definition: iob_reg_o.vhd:33
INIT slbit := '0'
Definition: iob_reg_o.vhd:27
in CLK slbit
Definition: iob_reg_o.vhd:29
in DO slbit
Definition: iob_reg_o.vhd:31
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31
Definition: xlib.vhd:35