-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock_divider.v
executable file
·64 lines (60 loc) · 1.41 KB
/
clock_divider.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
63
64
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Laboratorio de Particulas - Centro Atomico Bariloche
// Engineer: Miguel Sofo Haro
//
// Create Date: 14:13:56 10/29/2010
// Design Name:
// Module Name: clock_divider
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
// A partir del clock global de la FPGA, el proposito del modulo es generar
// una señal de clock de frecuencia inferior (< frecuencia del clock global)
//
//////////////////////////////////////////////////////////////////////////////////
module clock_divider
(
input wire global_clock,
output reg clock
);
//Parameters,
parameter o_freq_MHz = 10; //Output clock frecuency in MHz
parameter gc_freq_MHz = 50; //Global clock frecuency in MHz
//Local Paramters
localparam first_trigger = ((gc_freq_MHz/o_freq_MHz)+1)/2;
localparam second_trigger = (gc_freq_MHz/o_freq_MHz)+1;
//Internal Variables
reg [31:0] counter;
//Initial Variables Values
initial
begin
counter = 0;
clock = 0;
end
//Circuit
always @(posedge global_clock)
begin
counter = counter + 1;
if(counter == first_trigger)
begin
clock = ~clock;
end
else
begin
if(counter == second_trigger)
begin
counter = 0;
clock = ~clock;
end
end
end
endmodule