You are on page 1of 5

Experiment -2

Name-Saiyam sood
Roll no-21104091

Aim: Design Half-adder combinational logic circuit


using any two-modelling styles.
Using Data Flow: Code:
`timescale 1ns / 1ps
module half_adder(
input a,b,
output sum,carry
);
assign sum=a^b;
assign
carry=a&b;
endmodule

Simulation
`timescale 1ns / 1ps
module half_adder_tb;
reg a,b;
wire sum,carry;

half_adder uut(
.a(a)
.b(b),
.sum(sum),
.carry(carry)
);

initia
l
begin
a=0;b=0;

#10 a=0; b=1;


#10 a=1; b=0;
#10 a=1; b=1;
#10
$finish; end
endmodule
Using Structural:
Code:
`timescale 1ns / 1ps
module half_adder(
input a,b,
output sum,carry
);
xor(sum,a,b);
and(carry,a,b);
endmodule

Simulation:
`timescale 1ns / 1ps
module half_adder_tb;
reg a,b;
wire sum,carry;

half_adder uut(
.a(a),
.b(b),
.sum(sum),
.carry(carry)
);

initia
l
begin
a=0;b=0;
#10 a=0; b=1;
#10 a=1; b=0;
#10 a=1; b=1;
#10
$finish; end
endmodule

You might also like