LED blinking Example on Spartixed

The LED blinking example uses just a clock divider ( 2 to power N) and uses this clock divider to blink an LED.

//Spartixed board from referencedesigner.com
module clk_div (
input clk,
output  led2    
    reg [32:0] counter;
    reg state;
    assign led2 = state;
    always @ (posedge clk)
        counter <= counter + 1;
        state <= counter[26]; // Changes when MSB changes

The video shows the result when it is implemmented on Spartixed board.

Following ucf file is used.

NET "LED2" LOC = P131; //LED2
NET "clk" LOC = P55; // clk

Suggested Exercises

1. Modify the code so that the LED blinks for about 1/2 second and is off for say, 4 seconds - this will preserve the power consumption.