VLSI-Assignment
VLSI-Assignment
Bengaluru
Assignment I
“Carry Adders (skip , save & select)”
Subject: Advanced VLSI [21EC71]
THEORY : A Carry Skip Adder is an adder that improves the performance of addition by
skipping over the carry propagation for certain conditions. It is typically used in situations
where the addition of numbers involves several bits, and the carry propagation takes too long.
By skipping certain carry propagations, the overall speed of the addition is improved.
Carry Skip Adder works by dividing the bit addition into segments and attempting to
skip over the carry propagation when it is not necessary.
The key idea is to use a condition (like a generate signal) to check if the carry for a
group of bits will propagate. If no carry propagation occurs, the adder skips over that
group and performs the addition on the next group of bits.
It is a combination of a Ripple Carry Adder and Carry Lookahead Adder where carry
is "skipped" if the condition is met, speeding up the addition process.
CIRCUIT :
CODE :
module carry_skip_adder_4bit(A [3:0], B[3:0], Cin, Sum[3:0], Cout );
wire [3:0] G;
wire [3:0] P;
wire [3:0] C;
assign G = A & B;
assign P = A ^ B;
assign C[0] = Cin;
assign C[1] = G[0] | (P[0] & C[0]);
assign C[2] = G[1] | (P[1] & C[1]);
assign C[3] = G[2] | (P[2] & C[2]);
assign Sum = P ^ C[3:0];
assign Cout = G[3] | (P[3] & C[3]);
endmodule
Testbench:
module tb_carry_skip_adder_4bit;
reg [3:0] A;
reg [3:0] B;
reg Cin;
wire [3:0] Sum;
wire Cout;
initial begin
$monitor("A = %b, B = %b, Cin = %b, Sum = %b, Cout = %b", A, B, Cin, Sum, Cout);
A = 4'b0011; B = 4'b0101; Cin = 1'b0; #10;
A = 4'b1100; B = 4'b1010; Cin = 1'b0; #10;
A = 4'b1111; B = 4'b1111; Cin = 1'b1; #10;
A = 4'b1001; B = 4'b0110; Cin = 1'b1; #10;
A = 4'b0000; B = 4'b0000; Cin = 1'b0; #10;
A = 4'b1111; B = 4'b0001; Cin = 1'b0; #10;
$finish;
end
endmodule
OUTPUT :
Then, these results are combined in further stages (if multiple operands are involved).
CIRCUIT:
CODE:
module fulladder(input a,b,cin,output sum,carry);
assign sum = a ^ b ^ cin;
assign carry = (a & b) | (cin & b) | (a & cin);
endmodule
Testbench:
module tb_adder;
reg [3:0] x,y,z;
wire [4:0] s;
wire cout;
integer i,j,k,error;
CSA uut(x,y,z,s,cout);
initial begin
x = 0;
y = 0;
z = 0;
error = 0;
for(i=0;i<16;i=i+1) begin
for(j=0;j<16;j=j+1) begin
for(k=0;k<16;k=k+1) begin
x = i;
y = j;
z = k;
#10;
if({cout,s} != (i+j+k))
error <= error + 1;
end
end
end
end
endmodule
OUTPUT:
3. AIM: Carry select Adder
THEORY: The Carry Select Adder is a fast adder used for binary addition, designed to speed
up the computation by reducing the time delay of carry propagation.The Carry Select Adder
works by calculating the sum of two binary numbers in parallel, considering both possible
values of the carry-in: 0 and 1. It then selects the correct sum and carry-out based on the
actual carry-in.
The key idea behind the carry select adder is to use multiple Ripple Carry Adders to calculate
the sum of the two input numbers for both possible carry-in values, and then select the correct
result using multiplexers.
CIRCUIT:
CODE:
module fulladder(input a,b,cin,output sum,carry);
assign sum = a ^ b ^ cin;
assign carry = (a & b) | (cin & b) | (a & cin);
endmodule
Testbench:
module tb_adder;
reg [3:0] A,B;
reg cin;
wire [3:0] S;
wire cout;
integer i,j,error;
carry_select_adder uut(.A(A),.B(B),.cin(cin),.S(S),.cout(cout));
initial begin
A = 0;
B = 0;
error = 0;
cin = 0;
for(i=0;i<16;i=i+1) begin
for(j=0;j<16;j=j+1) begin
A = i;
B = j;
#10;
if({cout,S} != (i+j))
error <= error + 1;
end
end
cin = 1;
for(i=0;i<16;i=i+1) begin
for(j=0;j<16;j=j+1) begin
A = i;
B = j;
#10;
if({cout,S} != (i+j+1))
error <= error + 1;
end
end
end
endmodule
OUTPUT: