-
Notifications
You must be signed in to change notification settings - Fork 71
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 #298 from yrabbit/ioregs-m
Implement FF in IO blocks.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module top ( | ||
input clk, | ||
input key_i, | ||
input rst_i, | ||
output [`LEDS_NR-1:0] led | ||
); | ||
|
||
wire key = key_i ^ `INV_BTN; | ||
wire reset = rst_i ^ `INV_BTN; | ||
|
||
reg [25:0] ctr_q; | ||
wire [25:0] ctr_d; | ||
|
||
always @(posedge clk) begin | ||
if (reset) begin | ||
ctr_q <= ctr_d; | ||
end | ||
end | ||
|
||
reg [`LEDS_NR - 2:0] led_r; | ||
assign led = {ctr_q[25:25], led_r}; | ||
assign ctr_d = ctr_q + 1'b1; | ||
|
||
always @(posedge clk) begin | ||
if (!key) begin | ||
led_r <= ctr_q[25:25-(`LEDS_NR - 2)]; | ||
end | ||
end | ||
|
||
endmodule |