3 Bit ALU Using Schematic Capture
3 Bit ALU Using Schematic Capture
1 bit adder
1 bit adder: module adder(a,b,c,f,carry); input a,b,c; output f,carry; wire w1,w2,w3; xor xor1(w1,a,b); xor xor2(f,w1,c); and and1(w2,w1,c); and and2(w3,a,b); or or1(carry,w2,w3); endmodule
4 bit full adder using function: module adder(a,b,c,f,carry); input a,b,c; output f,carry;
wire w1,w2,w3;
xor xor1(w1,a,b); xor xor2(f,w1,c); and and1(w2,w1,c); and and2(w3,a,b); or or1(carry,w2,w3);
endmodule
wire w1,w2,w3;
adder adder1(a0,b0,c0,f0,w1); adder adder2(a1,b1,w1,f1,w2); adder adder3(a2,b2,w2,f2,w3); adder adder4(a3,b3,w3,f3,f_carry); endmodule
O1 = ab
O2 = ab
O3 = ab+ab
CIRCUIT DIAGRAM
1 bit comparator:
module comp(a,b,o1,o2,o3);
S0 0
S1 0
O/P add
0
1 1
1
0 1
subtract
and or
Steps: 1. design 4 to 1 mux using 3 2 to 1 mux 2. design half adder & make the block 3. design half subtractor & make the block 4. design the ALU
BLOCK DIAGRAM
0
1
CIRCUIT DIAGRAM
BLOCK DIAGRAM
half subtractor
a 0 0 1 1 b 0 1 0 1 diff 0 1 1 0 borrow
0
1
0
0
diff = ab+ab
borrow = ab
CIRCUIT DIAGRAM
BLOCK DIAGRAM
ALU DESIGN