A JK flip-flop has the below truth table. Implement a JK flip-flop with only a D-type flip-flop and gates. Note: Qold is the output of the D flip-flop before the positive clock edge.
前言
三个输入,包括一个时钟clk,一个主输入信号j,一个副输入信号k;一个输出信号Q。
代码
module top_module (
input clk,
input j,
input k,
output Q);
always@(posedge clk)begin
Q<=(j^k)?j:k?(~Q):Q;
end
endmodule
总结
观察真值表找出输出值与输入值之间的联系,以及判断语句的复用。