So I’m new to Verilog and CPLDs. I wrote some code that turns on an LED, and now I would like to have it blinking.
module LEDON(LED);
output LED;
reg LED;
always
begin
LED=1'b1;
end
endmodule
So how do I add a delay that will allow me to see the LED coming on and off? I’ve read tha tI have to slow down the clock speed using flip flops, but I’m not quite sure what this means.
You don’t have to slow down the clock frequency. What you want to do is to make a counter that toggles the LED after so many clock cycles.
If you have a 1MHz clock, and you want to toggle the led once per second, then do something like this
Basically this is just a free running counter, and every time it hits a certain value, it toggles the led_state and resets itself.
You’ll have to adjust the value of the count_max based on your desired blink rate and clock frequency.