Beginning FPGA Programming - Partie32
Beginning FPGA Programming - Partie32
8.1.2 Truth Tables
Truth tables are another way to express Boolean algebra or gate logic. In general, the truth table has 2^n
rows where n is the number of inputs. For example, three input will have 2^3 = 8 combinations. Let’s use
example 2 to demonstrate writing truth tables. In Table 8-1 it’s clear that the result is set to high if and only if
all inputs are low. This can help you compare the simulation result with the expected behavior.
149
Chapter 8 ■ Telling the Truth: Boolean Algebra and Truth Tables
A B C Result
0 0 0 0 1
1 0 0 1 0
2 0 1 0 0
3 0 1 1 0
4 1 0 0 0
5 1 0 1 0
6 1 1 0 0
7 1 1 1 0
Truth tables are very good tools for expressing Boolean algebra in a systematic way. They show all the
input combinations and all you need to do is work through them one by one and fill out all the possible
combinations of output. Therefore, the FPGA creates Boolean algebra by using the truth table in look-up
tables (LUTs). FPGAs can combine more than one LUT to form a bigger truth table.
Having these nine values, it becomes possible to accurately model the behavior of a digital system
during simulation. The 'Z' is used to model and output enable and the '-' don't care is used to optimize the
combinational logic.
The most important reason to use standard logic data types is to provide portability between models
written by different designers or different FPGA design tools.
150
Chapter 8 ■ Telling the Truth: Boolean Algebra and Truth Tables
To use this standard logic type in the VHDL file, you need to add two statements in the very beginning
of VHDL code.
The third data type std_logic_vector is an array type. Users need to define the array width in
the VHDL code.
151
Chapter 8 ■ Telling the Truth: Boolean Algebra and Truth Tables
2.
Copy the code in Figure 8-21 to a new VHDL file and save the file as four_bit_
adder.vhd with the check box Add file to current project. Before we can use the
fulladder inside four_bit_adder (both section A and B show in Figure 8-21), we
must declare the full adder in section - A.
152
Chapter 8 ■ Telling the Truth: Boolean Algebra and Truth Tables
Figure 8-21. four_bit_adder.vhd
153