forked from NitinBnittu/Frequency-divider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrequency_divided_5.v
62 lines (46 loc) · 869 Bytes
/
Frequency_divided_5.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
61
62
//design
module d_ff(in,clk,q);
input in,clk;
output reg q;
always@(posedge clk or negedge clk)begin
q=in;
end
endmodule
module dec(rst,clk,count);
input rst,clk;
output reg [2:0]count;
reg q,qb,freq_out;
always@(posedge clk)begin
if(rst)
count=3'b0;
else
count=count+1;
if(count==3'b101)
count=3'b00;
end
d_ff eey(.in(count[1]),.clk(clk),.q(q));
always@(*)begin
freq_out=q|count[1];
end
endmodule
//testbench
module tb;
reg rst,clk;
wire[2:0]count;
dec e(.rst(rst),.clk(clk),.count(count));
initial begin
clk=0;
forever #1clk=~clk;
end
initial begin
$monitor("Time=%0t rst=%b count=%b",$time,rst,count);
rst=1;
#5rst=0;
#30$finish;
end
initial
begin
$dumpfile("dump.vcd");
$dumpvars();
end
endmodule