-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdivisor.sv
64 lines (56 loc) · 1.08 KB
/
divisor.sv
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
63
64
//module divisor (input rst, clk_in, output logic clk_out);
// logic [25:0] count;
//
// always_ff @(posedge clk_in)
// begin
// if(!rst)
// begin
// count <= 26'd0;
// end
// else
// begin
// if(count == 26'd49999999)
// begin
// count <= 26'd0;
// end
// else
// count <= count + 26'd1;
// end
// end
//
//always_comb
// clk_out <= (count == 26'd49999999);
//endmodule
// Divisor para teste
module divisor (
input rst, clk_in,
output logic clk_out
);
logic [1:0] count = 2'd0;
always_ff @(posedge clk_in)
begin
if(!rst)
begin
// $display ("divisor: reset");
// clk_out <= 0;
count <= 2'd1;
end
else
begin
if(count == 2'd1)
begin
// $display ("divisor: count %d", count);
// $display ("divisor: 1clk_out %d", clk_out);
// clk_out <= ~clk_out;
// $display ("divisor: 2clk_out %d", clk_out);
count <= 2'd0;
end
else begin
count <= count + 2'd1;
// $display ("divisor: else %d", count);
end
end
end
always_comb
clk_out <= (count == 2'd1);
endmodule