「Verilog学习笔记」序列检测器(Moore型)

专栏前言

本专栏的内容主要是记录本人学习Verilog过程中的一些知识点,刷题网站用的是牛客网

复制代码
`timescale 1ns/1ns

module det_moore(
   input                clk   ,
   input                rst_n ,
   input                din   ,
 
   output	reg         Y   
); 
    parameter S0 = 0, S1 = 1 , S2 = 2, S3 = 3, S4 = 4 ;
    reg [2:0] nstate, state ; 

    always @ (posedge clk or negedge rst_n) 
        if (!rst_n) state <= S0 ; 
        else state <= nstate ; 

    always @ (*) 
        case (state) 
            S0 : nstate = din ? S1 : S0 ; 
            S1 : nstate = din ? S2 : S0 ; 
            S2 : nstate = din ? S2 : S3 ;
            S3 : nstate = din ? S4 : S0 ; 
            S4 : nstate = din ? S1 : S0 ; 
            default : nstate = S0 ;
        endcase

    always @ (posedge clk or negedge rst_n) 
        if (!rst_n) Y <= 0 ; 
        else if (state == S4) Y <= 1 ; 
        else Y <= 0 ; 

endmodule
相关推荐
辞旧 lekkk18 分钟前
【Qt系统相关】鼠标事件
linux·开发语言·qt·学习·计算机外设·萌新
子非鱼94271 小时前
10-Flutter调用鸿蒙原生能力前置课:MethodChannel和PlatformView准备
学习·flutter·华为·harmonyos
小L~~~1 小时前
MLIR学习笔记
笔记·学习·mlir
从零开始的代码生活_1 小时前
C++ string 详解:常用接口、字符串算法与深拷贝实现
开发语言·c++·后端·学习·算法
阿哟阿哟3 小时前
Ansys Electronics Desktop(hfss)仿真PCB(AD)
笔记
~kiss~3 小时前
LLM 的 层归一化(稳定训练) - Layer Normalization & RMSNorm
学习
MartinYeung53 小时前
[论文学习]LLM-based AI Agent 安全威胁与防御系统性综述
人工智能·学习·安全
阿米亚波3 小时前
【C++ STL】std::deque
数据结构·c++·笔记·算法·stl
再玩一会儿看代码4 小时前
JUnit 测试框架详解:从实际开发、业务测试到 Java 面试高频问题
java·经验分享·笔记·junit·面试
巴巴媛6664 小时前
STM32学习笔记【36.CAN收发实验】
笔记·stm32·学习