「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
相关推荐
墨黎芜37 分钟前
ArcGIS从入门到精通——地图符号、注记的初步使用
学习·arcgis·信息可视化
小李云雾41 分钟前
FastAPI重要知识点---中间件(Middleware)
学习·程序人生·中间件·fastapi·middleware
.Cnn1 小时前
JavaScript 前端基础笔记(网页交互核心)
前端·javascript·笔记·交互
小夏子_riotous1 小时前
Docker学习路径——3、常用命令
linux·运维·服务器·学习·docker·容器·centos
STLearner1 小时前
WSDM 2026 | 时间序列(Time Series)论文总结【预测,表示学习,因果】
大数据·论文阅读·人工智能·深度学习·学习·机器学习·数据挖掘
redaijufeng2 小时前
网络爬虫学习:应用selenium获取Edge浏览器版本号,自动下载对应版本msedgedriver,确保Edge浏览器顺利打开。
爬虫·学习·selenium
九成宫2 小时前
IT项目管理期末复习——Chapter 10 项目沟通管理
笔记·项目管理·软件工程
腾科IT教育2 小时前
零基础快速上岸HCIP,高效学习思路分享
学习·华为认证·hcip·hcip考试·hcip认证
23471021272 小时前
4.14 学习笔记
笔记·python·学习
醇氧2 小时前
【学习】软件过程模型全解析:从瀑布到敏捷的演进之路
学习·log4j