I want to create a JK flip flop with asynchronous reset = 0.
The first way is if-else
module JK_Behavior_a(output reg Q, input J,K,CLK, rst);
//Q(t+1)=JQ'+K'Q
//when Q=0, Q(t+1)=J
//When Q=1 Q(t+1)=K'
always @ (posedge CLK)
if(rst==0)
if(Q==0) Q<=J;
else Q<=~K;
else Q=0;
endmodule
And the second way is case
module JK_Behavior_b(input J,K,Clk,rst output reg Q, output Q_b);
assign Q_b=~Q;
always@(posedge Clk)
if(rst==0)
case({J,K})
2'b00: Q<=Q;
2'b01: Q<=1'b0;
2'b10: Q<=1'b1;
2'b11: Q<=!Q;
endcase
else
endmodule
Is the first way with if-else correct?
And the second way with case, what can I write after else?
question from:
https://stackoverflow.com/questions/65924502/craeting-a-jk-flip-flop-in-verilog-using-if-else-or-case-with-reset-0 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…