-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclockdiv.v
50 lines (45 loc) · 1.04 KB
/
clockdiv.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 20:49:36 03/19/2013
// Design Name:
// Module Name: clockdiv
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module clockdiv(
input wire clk, //master clock: 50MHz
input wire clr, //asynchronous reset
output wire dclk //pixel clock: 25MHz
// output wire segclk //7-segment clock: 381.47Hz
);
// 17-bit counter variable
reg [16:0] q;
// Clock divider --
// Each bit in q is a clock signal that is
// only a fraction of the master clock.
always @(posedge clk or posedge clr)
begin
// reset condition
if (clr == 1)
q <= 0;
// increment counter by one
else
q <= q + 1;
end
// 50Mhz � 2^17 = 381.47Hz
// assign segclk = q[16];
// 50Mhz � 2^1 = 25MHz
assign dclk = q[1];
endmodule