Advertisement
Hampus-Toft

Untitled

Apr 12th, 2021
317
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library ieee;              -- Load the ieee 1164 library
  2. use ieee.std_logic_1164.all;  -- Make the package 'visible'
  3.  
  4.  
  5. -- The top level entity of the test bench has no ports...
  6. entity adder4bit_slow_tb is
  7. end adder4bit_slow_tb;
  8.  
  9. architecture stimulus of adder4bit_slow_tb is
  10.   -- First, declare the lower-level entity...
  11.   component adder4bit_slow
  12.     port(a ,b : in std_logic_vector(3 downto 0);
  13.         c_in: in std_logic;
  14.         s : out std_logic_vector(3 downto 0);
  15.         c_out : out std_logic);
  16.   end component;
  17.  
  18.   -- Next, declare some local signals to assign values to AN observe...
  19.   -- adder4bit_slow input
  20.   signal a ,b : std_logic_vector(3 downto 0);
  21.   signal c_in : std_logic;
  22.  
  23.   -- adder4bit_slow outputss
  24.   signal s : std_logic_vector(3 downto 0);
  25.   signal c_out : std_logic;
  26.  
  27.  
  28. begin
  29.   -- Create an instance of the component under test
  30.   adder4bit_slow_instance: adder4bit_slow port map( a => a, b => b, c_in => c_in, s => s, c_out => c_out);
  31.  
  32.   -- Now define a process to apply some stimulus over time...
  33.   process
  34.     constant PERIOD: time := 40 ns;
  35.   begin
  36.  
  37.     avector : for a4 in 0 to 15 loop
  38.         if (a4 = 15) then
  39.             a <= X"F";
  40.         else if (a4 = 14) then
  41.             a <= X"E";
  42.         else if (a4 = 13) then
  43.             a <= X"D";
  44.         else if (a4 = 12) then
  45.             a <= X"C";
  46.         else if (a4 = 11) then
  47.             a <= X"B";
  48.         else if (a4 = 10) then
  49.             a <= X"A";
  50.         else if (a4 = 9) then
  51.             a <= X"9";
  52.         else if (a4 = 8) then
  53.             a <= X"8";
  54.         else if (a4 = 7) then
  55.             a <= X"7";
  56.         else if (a4 = 6) then
  57.             a <= X"6";
  58.         else if (a4 = 5) then
  59.             a <= X"5";
  60.         else if (a4 = 4) then
  61.             a <= X"4";
  62.         else if (a4 = 3) then
  63.             a <= X"3";
  64.         else if (a4 = 2) then
  65.             a <= X"2";
  66.         else if (a4 = 1) then
  67.             a <= X"1";
  68.         else if (a4 = 0) then
  69.             a <= X"0";
  70.         end if;
  71.         wait for PERIOD;
  72.     end loop avector;
  73.    
  74.     -- put breakpoint to line below
  75.     wait for PERIOD;        
  76.    
  77.     -- do not run again
  78.     wait;
  79.   end process;
  80. end stimulus;
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
Advertisement
RAW Paste Data Copied
Advertisement