我是靠谱客的博主 美丽钻石,最近开发中收集的这篇文章主要介绍Verilog 实现101序列检测器——Moore和Mealy型状态机实现可重叠和不可重叠1. 可重叠和不可重叠区分2. 可重叠序列检测器实现3. 不可重叠序列检测器实现摩尔机和米利机的区别,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

101序列检测器

  • 1. 可重叠和不可重叠区分
  • 2. 可重叠序列检测器实现
    • 2.1. 米利机
    • 2.2. 摩尔机
  • 3. 不可重叠序列检测器实现
    • 3.1. 米利机
    • 3.2. 摩尔机
  • 摩尔机和米利机的区别

1. 可重叠和不可重叠区分

  • 可重叠的序列检测器检测到一个目标串后可以不用回到初始状态,该目标串的元素的可作为下一个目标串的子串继续进行判断。
    0 1 1 0 1 0 1 0 1 1 1 0
  • 不可重叠的序列检测器一次检测完成后必须回到初始状态。
    0 1 1 0 1 0 1 0 1 1 1 0
输入011010101110
可重叠检测输出000010101000
不可重叠检测输出000010001000

2. 可重叠序列检测器实现

2.1. 米利机

1

  • 输出由当前状态和输入共同决定
module	mealy_overlap	(
	output		reg		dout,
	
	input		wire	clk,
	input		wire	rst,
	input		wire	din
);

	reg	[1:0]	curr_state;
	reg	[1:0]	next_state;
	
	parameter	IDLE	=	2'b 00;
	parameter	S1		=	2'b 01;
	parameter	S2		=	2'b 10;
	
	always @ (posedge clk or negedge rst)	begin
		if (!rst)	begin
			curr_state	<=	IDLE;
		end else	begin
			curr_state	<=	next_state;
		end
	end
	
	always @ (*)	begin
		case	(curr_state)
			IDLE:	begin
				if (din == 1)	begin		next_state <= S1;	dout <= 0;	end
				else			begin		next_state <= IDLE;	dout <= 0;	end
			end
			S1:		begin
				if (din == 0)	begin		next_state <= S2;	dout <= 0;	end
				else			begin		next_state <= S1;	dout <= 0;	end
			end
			S2:		begin
				if (din == 1)	begin		next_state <= S1;	dout <= 1;	end
				else			begin		next_state <= IDLE;	dout <= 0;	end
			end
			default:	begin				next_state <= IDLE;	dout <= 0;	end
		endcase
	end
	
endmodule

在这里插入图片描述

2.2. 摩尔机

2

  • 输出由当前状态决定
module	moore_overlap	(
	output	reg		dout,
	
	input	wire	clk,
	input	wire	rst,
	input	wire	din
);

	reg	[1:0]	curr_state;
	reg	[1:0]	next_state;
	
	parameter	IDLE	=	2'b 00;
	parameter	S1		=	2'b 01;
	parameter	S2		=	2'b 10;
	parameter	S3		=	2'b 11;
	
	always@ (posedge clk or negedge rst)	begin
		if (!rst)	begin
			curr_state	<=	IDLE;
		end	else	begin
			curr_state	<=	next_state;
		end
	end
	
	always @ (*)	begin
		case	(curr_state)
			IDLE:	begin
				if (din == 1)		next_state	<=	S1;
				else				next_state	<=	IDLE;
			end
			S1:		begin
				if (din == 0)		next_state	<=	S2;
				else				next_state	<=	S1;
			end
			S2:		begin
				if (din == 1)		next_state	<=	S3;
				else				next_state	<=	IDLE;
			end
			S3:		begin
				if (din == 1)		next_state	<=	S1;
				else				next_state	<=	S2;
			end
			default:	begin		next_state	<=	IDLE;
			end
		endcase
	end
	
	always @ (*)	begin
		if (curr_state == S3)		dout	<=	1;
		else						dout	<=	0;
	end
	
endmodule

在这里插入图片描述

3. 不可重叠序列检测器实现

3.1. 米利机

3

module	mealy_not_overlap	(
	output		reg		dout,
	
	input		wire	clk,
	input		wire	rst,
	input		wire	din
);

	reg	[1:0]	curr_state;
	reg	[1:0]	next_state;
	
	parameter	IDLE	=	2'b 00;
	parameter	S1		=	2'b 01;
	parameter	S2		=	2'b 10;
	
	always @ (posedge clk or negedge rst)	begin
		if (!rst)	begin
			curr_state	<=	IDLE;
		end else	begin
			curr_state	<=	next_state;
		end
	end
	
	always @ (*)	begin
		case	(curr_state)
			IDLE:	begin
				if (din == 1)	begin		next_state <= S1;		dout <= 0;	end
				else			begin		next_state <= IDLE;		dout <= 0;	end
			end
			S1:		begin
				if (din == 0)	begin		next_state <= S2;		dout <= 0;	end
				else			begin		next_state <= S1;		dout <= 0;	end
			end
			S2:		begin
				if (din == 1)	begin		next_state <= IDLE;		dout <= 1;	end
				else			begin		next_state <= IDLE;		dout <= 0;	end
			end
			default:	begin				next_state <= IDLE;		dout <= 0;	end
		endcase
	end
	
endmodule

在这里插入图片描述

3.2. 摩尔机

在这里插入图片描述

module	moore_not_overlap	(
	output	reg		dout,
	
	input	wire	clk,
	input	wire	rst,
	input	wire	din
);

	reg	[1:0]	curr_state;
	reg	[1:0]	next_state;
	
	parameter	IDLE	=	2'b 00;
	parameter	S1		=	2'b 01;
	parameter	S2		=	2'b 10;
	parameter	S3		=	2'b 11;
	
	always@ (posedge clk or negedge rst)	begin
		if (!rst)	begin
			curr_state	<=	IDLE;
		end	else	begin
			curr_state	<=	next_state;
		end
	end
	
	always @ (*)	begin
		case	(curr_state)
			IDLE:	begin
				if (din == 1)		next_state	<=	S1;
				else				next_state	<=	IDLE;
			end
			S1:		begin
				if (din == 0)		next_state	<=	S2;
				else				next_state	<=	S1;
			end
			S2:		begin
				if (din == 1)		next_state	<=	S3;
				else				next_state	<=	IDLE;
			end
			S3:		begin
				if (din == 1)		next_state	<=	S1;
				else				next_state	<=	IDLE;
			end
			default:	begin		next_state	<=	IDLE;
			end
		endcase
	end
	
	always @ (*)	begin
		if (curr_state == S3)		dout	<=	1;
		else						dout	<=	0;
	end
	
endmodule

在这里插入图片描述

摩尔机和米利机的区别

Moore状态机的输出仅依赖于当前状态而与输入无关。想要输出dout = 1,状态S3必须形成。

Mealy状态机的输出与当前状态和输入有关。想要输出dout = 1,状态S2下输入din = 1就可以了,不需要状态S3。根据波形可对比反应更快。

最后

以上就是美丽钻石为你收集整理的Verilog 实现101序列检测器——Moore和Mealy型状态机实现可重叠和不可重叠1. 可重叠和不可重叠区分2. 可重叠序列检测器实现3. 不可重叠序列检测器实现摩尔机和米利机的区别的全部内容,希望文章能够帮你解决Verilog 实现101序列检测器——Moore和Mealy型状态机实现可重叠和不可重叠1. 可重叠和不可重叠区分2. 可重叠序列检测器实现3. 不可重叠序列检测器实现摩尔机和米利机的区别所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部