Prev Problem
Next Problem

82. JK Flip-Flop with Enable

Back To All Submissions
Previous Submission
Next Submission

Code

module jk_ff_enable (
    input  CLK,
    input  EN,
    input  J,
    input  K,
    output reg Q
);
// Write your code here
   always @(posedge CLK) begin
    if(EN) begin
        case({J, K})
          2'b00: begin
            Q <= Q;
          end
          2'b01: begin
            Q <= 0;
          end
          2'b10: begin
            Q <= 1;
          end
          2'b11: begin
            Q <= ~Q;
          end
        endcase
    end
    else begin
        Q <= Q;
    end
   end
endmodule

 

Was this helpful?
Upvote
Downvote