Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 7.04 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    08:44:54 10/18/2017
  6. -- Design Name:
  7. -- Module Name:    ALU - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25.  
  26. -- Uncomment the following library declaration if using
  27. -- arithmetic functions with Signed or Unsigned values
  28. --use IEEE.NUMERIC_STD.ALL;
  29.  
  30. -- Uncomment the following library declaration if instantiating
  31. -- any Xilinx primitives in this code.
  32. --library UNISIM;
  33. --use UNISIM.VComponents.all;
  34.  
  35. entity ALU is
  36.     Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
  37.            B : in  STD_LOGIC_VECTOR (3 downto 0);
  38.            f0 : in  STD_LOGIC;
  39.            f1 : in  STD_LOGIC;
  40.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  41. end ALU;
  42.  
  43. architecture Behavioral of ALU is
  44.  
  45. begin
  46. process(f0,f1)
  47. begin
  48. if (f0='0' and f1='0') then
  49.   Y<=A+B;
  50.   elsif  (f0='1' and f1='0') then
  51.   Y<=A-B;
  52.   end if;
  53. end process;
  54. end Behavioral;
  55.  
  56.  
  57. ----------------------------------------------------------------------------------
  58. -- Company:
  59. -- Engineer:
  60. --
  61. -- Create Date:    09:03:22 10/18/2017
  62. -- Design Name:
  63. -- Module Name:    ALU2 - Behavioral
  64. -- Project Name:
  65. -- Target Devices:
  66. -- Tool versions:
  67. -- Description:
  68. --
  69. -- Dependencies:
  70. --
  71. -- Revision:
  72. -- Revision 0.01 - File Created
  73. -- Additional Comments:
  74. --
  75. ----------------------------------------------------------------------------------
  76. library IEEE;
  77. use IEEE.STD_LOGIC_1164.ALL;
  78. use IEEE.STD_LOGIC_ARITH.ALL;
  79. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  80.  
  81. -- Uncomment the following library declaration if using
  82. -- arithmetic functions with Signed or Unsigned values
  83. --use IEEE.NUMERIC_STD.ALL;
  84.  
  85. -- Uncomment the following library declaration if instantiating
  86. -- any Xilinx primitives in this code.
  87. --library UNISIM;
  88. --use UNISIM.VComponents.all;
  89.  
  90. entity ALU2 is
  91.     Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
  92.            B : in  STD_LOGIC_VECTOR (3 downto 0);
  93.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  94. end ALU2;
  95.  
  96. architecture Behavioral of ALU2 is
  97.  
  98. begin
  99. Y<= A and B;
  100. end Behavioral;
  101.  
  102.  
  103. - Company:
  104. -- Engineer:
  105. --
  106. -- Create Date:    09:05:37 10/18/2017
  107. -- Design Name:
  108. -- Module Name:    ALU3 - Behavioral
  109. -- Project Name:
  110. -- Target Devices:
  111. -- Tool versions:
  112. -- Description:
  113. --
  114. -- Dependencies:
  115. --
  116. -- Revision:
  117. -- Revision 0.01 - File Created
  118. -- Additional Comments:
  119. --
  120. ----------------------------------------------------------------------------------
  121. library IEEE;
  122. use IEEE.STD_LOGIC_1164.ALL;
  123. use IEEE.STD_LOGIC_ARITH.ALL;
  124. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  125.  
  126. -- Uncomment the following library declaration if using
  127. -- arithmetic functions with Signed or Unsigned values
  128. --use IEEE.NUMERIC_STD.ALL;
  129.  
  130. -- Uncomment the following library declaration if instantiating
  131. -- any Xilinx primitives in this code.
  132. --library UNISIM;
  133. --use UNISIM.VComponents.all;
  134.  
  135. entity ALU3 is
  136.     Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
  137.            B : in  STD_LOGIC_VECTOR (3 downto 0);
  138.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  139. end ALU3;
  140.  
  141. architecture Behavioral of ALU3 is
  142.  
  143. begin
  144. Y<= A and B;
  145. end Behavioral;
  146.  
  147.  
  148. ----------------------------------------------------------------------------------
  149. -- Company:
  150. -- Engineer:
  151. --
  152. -- Create Date:    09:09:02 10/18/2017
  153. -- Design Name:
  154. -- Module Name:    MUX - Behavioral
  155. -- Project Name:
  156. -- Target Devices:
  157. -- Tool versions:
  158. -- Description:
  159. --
  160. -- Dependencies:
  161. --
  162. -- Revision:
  163. -- Revision 0.01 - File Created
  164. -- Additional Comments:
  165. --
  166. ----------------------------------------------------------------------------------
  167. library IEEE;
  168. use IEEE.STD_LOGIC_1164.ALL;
  169.  
  170. -- Uncomment the following library declaration if using
  171. -- arithmetic functions with Signed or Unsigned values
  172. --use IEEE.NUMERIC_STD.ALL;
  173.  
  174. -- Uncomment the following library declaration if instantiating
  175. -- any Xilinx primitives in this code.
  176. --library UNISIM;
  177. --use UNISIM.VComponents.all;
  178.  
  179. entity MUX is
  180.     Port ( i0 : in  STD_LOGIC_VECTOR (4 downto 0);
  181.            i1 : in  STD_LOGIC_VECTOR (4 downto 0);
  182.            i2 : in  STD_LOGIC_VECTOR (4 downto 0);
  183.            i3 : in  STD_LOGIC_VECTOR (4 downto 0);
  184.            f0 : in  STD_LOGIC;
  185.            f1 : in  STD_LOGIC;
  186.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  187. end MUX;
  188.  
  189. architecture Behavioral of MUX is
  190.  
  191. begin
  192. Y<= i0 when (f1='0' and f0='0') else
  193.         i1 when (f1='0' and f0='1') else
  194.         i2 when (f1='1' and f0='0') else
  195.         i3;
  196.  
  197. end Behavioral;
  198.  
  199. ----------------------------------------------------------------------------------
  200. -- Company:
  201. -- Engineer:
  202. --
  203. -- Create Date:    09:20:29 10/18/2017
  204. -- Design Name:
  205. -- Module Name:    ALU_D - str_arch
  206. -- Project Name:
  207. -- Target Devices:
  208. -- Tool versions:
  209. -- Description:
  210. --
  211. -- Dependencies:
  212. --
  213. -- Revision:
  214. -- Revision 0.01 - File Created
  215. -- Additional Comments:
  216. --
  217. ----------------------------------------------------------------------------------
  218. library IEEE;
  219. use IEEE.STD_LOGIC_1164.ALL;
  220. use IEEE.STD_LOGIC_ARITH.ALL;
  221. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  222.  
  223.  
  224.  
  225. -- Uncomment the following library declaration if using
  226. -- arithmetic functions with Signed or Unsigned values
  227. --use IEEE.NUMERIC_STD.ALL;
  228.  
  229. -- Uncomment the following library declaration if instantiating
  230. -- any Xilinx primitives in this code.
  231. --library UNISIM;
  232. --use UNISIM.VComponents.all;
  233.  
  234. entity ALU_D is
  235.  
  236. end ALU_D;
  237. port (Af : in  STD_LOGIC_VECTOR (3 downto 0);
  238.            Bf : in  STD_LOGIC_VECTOR (3 downto 0);
  239.            f0f : in  STD_LOGIC;
  240.            f1f : in  STD_LOGIC;
  241.            Yf : out  STD_LOGIC_VECTOR (4 downto 0));
  242. architecture str_arch of ALU_D is
  243. component ALU
  244. port (A : in  STD_LOGIC_VECTOR (3 downto 0);
  245.            B : in  STD_LOGIC_VECTOR (3 downto 0);
  246.            f0 : in  STD_LOGIC;
  247.            f1 : in  STD_LOGIC;
  248.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  249.               end component;
  250. component ALU2
  251.  Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
  252.            B : in  STD_LOGIC_VECTOR (3 downto 0);
  253.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  254. end component;
  255.    
  256. component ALU3
  257. Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
  258.            B : in  STD_LOGIC_VECTOR (3 downto 0);
  259.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  260. end component;
  261. component MUX
  262. Port ( i0 : in  STD_LOGIC_VECTOR (4 downto 0);
  263.            i1 : in  STD_LOGIC_VECTOR (4 downto 0);
  264.            i2 : in  STD_LOGIC_VECTOR (4 downto 0);
  265.            i3 : in  STD_LOGIC_VECTOR (4 downto 0);
  266.            f0 : in  STD_LOGIC;
  267.            f1 : in  STD_LOGIC;
  268.            Y : out  STD_LOGIC_VECTOR (4 downto 0));
  269. end component;
  270.    
  271. signal p1,p2,p3 : 4 downto 0;  
  272.  
  273. begin
  274. unit1: ALU port map ()
  275.  
  276. end str_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement