Advertisement
PedroNY

Conversor a BCD

Aug 1st, 2019
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.58 KB | None | 0 0
  1. Library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4. use IEEE.std_logic_unsigned.all;
  5.  
  6. entity Conversor_BDC is
  7.     Port ( Q : in  STD_LOGIC_VECTOR (3 downto 0);
  8.            OverF : out std_logic;
  9.            BCD : out  STD_LOGIC_VECTOR (3 downto 0));
  10.  
  11. end Conversor_BDC;
  12.  
  13. architecture Behavioral of Conversor_BDC is
  14.  
  15. CONSTANT FC: STD_LOGIC_VECTOR := "0110"; --Factor de Correccion 6 - 0110
  16.  
  17. begin
  18.  
  19.  BCD <= Q + FC when Q > "1001" else --si el codigo de entrada es mayor a 9 - 1001
  20.           Q;
  21.  
  22.  OverF <= Q(3) and (Q(2) or Q(1));  -- Overflow
  23.  
  24. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement