Last active
May 8, 2017 01:00
-
-
Save koyamalmsteen/765871ea4f71dd5bbb564dd42b3d258c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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