Skip to content

Instantly share code, notes, and snippets.

@maxkunes
Last active February 24, 2018 04:56
Show Gist options
  • Save maxkunes/c5ee23cfe1aa8b0f791a311724cf306a to your computer and use it in GitHub Desktop.
Save maxkunes/c5ee23cfe1aa8b0f791a311724cf306a to your computer and use it in GitHub Desktop.
Simple verilog file where a switch is used to control the state of an LED through an fpga. 100 MHZ clock is used, this doesn't matter though.
`timescale 1ns / 1ps
module led_switch(
output reg led0_r,
input CLK100MHZ,
input btn
);
reg tickedLastFrame = 1'b0;
always@ (posedge CLK100MHZ) begin
if(btn)
begin
if(!tickedLastFrame) begin
led0_r = ~led0_r;
tickedLastFrame = 1'b1;
end
end
else begin
tickedLastFrame = 1'b0;
end
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment