summaryrefslogtreecommitdiff
path: root/testsuite/gna/bug15993/cells.vhdl
blob: 98a1aa507f32f72fbe604a782da3ea19f1b21f69 (plain)
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
-------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
-------------------------------------------------------------------------------
--| c | a | b | s | c
--|---+---+---+---+--
--| 0 | 0 | 0 | 0 | 0
--| 0 | 0 | 1 | 1 | 0
--| 0 | 1 | 0 | 1 | 0
--| 0 | 1 | 1 | 0 | 1
--| 1 | 0 | 0 | 1 | 0
--| 1 | 0 | 1 | 0 | 1
--| 1 | 1 | 0 | 0 | 1
--| 1 | 1 | 1 | 1 | 1

ENTITY addern IS
    GENERIC ( n : INTEGER );
    PORT ( a, b : IN STD_LOGIC_VECTOR ( n-1 DOWNTO 0 );
            cin : IN STD_LOGIC;
            sum : OUT STD_LOGIC_VECTOR ( n DOWNTO 0 ) );
END addern;

ARCHITECTURE behave OF addern IS

    SIGNAL carry : STD_LOGIC;
BEGIN
    carry <= cin;
    suma : FOR i IN 0 TO n - 1 GENERATE
        sum(i) <= ( a(i) XOR b(i) ) XOR carry ;
        carry  <= ( a(i) AND b(i) ) OR (carry AND ( a(i) XOR b(i) ));
    END GENERATE;
    sum(n) <= carry;
END behave;