library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.NUMERIC_STD.ALL;
entity DisplayNumbers is
port (
Data: in std_logic_vector(5 downto 0);
Alt: in std_logic;
Validate: in std_logic;
vd1: out std_logic_vector(6 downto 0);
vd0: out std_logic_vector(6 downto 0);
V_Alt: out std_logic
);
end DisplayNumbers;
architecture Behavioral of DisplayNumbers is
signal binario: std_logic_vector(5 downto 0);
signal bcd1: std_logic_vector(3 downto 0);
signal bcd0: std_logic_vector(3 downto 0);
signal nmax: std_logic;
begin
process (Alt, Validate, Data)
variable binx : std_logic_vector (5 downto 0);
variable bcd : std_logic_vector (7 downto 0);
begin
vd0 <= (others => '0');
vd1 <= (others => '0');
V_Alt <= '0';
binario <= Data;
if Validate = '1' then
if Alt = '1' then
for i in 0 to 5 loop
if Data(i) = '1' then
nmax <= '1';
end if;
end loop;
V_Alt <= '1';
end if;
bcd := (others => '0') ;
binx := binario(5 downto 0) ;
for i in binx'range loop
if bcd(3 downto 0) > "0100" then
bcd(3 downto 0) := std_logic_vector(unsigned( bcd(3 downto 0)) + "0011");
end if ;
if bcd(7 downto 4) > "0100" then
bcd(7 downto 4) := std_logic_vector(unsigned( bcd(7 downto 4)) + "0011");
end if ;
bcd := bcd(6 downto 0) & binx(5) ;
binx := binx(4 downto 0) & '0' ;
end loop ;
bcd1 <= bcd(7 downto 4) ;
bcd0 <= bcd(3 downto 0) ;
case bcd1 is
when "0000" => vd1 <= not("0111111");
when "0001" => vd1 <= not("0000110");
when "0010" => vd1 <= not("1011011");
when "0011" => vd1 <= not("1001111");
when "0100" => vd1 <= not("1100110");
when "0101" => vd1 <= not("1101101");
when "0110" => vd1 <= not("1111101");
when "0111" => vd1 <= not("0000111");
when "1000" => vd1 <= not("1111111");
when "1001" => vd1 <= not("1101111");
when others => null;
end case;
case bcd0 is
when "0000" => vd0 <= not("0111111");
when "0001" => vd0 <= not("0000110");
when "0010" => vd0 <= not("1011011");
when "0011" => vd0 <= not("1001111");
when "0100" => vd0 <= not("1100110");
when "0101" => vd0 <= not("1101101");
when "0110" => vd0 <= not("1111101");
when "0111" => vd0 <= not("0000111");
when "1000" => vd0 <= not("1111111");
when "1001" =>vd0 <= not("1101111");
when others => null;
end case;
end if;
end process;
end Behavioral;
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}