| 1 |
/* Pressing the button stops the blinking of one or another group of LEDs */ |
| 2 |
module top ( |
| 3 |
input clk, |
| 4 |
input key_i, |
| 5 |
input rst_i, |
| 6 |
output [`LEDS_NR-1:0] led |
| 7 |
); |
| 8 |
|
| 9 |
reg [31:0] counter; |
| 10 |
reg [31:0] counter2; |
| 11 |
wire clk1, clk2; |
| 12 |
|
| 13 |
wire key = key_i ^ `INV_BTN; |
| 14 |
wire key1 = rst_i ^ `INV_BTN; |
| 15 |
|
| 16 |
DQCE dqce( |
| 17 |
.CLKIN(clk), |
| 18 |
.CE(key), |
| 19 |
.CLKOUT(clk1) |
| 20 |
); |
| 21 |
|
| 22 |
DQCE dqce2( |
| 23 |
.CLKIN(clk), |
| 24 |
.CE(key1), |
| 25 |
.CLKOUT(clk2) |
| 26 |
); |
| 27 |
|
| 28 |
always @(posedge clk1) begin |
| 29 |
if (counter < 31'd1350_0000) |
| 30 |
counter <= counter + 1; |
| 31 |
else begin |
| 32 |
counter <= 31'd0; |
| 33 |
led[1:0] <= {~led[0],led[1]}; |
| 34 |
end |
| 35 |
end |
| 36 |
|
| 37 |
always @(posedge clk2) begin |
| 38 |
if (counter2 < 31'd1350_0000) |
| 39 |
counter2 <= counter2 + 1; |
| 40 |
else begin |
| 41 |
counter2 <= 31'd0; |
| 42 |
led[2] <= ~led[2]; |
| 43 |
end |
| 44 |
end |
| 45 |
|
| 46 |
endmodule |