使用iverilog设计一个110110111序列检测器

module seq9_detect_mealy(x,clk, y);
// Mealy machine for a three-1s sequence detection
    input x, clk;
    output y;
    reg y;
    reg [3:0] state=4'b0101; //present and next states
    parameter S0=4'b0101,S1=4'b1101,S2=4'b1001,S3=4'b1111,S4=4'b0111,
              S5=4'b1100,S6=4'b0100,S7=4'b0001,S8=4'b1000;
// Next state and output combinational logic
// Use blocking assignments "="
always @(posedge clk)
case (state)
        S0: if (x) begin state = S1; y = 0; end
    	else begin state = S0; y = 0; end
	S1: if (x) begin state = S2; y = 0; end
	else begin state = S0; y = 0; end
	S2: if (x) begin state = S2; y = 0; end
	else begin state = S3; y = 0; end
	S3: if (x) begin state = S4; y = 0; end
	else begin state = S0; y = 0; end
	S4: if (x) begin state = S5; y = 0; end
	else begin state = S0; y = 0; end
	S5: if (x) begin state = S2; y = 0; end
	else begin state = S6; y = 0; end
	S6: if (x) begin state = S7; y = 0; end
	else begin state = S0; y = 0; end
	S7: if (x) begin state = S8; y = 0; end
	else begin state = S0; y = 0; end
	S8: if (x) begin state = S2; y = 1; end
	else begin state = S6; y = 0; end
endcase
// Sequential logic, use nonblocking assignments "<="
endmodule

或者

module seq9_detect_mealy(x,clk, y);
// Mealy machine for a three-1s sequence detection
    input x, clk;
    output y;
    reg y;
    reg [3:0] pstate=4'b0101, nstate=4'b0101; //present and next states
    parameter S0=4'b0101,S1=4'b1101,S2=4'b1001,S3=4'b1111,S4=4'b0111,
              S5=4'b1100,S6=4'b0100,S7=4'b0001,S8=4'b1000;
// Next state and output combinational logic
// Use blocking assignments "="
always @(x or pstate)
case (pstate)
        S0: if (x) begin nstate = S1; y = 0; end
    	else begin nstate = S0; y = 0; end
	S1: if (x) begin nstate = S2; y = 0; end
	else begin nstate = S0; y = 0; end
	S2: if (x) begin nstate = S2; y = 0; end
	else begin nstate = S3; y = 0; end
	S3: if (x) begin nstate = S4; y = 0; end
	else begin nstate = S0; y = 0; end
	S4: if (x) begin nstate = S5; y = 0; end
	else begin nstate = S0; y = 0; end
	S5: if (x) begin nstate = S2; y = 0; end
	else begin nstate = S6; y = 0; end
	S6: if (x) begin nstate = S7; y = 0; end
	else begin nstate = S0; y = 0; end
	S7: if (x) begin nstate = S8; y = 0; end
	else begin nstate = S0; y = 0; end
	S8: if (x) begin nstate = S2; y = 1; end
	else begin nstate = S6; y = 0; end
endcase
// Sequential logic, use nonblocking assignments "<="
always @(posedge clk)
pstate <= nstate;
endmodule

在前面的基础上已经得到相应的状态分配表,按着状态表即可写出相应的程序。上面两个程序都可以起到110110111序列检测的功能。最后是在digital上实现的,具体步骤如下:

首先,打开digital找到External
在这里插入图片描述
然后,放入代码,将语言调成iverilog,进行check,没有问题就模拟好了,接下来运行就可以了。
在这里插入图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
一、实验目的: 1、深入了解与掌握同步时序逻辑电路的设计过程; 2、了解74LS74、74LS08、74LS32及74LS04芯片的功能; 3、能够根据电路图连接好实物图,并实现其功能。学会设计过程中的检验与完善。 二、实验内容描述: 题目:“1 1 1”序列检测器。 原始条件:使用D触发器( 74 LS 74 )、“与”门 ( 74 LS 08 )、“或”门( 74 LS 32 )、非门 ( 74 LS 04 ),设计“1 1 1”序列检测器。 集成电路引脚图: D触发器( 74 LS 74 ) “与”门 ( 74 LS 08 ) “或........ 三、实验设计过程: 第1步,画出原始状态图和状态表。 根据任务书要求,设计序列检测器一个外部输入x和一个外部输出Z。输入和输出的逻辑关系为:当外部输入x第一个为“1”,外部输出Z为“0”;当外部输入x第二个为“1”,外部输出Z为“0”;当外部输入x第三个为“1”,外部输出Z才为“1”。假定有一个外部输入x序列以及外部输出Z为: 输入x: 0 1 0 1 1 1 0 1 1 1 1 0 1 输出Z: 0 0 0 0 0 1 0 0 0 1 1 0 0 要判别序列检测器是否连续接收了“111”,电路必须用不同的状态记载外部输入x的值。假设电路的初始状态为A,x输入第一个“1”,检测器状态由A装换到B,用状态B记载检测器接受了111序列的第一个“1”,这时外部输出Z=0;x输入第二个“1”,检测器状态由B装换到C,用状态C记载检测器接受了111序列的第二个“1”,外部输出Z=0;x输入第三个“1”,检测器状态由C装换到D,外部输出Z=1。然后再根据外部输入及其他情况时的状态转移,写出相应的输出。以上分析了序列检测器工作,由此可画出图7-1所示的原始状态图。根据原始状态图可列出原始状态表,如表7-2所示。 现态 次态/输出 x = 0 x = 1 A A / 0 B / 0 B A / 0 C / 0 C A / 0 D / 1 D A / 0 D / 1 (表 7-2 原始状态表) (图
课程设计任务书 学生姓名 胡俊 学生专业班级 计 算 机0801 指导教师 王莹 学 院 名 称 计算机科学与技术学院 一、题目:“1 1 1”序列检测器。 原始条件:使用D触发器( 74 LS 74 )、“与”门 ( 74 LS 08 )、“或”门( 74 LS 32 )、非门 ( 74 LS 04 ),设计“1 1 1”序列检测器。 二、要求完成设计的主要任务如下: 1.能够运用数字逻辑的理论和方法,把时序逻辑电路设计和组合逻辑电路设计相结合,设计一个有实际应用的数字逻辑电路。 2.使用同步时序逻辑电路的设计方法,设计“1 1 1”序列检测器。写出设计中的5个过程。画出课程设计图。 3.根据74 LS 74、74 LS 08、74 LS 32、74 LS 04集成电路引脚号,在设计好的“1 1 1”序列检测器电路图中标上引脚号。 4.在试验设备上,使用74 LS 74、74 LS 08、74 LS 32、74 LS 04集成电路连接、调试和测试“1 1 1”序列检测器电路。 三、实验设计过程: 第1步,画出原始状态图和状态表。 根据任务书要求,设计序列检测器一个外部输入x和一个外部输出Z。输入和输出的逻辑关系为:当外部输入x第一个为“1”,外部输出Z为“0”;当外部输入x第二个为“1”,外部输出Z为“0”;当外部输入x第三个为“1”,外部输出Z才为“1”。假定有一个外部输入x序列以及外部输出Z为: 输入x: 0 1 0 1 1 1 0 1 1 1 1 0 1 输出Z: 0 0 0 0 0 1 0 0 0 1 1 0 0 要判别序列检测器是否连续接收了“111”,电路必须用不同的状态记载外部输入x的值。假设电路的初始状态为A,x输入第一个“1”,检测器状态由A装换到B,用状态B记载检测器接受了111序列的第一个“1”,这时外部输出Z=0;x输入第二个“1”,检测器状态由B装换到C,用状态C记载检测器接受了111序列的第二个“1”,外部输出Z=0;x输入第三个“1”,检测器状态由C装换到D,外部输出Z=1。然后再根据外部输入及其他情况时的状态转移,写出相应的输出。以上分析了序列检测器工作,由此可画出图7-1所示的原始状态图。根据原始状态图可列出原始状态表,如表7-2所示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值