Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
226 views
in Technique[技术] by (71.8m points)

Craeting a JK Flip Flop in Verilog using if/else or case with reset=0

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...