18251A04C0
Sharon priyanka
Aim:to test and design Fulladder in dataflow, structural, behavioural methods
Software :edaplayground
FULLADDER BEHAVIORAL
// Code your testbench here
// or browse Examples
module fa_tb;
reg a,b,cin;
wire s,cout;
fa uut(a,b,cin,s,cout);
initial
begin
$dumpfile("[Link]");
$dumpvars();
a=1'b0;b=1'b0;cin=1'b0;
#10;a=1'b0;b=1'b0;cin=1'b1;
#10;a=1'b0;b=1'b1;cin=1'b0;
#10;a=1'b0;b=1'b1;cin=1'b1;
#10;a=1'b1;b=1'b0;cin=1'b0;
#10;a=1'b1;b=1'b0;cin=1'b1;
#10;a=1'b1;b=1'b1;cin=1'b0;
#10;a=1'b1;b=1'b1;cin=1'b1;
end
initial#80;
endmodule
// Code your design here
module fa(a,b,cin,s,cout);
input a,b,cin;
output s,cout;
reg s,cout;
always@(a,b,cin)
begin
if(a==0&&b==0&&cin==0)
begin
s=0;
cout=0;
end
else
if(a==0&&b==0&&cin==1)
begin
s=1;
cout=0;
end
else
if(a==0&&b==1&&cin==0)
begin
s=1;
cout=0;
end
else
if(a==0&&b==1&&cin==1)
begin
s=0;
cout=1;
end
else
if(a==1&&b==0&&cin==0)
begin
s=1;
cout=0;
end
else
if(a==1&&b==0&&cin==1)
begin
s=0;
cout=1;
end
else
if(a==1&&b==1&&cin==0)
begin
s=0;
cout=1;
end
else
if(a==1&&b==1&&cin==1)
begin
s=1;
cout=1;
end
end
endmodule
Full adder structural
// Code your testbench here
// or browse Examples
module fa_tb;
reg a,b,cin;
wire s,cout;
fa uut(a,b,cin,s,cout);
initial
begin
$dumpfile("[Link]");
$dumpvars();
a=1'b0;b=1'b0;cin=1'b0;
#10;a=1'b0;b=1'b0;cin=1'b1;
#10;a=1'b0;b=1'b1;cin=1'b0;
#10;a=1'b0;b=1'b1;cin=1'b1;
#10;a=1'b1;b=1'b0;cin=1'b0;
#10;a=1'b1;b=1'b0;cin=1'b1;
#10;a=1'b1;b=1'b1;cin=1'b0;
#10;a=1'b1;b=1'b1;cin=1'b1;
end
initial#80;
endmodule
module fa(a,b,cin,s,cout);
input a,b,cin;
output s,cout;
wire p,q,r;
xor v1(s,a,b,cin);
and v2(p,a,b);
and v3(q,b,cin);
and v4(r,a,cin);
or v5(cout,p,q,r);
endmodule
Fulladder dataflow
// Code your testbench here
• // or browse Examples
• module fa_tb;
• reg a,b,cin;
• wire s,cout;
• fa uut(a,b,cin,s,cout);
• initial
• begin
• $dumpfile("[Link]");
• $dumpvars();
• a=1'b0;b=1'b0;cin=1'b0;
• #10;a=1'b0;b=1'b0;cin=1'b1;
• #10;a=1'b0;b=1'b1;cin=1'b0;
• #10;a=1'b0;b=1'b1;cin=1'b1;
• #10;a=1'b1;b=1'b0;cin=1'b0;
• #10;a=1'b1;b=1'b0;cin=1'b1;
• #10;a=1'b1;b=1'b1;cin=1'b0;
• #10;a=1'b1;b=1'b1;cin=1'b1;
• end
• initial#80;
• endmodule
• // Code your design here
• module fa(a,b,cin,s,cout);
• input a,b,cin;
• output s,cout;
• assign s=(a^b^cin);
• assign cout=(a&b)|(b&cin)|(a&cin);
• endmodule
Result:Fulladder is realized in data flow, behavioural, structural methods using eda software