dsy_assignment1
dsy_assignment1
ASSIGNMENT – 1
ADDERS
Design code : -
module FA_usingHA(
input a,
input b,
input c,
output sum,
output carry);
wire w1,w2,w3;
half_adder_dataflow i1(a,b,w2,w1);
half_adder_dataflow i2(w2,c,sum,w3);
or i3(carry,w1,w3);
Testbench Code : -
module tb_FA(
);
reg A,B,C;
wire sum,carry;
FA_usingHA dut(.a(A),.b(B),.c(C),.sum(sum),.carry(carry));
initial begin
A=0;B=0;C=0; #10;
A=0;B=1;C=0; #10;
A=0;B=0;C=1; #10;
A=0;B=1;C=1; #10;
A=1;B=0;C=0; #10;
A=1;B=1;C=0; #10;
A=1;B=0;C=1; #10;
A=1;B=1;C=1; #10;
$finish;
end
endmodule
Desgin Code : -
module twob_mul(
input [1:0] a,
input [1:0] b,
output [3:0] p
);
pin3, pcarry;
half_adder ha1(
.a(pin1),
.b(pin2),
.sum(p[1]),
.carry(pcarry)
);
endmodule
Testbench Code : -
module
twob_mul_tb; reg
[1:0] a;
reg [1:0] b;
wire [3:0] p;
twob_mul tb(
.a(a),
.b(b),
.p(p)
);
initial begin
a = 2'b00; b = 2'b00;
#10; a = 2'b00; b =
2'b01; #10;
a = 2'b00; b = 2'b10;
#10; a = 2'b00; b =
2'b11; #10; a =
2'b01; b = 2'b00;
#10; a = 2'b01; b =
2'b01; #10; a =
2'b01; b = 2'b10;
#10; a = 2'b01; b =
2'b11; #10; a =
2'b10; b = 2'b00;
#10; a = 2'b10; b =
2'b01; #10; a =
2'b10; b = 2'b10;
#10; a = 2'b10; b =
2'b11; #10; a =
2'b11; b = 2'b00;
#10; a = 2'b11; b =
2'b01; #10; a =
2'b11; b = 2'b10;
#10; a = 2'b11; b =
2'b11; #10;
$finis
h; end
endmodule
Two bit multiplier Simulation Output