-
Notifications
You must be signed in to change notification settings - Fork 6
/
ClockDivider.v
46 lines (42 loc) · 1.05 KB
/
ClockDivider.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 14:24:24 02/25/2020
// Design Name:
// Module Name: ClockDivider
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module ClockDivider#(parameter velocity = 1)
(input wire clk,
output wire speed);
reg [31:0] counter;
reg clock;
localparam threashold = 50000000 / velocity;
initial begin
counter <= 0;
clock <= 0;
end
always @(posedge clk) begin
if (counter == threashold - 1) begin
counter <= 0;
clock <= ~clock;
end
else begin
counter <= counter + 1;
clock <= clock;
end
end
assign speed = clock;
endmodule