Advertisement
STANAANDREY

av lab4 pb3

Oct 24th, 2023 (edited)
1,549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module fac(input x, y, ci,
  2.            output co, z);
  3.     assign {co,z}=x+y+ci;
  4. endmodule
  5.  
  6. module add2b(input [1:0] x, y,
  7.                       input ci,
  8.                       output [1:0] z,
  9.                       output co);
  10.  
  11.         wire c1;
  12.     fac fac1(.x(x[0]), .y(y[0]), .ci(ci), .z(z[0]), .co(c1));
  13.         fac fac2(.x(x[1]), .y(y[1]), .ci(c1), .z(z[1]), .co(co));
  14.    
  15. endmodule
  16.  
  17.  
  18. module add2b_tb;
  19.     reg[1:0] x, y;
  20.     reg ci;
  21.     wire[1:0] z;
  22.     wire co;
  23.     add2b add2b_i(.x(x), .y(y), .ci(ci), .co(co), .z(z));
  24.     integer k;
  25.         initial begin
  26.             $display("Time\tx\ty\tci\t\tco\tz");
  27.             $monitor("%0t\t%b\t%b\t%b\t\t%b\t%b", $time, x,x, y,y, ci, co, z,z);
  28.             for (k = 0; k < 32; k = k + 1) begin
  29.                     {x,y,ci} = k;
  30.                     #10;
  31.             end
  32.         end
  33.    
  34. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement