题解 | #根据状态转移图实现时序电路#
根据状态转移图实现时序电路
https://www.nowcoder.com/practice/e405fe8975e844c3ab843d72f168f9f4
`timescale 1ns/1ns
module seq_circuit(
input C ,
input clk ,
input rst_n,
output wire Y
);
reg q0,q1;
always@(posedge clk or negedge rst_n)
if(!rst_n)begin
q0<=0;
q1<=0;
end else
begin
q0<=(q0&C)|(q1&~C);
q1<=(~q0&C)|(q1&~C);
end
assign Y=(q0&q1)|(q0&C);
endmodule
