summaryrefslogtreecommitdiff
path: root/playground/led_toggle_bouncy.v
blob: 8e783f227cb6b69cfb95f0a10f0292ffb801ce7d (plain)
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
`timescale 1us/1us

// From the book
// bouncy variant

module led_toggle_bouncy (
  input wire clk_i,
  input wire key_i,
  output wire [5:0] led
);

reg r_LED_1 = 1'b1;
reg r_Switch_1 = 1'b1;

always @(posedge clk_i) begin
  r_Switch_1 <= key_i;
  if (key_i == 1'b1 && r_Switch_1 == 1'b0) begin
    r_LED_1 <= ~r_LED_1;
  end
end

assign led[0] = r_LED_1;
assign led[5:1] = 5'b11111;

endmodule