-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU.vhd
64 lines (39 loc) · 1.48 KB
/
ALU.vhd
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
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use IEEE.numeric_STD.ALL;
entity ALU_ENTITY is
port(
Data1,Data2: in std_logic_vector (31 downto 0);
OpCode: in std_logic_vector(3 downto 0);
enable : in std_logic;
FlagsIn:in std_logic_vector(2 downto 0) ;
FlagsOut:out std_logic_vector(2 downto 0) ;
Result : out std_logic_vector(31 downto 0));
end entity ALU_ENTITY;
architecture ALU_ARCH of ALU_ENTITY is
component ALU_PortA_Entity is
port(
Data1,Data2: in std_logic_vector (31 downto 0) ;
S: in std_logic_vector(2 downto 0);
FlagsIn:in std_logic_vector(2 downto 0);
FlagsOut:out std_logic_vector(2 downto 0) ;
F : out std_logic_vector(31 downto 0));
end component ALU_PortA_Entity;
component ALU_PORTB_ENTITY is
port(
Data1,Data2: in std_logic_vector (31 downto 0) ;
S: in std_logic_vector(2 downto 0);
FlagsIn : in std_logic_vector (2 downto 0) ;
FlagsOut : out std_logic_vector (2 downto 0) ;
F : out std_logic_vector(31 downto 0));
end component ALU_PORTB_ENTITY;
signal PAOUT,PBOUT :std_logic_vector (31 downto 0);
signal FA, FB, FC :std_logic_vector (2 downto 0);
Begin
pa:ALU_PORTA_ENTITY PORT MAP(Data1,Data2,OpCode(2 downto 0),FlagsIn,FA,PAOUT) ;
pb:ALU_PORTB_ENTITY PORT MAP(Data1,Data2,OpCode(2 downto 0),FlagsIn,FB,PBOUT) ;
FlagsOut <= FA WHEN OpCode(3) ='0' and enable = '1'
ELSE FB when OpCode(3) ='1' and enable = '1' ;
Result <= PAOUT WHEN OpCode(3) ='0'
ELSE PBOUT ;
end architecture;