library ieee; use ieee.std_logic_1164.all; library work; use work.bin2bcd_pkg.all; entity bcdshifter is port ( clk : in std_logic; rst : in std_logic; s_in : in std_logic; bcd : out bcd_digit; s_out : out std_logic ); end bcdshifter; architecture arch of bcdshifter is signal shift_reg : bcd_digit; -- the actual register signal converted : bcd_digit; -- converted value begin process(clk) begin if clk'event and clk='1' then if rst='0' then shift_reg <= "000" & s_in; else shift_reg <= converted(2 downto 0) & s_in; end if; end if; end process; bcd <= shift_reg; s_out <= converted(3); with shift_reg select converted <= "1000" when "0101", "1001" when "0110", "1010" when "0111", "1011" when "1000", "1100" when "1001", shift_reg when others; end arch;