Skip to content

Instantly share code, notes, and snippets.

@koyamalmsteen
Last active May 8, 2017 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koyamalmsteen/765871ea4f71dd5bbb564dd42b3d258c to your computer and use it in GitHub Desktop.
Save koyamalmsteen/765871ea4f71dd5bbb564dd42b3d258c to your computer and use it in GitHub Desktop.
module JKFF2(sw, clk, led);
input [1:0] sw; // sw[1]:j, sw[0]:k
input clk;
output led; // led:Q
reg q;
always@(posedge clk) begin
case ({sw[1], sw[0]}) // sw[1]:J, sw[0]:K
2'b00 : q <= q; // sw[1]=0 & sw[0]=0
2'b01 : q <= 0;
2'b10 : q <= 1;
2'b11 : q <= ~q; // This is feature of JK-FF.
endcase
end
assign led = q;
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment