Advertisement
Lauda

Untitled

Nov 4th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.95 KB | None | 0 0
  1. -- Vhdl test bench created from schematic E:\RA153-2011\Dvobitnisabirac\Dvobitni_sabirac_sch.sch - Mon Nov 05 01:03:55 2012
  2. --
  3. -- Notes:
  4. -- 1) This testbench template has been automatically generated using types
  5. -- std_logic and std_logic_vector for the ports of the unit under test.
  6. -- Xilinx recommends that these types always be used for the top-level
  7. -- I/O of a design in order to guarantee that the testbench will bind
  8. -- correctly to the timing (post-route) simulation model.
  9. -- 2) To use this template as your testbench, change the filename to any
  10. -- name of your choice with the extension .vhd, and use the "Source->Add"
  11. -- menu in Project Navigator to import the testbench. Then
  12. -- edit the user defined section below, adding code to generate the
  13. -- stimulus for your design.
  14. --
  15. LIBRARY ieee;
  16. USE ieee.std_logic_1164.ALL;
  17. USE ieee.numeric_std.ALL;
  18. LIBRARY UNISIM;
  19. USE UNISIM.Vcomponents.ALL;
  20. ENTITY Dvobitni_sabirac_sch_Dvobitni_sabirac_sch_sch_tb IS
  21. END Dvobitni_sabirac_sch_Dvobitni_sabirac_sch_sch_tb;
  22. ARCHITECTURE behavioral OF Dvobitni_sabirac_sch_Dvobitni_sabirac_sch_sch_tb IS
  23.  
  24.    COMPONENT Dvobitni_sabirac_sch
  25.    PORT( iA0    :   IN  STD_LOGIC;
  26.           iB0   :   IN  STD_LOGIC;
  27.           oS0   :   OUT STD_LOGIC;
  28.           oC    :   OUT STD_LOGIC;
  29.           iA1   :   IN  STD_LOGIC;
  30.           iB1   :   IN  STD_LOGIC;
  31.           oS1   :   OUT STD_LOGIC);
  32.    END COMPONENT;
  33.  
  34.    SIGNAL iA0   :   STD_LOGIC;
  35.    SIGNAL iB0   :   STD_LOGIC;
  36.    SIGNAL oS0   :   STD_LOGIC;
  37.    SIGNAL oC    :   STD_LOGIC;
  38.    SIGNAL iA1   :   STD_LOGIC;
  39.    SIGNAL iB1   :   STD_LOGIC;
  40.    SIGNAL oS1   :   STD_LOGIC;
  41.  
  42. BEGIN
  43.  
  44.    UUT: Dvobitni_sabirac_sch PORT MAP(
  45.         iA0 => iA0,
  46.         iB0 => iB0,
  47.         oS0 => oS0,
  48.         oC => oC,
  49.         iA1 => iA1,
  50.         iB1 => iB1,
  51.         oS1 => oS1
  52.    );
  53.  
  54. -- *** Test Bench - User Defined Section ***
  55.    tb : PROCESS
  56.    BEGIN
  57.     iA0 <= '1';
  58.     iB0 <= '0';
  59.     iA1 <= '1';
  60.     iB1 <= '1';
  61.     wait for 50 ns;
  62.     iA0 <= '0';
  63.     iB0 <= '1';
  64.     iA1 <='1';
  65.     iB1 <= '1';
  66.     wait for 50 ns;
  67.     iA0 <= '1';
  68.     iB0 <= '1';
  69.     iA1 <='0';
  70.     iB1 <= '0';
  71.     wait for 50 ns;
  72.     iA0 <= '1';
  73.     iB0 <= '1';
  74.     iA1 <= '0';
  75.     iB1 <= '1';
  76.     wait for 50 ns;
  77.     iA0 <= '1';
  78.     iB0 <= '1';
  79.     iA1 <= '0';
  80.     iB1 <= '1';
  81.     wait for 50 ns;
  82.     iA0 <= '1';
  83.     iB0 <= '1';
  84.     iA1 <= '1';
  85.     iB1 <= '1';
  86.     wait for 50 ns;
  87.       WAIT; -- will wait forever
  88.    END PROCESS;
  89. -- *** End Test Bench - User Defined Section ***
  90.  
  91. END;
  92.  
  93.  
  94. ----------------------------------------------------------------------------------
  95. -- Company:
  96. -- Engineer:
  97. --
  98. -- Create Date:    01:16:53 11/05/2012
  99. -- Design Name:
  100. -- Module Name:    cetvorobitnisabirac_vhdl - Behavioral
  101. -- Project Name:
  102. -- Target Devices:
  103. -- Tool versions:
  104. -- Description:
  105. --
  106. -- Dependencies:
  107. --
  108. -- Revision:
  109. -- Revision 0.01 - File Created
  110. -- Additional Comments:
  111. --
  112. ----------------------------------------------------------------------------------
  113. library IEEE;
  114. use IEEE.STD_LOGIC_1164.ALL;
  115.  
  116. -- Uncomment the following library declaration if using
  117. -- arithmetic functions with Signed or Unsigned values
  118. --use IEEE.NUMERIC_STD.ALL;
  119.  
  120. -- Uncomment the following library declaration if instantiating
  121. -- any Xilinx primitives in this code.
  122. --library UNISIM;
  123. --use UNISIM.VComponents.all;
  124.  
  125. entity cetvorobitni_sabirac is
  126.     Port ( iA : in  STD_LOGIC_VECTOR (3 downto 0);
  127.            iB : in  STD_LOGIC_VECTOR (3 downto 0);
  128.            oLED : out  STD_LOGIC_VECTOR (7 downto 0);
  129.               iJOY : in STD_LOGIC_VECTOR (4 downto 0)
  130. );
  131.            
  132. end cetvorobitni_sabirac;
  133.  
  134. architecture Behavioral of cetvorobitni_sabirac is
  135.     SIGNAL oS: STD_LOGIC_VECTOR (3 downto 0);  
  136.     SIGNAL oC: STD_LOGIC_VECTOR (3 downto 0);
  137.     SIGNAL oLED1 : STD_LOGIC_VECTOR (7 downto 0); -- Led1 izlaz za plocu
  138.     SIGNAL oLED2 : STD_LOGIC_VECTOR (7 downto 0); -- Led2 izlaz za plocu
  139.    
  140.  
  141. begin
  142. -- Prvi potpuni sabirac
  143.     oC(0) <= (iA(0) and iB(0)) or (iA(0) and '0') or (iB(0) and '0');
  144.     oS(0) <= iA(0) xor iB(0) xor '0';
  145.    
  146. -- Drugi potpuni sabirac
  147.     oC(1) <= (iA(1) and iB(1)) or (iA(1) and oC(0)) or (iB(1) and oC(0));
  148.     oS(1) <= iA(1) xor iB(1) xor oC(0);
  149.    
  150. -- Treci potpuni sabirac
  151.     oC(2) <= (iA(2) and iB(2)) or (iA(2) and oC(1)) or (iB(2) and oC(1));
  152.     oS(2) <= iA(2) xor iB(2) xor oC(1);
  153.    
  154. -- Cetvrti potpuni sabirac
  155.     oC(3) <= (iA(3) and iB(3)) or (iA(3) and oC(2)) or (iB(3) and oC(2));
  156.     oS(3) <= iA(3) xor iB(3) xor oC(2);
  157.    
  158. -- Ukupna suma
  159.     oLED1 <= ("000"&oC(3)&oS);
  160.    
  161. -- Prvi dodatak
  162.     oLED2 <= ("000"&oC(3)&oS) when iJOY = "11111" else
  163.                 "00010001" when iJOY="01110" else
  164.                 "00100010" when iJOY="01101" else
  165.                 "01000100" when iJOY="01011" else
  166.                 "10001000" when iJOY="00111" else
  167.                 "11111111";
  168.                
  169. -- Drugi dodatak
  170. process(iA, iB, iJOY, oLED1, oLED2)
  171. begin
  172.     case (iA(1 downto 0)) is
  173.         when "00" => oLED <= oLED1;
  174.         when "01" => oLED <= oLED2;
  175.         when "10" => oLED <= iB&iA;
  176.         when "11" => oLED <= ("0000000" & (iA(0) xor iA(1) xor iA(2) xor iA(3) xor iB(0) xor iB(1) xor iB(2) xor iB(3)));
  177.         when others  => oLED <= "11111111";
  178.     end case;
  179. end process;
  180.    
  181. -- Treci dodatak
  182.    
  183. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement