-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrequency_scaling.v
39 lines (29 loc) · 1.07 KB
/
frequency_scaling.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
// AstroTinker Bot : Task 1A : Frequency Scaling
/*
Instructions
-------------------
Students are not allowed to make any changes in the Module declaration.
This file is used to design a module which will scale down the 50M Clock Frequency to 3.125MHz.
Recommended Quartus Version : 20.1
The submitted project file must be 20.1 compatible as the evaluation will be done on Quartus Prime Lite 20.1.
Warning: The error due to compatibility will not be entertained.
-------------------
*/
//Frequency Scaling
//Inputs : clk_50M
//Output : clk_3125KHz
module frequency_scaling (
input clk_50M,
output reg clk_3125KHz
);
initial begin
clk_3125KHz = 0;
end
//////////////////DO NOT MAKE ANY CHANGES ABOVE THIS LINE //////////////////
reg [2:0] counter = 0; // counts 0 to 7
always @ (posedge clk_50M) begin
if (!counter) clk_3125KHz = ~clk_3125KHz; // toggles clock signal
counter = counter + 1'b1; // increment counter // after 7 it resets to 0
end
//////////////////DO NOT MAKE ANY CHANGES BELOW THIS LINE //////////////////
endmodule