In this project, you will download a bit file to your board in order to configure the FPGA with four different logic circuits. The circuits use buttons and switches for inputs, and LEDs for outputs. You must probe the logic circuits by applying all possible combinations of input signals. From the results of applying all possible combinations, you will be able to write logic equations that describe the circuits' behaviors. You will then rewrite the equations using Verilog HDL, which will re-implement them on the FPGA and compare the circuit behavior with the given bit file.
Qty | Description |
---|---|
1 | Digilent® Nexys™4, Nexys™3, Nexys™2, or Basys™2 FPGA Board |
1 | Xilinx ISE Design Suite: WebPACK (14.6 Recommended) |
1 | Digilent Adept |
A truth table is the primary tool for capturing logical relationships in a concise and universally understood format. A truth table contains a column of each input on the left and one final column for the output on the right. The truth table contains all possible input and output configurations of any given logic equation. A two input AND logic operation is defined using the truth table below:
A | B | F |
---|---|---|
false | false | false |
false | true | false |
true | false | false |
true | true | true |
A signal in a digital circuit is a circuit net that transports an output voltage from one device to one or more input connections of other devices. In a digital circuit, signals are constrained to be at one of two voltages, either Vdd (1) or GND (0). Thus, all data in digital circuits can only be represented as a zero or one for the two available states. Systems that use two-state data are known as binary systems, and a two-state signal is a binary signal. One signal wire in a digital circuit can carry one binary digit (abbreviated to bit) of information. Conventionally, we assign symbol “1” to true and “0” to false. For example, an AND relation can be logically described as “true” when all of the inputs are “true.” Using the binary numbers assigned to a digital system, the logical AND truth table appears below:
A | B | F |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
There are four circuits implemented in the bit file that you downloaded in Step 1. You are going to start probing them one by one.
The first circuit takes SW0 and SW1 as inputs and uses LD0 to indicate the output of the logic function. As there are two inputs for this logic circuit, there are four possible combinations. According to the circuit of the switch, when the switch slides on, a high voltage (i.e., a logic “1”) will be presented on the input of the circuit. Similarly, if the LD0 turns on, a high voltage is presented on the output of the circuit, which means the current output of the logic circuit is a logic “1”. So we have both SW0 and SW1 off and we will need to check the LD0 status to fill out the first line of the truth table below. Slide the SW0 on to fill out the second row. Slide the SW0 off and SW1 on to fill out the third row. Slide both of them on to fill out the final row. After you fill out the truth table, you can click button “Check Result” to see if you filled it all out correctly.
SW1 | SW0 | LD0 | |
---|---|---|---|
0 | 0 | ||
0 | 1 | ||
1 | 0 | ||
1 | 1 | ||
The second circuit takes SW1, SW2, and SW3 as inputs, and LD1 as output. Probe Circuit 2 the same way you did Circuit 1 and fill out the truth table below. After you fill out the truth table, you can click button “Check Result” to see if you filled it out correctly.
SW3 | SW2 | SW1 | LD1 | |
---|---|---|---|---|
0 | 0 | 0 | ||
0 | 0 | 1 | ||
0 | 1 | 0 | ||
0 | 1 | 1 | ||
1 | 0 | 0 | ||
1 | 0 | 1 | ||
1 | 1 | 0 | ||
1 | 1 | 1 | ||
The third circuit takes SW4, SW5, SW6, and SW7 as inputs, and LD2 as output. Probe Circuit 3 the same way you did Circuit 1 and fill out the truth table below. After you fill out the truth table, you can click button “Check Result” to see if you filled it out correctly.
SW7 | SW6 | SW5 | SW4 | LD2 | |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | ||
0 | 0 | 0 | 1 | ||
0 | 0 | 1 | 0 | ||
0 | 0 | 1 | 1 | ||
0 | 1 | 0 | 0 | ||
0 | 1 | 0 | 1 | ||
0 | 1 | 1 | 0 | ||
0 | 1 | 1 | 1 | ||
1 | 0 | 0 | 0 | ||
1 | 0 | 0 | 1 | ||
1 | 0 | 1 | 0 | ||
1 | 0 | 1 | 1 | ||
1 | 1 | 0 | 0 | ||
1 | 1 | 0 | 1 | ||
1 | 1 | 1 | 0 | ||
1 | 1 | 1 | 1 | ||
AND, OR, and NOT (or inversion) are the three primary logic relationships that can be used to express any logical relationship between any number of variables. These simple logic functions form the basis for all digital electronic devices, from a simple microwave oven controller to a desktop PC. There are a set of symbols that are commonly used to express these logic operations. You may have seen some of the symbols in your math classes or in other programming languages. Here is a list for the symbols for the three primary logic relationships:
Logic Operation | in Math Class | in Real Digital | in C Programming Language |
in Circuit Schematic | in Verilog HDL |
---|---|---|---|---|---|
A And B | $A\cdot B$ \(A \land B\) \(A \& B\) |
\(A \cdot B\) | \(A \& B\) | \(A \& B\) | |
A Or B | \(A \vee B\) \(A + B\) \(A | B\) |
\(A + B\) | \(A | B\) | \(A | B\) | |
Not A | \(\lnot A\) \(\sim A\) \(!A\) \(A'\) \(\overline{A}\) |
\(\overline{A}\) | \(\sim A\) | \(\sim A\) |
A product term is defined as an AND relationship between any number of variables, and a sum term is defined as an OR relationship between any number of logic variables. Any logic system can be represented in two logically equivalent ways: as the OR'ing of AND'ed terms, known as the sum of products (SOP) form; or as the AND'ing of OR'ed terms, known as the product of sums (POS) form.
A logic equation (and therefore a logic circuit) can easily be constructed from any truth table by applying the rules presented below.
For SOP circuits:
For POS circuits:
`timescale 1ns/1ps;
// Comment
module top (
input [7:0] sw,
output [2:0] led
);
endmodule
We will construct the logic equation in SOP form for demonstration. In Circuit 1, we have two rows (second row and third row) that shows a “1” in the output. So we need an OR gate with two inputs that generate the output, and two 2-input AND gates that provide the input for the OR gate. In the second row, input SW0 shows a “1” and input SW1 shows a “0”. So SW0 is connected to the input of the first AND gate and SW1 is inverted before connecting to the second input of the AND gate, as shown in the first product term in the equation. In the third row, input SW0 shows a “0” and input SW1 shows a “1”. So SW0 is inverted before connecting to the input of the second AND gate and SW1 is connected directly to the second input of the AND gate, as shown in the second product term in the equation. The output LD0 is the summation of these two product terms. \[LD0 = SW0 \cdot \overline{SW1}+ \overline{SW0} \cdot SW1\] In Verilog HDL, this circuit is implemented as follows:
assign led[0] = (sw[0] & ~sw[1]) | (~sw[0] & sw[1]);
Similar to Circuit 1, you can come up with the logic function for the second circuit in SOP form as: \[LD1 = \overline{SW3} \cdot \overline{SW2} \cdot \overline{SW1} + \overline{SW3} \cdot SW2 \cdot SW1 + SW3 \cdot \overline{SW2} \cdot SW1 \] In Verilog HDL, we have:
assign led[1] = (~sw[3] & ~sw[2] & ~sw[1]) | (~sw[3] & sw[2] & sw[1]) | (sw[3] & ~sw[2] & sw[1]);
Similar to Circuit 1, you can come up with the logic function for the second circuit in SOP form as: \[LD1 = \overline{SW7} \cdot \overline{SW6} \cdot \overline{SW5} \cdot SW4 + \overline{SW7} \cdot \overline{SW6} \cdot SW5 \cdot SW4 + \\ \overline{SW7} \cdot SW6 \cdot \overline{SW5} \cdot \overline{SW4} + SW7 \cdot SW6 \cdot SW5 \cdot SW4\] In Verilog HDL, we have:
assign led[2] = (~sw[7] & ~sw[6] & ~sw[5] & sw[4]) | (~sw[7] & ~sw[6] & sw[5] & sw[4]) |
(~sw[7] & sw[6] & ~sw[5] & ~sw[4]) | (sw[7] & sw[6] & sw[5] & sw[4]);
Now that you've completed this project, try these modifications: