Last active
February 24, 2018 04:56
-
-
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.
This file contains hidden or 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
`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