if rising_edge(RX_CLK) then
if RESET = '1' then
fifo_data_in <= (others => '0');
- elsif SYNCH_CURRENT = NORMAL_OPERATION_1 then
- fifo_data_in <= '0' & (not RX_K(0)) & RXD;
elsif SYNCH_CURRENT = NORMAL_OPERATION_2 then
+ fifo_data_in <= '0' & (not RX_K(0)) & RXD;
+ elsif SYNCH_CURRENT = NORMAL_OPERATION_1 then
fifo_data_in <= '0' & (not RX_K(1)) & RXD(7 downto 0) & RXD(15 downto 8);
else
fifo_data_in <= (others => '0');
end if;
end process SHIFT_OR_NOT_DATA_IN;
- SYNCH_CLOCK : process (RX_CLK, RESET)
+-- SYNCH_CLOCK : process (RX_CLK, RESET)
+ SYNCH_CLOCK : process (SYSTEM_CLK, RESET)
begin
- if rising_edge (RX_CLK) then
+ if rising_edge (SYSTEM_CLK) then
if RESET = '1' then
SYNCH_CURRENT <= IDLE;
cv_i <= (others => '0');
rx_rst_i <= '1';
resync_counter_up <= '1';
resync_counter_clr <= '0';
- if resync_counter = 200 then
+ if resync_counter(8) = '1' then
SYNCH_NEXT <= RESYNC2;
else
SYNCH_NEXT <= RESYNC1;
when RESYNC2 =>
fifo_rst <= '0';
fifo_wr_en <= '0';
- fsm_debug_register(2 downto 0) <= "011";
+ fsm_debug_register(2 downto 0) <= "010";
rx_rst_i <= '0';
resync_counter_up <= '1';
resync_counter_clr <= '0';
- if resync_counter(17) = '1' then --at least 400us
+ if resync_counter(16) = '1' then --at least 400us
SYNCH_NEXT <= RESYNC3;
else
SYNCH_NEXT <= RESYNC2;
when RESYNC3 =>
fifo_rst <= '0';
fifo_wr_en <= '0';
- fsm_debug_register(2 downto 0) <= "100";
+ fsm_debug_register(2 downto 0) <= "010";
rx_rst_i <= '0';
resync_counter_up <= '0';
resync_counter_clr <= '1';
- if rxd_synch_i = x"bc50" then
+ if rxd_synch_i = x"bc50" and rx_k_synch_i(1) = '1' then
SYNCH_NEXT <= WAIT_1;--NORMAL_OPERATION_1;
- elsif rxd_synch_i = x"50bc" then
+ elsif rxd_synch_i = x"50bc" and rx_k_synch_i(0) = '1' then
SYNCH_NEXT <= WAIT_2;--NORMAL_OPERATION_2;
else
SYNCH_NEXT <= IDLE;
fifo_rst <= '0';
rx_rst_i <= '0';
fifo_wr_en <= '0';
- fsm_debug_register(2 downto 0) <= "101";
+ fsm_debug_register(2 downto 0) <= "011";
resync_counter_up <= '1';
resync_counter_clr <= '0';
- if resync_counter(29) = '1' then
+ if resync_counter(27) = '1' and rxd_synch_i = x"bc50" and rx_k_synch_i(1) = '1' then
SYNCH_NEXT <= NORMAL_OPERATION_1;
+ elsif resync_counter(29) = '1' and (rxd_synch_i /= x"bc50" or rx_k_synch_i(1) = '0') then
+ SYNCH_NEXT <= RESYNC1;
else
SYNCH_NEXT <= WAIT_1;
end if;
fifo_rst <= '0';
fifo_wr_en <= '0';
rx_rst_i <= '0';
- fsm_debug_register(2 downto 0) <= "101";
+ fsm_debug_register(2 downto 0) <= "011";
resync_counter_up <= '1';
resync_counter_clr <= '0';
- if resync_counter(29) = '1' then
+ if resync_counter(27) = '1' and rxd_synch_i = x"50bc" and rx_k_synch_i(0) = '1' then
SYNCH_NEXT <= NORMAL_OPERATION_2;
+ elsif resync_counter(29) = '1' and (rxd_synch_i /= x"50bc" or rx_k_synch_i(0) = '0') then
+ SYNCH_NEXT <= RESYNC1;
else
SYNCH_NEXT <= WAIT_2;
end if;