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

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

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

`timescale 1ns/1ns

module seq_circuit(
   input                C   ,
   input                clk ,
   input                rst_n,
 
   output   wire        Y   
);
reg [1:0] state = 2'b00;

always@(posedge clk or negedge rst_n)
begin
    if(~rst_n)
    begin
        state <= 2'b00;
    end
    else
    begin
        case(state)
        2'b00: state <= C? 2'b01:2'b00;
        2'b01: state <= C? 2'b01:2'b11;
        2'b10: state <= C? 2'b10:2'b00;
        2'b11: state <= C? 2'b10:2'b11;
        endcase
    end
end
assign Y = state[1]&state[0] | state[1]&(~state[0])&C;

endmodule

全部评论

相关推荐

_mos_:要不是看评论区我都不知道你要找的是数分
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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