题解 | #序列检测器(Moore型)#

序列检测器(Moore型)

https://www.nowcoder.com/practice/d5c5b853b892402ea80d27879b8fbfd6

`timescale 1ns/1ns

module det_moore(
   input                clk   ,
   input                rst_n ,
   input                din   ,
 
   output	reg         Y   
);
parameter s0=3'd0,s1=3'd1,s2=3'd2,s3=3'd3,s4=3'd4;
reg [2:0] current_state,next_state;

always@(*)
begin
case(current_state)
s0: next_state = din ? s1 :s0;
s1: next_state = din ? s2 :s0;
s2: next_state = din ? s1 :s3;
s3: next_state = din ? s4 :s0;
s4: next_state = din ? s1 :s0;
default : next_state = s0;
endcase
end
    always @ (posedge clk or negedge rst_n)
    begin
        if(!rst_n)
        begin
        current_state<=s0;
        end
        else
        begin
        current_state<=next_state;
        end
    end
        always@(posedge clk or negedge rst_n)
        begin
            if(!rst_n)
            begin
            Y<=1'b0;
            end
            else
            begin
            Y<= current_state==s4;
            end
        end
endmodule

全部评论

相关推荐

nus2201602...:兄弟,你这个简历撕了丢了吧,就是一坨,去找几个项目,理解项目流程,看几遍就是你的了,看看八股就去干了,多看看牛客里别人发出来的简历,对着写,你这写的啥啊,纯一坨
点赞 评论 收藏
分享
龙珠传说:nb,公务员解约不需要支付违约金吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务