Truth Table Example - 7-Segment Display Decoder
Design Specification
The following block diagram shows a 7-segment decoder and the positions of the
display segments. To light a segment, the corresponding line is driven low.
When ena is low, the decoder is enabled. When ena is high, all outputs are driven
to a high impedance state.
Design Method
The following figure shows the simplified block diagram of the design. The
binary inputs and the decoder outputs are grouped into sets (bcd and led). The
constants ON and OFF are declared so the design can be described in terms of
turning a segment on and off. Because the outputs are active low, ON is declared as
0 and OFF is declared as 1.
The design is described in an equations section and a truth table section. The
decoding function is described with a truth table that specifies the outputs
required for each combination of inputs. The truth table header names the inputs
and outputs. The body of the truth table defines the input to output function.
Because the design decodes a number to a 7-segment display, values for bcd are
expressed as decimal numbers, and values for led are expressed with the
constants ON and OFF; this makes the truth table easy to understand.
The input and output values could just as easily been described in another
form. For example, the line in the truth table:
7-Segment Display Decoder Source File
title `7-segment display decoder`
D3,D2,D1,D0,Ena pin;
a,b,c,d,e,f,g pin istype `com`;
bcd = [D3,D2,D1,D0];
led = [a,b,c,d,e,f,g];
ON,OFF = 0,1;
L,H,X,Z = 0,1,.X.,.Z.;
equations
led.oe = !Ena;
@dcset
truth_table (bcd -> [ a, b, c, d, e, f, g ])
0 -> [ ON, ON, ON, ON, ON, ON, OFF]
1 -> [ OFF,ON, ON, OFF,OFF,OFF,OFF]
2 -> [ ON, ON, OFF,ON, ON, OFF,ON ]
3 -> [ ON, ON, ON, ON, OFF,OFF,ON ]
4 -> [ OFF,ON, ON, OFF,OFF,ON, ON ]
5 -> [ ON, OFF,ON, ON, OFF,ON, ON ]
6 -> [ ON, OFF,ON, ON, ON, ON, ON ]
7 -> [ ON, ON, ON, OFF,OFF,OFF,OFF]
8 -> [ ON, ON, ON, ON, ON, ON, ON ]
9 -> [ ON, ON, ON, ON, OFF,ON, ON ]
end