forked from MahmoudSamy1452/6StageProcessor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_adder.vhd
32 lines (25 loc) · 867 Bytes
/
select_adder.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
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
ENTITY select_adder IS
generic (n: integer := 8);
PORT (a,b : IN std_logic_vector(n-1 downto 0);
cin : in std_logic;
s : out std_logic_vector(n-1 downto 0);
cout : OUT std_logic );
END select_adder;
ARCHITECTURE a_my_adder OF select_adder IS
component my_nadder IS
generic (n: integer := 8);
PORT (a,b : IN std_logic_vector(n-1 downto 0);
cin : in std_logic;
s : out std_logic_vector(n-1 downto 0);
cout : OUT std_logic );
END component;
signal S0,S1 : std_logic_vector( n-1 downto 0);
signal cout0,cout1:std_logic;
BEGIN
f0:my_nadder generic map(n) port map(a,b,'0',s0,cout0);
f1:my_nadder generic map(n) port map(a,b,'1',s1,cout1);
s <= s0 when cin ='0' else s1;
cout <= cout0 when cin = '0' else cout1;
END a_my_adder;