「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
相关推荐
diablobaal4 分钟前
云计算学习100天-第26天
学习·云计算
测试老哥1 小时前
pytest+requests+allure自动化测试接入Jenkins学习
自动化测试·软件测试·学习·测试工具·职场和发展·jenkins·pytest
UserNamezhangxi2 小时前
kotlin 协程笔记
java·笔记·kotlin·协程
diablobaal4 小时前
云计算学习100天-第21天
学习
翻滚的小@强6 小时前
数据挖掘笔记:点到线段的距离计算
人工智能·笔记·数据挖掘
会思考的猴子6 小时前
UE5 PCG 笔记(二) Difference 节点
笔记·ue5
yuxb736 小时前
Linux 文本处理与 Shell 编程笔记:正则表达式、sed、awk 与变量脚本
linux·笔记·正则表达式
饕餮争锋9 小时前
设计模式笔记_行为型_访问者模式
笔记·设计模式·访问者模式
不羁。。11 小时前
【撸靶笔记】第七关:GET - Dump into outfile - String
数据库·笔记·oracle
好望角雾眠16 小时前
第一阶段C#基础-10:集合(Arraylist,list,Dictionary等)
笔记·学习·c#