Hexadecimal on a 7-segment display
Saturday, September 16th, 2006Well, now I think we should do something a bit more useful.
The fourth design displays a hexadecimal number on one of the 7-segment LED displays. A binary number is set with four slide switches, with UP meaning 1, and DOWN meaning 0.
There are several ways to solve this problem. The solution I chose is the VHDL when-else syntax used in an XESS tutorial. The Verilog equivalent is the ternary ?: syntax.
Two other ways are to use a process with if-elsif, or a process with case-when. The Verilog equivalents are an always block with if-else, or an always block with switch-case.
There is yet another way - determine the Boolean equation for lighting up each individual line segment and encode them as assignments. It doesn’t much matter if the assignments are inside or outside a process or always block.
On my previous designs, the 7-segment LED’s were dimly lit on my board. Why? Because of my default configuration of unused I/O pins, and the electronics on the Digilent board.
The default configuration attaches a PULLDOWN resistor to all the unused I/O pins, which pulls the pin voltage down towards 0V. You turn on a line segment by setting both the anode pin (for a digit) and the segment pin to 0V (= 0 in Verilog and VHDL). This ought to fully turn on unused line segments. However, due to the off-chip circuitry, the PULLDOWN is not strong enough to pull all the 7-segment pins to 0V. The result is dim line segments.
The fix is to put a “standard” 0 or 1 to turn the LED full on or full off. For example, setting AN3, AN2, and AN1 to 1 turns off the left three digits. However, because I am turning on AN0 with a 0, the decimal point on that digit will be lit dimly unless I turn it off with a 1 or turn it full on with a 0.
Update: 2008-12-29
My fourth design is now listed as my fifth design. Design #4 is a pair of RS latches.