一. 用D触发器设计可重叠101序列检测器
1. 分析设计要求,列出全部可能状态
1. 未收到一个有效位(0):S0
2. 收到一个有效位(1):S1
3. 连续收到两个有效位(10):S2
4. 连续收到三个有效位(101):S3
5. 状态转移表如下
b) 画出状态转移图
c) HDL语言描述(verilog源代码)
i. MOORE型
输出只取决于当前的状态
源文件:
`timescale 1ns / 1ps
//
// Company:
// Engineer:
//
// Create Date: 2018/05/13 16:50:14
// Design Name:
// Module Name: Checker
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//
module Checker(
input x, clk, rst,
output y
);
reg y;
//register to store the state and nextstate
reg [1:0] currentstate, nextstate;
//the code for states, can be changed
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
parameter S3 = 2'b11;
//the D_trigger to set the currentstate
always@(posedge clk or negedge rst)
begin
if(!rst)
currentstate <= S0;
else
c