0101/110 序列检测器仿真 1
实验目的 熟悉Modelsim 仿真软件的使用方法,了解状态机的建模方法,使用ModelSim 仿真Qu artu sII 工程
实验内容 用HDL 语言的输入方式,实现 0101/110 序列检测器
用modelsim 进行仿真 下载至 DE0 开发板上观察实验结果 3
代码分析(以 0 1 0 1 序列检测器为例) 1) 状态图如下: 2) 主模块中首先定义了本次实验的所有输入输出接口及各个状态
其中,因为有 4 种状态,所以 cu rrent 为 2 位
//0101 Sequ ential detector modu le lab1a (v in,cp,ncr,v ou t); inpu t v in,cp,ncr; ou tpu t v ou t; reg v ou t; reg [1:0] cu rrent,nex t; parameter s0=2'b00,s1=2'b01,s2=2'b10,s3=2'b11; 3) 然后设置异步清零,在 cp 上升沿则沿触发器状态翻转
St0 St1 St3 St2 St0 St1 St2 0/0 1/0 0/0 1/1 1/0 0/0 0/0 1/0 0/0 0/0 1/0 1/0 1/0 0/1 图 3
1 0101(左)/110(右)序列检测状态图 always @(posedge cp or negedge ncr) begin if (~ncr) current