题解 | #根据状态转移表实现时序电路#

根据状态转移表实现时序电路

https://www.nowcoder.com/practice/455c911bee0741bf8544a75d958425f7

`timescale 1ns/1ns

module seq_circuit(
      input                A   ,
      input                clk ,
      input                rst_n,
 
      output   wire        Y   
);
    reg [1:0]cur_state;
    reg [1:0]nex_state;
    reg y_reg=0;

    always@(posedge clk or negedge rst_n)begin
        if(!rst_n)begin
            cur_state<=2'b00;
            nex_state<=2'b00;
        end
        else begin
            cur_state<=nex_state;
        end
    end

    always@(*)begin
        case(cur_state)
        2'b00:nex_state=(!A)?2'b01:2'b11;
        2'b01 : nex_state = (A == 1'b1) ? 2'b00 : 2'b10;
        2'b10 : nex_state = (A == 1'b1) ? 2'b01 : 2'b11;
        2'b11 : nex_state = (A == 1'b1) ? 2'b10 : 2'b00;
        default : nex_state = 2'b00;
        endcase
    end

    assign Y=(cur_state==2'b11)?1:0;
endmodule

两段式书写

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-03 18:22
投了几百份简历,专业和方向完全对口,都已读不回。尝试改了一下学校,果然有奇效。
steelhead:这不是很正常嘛,BOSS好的是即便是你学院本可能都会和聊几句,牛客上学院本机会很少了
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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