signal tx_data : std_logic_vector(4*8-1 downto 0);
signal tx_k : std_logic_vector(3 downto 0);
- signal tx_cd : std_logic_vector(3 downto 0);
signal rx_data : std_logic_vector(4*8-1 downto 0);
signal rx_k : std_logic_vector(3 downto 0);
signal rx_error : std_logic_vector(3 downto 0);
type u8_arr is array (0 to 3) of unsigned(7 downto 0);
signal cv_cnt, cv_cnt_sys : u8_arr;
- signal tx_ref_clk_i : std_logic;
-
signal powerup_ch : std_logic_vector(3 downto 0);
signal link_rx_ready_i : std_logic_vector(3 downto 0);
signal link_rx_null_i : std_logic_vector(3 downto 0);
signal rx_dlm_i : std_logic_vector(3 downto 0);
signal tx_rst_i : std_logic_vector(3 downto 0);
- signal pll_lol_i : std_logic;
+ signal lb_sel_i : std_logic_vector(3 downto 0);
+ signal lb_start_i : std_logic;
+ signal lb_start_qsys : std_logic;
- signal quad_mode : integer range 0 to 100;
+ signal quad_mode : integer range 0 to 100;
begin
-- TX ref clock
-- output only if a slave port is available in QUAD
-------------------------------------------------
- MASTER_CLK_OUT <= clk_rx_full(0) when ((quad_mode >= 8) and (IS_MODE(0) = c_IS_SLAVE)) else
- clk_rx_full(1) when ((quad_mode >= 8) and (IS_MODE(1) = c_IS_SLAVE)) else
- clk_rx_full(2) when ((quad_mode >= 8) and (IS_MODE(2) = c_IS_SLAVE)) else
- clk_rx_full(3) when ((quad_mode >= 8) and (IS_MODE(3) = c_IS_SLAVE)) else
+ MASTER_CLK_OUT <= clk_rx_full(0) when (IS_MODE(0) = c_IS_SLAVE) else
+ clk_rx_full(1) when (IS_MODE(1) = c_IS_SLAVE) else
+ clk_rx_full(2) when (IS_MODE(2) = c_IS_SLAVE) else
+ clk_rx_full(3) when (IS_MODE(3) = c_IS_SLAVE) else
'0';
-------------------------------------------------
-------------------------------------------------
-- stable RX recovered clock available
-------------------------------------------------
- TX_CLK_AVAIL_OUT <= link_rx_ready_i(0) when ((quad_mode >= 8) and (IS_MODE(0) = c_IS_SLAVE)) else
- link_rx_ready_i(1) when ((quad_mode >= 8) and (IS_MODE(1) = c_IS_SLAVE)) else
- link_rx_ready_i(2) when ((quad_mode >= 8) and (IS_MODE(2) = c_IS_SLAVE)) else
- link_rx_ready_i(3) when ((quad_mode >= 8) and (IS_MODE(3) = c_IS_SLAVE)) else
+ TX_CLK_AVAIL_OUT <= link_rx_ready_i(0) when (IS_MODE(0) = c_IS_SLAVE) else
+ link_rx_ready_i(1) when (IS_MODE(1) = c_IS_SLAVE) else
+ link_rx_ready_i(2) when (IS_MODE(2) = c_IS_SLAVE) else
+ link_rx_ready_i(3) when (IS_MODE(3) = c_IS_SLAVE) else
'1';
-------------------------------------------------
-- reset komma receive
-- output only if a slave port is available in QUAD
-------------------------------------------------
- RX_RST_OUT <= rx_rst_i(0) when ((quad_mode >= 8) and (IS_MODE(0) = c_IS_SLAVE)) else
- rx_rst_i(1) when ((quad_mode >= 8) and (IS_MODE(1) = c_IS_SLAVE)) else
- rx_rst_i(2) when ((quad_mode >= 8) and (IS_MODE(2) = c_IS_SLAVE)) else
- rx_rst_i(3) when ((quad_mode >= 8) and (IS_MODE(3) = c_IS_SLAVE)) else
+ RX_RST_OUT <= rx_rst_i(0) when (IS_MODE(0) = c_IS_SLAVE) else
+ rx_rst_i(1) when (IS_MODE(1) = c_IS_SLAVE) else
+ rx_rst_i(2) when (IS_MODE(2) = c_IS_SLAVE) else
+ rx_rst_i(3) when (IS_MODE(3) = c_IS_SLAVE) else
'0';
- RX_RST_WORD_OUT <= rx_rst_word_i(0*8+7 downto 0*8) when ((quad_mode >= 8) and (IS_MODE(0) = c_IS_SLAVE)) else
- rx_rst_word_i(1*8+7 downto 1*8) when ((quad_mode >= 8) and (IS_MODE(1) = c_IS_SLAVE)) else
- rx_rst_word_i(2*8+7 downto 2*8) when ((quad_mode >= 8) and (IS_MODE(2) = c_IS_SLAVE)) else
- rx_rst_word_i(3*8+7 downto 3*8) when ((quad_mode >= 8) and (IS_MODE(3) = c_IS_SLAVE)) else
+ RX_RST_WORD_OUT <= rx_rst_word_i(0*8+7 downto 0*8) when (IS_MODE(0) = c_IS_SLAVE) else
+ rx_rst_word_i(1*8+7 downto 1*8) when (IS_MODE(1) = c_IS_SLAVE) else
+ rx_rst_word_i(2*8+7 downto 2*8) when (IS_MODE(2) = c_IS_SLAVE) else
+ rx_rst_word_i(3*8+7 downto 3*8) when (IS_MODE(3) = c_IS_SLAVE) else
x"00";
-------------------------------------------------
wap_requested_i(2*4+3 downto 2*4) <= WAP_REQUESTED_IN when (IS_MODE(2) = c_IS_MASTER) else x"0";
wap_requested_i(3*4+3 downto 3*4) <= WAP_REQUESTED_IN when (IS_MODE(3) = c_IS_MASTER) else x"0";
--------------------------------------------------
+-------------------------------------------------
+-- loopback select
+-------------------------------------------------
+ lb_sel_i(0) <= '1' when (IS_MODE(0) = c_IS_SLAVE) else '0';
+ lb_sel_i(1) <= '1' when (IS_MODE(1) = c_IS_SLAVE) else '0';
+ lb_sel_i(2) <= '1' when (IS_MODE(2) = c_IS_SLAVE) else '0';
+ lb_sel_i(3) <= '1' when (IS_MODE(3) = c_IS_SLAVE) else '0';
+
+ lb_start_i <= rx_rst_i(0) when (IS_MODE(0) = c_IS_SLAVE) else
+ rx_rst_i(1) when (IS_MODE(1) = c_IS_SLAVE) else
+ rx_rst_i(2) when (IS_MODE(2) = c_IS_SLAVE) else
+ rx_rst_i(3) when (IS_MODE(3) = c_IS_SLAVE) else
+ '0';
+
+ THE_LB_START_SYNC: entity pulse_sync
+ port map(
+ CLK_A_IN => MASTER_CLK_IN,
+ RESET_A_IN => '0',
+ PULSE_A_IN => lb_start_i,
+ CLK_B_IN => SYSCLK,
+ RESET_B_IN => '0',
+ PULSE_B_OUT => lb_start_qsys
+ );
+
+-------------------------------------------------
-- Serdes
--------------------------------------------------
+-------------------------------------------------
gen_SERDES: if LINK_SPEED = 125 generate
THE_SERDES: entity work.serdes_sync_all_125M_RS
port map(
-- WAP
WA_POS_OUT => wa_position_i,
WA_REQ_IN => wap_req_all_q(2),
+ -- Loopback hack
+ LB_START_IN => '0', --lb_start_qsys,
+ LB_SEL_IN => (others => '0'), --lb_sel_i,
--Slowcontrol
BUS_RX => BUS_RX,
BUS_TX => BUS_TX,
signal reset_i : std_logic;
signal link_tx_ready_i : std_logic;
signal link_rx_ready_i : std_logic;
- signal link_half_done_i : std_logic;
- signal link_full_done_i : std_logic;
signal media_med2int_i : MED2INT;
signal ctr_idle0 : unsigned(8 downto 0);\r
signal idle0_detected : std_logic;\r
\r
+ signal link_rx_null_i : std_logic;\r
signal link_active_i : std_logic;\r
signal link_active_qrx : std_logic;\r
signal link_active_qsys : std_logic;\r
sync_k_i <= '0';\r
ce_idle0_ctr <= '0';\r
rst_idle0_ctr <= '0';\r
+ link_rx_null_i <= '0';\r
\r
case rx_state is\r
when SLEEP =>\r
rx_state_bits <= x"1";\r
rx_data(7 downto 0) <= reg_rx_data_in;\r
rst_idle0_ctr <= '1';\r
+ link_rx_null_i <= '1';\r
if( (reg_rx_k_in = '1') and (reg_rx_data_in = K_IDLE) and (link_rx_ready_qrx = '1') ) then\r
rx_state <= WAIT_1;\r
sync_k_i <= '1';\r
\r
LINK_ACTIVE_OUT <= link_active_qrx;\r
\r
+ LINK_RX_NULL_OUT <= link_rx_null_i;\r
+ \r
----------------------------------------------------------------------\r
-- Debug and Status\r
---------------------------------------------------------------------- \r
-- WAP stuff
WA_POS_OUT : out std_logic_vector(15 downto 0);
WA_REQ_IN : in std_logic;
+ -- Loopback hack
+ LB_START_IN : in std_logic;
+ LB_SEL_IN : in std_logic_vector(3 downto 0);
--Slowcontrol
BUS_RX : in CTRLBUS_RX;
BUS_TX : out CTRLBUS_TX;
architecture sci_reader_arch of sci_reader_RS is
+--type sci_ctrl is (IDLE, SCTRL, SCTRL_WAIT, SCTRL_WAIT2, SCTRL_FINISH, GET_WA, GET_WA_WAIT, GET_WA_WAIT2, GET_WA_FINISH,
+-- W_RL, W_RL_WAIT, W_RL_WAIT2, W_RL_FINISH, W_RLS, W_RLS_WAIT, W_RLS_WAIT2, W_RLS_FINISH);
type sci_ctrl is (IDLE, SCTRL, SCTRL_WAIT, SCTRL_WAIT2, SCTRL_FINISH, GET_WA, GET_WA_WAIT, GET_WA_WAIT2, GET_WA_FINISH);
signal sci_state : sci_ctrl;
elsif( (sci_timer(sci_timer'left) = '1') and (WA_REQ_IN = '1') ) then
sci_timer <= (others => '0');
sci_state <= GET_WA;
+-- elsif( LB_START_IN = '1' ) then
+-- sci_state <= W_RL;
+-- next_sci_wr <= '1';
end if;
when SCTRL =>
if( sci_reg_i = '1' ) then
when SCTRL_FINISH =>
BUS_TX.data(7 downto 0) <= SCI_RDDATA;
BUS_TX.ack <= '1';
--- next_sci_wr <= '0';
SCI_RD <= '0';
sci_state <= IDLE;
+
+ ----------------------------------------
+ ----------------------------------------
+-- when W_RL =>
+-- SCI_SEL <= '0' & LB_SEL_IN;
+-- SCI_ADDR <= b"010001"; -- x"11" for ECP3
+-- SCI_WRDATA <= x"21"; -- set source of TX data
+-- SCI_RD <= '0';
+-- sci_state <= W_RL_WAIT;
+-- when W_RL_WAIT =>
+-- next_sci_wr <= '0';
+-- sci_state <= W_RL_WAIT2;
+-- when W_RL_WAIT2 =>
+-- sci_state <= W_RL_FINISH;
+-- when W_RL_FINISH =>
+-- next_sci_wr <= '1';
+-- sci_state <= W_RLS;
+-- when W_RLS =>
+-- SCI_ADDR <= b"010100"; -- x"14" for ECP3
+-- SCI_WRDATA <= x"69"; -- enable feedback
+-- SCI_RD <= '0';
+-- sci_state <= W_RLS_WAIT;
+-- when W_RLS_WAIT =>
+-- next_sci_wr <= '0';
+-- sci_state <= W_RLS_WAIT2;
+-- when W_RLS_WAIT2 =>
+-- sci_state <= W_RLS_FINISH;
+-- when W_RLS_FINISH =>
+-- SCI_SEL <= (others => '0');
+-- SCI_ADDR <= (others => '0');
+-- SCI_WRDATA <= (others => '0');
+-- sci_state <= IDLE;
+ ----------------------------------------
+ ----------------------------------------
+
when GET_WA =>
if( ((cnt = 4) and (FPGA_TYPE = 3)) or ((cnt = 2) and (FPGA_TYPE = 5)) ) then
cnt := 0;
architecture arch of tx_control_RS is\r
\r
type state_t is (IDLE, SEND_IDLE_L, SEND_IDLE_H, SEND_DATA_L, SEND_DATA_H, \r
- SEND_DLM_L, SEND_DLM_H, SEND_RST_L, SEND_RST_H);\r
+ SEND_DLM_L, SEND_DLM_H, SEND_RST_L, SEND_RST_H, SEND_NULL_L, SEND_NULL_H);\r
signal current_state : state_t;\r
signal state_bits : std_logic_vector(3 downto 0);\r
\r
current_state <= SEND_RST_H;\r
debug_sending_rst <= '1';\r
\r
- when SEND_RST_H =>\r
+ when SEND_RST_H =>\r
word_sync_i <= '1';\r
tx_data_i <= send_rst_word_i;\r
\r
+ when SEND_NULL_L =>\r
+ tx_data_i <= K_NULL;\r
+ tx_k_i <= '1';\r
+ current_state <= SEND_NULL_H;\r
+ \r
+ when SEND_NULL_H =>\r
+ word_sync_i <= '1';\r
+ tx_data_i <= K_NULL;\r
+ tx_k_i <= '1'; -- EXCEPTION\r
+ \r
when others =>\r
current_state <= SEND_IDLE_L;\r
\r
end case;\r
\r
if( (current_state = SEND_IDLE_H) or (current_state = SEND_DATA_H) or\r
- (current_state = SEND_DLM_H) or (current_state = SEND_RST_H) ) then\r
- if ( (link_tx_ready_qtx = '0') or (link_tx_null_qtx = '1') ) then\r
+ (current_state = SEND_DLM_H) or (current_state = SEND_RST_H) or (current_state = SEND_NULL_H)) then\r
+-- if ( (link_tx_ready_qtx = '0') or (link_tx_null_qtx = '1') ) then\r
+ if ( link_tx_ready_qtx = '0' ) then\r
current_state <= IDLE;\r
+ elsif( link_tx_null_qtx = '1' ) then\r
+ current_state <= SEND_NULL_L;\r
elsif( send_dlm_i = '1' ) then\r
current_state <= SEND_DLM_L;\r
elsif( send_rst_i = '1' ) then\r
end if;\r
end if;\r
end if;\r
+ end process THE_DATA_CONTROL_FSM;\r
\r
+ THE_DATA_CONTROL_ASYNC: process( current_state, ram_empty, link_active_qtx, send_dlm_i, send_rst_i, link_tx_null_qtx, CLEAR ) \r
+ begin\r
--async because of oreg.\r
- if ((current_state = SEND_IDLE_H) or (current_state = SEND_DATA_H) or (current_state = SEND_DLM_H) or (current_state = SEND_RST_H)) \r
- and (ram_empty = '0') and (link_active_qtx = '1') and (send_dlm_i = '0') and (send_rst_i = '0') then\r
+ -- read from RAM if the NEXT state will be "send data"\r
+ if ((current_state = SEND_IDLE_H) or (current_state = SEND_DATA_H) or \r
+ (current_state = SEND_DLM_H) or (current_state = SEND_RST_H) or (current_state = SEND_NULL_H))\r
+ and (ram_empty = '0') and (link_active_qtx = '1') and (send_dlm_i = '0') and (send_rst_i = '0') and (link_tx_null_qtx = '0') then\r
ram_read <= '1';\r
else \r
ram_read <= '0';\r
end if;\r
- if (CLEAR = '1') then\r
+ if( CLEAR = '1' ) then\r
ram_read <= '0';\r
end if;\r
\r
- end process THE_DATA_CONTROL_FSM;\r
+ end process THE_DATA_CONTROL_ASYNC;\r
\r
----------------------------------------------------------------------\r
--\r