Facebook
From Eratic Plover, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 70
  1. library IEEE;
  2. use IEEE.std_logic_1164.all;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5. entity DisplayNumbers is
  6.     port (
  7.         Data: in std_logic_vector(5 downto 0);
  8.         Alt: in std_logic;
  9.         Validate: in std_logic;
  10.         vd1: out std_logic_vector(6 downto 0);
  11.         vd0: out std_logic_vector(6 downto 0);
  12.         V_Alt: out std_logic
  13.     );
  14. end DisplayNumbers;
  15.  
  16. architecture Behavioral of DisplayNumbers is
  17.          signal binario: std_logic_vector(5 downto 0);
  18.          signal bcd1: std_logic_vector(3 downto 0);
  19.          signal bcd0: std_logic_vector(3 downto 0);
  20.          signal nmax: std_logic;
  21. begin
  22.  
  23.     process (Alt, Validate, Data)
  24.                 variable binx : std_logic_vector (5 downto 0);
  25.                 variable bcd : std_logic_vector (7 downto 0);
  26.     begin
  27.                         vd0 <= (others => '0');
  28.                         vd1 <= (others => '0');
  29.                         V_Alt <= '0';
  30.                         binario <= Data;
  31.                         if Validate = '1' then
  32.                                 if Alt = '1' then
  33.                                        
  34.                                         for i in 0 to 5 loop
  35.                                                 if Data(i) = '1' then
  36.                                                         nmax <= '1';
  37.                                                        
  38.                                                
  39.                                                 end if;
  40.                                         end loop;
  41.                                         V_Alt <= '1';
  42.                                 end if;
  43.                                 bcd := (others => '0') ;
  44.                                 binx := binario(5 downto 0) ;
  45.  
  46.                                 for i in binx'range loop
  47.                                   if bcd(3 downto 0) > "0100" then
  48.                                          bcd(3 downto 0) := std_logic_vector(unsigned( bcd(3 downto 0)) + "0011");
  49.  
  50.                                   end if ;
  51.                                   if bcd(7 downto 4) > "0100" then
  52.                                           bcd(7 downto 4) := std_logic_vector(unsigned( bcd(7 downto 4)) + "0011");    
  53.                                   end if ;
  54.                                   bcd := bcd(6 downto 0) & binx(5) ;
  55.                                   binx := binx(4 downto 0) & '0' ;
  56.                                 end loop ;
  57.  
  58.                                 bcd1 <= bcd(7  downto 4) ;
  59.                                 bcd0 <= bcd(3  downto 0) ;
  60.  
  61.                                 case bcd1 is
  62.                                         when "0000" => vd1 <= not("0111111");
  63.                                         when "0001" => vd1 <= not("0000110");
  64.                                         when "0010" => vd1 <= not("1011011");
  65.                                         when "0011" => vd1 <= not("1001111");
  66.                                         when "0100" => vd1 <= not("1100110");
  67.                                         when "0101" => vd1 <= not("1101101");
  68.                                         when "0110" => vd1 <= not("1111101");
  69.                                         when "0111" => vd1 <= not("0000111");
  70.                                         when "1000" => vd1 <= not("1111111");
  71.                                         when "1001" => vd1 <= not("1101111");
  72.                                         when others => null;
  73.                                 end case;
  74.  
  75.                                 case bcd0 is
  76.                                         when "0000" => vd0 <= not("0111111");
  77.                                         when "0001" => vd0 <= not("0000110");
  78.                                         when "0010" => vd0 <= not("1011011");
  79.                                         when "0011" => vd0 <= not("1001111");
  80.                                         when "0100" => vd0 <= not("1100110");
  81.                                         when "0101" => vd0 <= not("1101101");
  82.                                         when "0110" => vd0 <= not("1111101");
  83.                                         when "0111" => vd0 <= not("0000111");
  84.                                         when "1000" => vd0 <= not("1111111");
  85.                                         when "1001" =>vd0 <= not("1101111");
  86.                                         when others => null;
  87.                                 end case;
  88.                         end if;
  89.         end process;
  90. end Behavioral;