Sequence Detector Mealy

AIM:Design a controller that detects the overlapping sequence “0X01” in a bit stream using mealy machine.

DESIGN
Sequence Detector ox01 Mealy Verilog Program- Sequence Detector 0x01 Mealy implementation

`timescale 1ns / 1ps

///////////////////////////////////////////////////////////////////////////
// Company: TMP
// Create Date: 08:15:45 01/12/2015
// Module Name: SequenceDetectorMealy
// Project Name: Sequence Detector 0x01 Mealy implementation
///////////////////////////////////////////////////////////////////////////
module SequenceDetectorMealy(din,clk,reset,y);
input din,clk,reset;
output reg y;
parameter S0=3'b000, S1=3'b001, S2=3'b010, S3=3'b011, S4=3'b100, S5=3'b101;
reg [2:0]nextState;
always @(posedge clk)
begin
if(reset)
begin
y=0;
nextState=S0;
end
else
case(nextState)
S0:
begin
if(din==0)
begin
nextState=S1;
y=0;
end
else
begin
nextState=S0;
y=0;
end
end
S1:
begin
if(din==0)
begin
nextState=S3;
y=0;
end
else
begin
nextState=S2;
y=0;
end
end
S2:
begin
if(din==0)
begin
nextState=S5;
y=0;
end
else
begin
nextState=S0;
y=0;
end
end
S3:
begin
if(din==0)
begin
nextState=S4;
y=0;
end
else
begin
nextState=S2;
y=0;
end
end
S4:
begin
if(din==0)
begin
nextState=S4;
y=0;
end
else
begin
nextState=S2;
y=1;
end
end
S5:
begin
if(din==0)
begin
nextState=S3;
y=0;
end
else
begin
nextState=S2;
y=1;
end
end
endcase
end
endmodule

.................................................................................................
Related Programs:
Verilog program for Basic Logic Gates
Verilog program for Half Adder
Verilog program for Full Adder
Verilog program for 4bit Adder
Verilog program for Half Substractor
Verilog program for Full Substractor
Verilog program for 4bit Substractor
Verilog program for Carry Look Ahead Adder
Verilog program for 3:8 Decoder
Verilog program for 8:3 Encoder
Verilog program for 1:8 Demultiplxer
Verilog program for 8:1 Multiplexer
Verilog program for 8bit D Flipflop
Verilog program for T Flipflop
Verilog program for JK Flipflop
Verilog program for Equality Comparator
Verilog program for 8bit Up down counter
Verilog program for 8bit Shift Register (SIPO,PISO,PIPO)
Verilog program for Random Access Memory(RAM)
Verilog program for Programmable clock Generator
Verilog program for Finite State Machine (mealy)
Verilog program for Finite State Machine (moore)