Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the combinational circuit given below which has three inputs C1, CO, an

ID: 3723712 • Letter: C

Question

Consider the combinational circuit given below which has three inputs C1, CO, and X, three outputs C1+, C0+ and Y: Q.1. C1+ 3c1 CO+ (ii) Write a Verilog model that instantiates four copies of this circuit and connects Cl and CO of the first instance to 11, C1+ and CO+ of the first instance to C1 and CO of the 2nd instance, Cl+ and C0+ of the 2nd instance to C1 and CO of the 3rd instance, and C1+ and CO+ of the 3rd instance to C1 and C0 of the 4th instance. (iv) Write a test bench that tests the 4-bit circuit modeled in (ii) that applies the following input patterns to your circuit (X3x2x1X0)-0001, 0010, 0011, 0100 0101 and observes the obtained outputs Y3Y2Y1YO. Can you guess the functionality of the 4-bit circuit?

Explanation / Answer

ANSWER FOR (III):

VERILOG CODE:

module Top_Block(X4,X3,X2,X1,Y4,Y3,Y2,Y1,C1+out,C0+out);

input X4,X3,X2,X1;

output Y4,Y3,Y2,Y1,C1+out,C0+out;

wire k1,k2,k3,k4,k5,k6;

block c1(Y1,k1,k2,X1,1'b1,1'b1);

block c2(Y2,k3,k4,X2,k1,k2);

block c3(Y3,k5,k6,X3,k3,k4);

block c4(Y4,C1+out,C0+out,X4,k5,k6);

endmodule

module block(Y,C1+,C0+,X,C1,C0);

output Y,C1+,C2+;

input X,C0,C1;

wire n1,n2,n3,n4;

and1 m1(C1+,X,C1,C0);

not1 m2(n2,C0);

and1 m3(n1,n2,C1);

xor1 m4(n3,C1,X);

xor1 m5(Y,X,C0);

and1 m6(n4,n3,C0);

or1 m7(C0+,n1,n4);

endmodule