In this tutorial, we'll decribe JK flip flip withour reset, with synchronous reset and asynchronous reset.
Clock Edge |
J |
K |
Q |
Description |
$$\downarrow$$ |
X |
X |
Q |
No Change (Store previous input) |
$$\uparrow$$ |
0 |
0 |
Q |
No Change (Store previous input) |
$$\uparrow$$ |
1 |
0 |
1 |
Set Q to 1 |
$$\uparrow$$ |
0 |
1 |
0 |
Reset Q to 0 |
$$\uparrow$$ |
1 |
1 |
$$\overline Q$$ |
Toggle |
module jkff(clk,j,k,q);
input clk,j,k;
output reg q;
always @ (posedge clk)begin
case({j,k})
2'b00:
q <= q;
2'b01:
q <= 0;
2'b10:
q <= 1;
2'b11:
q <= ~q;
default:
q <= q;
endcase
end
endmodule
module jkff(clk,j,k,q);
input clk,reset,j,k;
output reg q;
always @ (posedge clk)begin
if(reset)
q <= 0;
else begin
case({j,k})
2'b00:
q <= q;
2'b01:
q <= 0;
2'b10:
q <= 1;
2'b11:
q <= ~q;
default:
q <= q;
endcase
end
end
endmodule
module jkff(clk,j,k,reset,q);
input clk,reset,j,k;
output reg q;
always @ (posedge clk or negedge reset)begin
if(~reset)
q <= 0;
else begin
case({j,k})
2'b00:
q <= q;
2'b01:
q <= 0;
2'b10:
q <= 1;
2'b11:
q <= ~q;
default:
q <= q;
endcase
end
end
endmodule
Click like if you found this useful
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comments