Combine circuits A and B
module top_module (input x, input y, output z);
wire A_Z1;
wire A_Z2;
wire B_Z1;
wire B_Z2;
wire AB_1;
wire AB_2;
assign AB_1 = A_Z1|B_Z1;
assign AB_2 = A_Z2&B_Z2;
assign z = AB_1^AB_2;
a A_IA1(
.x(x),
.y(y),
.z(A_Z1)
);
a A_IA2(
.x(x),
.y(y),
.z(A_Z2)
);
b B_IB1(
.x(x),
.y(y),
.z(B_Z1)
);
b B_IB2(
.x(x),
.y(y),
.z(B_Z2)
);
endmodule
module a (
input wire x,
input wire y,
output wire z
);
assign z = (x^y) & x;
endmodule
module b (
input wire x,
input wire y,
output wire z
);
assign z = ~(x^y);
endmodule