Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module fac(input x, y, ci,
- output co, z);
- assign {co,z}=x+y+ci;
- endmodule
- module add2b(input [1:0] x, y,
- input ci,
- output [1:0] z,
- output co);
- wire c1;
- fac fac1(.x(x[0]), .y(y[0]), .ci(ci), .z(z[0]), .co(c1));
- fac fac2(.x(x[1]), .y(y[1]), .ci(c1), .z(z[1]), .co(co));
- endmodule
- module add2b_tb;
- reg[1:0] x, y;
- reg ci;
- wire[1:0] z;
- wire co;
- add2b add2b_i(.x(x), .y(y), .ci(ci), .co(co), .z(z));
- integer k;
- initial begin
- $display("Time\tx\ty\tci\t\tco\tz");
- $monitor("%0t\t%b\t%b\t%b\t\t%b\t%b", $time, x,x, y,y, ci, co, z,z);
- for (k = 0; k < 32; k = k + 1) begin
- {x,y,ci} = k;
- #10;
- end
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement