-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjk_latch.v
More file actions
36 lines (31 loc) · 861 Bytes
/
Copy pathjk_latch.v
File metadata and controls
36 lines (31 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
`timescale 1ns / 1ps
module jk_latch(
input rst,enb,j,k,output reg q,qbar
);
always@(enb,rst)begin
if(rst)
begin
q <= 1'b0;
qbar <= 1'b1;
end
if(enb)
begin
if(j == 0 && k == 0)begin
q <= q;
qbar <= qbar;
end
else if(j == 0 && k == 1)begin
q <= 1'b0;
qbar <= 1'b1;
end
else if(j == 1 && k == 0)begin
q <= 1'b1;
qbar <= 1'b0;
end
else if(j == 1 && k == 1)begin
q <= ~q;
qbar <= ~qbar;
end
end
end
endmodule