Aim: Sofware Used: Theory
Aim: Sofware Used: Theory
Theory :
The operations of both addition and subtraction can be performed by a one common binary adder
Here in this design designed module adds when ‘ar’ is high and subtracts when ‘ar’ is low.
RTL Schematic :
Test bench of Full Adder/ Subtractor :
`timescale 1ns / 1ps
module adsub;
reg a; reg b; reg c; reg ar ;wire sd; wire cout;
addsub uut (a,b,c,ar,sd,cout);
initial
begin
#10 a=1'b0;b=1'b0;c=1'b0;ar=1'b0;
#10 a=1'b0;b=1'b0;c=1'b1;
#10 a=1'b0;b=1'b1;c=1'b0;
#10 a=1'b0;b=1'b1;c=1'b1;
#10 a=1'b1;b=1'b0;c=1'b0;
#10 a=1'b1;b=1'b0;c=1'b1;
#10 a=1'b1;b=1'b1;c=1'b0;
#10 a=1'b1;b=1'b1;c=1'b1;
#10 a=1'b0;b=1'b0;c=1'b0;ar=1'b1;
#10 a=1'b0;b=1'b0;c=1'b1;
#10 a=1'b0;b=1'b1;c=1'b0;
#10 a=1'b0;b=1'b1;c=1'b1;
#10 a=1'b1;b=1'b0;c=1'b0;
#10 a=1'b1;b=1'b0;c=1'b1;
#10 a=1'b1;b=1'b1;c=1'b0;
#10 a=1'b1;b=1'b1;c=1'b1;
#10
$stop; end
endmodule
Simulation results:
Results :
Dataflow verilog module of Full Adder/Full subtractor designed.