fpga4fun.comwhere FPGAs are fun

Opto 0 - LED glow

Do you have an FPGA board with an LED?
Try this simple design.

module LEDglow(clk, LED);
input clk;
output LED;

reg [23:0] cnt;
always @(posedge clk) cnt <= cnt+1;

reg [4:0] PWM;
wire [3:0] intensity = cnt[23] ? cnt[22:19] : ~cnt[22:19];
always @(posedge clk) PWM <= PWM[3:0] + intensity;

assign LED = PWM[4];
endmodule

This makes the LED "glow".

Note: Use a "clk" clock signal at around 20MHz. Otherwise the effect might be too slow or too fast to be appreciated.