Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.44 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. -- Uncomment the following library declaration if using
  5. -- arithmetic functions with Signed or Unsigned values
  6. use IEEE.NUMERIC_STD.ALL;
  7.  
  8. -- Uncomment the following library declaration if instantiating
  9. -- any Xilinx leaf cells in this code.
  10. --library UNISIM;
  11. --use UNISIM.VComponents.all;
  12.  
  13. entity BINtoBCD_tb is
  14. --  Port ( );
  15. end BINtoBCD_tb;
  16.  
  17. architecture Behavioral of BINtoBCD_tb is
  18.  
  19. component BINtoBCD is
  20.     Port ( c  : in STD_LOGIC;
  21.            S3 : in STD_LOGIC;
  22.            S2 : in STD_LOGIC;
  23.            S1 : in STD_LOGIC;
  24.            S0 : in STD_LOGIC;
  25.            bcd1 : out STD_LOGIC_VECTOR(3 downto 0);
  26.            bcd0 : out STD_LOGIC_VECTOR(3 downto 0));    
  27. end component;
  28.  
  29. signal input: STD_LOGIC_VECTOR (4 downto 0);
  30. signal bcd1 : STD_LOGIC_VECTOR(3 downto 0);
  31. signal bcd0 : STD_LOGIC_VECTOR(3 downto 0);
  32. signal succes : boolean := true;
  33.  
  34. begin
  35.  
  36. decoder : BINtoBCD port map (
  37.     s0 => input(0),
  38.     s1 => input(1),
  39.     s2 => input(2),
  40.     s3 => input(3),
  41.     c => input(4),
  42.     bcd0 => bcd0,
  43.     bcd1 => bcd1
  44. );
  45.  
  46. process
  47. begin
  48.     for i in 0 to 31 loop
  49.         wait for 5 ns;
  50.         input <= std_logic_vector(to_unsigned(i, input'length));
  51.         wait for 5 ns;
  52.         if unsigned(bcd0) /= i mod 10 or unsigned(bcd1) /= i / 10 then
  53.             succes <= false;
  54.         end if;
  55.            
  56.     end loop;
  57.    
  58.     wait;
  59. end process;
  60.  
  61. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement