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

`timescale 1ns/1ns

module seq_circuit(
      input                A   ,
      input                clk ,
      input                rst_n,
 
      output   wire        Y   
);

reg [1:0] q0, q1;
assign Y = q1 & q0;

always@ (posedge clk or negedge rst_n) begin
    if(!rst_n) begin
        q0 <= 1'b0;
    end
    else begin
        q0 <= ~q0;
    end
end

always@ (posedge clk or negedge rst_n) begin
    if(!rst_n) begin
        q1 <= 1'b0;
    end
    else begin
        q1 <= q0 ^ q1 ^ A;
    end
end

endmodule

全部评论

相关推荐

06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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