Professional Documents
Culture Documents
Assignment-I
In the given data path, any path can be taken as critical path.
We have to ignore setup time and clock to q frequency.
Therefore, delay is of the 2 adder blocks in a data path.
I.e. 2+2 = 4ns.
Since the delay is of 4ns, the frequency is 0.25GHz.
If the time period of the clock is kept less than 4ns,
The output will not be optimum.
In data path 2, one advantage of using E and F registers is to keep the intermediate
computational results within the same clock cycles.
In simpler words, we can know the sum of our individual adder blocks.
In the case where we are not using the register, we cannot see the sum of individual adder
blocks.
Rather, only the final output are known.
Also, since the clock to Q delay and setup times are negligible,
There would not b and added delay due to it.
Therefore, data path 2 is better design in this case.
VERILOG CODE FOR LEAF CELLS AND TESTBENCH:
1) 4 BIT REGISTER
module register (out, data, clk);
output reg [3:0]out;
input [3:0]data;
input clk;
always @ (posedge clk)
assign out = data;
endmodule
4 BIT REGISTER TESTBENCH
module stimulus_reg;
reg clk;
reg [3:0]data;
wire [3:0]out;
register r(out, data, clk);
initial
clk = 1'b1;
always
#5 clk= ~clk;
initial
begin
data = 4'b0000;
#10 data = 4'b1000;
#10 data = 4'b1010;
#10 data = 4'b1100;
#10 data = 4'b1011;
#10 $finish;
end
endmodule
2) 1 BIT FULL ADDER
module stimulus_FA;
reg a, b, ci;
wire co, s;
FA F1(s, co, a, b, ci);
initial
begin
a=1'b0; b=1'b0; ci=0;
#10 a=1'b0; b=1'b0;
#10 a=1'b0; b=1'b1;
#10 a=1'b1; b=1'b0;
#10 a=1'b1; b=1'b1;
#10 $finish;
end
endmodule
3) 4 BIT FULL ADDER
module stimulus_FA4;
reg [3:0]a, b;
reg ci;
wire co;
wire [3:0]s;
FA4 F(s, co, a, b, ci);
initial
begin
a=4'b0000; b=4'b0000; ci=0;
#10 a=4'b0001; b=4'b0010;
#10 a=4'b0010; b=4'b1001;
#10 a=4'b1001; b=4'b0101;
#10 a=4'b0101; b=4'b0111;
#10 $finish;
end
endmodule
VERILOG CODE FOR DATA PATH 1
input [3:0]a, b, c, d;
input [2:0]ci;
output [3:0]x;
output [2:0]co;
wire [3:0]w [0:8];
assign clk=1;
register A(w[0], a, clk);
register B(w[1], b, clk);
register C(w[2], c, clk);
register D(w[3], d, clk);
FA4 M1(w[4], co[0], w[0], w[1], ci[0]);
FA4 M2(w[5], co[1], w[2], w[3], ci[1]);
register E(w[6], w[4], clk);
register F(w[7], w[5], clk);
FA4 M3(w[8], co[2], w[6], w[7], ci[2]);
register S(x, w[8], clk);
endmodule
TESTBENCH FOR DATA PATH 1 AND 2
module stimulus_addertree;
reg [3:0]a, b, c, d;
reg [2:0]ci;
wire [3:0]x;
wire [2:0]co;
reg clk;
addertree1 a1(x, co, a, b, c, d, ci);
//addertree2 a2(x, co, a, b, c, d, ci);
initial
clk=1'b1;
always
#5 clk= ~clk;
initial
begin
a=4'b0000; b=4'b0000; c=4'b0000; d=4'b0000; ci[0]=0; ci[1]=0; ci[2]=0;
#10 a=4'b0001; b=4'b0011;
#10 a=4'b0010; b=4'b0011;
#10 a=4'b0010; b=4'b0101;
#10 a=4'b0110; b=4'b0010;
#10 $finish;
end
initial
begin
#10 c=4'b0101; d=4'b0100;
#10 c=4'b0100; d=4'b0010;
#10 c=4'b0110; d=4'b0001;
#10 c=4'b0011; d=4'b0100;
#10 $finish;
end
endmodule
TESTBENCH WAVEFORM FOR DATA PATH 1