-
Notifications
You must be signed in to change notification settings - Fork 0
/
jk_flipflop.v
60 lines (49 loc) · 882 Bytes
/
jk_flipflop.v
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
56
57
58
59
60
module jkff(jk,clk,q,qbar);
input [1:0] jk;
input clk;
output q,qbar;
reg q,qbar;
always@(negedge clk)
begin
case(jk)
2'b00:
q= q;
2'b01:
q= 0;
2'b10:
q=1;
2'b11:
q= ~q;
endcase
qbar = ~q;
end
endmodule
module test;
reg [1:0] jk;
reg clk;
integer i;
wire q,qbar;
jkff j1(jk,clk,q,qbar);
initial
begin
$display("jk flip flop");
$monitor("%b %b %b \t %b %b",jk[1],jk[1],jk[0],clk,q,qbar);
$dumpfile("vcd/JKFlipFlop.vcd");
$dumpvars(1,test);
jk = 2'b00;
#10
jk = 2'b01;
#10
jk = 2'b10;
#10
jk = 2'b11;
#10
$finish;
end
initial
begin
clk = 0;
for(i=0;i<20;i=i+1)
#5 clk = ~clk;
end
endmodule