LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; USE IEEE.std_logic_arith.ALL; USE IEEE.std_logic_unsigned.ALL; entity stat_led is port ( local_clock : in std_logic; serial_clock : in std_logic; pardat_dec : in std_logic_vector(32 downto 1); rst : in std_logic; hm_stat : in std_logic_vector(1 downto 0); sstr_OK : in std_logic; sdat_OK : in std_logic; led_0 : out std_logic; led_1 : out std_logic; led_2 : out std_logic; led_3 : out std_logic ); end stat_led; architecture a of stat_led is --components... component counter_dec20 is port ( clk_in : in std_logic; sreset : in std_logic; hard_reset : in std_logic; --clock output overflow : out std_logic ); end component; --signal clock_counter : Integer; signal clock_counter : std_logic_vector(3 downto 0); --constant div_max :Integer := 16; constant div_max : std_logic_vector(3 downto 0) := "1111"; signal slo_clk : std_logic; signal sync_slo : std_logic; signal delbuf : std_logic; signal rst_counter : std_logic; signal sclk_BAD : std_logic; signal bcounter : std_logic_vector(12 downto 0); signal blinkF : std_logic; signal blinkS : std_logic; signal all_ch0 : std_logic; signal all_ch1 : std_logic; signal sdin0 : std_logic; signal sdin1 : std_logic; begin --clock divider for serial clock process(serial_clock, rst) begin if rst = '1' then clock_counter <= "0000"; slo_clk <= '0'; elsif serial_clock'event and serial_clock = '1' then clock_counter <= clock_counter + 1; if clock_counter = div_max then slo_clk <= not slo_clk; end if ; end if; end process ; --clock synchronizer process(local_clock, rst) begin if rst = '1' then sync_slo <= '0'; elsif local_clock'event and local_clock = '1' then sync_slo <= slo_clk; end if; end process; --delay process(local_clock, rst) begin if rst = '1' then delbuf <= '0'; elsif local_clock'event and local_clock = '1' then delbuf <= sync_slo; end if; end process; rst_counter <= (delbuf xor sync_slo); counter20: counter_dec20 port map( clk_in => local_clock, sreset => rst_counter, hard_reset => rst, overflow => sclk_BAD ); -- clock for LED blinking process(local_clock, rst) begin if rst = '1' then bcounter <= (others => '0'); elsif local_clock'event and local_clock = '1' then bcounter <= bcounter + 1; end if; end process; blinkF <= bcounter(bcounter'high-1); blinkS <= bcounter(bcounter'high); led_0 <= '1' when sclk_BAD='1' else -- LED OFF, if no sclk, sstr is ignored blinkF when sstr_OK ='1' else -- LED blink sclk OK, sstr OK '0'; -- LED ON if sclk OK but sstr BAD all_ch0 <= '1' when pardat_dec(30 downto 1) = "00" & x"0000000" else '0'; all_ch1 <= '1' when pardat_dec(30 downto 1) = "11" & x"FFFFFFF" else '0'; sdin0 <= all_ch0 and not sdat_OK; -- many bits 0 and static => cont. 0 sdin1 <= not all_ch0 and not sdat_OK; -- not all bits 0 and static => cont. 1 led_1 <= '1' when all_ch0='1' else -- LED OFF if all OFF '0' when all_ch1='1' else -- LED ON if all ON blinkS; -- some ON => blink led_2 <= '1' when sdin0='1' else -- sdin = 0 => LED OFF '0' when sdin1='1' else -- sdin = 1 => LED ON not blinkS; -- sdin /= const => LED blink -- LED ON when hamming errors led_3 <= '0' when hm_stat(0) = '1' or hm_stat(1) = '1' else '1'; end;