-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathALU.vhd
More file actions
executable file
·79 lines (48 loc) · 1.47 KB
/
ALU.vhd
File metadata and controls
executable file
·79 lines (48 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
----------------------------------------------------------------------------------
--ALU implementation
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ALU is
port(A,B: in std_logic_vector(15 downto 0);
s0,s1,cin,s2:in std_logic;
nf:out std_logic;
zf:out std_logic;
ovf:out std_logic;
cout: out std_logic;
Gout: out std_logic_vector(15 downto 0)
);
end ALU;
architecture Behavioral of ALU is
signal G_arith,G_logic: std_logic_vector(15 downto 0);
component arithmeticUnit
port(Ain,Bin:in std_logic_vector(15 downto 0);
s0,s1,cin: in std_logic;
nf:out std_logic;
zf:out std_logic;
ovf:out std_logic;
cout: out std_logic;
G:out std_logic_vector(15 downto 0)
);
end component;
component logicUnit
port(Ain,Bin:in std_logic_vector(15 downto 0);
s0,s1: in std_logic;
G:out std_logic_vector(15 downto 0)
);
end component;
component mux_16bit
port ( in0 : in std_logic_vector(15 downto 0);
in1 : in std_logic_vector(15 downto 0);
s : in std_logic;
Z : out std_logic_vector(15 downto 0));
end component;
begin
arithmetic: arithmeticUnit
port map(A,B,s0,s1,cin,nf,zf,ovf,cout,G_arith);
logic: logicUnit
port map(A,B,s0,s1,G_logic);
--select arithmetic or logic unit, the two inputs are G1 AND G2, ARITHMETIC AND LOGIC RESULT RESPECTIVELY.
ALU_MUX: mux_16bit
port map(G_arith,G_logic,s2,Gout);
end Behavioral;