题解 | #根据状态转移表实现时序电路#直接使用D触发器实现
根据状态转移表实现时序电路
https://www.nowcoder.com/practice/455c911bee0741bf8544a75d958425f7
`timescale 1ns/1ns module seq_circuit( input A , input clk , input rst_n, output wire Y ); wire Dn_0,Dn_1; wire Qn_0,Qn_1; assign Dn_0=~Qn_0; //Q0n+1=D0n=~Qn assign Dn_1=A^Qn_1^Qn_0; //Q1n+1=D1n=A^Q1n^Q0n D d1( //D模块例化 d1 .clk(clk), .rst_n(rst_n), .D(Dn_1), .Q(Qn_1) ); D d0( //D模块例化 d0 .clk(clk), .rst_n(rst_n), .D(Dn_0), .Q(Qn_0) ); assign Y=Qn_0&Qn_1; endmodule module D( //D模块 input clk,rst_n, input wire D, output reg Q ); always@(posedge clk or negedge rst_n) if(!rst_n) Q<=0; else Q<=D; endmodule
题解不难看出,