题解 | #根据状态转移表实现时序电路#
根据状态转移表实现时序电路
https://www.nowcoder.com/practice/455c911bee0741bf8544a75d958425f7
`timescale 1ns/1ns
module seq_circuit(
input A ,
input clk ,
input rst_n,
output wire Y
);
wire Q0,Q1;
dff dff1(
.clk_d(clk),
.rst_d(rst_n),
.d(A^Q1^Q0),
.q(Q1)
);
dff dff2(
.clk_d(clk),
.rst_d(rst_n),
.d(~Q0),
.q(Q0)
);
assign Y = Q1&Q0;
endmodule
module dff(
input clk_d,
input rst_d,
input d,
output reg q
);
always@(posedge clk_d or negedge rst_d)begin
if(~rst_d)
q<=0;
else
q<=d;
end
endmodule