library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity bcd_converter is
port (
bcd_0 : in integer range 0 to 9;
bcd_1 : in integer range 0 to 9;
bcd_2 : in integer range 0 to 9;
bcd_3 : in integer range 0 to 9;
bcd_4 : in integer range 0 to 9;
char_0 : out std_logic_vector(7 downto 0);
char_1 : out std_logic_vector(7 downto 0);
char_2 : out std_logic_vector(7 downto 0);
char_3 : out std_logic_vector(7 downto 0);
char_4 : out std_logic_vector(7 downto 0)
);
end bcd_converter;
architecture rtl of bcd_converter is
type hex_array is array (0 to 9) of std_logic_vector(7 downto 0);
constant hex_codes : hex_array := (
"10000001", -- 0
"11110011", -- 1
"01001001", -- 2
"01100001", -- 3
"00110011", -- 4
"00100101", -- 5
"00000101", -- 6
"11110001", -- 7
"00000001", -- 8
"00100001" -- 9
);
begin
-- Просто преобразуем BCD в сегменты, без гашения
char_0 <= hex_codes(bcd_0);
char_1 <= hex_codes(bcd_1);
char_2 <= hex_codes(bcd_2);
char_3 <= hex_codes(bcd_3);
char_4 <= hex_codes(bcd_4);
end rtl;