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