Advertisement
STANAANDREY

aclab3 pb4

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