Facebook
From Gg, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 193
  1. module testbench;
  2.  
  3.     reg clk;
  4.     reg reset;
  5.     reg in_data;
  6.     wire out_data;
  7.  
  8.     sequence_detector detector(
  9.         .clk(clk),
  10.         .reset(reset),
  11.         .in_data(in_data),
  12.         .out_data(out_data)
  13.     );
  14.  
  15.     initial begin
  16.         clk = 0;
  17.         reset = 1;
  18.         in_data = 0;
  19.         #10 reset = 0; // Release reset after 10 time units
  20.        
  21.         // Test multiple input strings
  22.         repeat(4) begin
  23.             #10;
  24.             // Test Case: Example input string: 111010111000110
  25.             in_data = 1; #10;
  26.             in_data = 1; #10;
  27.             in_data = 1; #10;
  28.             in_data = 0; #10;
  29.             in_data = 1; #10;
  30.             in_data = 0; #10;
  31.             in_data = 1; #10;
  32.             in_data = 1; #10;
  33.             in_data = 1; #10;
  34.             in_data = 0; #10;
  35.             in_data = 0; #10;
  36.             in_data = 0; #10;
  37.             in_data = 1; #10;
  38.             in_data = 1; #10;
  39.             in_data = 0; #10;
  40.             // After detecting '110', wait for the output to stabilize
  41.             #10;
  42.         end
  43.  
  44.         $finish; // End simulation
  45.     end
  46.  
  47.     always #5 clk = ~clk; // Clock generator
  48.  
  49. endmodule
  50.