This preview shows page 1. Sign up to view the full content.
Unformatted text preview: full adder" has three inputs. In addition to the two addends, there is also a "carry in" input, which adds the bit carried from the previous column, as in the middle column in the following example: 101 +101 1010
Figure 3-3. Three-Bit Binary Addition The truth table for a single-bit full adder therefore has three inputs, and thus eight possible states:
Table 3-2. Truth Table for Addition with a Carry In Carry In 0 0 0 0 1 1 1 1 A1 0 0 1 1 0 0 1 1 A2 0 1 0 1 0 1 0 1 Sum 0 1 1 0 1 0 0 1 Carry Out 0 0 0 1 0 1 1 1 Fundamentals of Digital Electronics 3-2 National Instruments Corporation Lab 3 Binary Addition Note that all three inputs are essentially equivalent; the full adder simply adds the three inputs. One way to build a 1-bit full adder is by combining two half adders: Figure 3-4. Full Adder Using Two Half Adder SubVIs Note the simplicity achieved in the wiring diagram by using the half adders. Adder Expansion
You can construct a device that adds multibit binary numbers by combining 1-bit adders. Each single-bit adder performs the addition in one "column" of a sum such as 1011 +0010 1101
Figure 3-5. 4-Bit Binary Addition (11+2=13) For example, a 4-bit adder could be constructed in LabVIEW as: Figure 3-6. LabVIEW Block Diagram for 4-Bit Binary Addition Note that this VI uses four 1-bit full adders. If you plan to add only 4-bit numbers with this circuit, the lowest-order adder could be a half adder. The National Instruments Corporation 3-3 Fundamentals of Digital Electronics Lab 3 Binary Addition use of all full adders allows the 4-bit adder to have a carry-in input, as well as the two 4-bit addend inputs. Load Four-bit Adder1.vi and observe the addition of two 4-bit numbers. It uses two subVIs, Full Adder.vi, shown in Figure 3-4, and Half Adder.vi, shown in Figure 3-2. As you can see, the wiring above is somewhat complicated and would become even more complex if you extended the adder to more bits. By using a LabVIEW For Loop with a shift register, you can simplify the wiring significantly: Figure 3-7. 4-Bit Binary Addition Using LabVIEW Arrays (Four-Bit Adder2.vi) Note how the four independent bits are formed into 4-bit arrays before passing into the interior of the For Loop, which iterates four times, each time adding a pair of bits, starting at the least significant bit. On the first iteration, the carry input to the 1-bit full adder is from the panel carry input; on subsequent iterations, it is the carry from the previous iteration. Run both versions of the VI and confirm that their behaviors are identical. Figure 3-8. 4-Bit Adder Using Array Inputs and Outputs Fundamentals of Digital Electronics 3-4 National Instruments Corporation Lab 3 Binary Addition There is also a third version of the above VI, named simply Four-bit Adder3.vi, which is identical to Figure 3-7 above except that the inputs and outputs are displayed as Boolean arrays. Note that in Boolean arrays, the LSB is on the left and the MSB is on the right. This version has been configured as a subVI, and you can combine two of these to create an 8-bit adder. Note that each 8-bit (one-byte) addend is separated into two 4-bit "nibbles," and then the two "least significant nibbles" are sent to one 4-bit adder, while the two "most significant nibbles" go to a second 4-bit adder. Figure 3-9. 8-Bit Adder Using Two 4-Bit Adders Binary Coded Decimal (BCD)
Not all digital arithmetic is performed by a direct conversion to the base-2 representation. Binary coded decimal, or BCD, representation is also used. In BCD, each decimal digit is separately encoded in four bits as follows:
Table 3-3. BCD Representation for the Numbers 0 to 9 Decimal Digit 0 1 2 3 4 BCD Representation 0000 0001 0010 0011 0100 Decimal Digit 5 6 7 8 9 BCD Representation 0101 0110 0111 1000 1001 BCD can be considered to be a subset of full binary notation, in which only the states 0000 to 1001 (0 to 9) are used. For example,
42 10 = 0100 0010 BCD National Instruments Corporation 3-5 Fundamentals of Digital Electronics Lab 3 Binary Addition Note that this is distinct from the binary representation, which in this case would be
42 10 = 00101010 2 Clearly, BCD is wasteful of bits, because there are a number of 4-bit patterns that are not used to encode a decimal digit. The waste becomes more pronounced for larger integers. Two bytes (16 bits) is enough to encode unsigned decimal integers in the range 0-65535 if the binary representation is used, but the same two bytes will span only the range 0-9999 when using BCD. The advantage of BCD is that it maps cleanly to decimal output displays. LabVIEW Challenge
Create a BCD encoder that takes as its input a digit in the range 0-9 and outputs the 4-bit BCD representation. Build a BCD decoder that reverses the behavior of the above encoder. Build a one-digit BCD adder. Lab 3 Library VIs (Listed in the Order Presented) Half Adder.vi (single-bit addition) Full Adder.vi (single-bit addition with carry in) Four-bit Adder1.vi (...
View Full Document
This note was uploaded on 12/01/2009 for the course S ss taught by Professor S during the Spring '09 term at Universidad Autonoma de Nuevo Leon - School of Business.
- Spring '09