forked from ashishrana160796/verilog-starter-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSRFlipFlop.v
More file actions
62 lines (50 loc) · 751 Bytes
/
SRFlipFlop.v
File metadata and controls
62 lines (50 loc) · 751 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
56
57
58
59
60
61
62
module srff(sr,clk,q,qbar);
input [1:0] sr;
input clk;
output q,qbar;
reg q,qbar;
always@(posedge clk)
begin
case(sr)
2'b00:
q = q;
2'b01:
q=0;
2'b10:
q=1;
2'b11:
q= 1'bz;
endcase
qbar = ~q;
end
endmodule
module test;
reg [1:0] sr;
reg clk;
integer i;
wire q,qbar;
srff s(sr,clk,q,qbar);
initial
begin
$display("sr flip flop");
$monitor("%b %b %b \t %b %b",sr[1],sr[0],clk, q,qbar);
$dumpfile("vcd/SRFlipFlop.vcd");
$dumpvars(1,test);
sr = 2'b00;
#10
sr = 2'b01;
#10
sr = 2'b10;
#10
sr = 2'b00;
#10
sr = 2'b11;
#10
$finish;
end
initial begin
clk = 0;
for(i=0;i<20;i=i+1)
#5 clk = ~clk;
end
endmodule