-- $Id$: -- Error Decoder / clock activity handler / bus selector -- Version 1.10 -- Last updated: 2012.08.24 library ieee; use ieee.std_logic_1164.all; -- ================================================ entity error_decoder is port ( -- mrst : in std_logic; -- master reset -- mclk : in std_logic; -- master clock 100kHz -- state => 00 = ok; 01 = parity error; 10 = 2-Bit error; 11 1-Bit error (corrected) valid : in std_logic_vector(2 downto 1); -- bit 31 ham_err_summ : in std_logic_vector(2 downto 1); spi_act_all : in std_logic_vector(2 downto 1); bus_mux_sel : out std_logic; -- bus multiplexer output signal out_reg_strobe : out std_logic -- output register strobe output signal ); end error_decoder; -- ================================================ architecture a of error_decoder is signal ch_good : std_logic_vector (2 downto 1); -- ================================================ begin ch_good <= valid and spi_act_all and not ham_err_summ; -- -- ch_good(1) <= valid(1) when spi_act_all(1) = '1' and ham_err_summ(1) = '0' else '0'; -- ch_good(2) <= valid(2) when spi_act_all(2) = '1' and ham_err_summ(2) = '0' else '0'; -- ------------------------------------------------ --error_dec: process(mclk, mrst) error_dec: process(ch_good) begin -- if mrst = '1' then -- -- out_reg_strobe <= '0'; -- bus_mux_sel <= '0'; -- fail_led_1 <= '0'; -- fail_led_2 <= '0'; -- -- elsif rising_edge(mclk) then out_reg_strobe <= '0'; bus_mux_sel <= '0'; case ch_good is when "11" => null; -- if both channels have good data just keep the channel and update output register bus_mux_sel <= '0'; out_reg_strobe <= '1'; when "01" => bus_mux_sel <= '0'; -- if channel 1 has good data but channel 2 has not switch multiplexer to -- channel 1 and strobe in data to output register with the following clock out_reg_strobe <= '1'; when "10" => bus_mux_sel <= '1'; -- if channel 2 has good data but channel 1 has not switch multiplexer to -- channel 2 and strobe in data to output register with the following clock out_reg_strobe <= '1'; when others => out_reg_strobe <= '0'; -- if none of the channels has good data just keep status and do NOT update output register end case; -- end if; end process; -- ================================================ end;