GCB_JK.v
759 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
`timescale 1ns/1ns
module GCB_JK (q, qn, j, k, cp, sdn, cdn);
input j, k, cp, sdn, cdn;
output q, qn;
reg q, qn;
wire next_q;
always @(sdn or cdn) begin
case ({sdn, cdn})
2'b00 : begin
assign q = 0;
assign qn = 0;
end
2'b01 : begin
assign q = 1;
assign qn = 0;
end
2'b10 : begin
assign q = 0;
assign qn = 1;
end
2'b11 : begin
deassign q;
deassign qn;
end
endcase
end
jk_prim jk_next(next_q, j, k, q);
always @(posedge cp) begin
q <= #1 next_q;
qn <= #1 ~next_q;
end
endmodule
primitive jk_prim(out, j, k, q);
output out;
input j, k, q;
table
? 0 1 : 1;
1 ? 0 : 1;
? 1 1 : 0;
0 ? 0 : 0;
1 0 ? : 1;
0 1 ? : 0;
endtable
endprimitive