-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from yrabbit/dyn-clk
Add dynamic clock control
- Loading branch information
Showing
7 changed files
with
273 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Pressing the button stops the blinking because no clock source will be selected */ | ||
module top ( | ||
input clk, | ||
input key_i, | ||
input rst_i, | ||
output [`LEDS_NR-1:0] led | ||
); | ||
|
||
reg [31:0] counter; | ||
reg [31:0] counter2; | ||
wire clk1, clk2; | ||
|
||
wire key = key_i ^ `INV_BTN; | ||
|
||
DCS dcs( | ||
.CLK0(1'b1), | ||
.CLK1(clk), | ||
.CLK2(1'b1), | ||
.CLK3(1'b1), | ||
.CLKSEL({1'b0, 1'b0, key, 1'b0}), | ||
.SELFORCE(1'b1), | ||
.CLKOUT(clk1) | ||
); | ||
defparam dcs.DCS_MODE="CLK1_GND"; | ||
|
||
always @(posedge clk1) begin | ||
if (counter < 31'd1350_0000) | ||
counter <= counter + 1; | ||
else begin | ||
counter <= 31'd0; | ||
led[1:0] <= {~led[0],led[1]}; | ||
end | ||
end | ||
|
||
endmodule |
Oops, something went wrong.