Advertisement
STANAANDREY

aclab3 pb2

Oct 11th, 2023
1,367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module div3 (
  2.   input [3:0] i,
  3.   output reg[2:0] o
  4. );
  5.   always @(*)
  6.     case (i)
  7.     0,1,2: o = 0;
  8.     3,4,5: o = 1;
  9.     6,7,8: o = 2;
  10.     9,10,11: o = 3;
  11.     12,13,14: o = 4;
  12.     15: o = 5;
  13.     endcase
  14. endmodule
  15.  
  16. module div3_tb;
  17.   reg [3:0] i;
  18.   wire [2:0] o;
  19.  
  20.   div3 div3_i (.i(i), .o(o));
  21.  
  22.   integer k;
  23.   initial begin
  24.     $display("Time\ti\t\to");
  25.     $monitor("%0t\t%b(%2d)\t%b(%0d)", $time, i, i, o, o);
  26.     i = 0;
  27.     for (k = 1; k < 16; k = k + 1)
  28.       #10 i = k;
  29.   end
  30. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement