Line 39... |
Line 39... |
-- // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // --
|
-- // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // --
|
-- // POSSIBILITY OF SUCH DAMAGE. // --
|
-- // POSSIBILITY OF SUCH DAMAGE. // --
|
-- // // --
|
-- // // --
|
-- /////////////////////////////////////////////////////////////////// --
|
-- /////////////////////////////////////////////////////////////////// --
|
--======================================================================================--
|
--======================================================================================--
|
|
-- --
|
|
-- Change history --
|
|
-- +-------+-----------+-------+------------------------------------------------------+ --
|
|
-- | Vers. | Date | Autor | Comment | --
|
|
-- +-------+-----------+-------+------------------------------------------------------+ --
|
|
-- | 1.0 |04 Feb 2011| MN | Initial version | --
|
|
-- | 1.1 |23 Apr 2011| MN | Added missing 'rst' in process sensitivity lists. | --
|
|
-- | | | | Added ELSE construct in fs_next_state process to | --
|
|
-- | | | | prevent an undesired latch implementation. | --
|
|
--======================================================================================--
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
Line 119... |
Line 129... |
if rising_edge(clk) then
|
if rising_edge(clk) then
|
rx_en <= RxEn_i;
|
rx_en <= RxEn_i;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
p_sync_err: process (clk)
|
p_sync_err: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
sync_err <= '0';
|
sync_err <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
sync_err <= not rx_active and sync_err_d;
|
sync_err <= not rx_active and sync_err_d;
|
Line 174... |
Line 184... |
|
|
j <= rxdp_s and not rxdn_s;
|
j <= rxdp_s and not rxdn_s;
|
k <= not rxdp_s and rxdn_s;
|
k <= not rxdp_s and rxdn_s;
|
se0 <= not rxdp_s and not rxdn_s;
|
se0 <= not rxdp_s and not rxdn_s;
|
|
|
p_se0_s: process (clk)
|
p_se0_s: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
se0_s <= '0';
|
se0_s <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
if fs_ce ='1' then
|
if fs_ce ='1' then
|
Line 248... |
Line 258... |
if fs_ce='1' and rx_active='0' and se0='0' and se0_s='0' then
|
if fs_ce='1' and rx_active='0' and se0='0' and se0_s='0' then
|
case fs_state is
|
case fs_state is
|
when FS_IDLE => if k ='1' and rx_en ='1' then -- 0
|
when FS_IDLE => if k ='1' and rx_en ='1' then -- 0
|
fs_next_state <= K1;
|
fs_next_state <= K1;
|
sync_err_d <= '0';
|
sync_err_d <= '0';
|
|
else
|
|
fs_next_state <= FS_IDLE;
|
|
sync_err_d <= '0';
|
end if;
|
end if;
|
when K1 => if j ='1' and rx_en ='1' then -- 1
|
when K1 => if j ='1' and rx_en ='1' then -- 1
|
fs_next_state <= J1;
|
fs_next_state <= J1;
|
sync_err_d <= '0';
|
sync_err_d <= '0';
|
else
|
else
|
Line 329... |
Line 342... |
rx_active <= '0';
|
rx_active <= '0';
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
p_rx_valid_r: process (clk)
|
p_rx_valid_r: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
rx_valid_r <= '0';
|
rx_valid_r <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
if rx_valid ='1' then
|
if rx_valid ='1' then
|
Line 346... |
Line 359... |
|
|
--====================================================================================--
|
--====================================================================================--
|
-- NRZI Decoder --
|
-- NRZI Decoder --
|
--====================================================================================--
|
--====================================================================================--
|
|
|
p_sd_r: process (clk)
|
p_sd_r: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
sd_r <= '0';
|
sd_r <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
if fs_ce ='1' then
|
if fs_ce ='1' then
|
Line 393... |
Line 406... |
end if;
|
end if;
|
end process;
|
end process;
|
|
|
drop_bit <= '1' when one_cnt ="110" else '0';
|
drop_bit <= '1' when one_cnt ="110" else '0';
|
|
|
p_bit_stuff_err: process (clk) -- Bit Stuff Error
|
p_bit_stuff_err: process (clk, rst) -- Bit Stuff Error
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
bit_stuff_err <= '0';
|
bit_stuff_err <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
bit_stuff_err <= drop_bit and sd_nrzi and fs_ce and not se0 and rx_active;
|
bit_stuff_err <= drop_bit and sd_nrzi and fs_ce and not se0 and rx_active;
|
Line 406... |
Line 419... |
|
|
--====================================================================================--
|
--====================================================================================--
|
-- Serial => Parallel converter --
|
-- Serial => Parallel converter --
|
--====================================================================================--
|
--====================================================================================--
|
|
|
p_shift_en: process (clk)
|
p_shift_en: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
shift_en <= '0';
|
shift_en <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
if fs_ce ='1' then
|
if fs_ce ='1' then
|
Line 456... |
Line 469... |
rx_valid1 <= '0';
|
rx_valid1 <= '0';
|
end if;
|
end if;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
p_rx_valid: process (clk)
|
p_rx_valid: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
rx_valid <= '0';
|
rx_valid <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
rx_valid <= not drop_bit and rx_valid1 and fs_ce;
|
rx_valid <= not drop_bit and rx_valid1 and fs_ce;
|
Line 472... |
Line 485... |
if rising_edge(clk) then
|
if rising_edge(clk) then
|
se0_r <= se0;
|
se0_r <= se0;
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|
p_byte_err: process (clk)
|
p_byte_err: process (clk, rst)
|
begin
|
begin
|
if rst ='0' then
|
if rst ='0' then
|
byte_err <= '0';
|
byte_err <= '0';
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
byte_err <= se0 and not se0_r and (bit_cnt(1) or bit_cnt(2)) and rx_active;
|
byte_err <= se0 and not se0_r and (bit_cnt(1) or bit_cnt(2)) and rx_active;
|