Most of the FPGAs have 7-segment decoders. These 7-seg displays are of following type:
- Common Anode
- All the anode i.e. +ve pins of LEDs connected to ‘1’ in digital design terms
- Cathodes i.e. -ve pins are used to turn-on or turn-off LED segments by setting ‘0’ or ‘1’
- Common Cathode
- All the cathode i.e. -ve pins of LEDs connected to ‘0’ in digital design terms
- Anodes i.e. +ve pins are used to turn-on or turn-off LED segments by setting ‘1’ or ‘0’
Following is the code for 7-seg decoder. Depending on which board you are using, you will need to set value of seg_type parameter.
- ‘1’ for common-anode
- ‘0’ for common-cathode
Use a Applet below to play with the values that you can get when you click on individual segment. You can select your 7-seg type by clicking on CMN Anode button. Compare these values with code below for better understanding.