00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/rio/cal_block_v1_4_1.vhd,v $
00015 --* $Revision: 1.4.2.4 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:47 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023 -------------------------------------------------------------------------------
00024 --$Date: 2008/11/03 17:57:47 $
00025 --$RCSfile: cal_block_v1_4_1.vhd,v $
00026 --$Revision: 1.4.2.4 $
00027 -------------------------------------------------------------------------------
00028 ------------------------------------------------------------------------------
00029 -- MGT Calibration Block v1.4.1
00030 ------------------------------------------------------------------------------
00031 -- $Revision: 1.4.2.4 $
00032 -- $Date: 2008/11/03 17:57:47 $
00033 ------------------------------------------------------------------------------
00034 --
00035 -- ***************************************************************************
00036 -- ** Copyright(C) 2006 by Xilinx, Inc. All rights reserved. **
00037 -- ** **
00038 -- ** This text contains proprietary, confidential **
00039 -- ** information of Xilinx, Inc. , is distributed by **
00040 -- ** under license from Xilinx, Inc., and may be used, **
00041 -- ** copied and/or disclosed only pursuant to the terms **
00042 -- ** of a valid license agreement with Xilinx, Inc. **
00043 -- ** **
00044 -- ** Unmodified source code is guaranteed to place and route, **
00045 -- ** function and run at speed according to the datasheet **
00046 -- ** specification. Source code is provided "as-is", with no **
00047 -- ** obligation on the part of Xilinx to provide support. **
00048 -- ** **
00049 -- ** Xilinx Hotline support of source code IP shall only include **
00050 -- ** standard level Xilinx Hotline support, and will only address **
00051 -- ** issues and questions related to the standard released Netlist **
00052 -- ** version of the core (and thus indirectly, the original core source). **
00053 -- ** **
00054 -- ** The Xilinx Support Hotline does not have access to source **
00055 -- ** code and therefore cannot answer specific questions related **
00056 -- ** to source HDL. The Xilinx Support Hotline will only be able **
00057 -- ** to confirm the problem in the Netlist version of the core. **
00058 -- ** **
00059 -- ** This copyright and support notice must be retained as part **
00060 -- ** of this text at all times. **
00061 -- ***************************************************************************
00062 --
00063 ------------------------------------------------------------------------------
00064 -- Filename: cal_block_v1_4_1.v
00065 -- Description: DRP Calibration Block v1.4.1
00066 --
00067 -- VHDL-standard: VHDL '93
00068 ------------------------------------------------------------------------------
00069 -- Authors: Xilinx
00070 -- History:
00071 -- ML 01/27/2006 - Initial Code based on v1.4.1 VHDL version
00072 --
00073 ------------------------------------------------------------------------------
00074
00075 library ieee;
00076
00077 use ieee.std_logic_1164.all;
00078
00079 use ieee.numeric_std.all;
00080
00081 library work;
00082 use work.all;
00083
00084
00085
00086 entity cal_block_v1_4_1 is
00087 generic (
00088 C_MGT_ID : := 0;
00089 C_TXPOST_TAP_PD : := "TRUE";
00090 C_RXDIGRX : := "FALSE"
00091 );
00092
00093 port (
00094 -- User DRP Interface (destination/slave interface)
00095 USER_DO : out (16-1 downto 0);
00096 USER_DI : in (16-1 downto 0);
00097 USER_DADDR : in (8-1 downto 0);
00098 USER_DEN : in ;
00099 USER_DWE : in ;
00100 USER_DRDY : out ;
00101 -- MGT DRP Interface (source/master interface)
00102 GT_DO : out (16-1 downto 0);
00103 GT_DI : in (16-1 downto 0);
00104 GT_DADDR : out (8-1 downto 0);
00105 GT_DEN : out ;
00106 GT_DWE : out ;
00107 GT_DRDY : in ;
00108 -- DRP Clock and Reset
00109 DCLK : in ;
00110 RESET : in ;
00111 -- Calibration Block Active and Disable Signals (legacy)
00112 ACTIVE : out ;
00113 -- User side MGT Pass through Signals
00114 USER_LOOPBACK : in (1 downto 0);
00115 USER_TXENC8B10BUSE : in ;
00116 USER_TXBYPASS8B10B : in (7 downto 0);
00117 -- GT side MGT Pass through Signals
00118 GT_LOOPBACK : out (1 downto 0);
00119 GT_TXENC8B10BUSE : out ;
00120 GT_TXBYPASS8B10B : out (7 downto 0);
00121 -- Signal Detect Ports
00122 TX_SIGNAL_DETECT : in ;
00123 RX_SIGNAL_DETECT : in
00124 );
00125
00126
00127 attribute use_sync_reset : ;
00128 attribute use_sync_reset of cal_block_v1_4_1 : entity is "yes";
00129
00130 attribute use_sync_set : ;
00131 attribute use_sync_set of cal_block_v1_4_1 : entity is "yes";
00132
00133 attribute use_clock_enable : ;
00134 attribute use_clock_enable of cal_block_v1_4_1 : entity is "yes";
00135
00136 attribute use_dsp48 : ;
00137 attribute use_dsp48 of cal_block_v1_4_1 : entity is "no";
00138
00139 end cal_block_v1_4_1;
00140
00141
00142
00143 architecture rtl of cal_block_v1_4_1 is
00144
00145 ----------------------------------------------------------------------------
00146 -- Function Declaration
00147 ----------------------------------------------------------------------------
00148
00149 function ExtendString (string_in : ;
00150 string_len : )
00151 return is
00152 variable string_out : (1 to string_len) := (others => ' ');
00153
00154 begin
00155 if string_in'length > string_len then
00156 string_out := string_in(1 to string_len);
00157 else
00158 string_out(1 to string_in'length) := string_in;
00159 end if;
00160 return string_out;
00161 end ExtendString;
00162
00163
00164 function StringToBool (S : ) return is
00165 begin
00166 if (ExtendString(S, 5) = "TRUE ") then
00167 return true;
00168 elsif (ExtendString(S, 5) = "FALSE") then
00169 return false;
00170 else
00171 return false;
00172 end if;
00173 end function StringToBool;
00174
00175 ----------------------------------------------------------------------------
00176 -- Constants
00177 ----------------------------------------------------------------------------
00178 constant C_DRP_DWIDTH : := 16;
00179 constant C_DRP_AWIDTH : := 8;
00180
00181 ----------------------------------------------------------------------------
00182 -- Signals
00183 ----------------------------------------------------------------------------
00184 signal reset_r : (1 downto 0);
00185 signal user_di_r : (C_DRP_DWIDTH-1 downto 0) := (others => '0');
00186 signal user_daddr_r : (C_DRP_AWIDTH-3 downto 0);
00187 signal user_den_r : ;
00188 signal user_req : ;
00189 signal user_dwe_r : ;
00190 signal user_drdy_i : ;
00191 signal gt_drdy_r : := '0';
00192 signal gt_do_r : (C_DRP_DWIDTH-1 downto 0) := (others => '0');
00193 signal rxdigrx_cache : ;
00194 signal txpost_tap_pd_cache : ;
00195 signal gt_do_r_sel : (2 downto 0);
00196 signal gt_daddr_sel : (2 downto 0);
00197 signal c_rx_digrx_addr : (C_DRP_AWIDTH-1 downto 0);
00198 signal c_tx_pt_addr : (C_DRP_AWIDTH-1 downto 0);
00199 signal c_txpost_tap_pd_bin : ;
00200 signal c_rxdigrx_bin : ;
00201 signal user_sel : ;
00202 signal sd_sel : ;
00203 signal sd_req : := '0';
00204 signal sd_read : := '0';
00205 signal sd_write : := '0';
00206 signal sd_drp_done : := '0';
00207 signal sd_wr_wreg : (C_DRP_DWIDTH-1 downto 0) := (others => '0');
00208 signal sd_addr_r : (C_DRP_AWIDTH-3 downto 0);
00209 signal drp_rd : ;
00210 signal drp_wr : ;
00211 signal cb_state : (3 downto 0);
00212 signal cb_next_state : (3 downto 0);
00213 signal drp_state : (4 downto 0);
00214 signal drp_next_state : (4 downto 0);
00215 signal sd_state : (13 downto 0);
00216 signal sd_next_state : (13 downto 0);
00217
00218 ----------------------------------------------------------------------------
00219 -- Arbitration FSM
00220 ----------------------------------------------------------------------------
00221 constant C_RESET : (3 downto 0) := "0001";
00222 constant C_IDLE : (3 downto 0) := "0010";
00223 constant C_SD_DRP_OP : (3 downto 0) := "0100";
00224 constant C_USER_DRP_OP : (3 downto 0) := "1000";
00225
00226 ----------------------------------------------------------------------------
00227 -- DRP FSM
00228 ----------------------------------------------------------------------------
00229 constant C_DRP_IDLE : (4 downto 0) := "00001";
00230 constant C_DRP_READ : (4 downto 0) := "00010";
00231 constant C_DRP_WRITE : (4 downto 0) := "00100";
00232 constant C_DRP_WAIT : (4 downto 0) := "01000";
00233 constant C_DRP_COMPLETE : (4 downto 0) := "10000";
00234
00235 ----------------------------------------------------------------------------
00236 -- Signal Detect Indicator FSM
00237 ----------------------------------------------------------------------------
00238 constant C_SD_IDLE : (13 downto 0) := "00000000000001";
00239 constant C_SD_RD_PT_ON : (13 downto 0) := "00000000000010";
00240 constant C_SD_MD_PT_ON : (13 downto 0) := "00000000000100";
00241 constant C_SD_WR_PT_ON : (13 downto 0) := "00000000001000";
00242 constant C_SD_RD_RXDIGRX_ON : (13 downto 0) := "00000000010000";
00243 constant C_SD_MD_RXDIGRX_ON : (13 downto 0) := "00000000100000";
00244 constant C_SD_WR_RXDIGRX_ON : (13 downto 0) := "00000001000000";
00245 constant C_SD_WAIT : (13 downto 0) := "00000010000000";
00246 constant C_SD_RD_RXDIGRX_RESTORE : (13 downto 0) := "00000100000000";
00247 constant C_SD_MD_RXDIGRX_RESTORE : (13 downto 0) := "00001000000000";
00248 constant C_SD_WR_RXDIGRX_RESTORE : (13 downto 0) := "00010000000000";
00249 constant C_SD_RD_PT_OFF : (13 downto 0) := "00100000000000";
00250 constant C_SD_MD_PT_OFF : (13 downto 0) := "01000000000000";
00251 constant C_SD_WR_PT_OFF : (13 downto 0) := "10000000000000";
00252
00253 ----------------------------------------------------------------------------
00254 -- Make Addresses for MGTA or MGTB at compile time
00255 ----------------------------------------------------------------------------
00256 constant C_MGTA_RX_DIGRX_ADDR : (7 downto 0) := "01111101"; --7Dh
00257 constant C_MGTA_TX_PT_ADDR : (7 downto 0) := "01001100"; --4Ch
00258 constant C_MGTB_RX_DIGRX_ADDR : (7 downto 0) := "01011001"; --59h
00259 constant C_MGTB_TX_PT_ADDR : (7 downto 0) := "01001110"; --4Eh
00260
00261 begin
00262
00263 use_mgt_b : if (C_MGT_ID /= 0) generate
00264 begin
00265 c_rx_digrx_addr <= C_MGTB_RX_DIGRX_ADDR;
00266 c_tx_pt_addr <= C_MGTB_TX_PT_ADDR;
00267 end generate use_mgt_b;
00268
00269 use_mgt_a : if (C_MGT_ID = 0) generate
00270 begin
00271 c_rx_digrx_addr <= C_MGTA_RX_DIGRX_ADDR;
00272 c_tx_pt_addr <= C_MGTA_TX_PT_ADDR;
00273 end generate use_mgt_a;
00274
00275 ----------------------------------------------------------------------------
00276 -- Convert C_TXPOST_TAP_PD from ASCII text "TRUE"/"FALSE" to binary value
00277 ----------------------------------------------------------------------------
00278 use_txpost_tap_pd_true : if (StringToBool(C_TXPOST_TAP_PD) = true) generate
00279 begin
00280 c_txpost_tap_pd_bin <= '1';
00281 end generate;
00282
00283 use_txpost_tap_pd_false : if (StringToBool(C_TXPOST_TAP_PD) = false) generate
00284 begin
00285 c_txpost_tap_pd_bin <= '0';
00286 end generate;
00287
00288 ----------------------------------------------------------------------------
00289 -- Convert C_RXDIGRX from ASCII text "TRUE"/"FALSE" to binary value
00290 ----------------------------------------------------------------------------
00291 use_rxdigrx_true : if (StringToBool(C_RXDIGRX) = true) generate
00292 begin
00293 c_rxdigrx_bin <= '1';
00294 end generate;
00295
00296 use_rxdigrx_false : if (StringToBool(C_RXDIGRX) = false) generate
00297 begin
00298 c_rxdigrx_bin <= '0';
00299 end generate;
00300
00301
00302 process (DCLK, RESET)
00303 begin
00304 if (RESET = '1') then
00305 reset_r <= "11";
00306 elsif (rising_edge(DCLK)) then
00307 reset_r <= '0' & reset_r(1);
00308 end if;
00309 end process;
00310
00311 ----------------------------------------------------------------------------
00312 -- User DRP Transaction Capture Input Registers
00313 ----------------------------------------------------------------------------
00314
00315 process (DCLK)
00316 begin
00317 if (rising_edge(DCLK)) then
00318 if (USER_DEN = '1') then
00319 user_di_r <= USER_DI;
00320 end if;
00321 end if;
00322 end process;
00323
00324
00325 process (DCLK)
00326 begin
00327 if (rising_edge(DCLK)) then
00328 if (USER_DEN = '1') then
00329 user_daddr_r <= USER_DADDR(C_DRP_AWIDTH-3 downto 0);
00330 end if;
00331 end if;
00332 end process;
00333
00334
00335 process (DCLK)
00336 begin
00337 if (rising_edge(DCLK)) then
00338 if (reset_r(0) = '1') then
00339 user_dwe_r <= '0';
00340 elsif (USER_DEN = '1') then
00341 user_dwe_r <= USER_DWE;
00342 end if;
00343 end if;
00344 end process;
00345
00346
00347
00348 process (DCLK)
00349 begin
00350 if (rising_edge(DCLK)) then
00351 if ((reset_r(0) = '1') or
00352 (cb_state = C_USER_DRP_OP) or
00353 ((USER_DADDR(7) = '1') or (USER_DADDR(6) = '0'))) then
00354 user_den_r <= '0';
00355 elsif (user_den_r = '0') then
00356 user_den_r <= USER_DEN;
00357 end if;
00358 end if;
00359 end process;
00360
00361
00362
00363
00364 process (DCLK)
00365 begin
00366 if (rising_edge(DCLK)) then
00367 if ((reset_r(0) = '1') or (cb_state = C_USER_DRP_OP)) then
00368
00369 user_req <= '0';
00370
00371 elsif (
00372 (not(user_daddr_r(5 downto 0) = c_rx_digrx_addr(5 downto 0))) and
00373 (not(user_daddr_r(5 downto 0) = c_tx_pt_addr(5 downto 0)))
00374 ) then
00375
00376 user_req <= user_den_r;
00377
00378 elsif ((sd_state = C_SD_IDLE) or (sd_state = C_SD_WAIT)) then
00379
00380 user_req <= user_den_r;
00381
00382 end if;
00383 end if;
00384 end process;
00385
00386
00387 process (DCLK)
00388 begin
00389 if (rising_edge(DCLK)) then
00390 if ((cb_state = C_USER_DRP_OP) and (GT_DRDY = '1')) then
00391 USER_DO <= GT_DI;
00392 end if;
00393 end if;
00394 end process;
00395
00396
00397 process (DCLK)
00398 begin
00399 if (rising_edge(DCLK)) then
00400 if ((reset_r(0) = '1') or (user_drdy_i = '1')) then
00401 user_drdy_i <= '0';
00402 elsif (cb_state = C_USER_DRP_OP) then
00403 user_drdy_i <= GT_DRDY;
00404 end if;
00405 end if;
00406 end process;
00407
00408 USER_DRDY <= user_drdy_i;
00409
00410
00411 process (DCLK)
00412 begin
00413 if (rising_edge(DCLK)) then
00414 if (cb_state = C_RESET) then
00415 ACTIVE <= '0';
00416 else
00417 if ((not (cb_state = C_IDLE)) and
00418 (not (cb_state = C_USER_DRP_OP))) then
00419 ACTIVE <= '1';
00420 else
00421 ACTIVE <= '0';
00422 end if;
00423 end if;
00424 end if;
00425 end process;
00426
00427
00428
00429
00430 process (DCLK)
00431 begin
00432 if (rising_edge(DCLK)) then
00433 if (reset_r(0) = '1') then
00434 rxdigrx_cache <= c_rxdigrx_bin;
00435 elsif ((drp_state = C_DRP_WRITE) and
00436 (cb_state = C_USER_DRP_OP) and
00437 (user_daddr_r(5 downto 0) = c_rx_digrx_addr(5 downto 0))) then
00438 rxdigrx_cache <= user_di_r(1);
00439 end if;
00440 end if;
00441 end process;
00442
00443
00444
00445
00446 process (DCLK)
00447 begin
00448 if (rising_edge(DCLK)) then
00449 if (reset_r(0) = '1') then
00450 txpost_tap_pd_cache <= c_txpost_tap_pd_bin;
00451 elsif ((drp_state = C_DRP_WRITE) and
00452 (cb_state = C_USER_DRP_OP) and
00453 (user_daddr_r(5 downto 0) = c_tx_pt_addr(5 downto 0))) then
00454 txpost_tap_pd_cache <= user_di_r(12);
00455 end if;
00456 end if;
00457 end process;
00458
00459 ----------------------------------------------------------------------------
00460 -- GT DRP Interface
00461 ----------------------------------------------------------------------------
00462 gt_do_r_sel <= sd_sel & '0' & user_sel;
00463
00464
00465 process (DCLK)
00466 begin
00467 if (rising_edge(DCLK)) then
00468
00469 if (gt_do_r_sel(2) = '1') then
00470 gt_do_r <= sd_wr_wreg;
00471 elsif (gt_do_r_sel = "001") then
00472 gt_do_r <= user_di_r;
00473 else
00474 null;
00475 end if;
00476
00477 end if;
00478 end process;
00479
00480 GT_DO <= gt_do_r;
00481 gt_daddr_sel <= sd_sel & '0' & user_sel;
00482
00483
00484
00485 process (DCLK)
00486 begin
00487 if (rising_edge(DCLK)) then
00488
00489 if (gt_daddr_sel(2) = '1') then
00490 GT_DADDR(5 downto 0) <= sd_addr_r(5 downto 0);
00491 elsif (gt_daddr_sel = "001") then
00492 GT_DADDR(5 downto 0) <= user_daddr_r(5 downto 0);
00493 else
00494 null;
00495 end if;
00496
00497 GT_DADDR(7 downto 6) <= "01";
00498
00499 end if;
00500 end process;
00501
00502
00503
00504 process (DCLK)
00505 begin
00506 if (rising_edge(DCLK)) then
00507 if (reset_r(0) = '1') then
00508 GT_DEN <= '0';
00509 else
00510 if ((drp_state = C_DRP_IDLE) and
00511 ((drp_wr = '1') or (drp_rd = '1'))) then
00512 GT_DEN <= '1';
00513 else
00514 GT_DEN <= '0';
00515 end if;
00516 end if;
00517 end if;
00518 end process;
00519
00520 -- GT Data Write Enable
00521 GT_DWE <= '1' when (drp_state = C_DRP_WRITE) else '0';
00522
00523
00524 process (DCLK)
00525 begin
00526 if (rising_edge(DCLK)) then
00527 gt_drdy_r <= GT_DRDY;
00528 end if;
00529 end process;
00530
00531 ----------------------------------------------------------------------------
00532 -- Calibration Block Internal Logic: The different select signals are
00533 -- generated for a user DRP operations as well as internal Calibration Block
00534 -- accesses.
00535 ----------------------------------------------------------------------------
00536 sd_sel <= '1' when (cb_state = C_SD_DRP_OP) else '0';
00537 user_sel <= '1' when (cb_state = C_USER_DRP_OP) else '0';
00538
00539
00540 process (DCLK)
00541 begin
00542 if (rising_edge(DCLK)) then
00543 if (reset_r(0) = '1') then
00544 cb_state <= C_RESET;
00545 else
00546 cb_state <= cb_next_state;
00547 end if;
00548 end if;
00549 end process;
00550
00551
00552 process (cb_state, sd_req, user_req, gt_drdy_r)
00553 variable cb_fsm_name : (1 to 25);
00554 begin
00555 case cb_state is
00556
00557 when C_RESET =>
00558
00559 cb_next_state <= C_IDLE;
00560 cb_fsm_name := ExtendString("C_RESET", 25);
00561
00562 when C_IDLE =>
00563
00564 if (sd_req = '1') then
00565 cb_next_state <= C_SD_DRP_OP;
00566 elsif (user_req = '1') then
00567 cb_next_state <= C_USER_DRP_OP;
00568 else
00569 cb_next_state <= C_IDLE;
00570 end if;
00571
00572 cb_fsm_name := ExtendString("C_IDLE", 25);
00573
00574 when C_SD_DRP_OP =>
00575
00576 if (gt_drdy_r = '1') then
00577 cb_next_state <= C_IDLE;
00578 else
00579 cb_next_state <= C_SD_DRP_OP;
00580 end if;
00581
00582 cb_fsm_name := ExtendString("C_SD_DRP_OP", 25);
00583
00584 when C_USER_DRP_OP =>
00585
00586 if (gt_drdy_r = '1') then
00587 cb_next_state <= C_IDLE;
00588 else
00589 cb_next_state <= C_USER_DRP_OP;
00590 end if;
00591
00592 cb_fsm_name := ExtendString("C_USER_DRP_OP", 25);
00593
00594 when others =>
00595
00596 cb_next_state <= C_IDLE;
00597 cb_fsm_name := ExtendString("default", 25);
00598
00599 end case;
00600 end process;
00601
00602 ----------------------------------------------------------------------------
00603 -- Signal Detect Block Internal Logic
00604 ----------------------------------------------------------------------------
00605
00606 process (DCLK)
00607 begin
00608 if (rising_edge(DCLK)) then
00609 if ((sd_state = C_SD_IDLE) or (sd_drp_done = '1')) then
00610 sd_req <= '0';
00611 else
00612 sd_req <= sd_read or sd_write;
00613 end if;
00614 end if;
00615 end process;
00616
00617
00618 process (DCLK)
00619 begin
00620 if (rising_edge(DCLK)) then
00621 if ((sd_state = C_SD_IDLE) or (sd_drp_done = '1')) then
00622 sd_read <= '0';
00623 else
00624 if ((sd_state = C_SD_RD_PT_ON) or
00625 (sd_state = C_SD_RD_RXDIGRX_ON) or
00626 (sd_state = C_SD_RD_RXDIGRX_RESTORE) or
00627 (sd_state = C_SD_RD_PT_OFF)) then
00628 sd_read <= '1';
00629 else
00630 sd_read <= '0';
00631 end if;
00632 end if;
00633 end if;
00634 end process;
00635
00636
00637 process (DCLK)
00638 begin
00639 if (rising_edge(DCLK)) then
00640 if ((sd_state = C_SD_IDLE) or (sd_drp_done = '1')) then
00641 sd_write <= '0';
00642 else
00643 if ((sd_state = C_SD_WR_PT_ON) or
00644 (sd_state = C_SD_WR_RXDIGRX_ON) or
00645 (sd_state = C_SD_WR_RXDIGRX_RESTORE) or
00646 (sd_state = C_SD_WR_PT_OFF)) then
00647 sd_write <= '1';
00648 else
00649 sd_write <= '0';
00650 end if;
00651 end if;
00652 end if;
00653 end process;
00654
00655
00656 process (DCLK)
00657 begin
00658 if (rising_edge(DCLK)) then
00659 if ((cb_state = C_SD_DRP_OP) and (sd_read = '1') and (GT_DRDY = '1')) then
00660 sd_wr_wreg <= GT_DI;
00661 else
00662 case sd_state is
00663
00664 when C_SD_MD_PT_ON =>
00665 sd_wr_wreg <= sd_wr_wreg(15 downto 13) & '0' &
00666 sd_wr_wreg(11 downto 0);
00667 when C_SD_MD_RXDIGRX_ON =>
00668 sd_wr_wreg <= sd_wr_wreg(15 downto 2) & '1' & sd_wr_wreg(0);
00669 when C_SD_MD_RXDIGRX_RESTORE =>
00670 sd_wr_wreg <= sd_wr_wreg(15 downto 2) & rxdigrx_cache &
00671 sd_wr_wreg(0);
00672 when C_SD_MD_PT_OFF =>
00673 sd_wr_wreg <= sd_wr_wreg(15 downto 13) & txpost_tap_pd_cache &
00674 sd_wr_wreg(11 downto 0);
00675 when others =>
00676 null;
00677 end case;
00678 end if;
00679 end if;
00680 end process;
00681
00682
00683 process (sd_state)
00684 begin
00685 case sd_state is
00686 when C_SD_RD_PT_ON =>
00687 sd_addr_r(5 downto 0) <= c_tx_pt_addr(5 downto 0);
00688 when C_SD_WR_PT_ON =>
00689 sd_addr_r(5 downto 0) <= c_tx_pt_addr(5 downto 0);
00690 when C_SD_RD_PT_OFF =>
00691 sd_addr_r(5 downto 0) <= c_tx_pt_addr(5 downto 0);
00692 when C_SD_WR_PT_OFF =>
00693 sd_addr_r(5 downto 0) <= c_tx_pt_addr(5 downto 0);
00694 when C_SD_RD_RXDIGRX_ON =>
00695 sd_addr_r(5 downto 0) <= c_rx_digrx_addr(5 downto 0);
00696 when C_SD_WR_RXDIGRX_ON =>
00697 sd_addr_r(5 downto 0) <= c_rx_digrx_addr(5 downto 0);
00698 when C_SD_RD_RXDIGRX_RESTORE =>
00699 sd_addr_r(5 downto 0) <= c_rx_digrx_addr(5 downto 0);
00700 when C_SD_WR_RXDIGRX_RESTORE =>
00701 sd_addr_r(5 downto 0) <= c_rx_digrx_addr(5 downto 0);
00702 when others =>
00703 sd_addr_r(5 downto 0) <= c_tx_pt_addr(5 downto 0);
00704 end case;
00705 end process;
00706
00707
00708 process (DCLK)
00709 begin
00710 if (rising_edge(DCLK)) then
00711 if ((GT_DRDY = '1') and (cb_state = C_SD_DRP_OP)) then
00712 sd_drp_done <= '1';
00713 else
00714 sd_drp_done <= '0';
00715 end if;
00716 end if;
00717 end process;
00718
00719
00720
00721
00722 process (DCLK)
00723 begin
00724 if (rising_edge(DCLK)) then
00725 if (reset_r(0) = '1') then
00726 GT_LOOPBACK <= "00";
00727 elsif (RX_SIGNAL_DETECT = '0') then
00728 GT_LOOPBACK <= "11";
00729 else
00730 GT_LOOPBACK <= USER_LOOPBACK;
00731 end if;
00732 end if;
00733 end process;
00734
00735 GT_TXBYPASS8B10B <= USER_TXBYPASS8B10B when (TX_SIGNAL_DETECT = '1') else
00736 "00000000";
00737 GT_TXENC8B10BUSE <= USER_TXENC8B10BUSE when (TX_SIGNAL_DETECT = '1') else
00738 '1';
00739
00740 ----------------------------------------------------------------------------
00741
00742
00743 process (DCLK)
00744 begin
00745 if (rising_edge(DCLK)) then
00746 if (reset_r(0) = '1') then
00747 sd_state <= C_SD_IDLE;
00748 else
00749 sd_state <= sd_next_state;
00750 end if;
00751 end if;
00752 end process;
00753
00754 process (sd_state, RX_SIGNAL_DETECT, sd_drp_done)
00755 variable sd_fsm_name : (1 to 25);
00756 begin
00757 case sd_state is
00758
00759 when C_SD_IDLE =>
00760
00761 if (RX_SIGNAL_DETECT = '0') then
00762 sd_next_state <= C_SD_RD_PT_ON;
00763 else
00764 sd_next_state <= C_SD_IDLE;
00765 end if;
00766
00767 sd_fsm_name := ExtendString("C_SD_IDLE", 25);
00768
00769 when C_SD_RD_PT_ON =>
00770
00771 if (sd_drp_done = '1') then
00772 sd_next_state <= C_SD_MD_PT_ON;
00773 else
00774 sd_next_state <= C_SD_RD_PT_ON;
00775 end if;
00776
00777 sd_fsm_name := ExtendString("C_SD_RD_PT_ON", 25);
00778
00779 when C_SD_MD_PT_ON =>
00780
00781 sd_next_state <= C_SD_WR_PT_ON;
00782 sd_fsm_name := ExtendString("C_SD_MD_PT_ON", 25);
00783
00784 when C_SD_WR_PT_ON =>
00785
00786 if (sd_drp_done = '1') then
00787 sd_next_state <= C_SD_RD_RXDIGRX_ON;
00788 else
00789 sd_next_state <= C_SD_WR_PT_ON;
00790 end if;
00791
00792 sd_fsm_name := ExtendString("C_SD_WR_PT_ON", 25);
00793
00794 when C_SD_RD_RXDIGRX_ON =>
00795
00796 if (sd_drp_done = '1') then
00797 sd_next_state <= C_SD_MD_RXDIGRX_ON;
00798 else
00799 sd_next_state <= C_SD_RD_RXDIGRX_ON;
00800 end if;
00801
00802 sd_fsm_name := ExtendString("C_SD_RD_RXDIGRX_ON", 25);
00803
00804 when C_SD_MD_RXDIGRX_ON =>
00805
00806 sd_next_state <= C_SD_WR_RXDIGRX_ON;
00807 sd_fsm_name := ExtendString("C_SD_MD_RXDIGRX_ON", 25);
00808
00809 when C_SD_WR_RXDIGRX_ON =>
00810
00811 if (sd_drp_done = '1') then
00812 sd_next_state <= C_SD_WAIT;
00813 else
00814 sd_next_state <= C_SD_WR_RXDIGRX_ON;
00815 end if;
00816
00817 sd_fsm_name := ExtendString("C_SD_WR_RXDIGRX_ON", 25);
00818
00819 when C_SD_WAIT =>
00820
00821 if (RX_SIGNAL_DETECT = '1') then
00822 sd_next_state <= C_SD_RD_RXDIGRX_RESTORE;
00823 else
00824 sd_next_state <= C_SD_WAIT;
00825 end if;
00826
00827 sd_fsm_name := ExtendString("C_SD_WAIT", 25);
00828
00829 when C_SD_RD_RXDIGRX_RESTORE =>
00830
00831 if (sd_drp_done = '1') then
00832 sd_next_state <= C_SD_MD_RXDIGRX_RESTORE;
00833 else
00834 sd_next_state <= C_SD_RD_RXDIGRX_RESTORE;
00835 end if;
00836
00837 sd_fsm_name := ExtendString("C_SD_RD_RXDIGRX_RESTORE", 25);
00838
00839 when C_SD_MD_RXDIGRX_RESTORE =>
00840
00841 sd_next_state <= C_SD_WR_RXDIGRX_RESTORE;
00842 sd_fsm_name := ExtendString("C_SD_MD_RXDIGRX_RESTORE", 25);
00843
00844 when C_SD_WR_RXDIGRX_RESTORE =>
00845
00846 if (sd_drp_done = '1') then
00847 sd_next_state <= C_SD_RD_PT_OFF;
00848 else
00849 sd_next_state <= C_SD_WR_RXDIGRX_RESTORE;
00850 end if;
00851
00852 sd_fsm_name := ExtendString("C_SD_WR_RXDIGRX_RESTORE", 25);
00853
00854 when C_SD_RD_PT_OFF =>
00855
00856 if (sd_drp_done = '1') then
00857 sd_next_state <= C_SD_MD_PT_OFF;
00858 else
00859 sd_next_state <= C_SD_RD_PT_OFF;
00860 end if;
00861
00862 sd_fsm_name := ExtendString("C_SD_RD_PT_OFF", 25);
00863
00864 when C_SD_MD_PT_OFF =>
00865
00866 sd_next_state <= C_SD_WR_PT_OFF;
00867 sd_fsm_name := ExtendString("C_SD_MD_PT_OFF", 25);
00868
00869 when C_SD_WR_PT_OFF =>
00870
00871 if (sd_drp_done = '1') then
00872 sd_next_state <= C_SD_IDLE;
00873 else
00874 sd_next_state <= C_SD_WR_PT_OFF;
00875 end if;
00876
00877 sd_fsm_name := ExtendString("C_SD_WR_PT_OFF", 25);
00878
00879 when others =>
00880
00881 sd_next_state <= C_SD_IDLE;
00882 sd_fsm_name := ExtendString("default", 25);
00883
00884 end case;
00885 end process;
00886
00887 ----------------------------------------------------------------------------
00888 -- DRP Read/Write FSM
00889 ----------------------------------------------------------------------------
00890 -- Generate a read signal for the DRP
00891 drp_rd <= '1' when (((cb_state = C_SD_DRP_OP) and (sd_read = '1')) or
00892 ((cb_state = C_USER_DRP_OP) and (user_dwe_r = '0')))
00893 else '0';
00894
00895 -- Generate a write signal for the DRP
00896 drp_wr <= '1' when (((cb_state = C_SD_DRP_OP) and (sd_write = '1')) or
00897 ((cb_state = C_USER_DRP_OP) and (user_dwe_r = '1')))
00898 else '0';
00899
00900
00901 process (DCLK)
00902 begin
00903 if (rising_edge(DCLK)) then
00904 if (reset_r(0) = '1') then
00905 drp_state <= C_DRP_IDLE;
00906 else
00907 drp_state <= drp_next_state;
00908 end if;
00909 end if;
00910 end process;
00911
00912
00913 process (drp_state, drp_rd, drp_wr, gt_drdy_r)
00914 variable drp_fsm_name : (1 to 25);
00915 begin
00916 case drp_state is
00917 when C_DRP_IDLE =>
00918
00919 if (drp_wr = '1') then
00920 drp_next_state <= C_DRP_WRITE;
00921 else
00922 if (drp_rd = '1') then
00923 drp_next_state <= C_DRP_READ;
00924 else
00925 drp_next_state <= C_DRP_IDLE;
00926 end if;
00927 end if;
00928
00929 drp_fsm_name := ExtendString("C_DRP_IDLE", 25);
00930
00931 when C_DRP_READ =>
00932
00933 drp_next_state <= C_DRP_WAIT;
00934 drp_fsm_name := ExtendString("C_DRP_READ", 25);
00935
00936 when C_DRP_WRITE =>
00937
00938 drp_next_state <= C_DRP_WAIT;
00939 drp_fsm_name := ExtendString("C_DRP_WRITE", 25);
00940
00941 when C_DRP_WAIT =>
00942
00943 if (gt_drdy_r = '1') then
00944 drp_next_state <= C_DRP_COMPLETE;
00945 else
00946 drp_next_state <= C_DRP_WAIT;
00947 end if;
00948
00949 drp_fsm_name := ExtendString("C_DRP_WAIT", 25);
00950
00951 when C_DRP_COMPLETE =>
00952
00953 drp_next_state <= C_DRP_IDLE;
00954 drp_fsm_name := ExtendString("C_DRP_COMPLETE", 25);
00955
00956 when others =>
00957 drp_next_state <= C_DRP_IDLE;
00958 drp_fsm_name := ExtendString("default", 25);
00959
00960 end case;
00961 end process;
00962
00963 end rtl;
00964