`timescale 1ns/1ns
module sequence_detect(
	input clk,
	input rst_n,
	input a,
	output reg match
	);

	reg	[8:0]	data;
	reg	[3:0]	bit_cnt;
	reg	flag;

always@(posedge clk  or negedge rst_n)
	if(!rst_n)
		bit_cnt	<=	4'd0;
	else	if(bit_cnt== 4'd10)
		bit_cnt	<=	4'd0;
	else
		bit_cnt	<=	bit_cnt	+ 1'b1;

always@(posedge clk  or negedge rst_n)
	if(!rst_n)
		flag	<=	1'b0;
	else	if(bit_cnt == 4'd8)
		flag	<=	1'b1;
	else
		flag	<=	1'b0;

always@(posedge clk or negedge rst_n)
	if(!rst_n)
		data	<=	8'd0;
	else	if(bit_cnt <= 4'd8)
		data[8-bit_cnt] <=	a;
	
always@(posedge clk or negedge rst_n)
	if(!rst_n)
		match	<=	1'b0;
	else	if(flag && data[8:6]==3'b011 && data[2:0]==3'b110)
		match	<=	1'b1;
	else
		match	<=	1'b0;
endmodule