module genPatt (
	input logic clk, next, rst, 
	output logic [3:0] pattern
	);

	always_ff @(posedge clk) begin
	  if (rst)
		pattern <= 4'b0;
	  else if (next)
		pattern <= {pattern[2:0], !(pattern[3] ^ pattern[2])};
	  else
		pattern <= pattern;
	  end	
	  
endmodule  // genPatt


module genPatt_tb();
 logic clk, next, rst;
 logic [3:0] pattern;
 
 genPatt dut (.*);
 
 parameter T = 100;
 initial
	clk = 1'b0;
 always begin
	#(T/2)  clk <= 1'b0;
	#(T/2)  clk <= 1'b1;
 end

initial begin
	rst <= 1; @(posedge clk);
	rst <=0; next <= 1; @(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	@(posedge clk);
	next <= 0; @(posedge clk);
	@(posedge clk);
	next <= 1; @(posedge clk);
	rst <= 1; @(posedge clk); 
	@(posedge clk);
	
	$stop;
end


endmodule  // genPatt_tb