「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
相关推荐
YJlio5 分钟前
Contig 学习笔记(13.4):单文件碎片整理工具的原理与基本用法
笔记·学习·stable diffusion
石像鬼₧魂石8 小时前
HexStrike-AI人工智能 渗透测试学习(Metasploitable2 192.168.1.4)完整流程总结
学习·ubuntu
非凡ghost8 小时前
MusicPlayer2(本地音乐播放器)
前端·windows·学习·软件需求
大数据追光猿8 小时前
【大数据Doris】生产环境,Doris主键模型全表7000万数据更新写入为什么那么慢?
大数据·经验分享·笔记·性能优化·doris
sevenez8 小时前
Vibe Coding 实战笔记:从“修好了C坏了AB”到企业级数据库架构重构
c语言·笔记·数据库架构
智嵌电子8 小时前
【笔记篇】【硬件基础篇】模拟电子技术基础 (童诗白) 第10章 模拟电子电路读图
笔记·单片机·嵌入式硬件
蓝桉~MLGT9 小时前
Ai-Agent学习历程—— 阶段1——环境的选择、Pydantic基座、Jupyter Notebook的使用
人工智能·学习·jupyter
2301_800050999 小时前
mysql
数据库·笔记·mysql
QT 小鲜肉9 小时前
【Linux命令大全】001.文件管理之mmove命令(实操篇)
linux·服务器·前端·chrome·笔记
不会学习?9 小时前
markdown笔记分享
经验分享·笔记