1 | -- Additionneur 4 bits avec report entrant et sortant |
---|
2 | |
---|
3 | ENTITY adder IS |
---|
4 | PORT ( |
---|
5 | i0 : IN BIT_VECTOR(3 DOWNTO 0); |
---|
6 | i1 : IN BIT_VECTOR(3 DOWNTO 0); |
---|
7 | q : OUT BIT_VECTOR(3 DOWNTO 0); |
---|
8 | cin : IN BIT; |
---|
9 | cout : OUT BIT; |
---|
10 | vdd : IN BIT; |
---|
11 | vss : IN BIT |
---|
12 | ); |
---|
13 | END adder; |
---|
14 | |
---|
15 | ARCHITECTURE vbe OF adder IS |
---|
16 | |
---|
17 | SIGNAL carry : BIT_VECTOR(4 DOWNTO 0) ; |
---|
18 | |
---|
19 | BEGIN |
---|
20 | |
---|
21 | carry(0) <= cin; |
---|
22 | carry(4 DOWNTO 1) <= ( ( i1(3 DOWNTO 0) AND i0(3 DOWNTO 0) ) OR |
---|
23 | ( i0(3 DOWNTO 0) AND carry(3 DOWNTO 0) ) OR |
---|
24 | ( carry(3 DOWNTO 0) AND i1(3 DOWNTO 0) ) ) ; |
---|
25 | q <= i0 XOR i1 XOR carry(3 DOWNTO 0) ; |
---|
26 | cout <= carry(2); |
---|
27 | |
---|
28 | END; |
---|