examples/blinky.v
raw| 1 | module top ( |
| 2 | input clk, |
| 3 | input key_i, |
| 4 | output [`LEDS_NR-1:0] led |
| 5 | ); |
| 6 | |
| 7 | wire key = key_i ^ `INV_BTN; |
| 8 | |
| 9 | reg [25:0] ctr_q; |
| 10 | wire [25:0] ctr_d; |
| 11 | |
| 12 | // Sequential code (flip-flop) |
| 13 | always @(posedge clk) begin |
| 14 | if (key) begin |
| 15 | ctr_q <= ctr_d; |
| 16 | end |
| 17 | end |
| 18 | |
| 19 | // Combinational code (boolean logic) |
| 20 | assign ctr_d = ctr_q + 1'b1; |
| 21 | assign led = {ctr_q[25:25-(`LEDS_NR - 2)], |ctr_q[25-(`LEDS_NR - 1):25-(`LEDS_NR)] }; |
| 22 | |
| 23 | endmodule |