------------------------------------------------------------------------------- --! @file BCDto7SegmentDecoder.vhd --! @brief Definition of an BCD to 7 segment decoder. --! @author Dr. Ruediger Knoerig (ruediger@knoerig.de) --! @date 04.03.2015 ------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; entity BCDto7SegmentDecoder is generic ( invertedLogic : boolean := true); -- When true, drive the LED's with low level port ( input : in std_logic_vector(3 downto 0); -- 4 Bit input vector output : out std_logic_vector(6 downto 0)); -- 7 Bit segment code end BCDto7SegmentDecoder; architecture RTL of BCDto7SegmentDecoder is function booleanToStdLogic(input : boolean) return std_logic is begin if input = true then return '1'; else return '0'; end if; end function booleanToStdLogic; constant ledOn : std_logic := booleanToStdLogic(not invertedLogic); -- Level for driving the LED constant ledOff : std_logic := booleanToStdLogic(invertedLogic); -- Level for turning the LED off begin -- RTL with input select output <= (6 => ledOff, others => ledOn) when "0000", (1 => ledOn, 2 => ledOn, others => ledOff) when "0001", (2 => ledOff, 5=> ledOff, others => ledOn) when "0010", (4 => ledOff, 5=> ledOff, others => ledOn) when "0011", (0 =>ledOff, 3 => ledOff, 4=> ledOff, others => ledOn) when "0100", (1 => ledOff, 4=> ledOff, others => ledOn) when "0101", (1 => ledOff, others => ledOn) when "0110", (0 => ledOn, 1 => ledOn, 2 => ledOn, others => ledOff) when "0111", (others => ledOn) when "1000", (4 => ledOff,others => ledOn) when "1001", (others => ledOff) when others; end RTL;