I having been trying to implement a simple sequence detector on a Nexys 3 (Spartan 6) board. The code works perfectly on Xilinx simulation but on the hardware, it doesn't work. Since I am new to FPGA implementation I couldn't solve this issue. I dont know what changes I should make for the code to work in hardware. It would be great if someone could help me..
And this is the code
module sequence( in, clock,reset,test);
input in;
input reset;
output reg test=0;
reg [3:0] state=0, next=0 ;
input clock;
always@( posedge clock)
begin
if(reset==1)
begin
state= 0;
end
else
begin
state=next;
end
end
always @*
begin
if(reset == 1)
begin
next=0;
test=0;
end
else
begin
case ( state )
'd0 : begin
if ( in==1)
begin
next=state+1;
end
else
next=next;
end
'd1 : begin
if ( in==1)
begin
next=state+1;
end
else
next=0;
end
'd2 : begin
if ( in==1)
begin
next=state+1;
end
else
next=0;
end
'd3 : begin
if ( in==1)
begin
next=state+1;
end
else
next=0;
end
'd4 : begin
if ( in==1)
begin
next=state+1;
test=1;
end
else
next=0;
end
default : begin
next=0;
test=0;
end
endcase
end
end
endmodule