-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLA4.hdl
47 lines (35 loc) · 1.33 KB
/
CLA4.hdl
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
/*
* 4 bit CLA
*/
CHIP CLA4{
IN x[4] , y[4] , C;
OUT S[4] , Cn-1;
PARTS:
Xor(a = x[0] , b = y[0] , out = P0);
Xor(a = x[1] , b = y[1] , out = P1);
Xor(a = x[2] , b = y[2] , out = P2);
Xor(a = x[3] , b = y[3] , out = P3);
And(a = x[0] , b = y[0] , out = G0);
And(a = x[1] , b = y[1] , out = G1);
And(a = x[2] , b = y[2] , out = G2);
And(a = x[3] , b = y[3] , out = G3);
And(a = P0 , b = C , out = Ct1);
Or(a = Ct1 , b = G0 , out = C1); // C1 = P0.C + G0
And3In(a = P1 , b = P0 , c = C, out = Ct2);
And(a = P1 , b = G0 , out = C2t2);
OR3IN(a = Ct2 , b = C2t2 , c = G1 , out = C2); // C2 = P1.P0.C + P1.G0 + G1
And4In(a = P2 , b = P1 , c = P0 , d = C , out = Ct3);
And3In(a = P2 , b = P1 , c = G0 , out = C2t3);
And(a = P2 , b = G1 , out = C3t3);
OR4IN(a = Ct3 , b = C2t3 , c = C3t3 , d = G2, out = C3); // C3 = P2.P1.P0.C + P2.P1.G0 + P1.G1 + G2
Or(a = C3 , b = false , out = Cn-1);
// S[i] = ( x[i] Xor y[i] ) Xor Ci (C0 = C)
Xor(a = x[0] , b = y[0] , out = t10);
Xor(a = t10 , b = C , out = S[0]);
Xor(a = x[1] , b = y[1] , out = t11);
Xor(a = t11 , b = C1 , out = S[1]);
Xor(a = x[2] , b = y[2] , out = t12);
Xor(a = t12 , b = C2 , out = S[2]);
Xor(a = x[3] , b = y[3] , out = t13);
Xor(a = t13 , b = C3 , out = S[3]);
}