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 33. ThreeBit Binary Addition The truth table for a singlebit full adder therefore has three inputs, and thus eight possible states:
Table 32. 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 32 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 1bit full adder is by combining two half adders: Figure 34. 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 1bit adders. Each singlebit adder performs the addition in one "column" of a sum such as 1011 +0010 1101
Figure 35. 4Bit Binary Addition (11+2=13) For example, a 4bit adder could be constructed in LabVIEW as: Figure 36. LabVIEW Block Diagram for 4Bit Binary Addition Note that this VI uses four 1bit full adders. If you plan to add only 4bit numbers with this circuit, the lowestorder adder could be a half adder. The National Instruments Corporation 33 Fundamentals of Digital Electronics Lab 3 Binary Addition use of all full adders allows the 4bit adder to have a carryin input, as well as the two 4bit addend inputs. Load Fourbit Adder1.vi and observe the addition of two 4bit numbers. It uses two subVIs, Full Adder.vi, shown in Figure 34, and Half Adder.vi, shown in Figure 32. 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 37. 4Bit Binary Addition Using LabVIEW Arrays (FourBit Adder2.vi) Note how the four independent bits are formed into 4bit 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 1bit 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 38. 4Bit Adder Using Array Inputs and Outputs Fundamentals of Digital Electronics 34 National Instruments Corporation Lab 3 Binary Addition There is also a third version of the above VI, named simply Fourbit Adder3.vi, which is identical to Figure 37 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 8bit adder. Note that each 8bit (onebyte) addend is separated into two 4bit "nibbles," and then the two "least significant nibbles" are sent to one 4bit adder, while the two "most significant nibbles" go to a second 4bit adder. Figure 39. 8Bit Adder Using Two 4Bit Adders Binary Coded Decimal (BCD)
Not all digital arithmetic is performed by a direct conversion to the base2 representation. Binary coded decimal, or BCD, representation is also used. In BCD, each decimal digit is separately encoded in four bits as follows:
Table 33. 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 35 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 4bit 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 065535 if the binary representation is used, but the same two bytes will span only the range 09999 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 09 and outputs the 4bit BCD representation. Build a BCD decoder that reverses the behavior of the above encoder. Build a onedigit BCD adder. Lab 3 Library VIs (Listed in the Order Presented) Half Adder.vi (singlebit addition) Full Adder.vi (singlebit addition with carry in) Fourbit 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
 s

Click to edit the document details