Introduction
Here are some simple examples utilizing the icoBoards two buttons and three LED’s.
Physical constraints
All Examples will use the same *.pcf file, remember to comment in only those IO’s the example is actually using or arachne-pnr will fail:
The pins are taken from the icoBoard schematic.
Building and flashing
All Examples may use the same Makefile for building and flashing the Bitstream:
To build and flash the example, simply run:
To build and flash the Bitstream, do not forget to run the clean target when you have changed the content of example.v or example.pcf:
Basic
Light LED with Button press
When pressing button btn1 the LED led1 should light up. When the button is released, the button should be off again.
Solution: Always when the state of btn1 changes, change the state of led1 to the buttons current state.
This is what the yosys show command yields for our hardware description:
Toggle LED with Button press
When button btn1 is pressed, LED led1 should light up and stay lit, until button btn1 is pressed again.
Solution: In the initial block we initialize led1 to be off. Every time the button btn1 is pressed led1 will takes its inverted state. When it was off before the button was pressed it will be on afterwards and vice versa.
Four LED states
When button btn1 is pressed for the first time, led1, should light up and stay lit until the button is pressed a second time, then led2 should light up. When pressing the button a third time, LED led3 should be lit and all others off. Pressing the button a fourth time switches off all the LED’s again.
Solution: A register with three bits is initialized to zero. The first time the button is pressed, the register is set to 001 and output to the three LED’s every time the button is pushed, the register is shifted to the left by one bit, making the 1 bit wander to the left until it is all 0 again, then the process starts over.
Intermediate
Dimming a LED
led1 should start dim and increase in brightness, until it has reached full brightness and should then start to dim again.
Solution