






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Logic Circuit Lab Spring 2003
Due: By 6:00pm on Wednesday April 9. While Multiplexers are primarily thought of as “data selectors” because they select one of several inputs to be logically connected to the output, they can also be used to implement Boolean functions. Similarly, while n -bit Decoders are primarily thought of as n -bit binary to 1 of 2 n^ code converters or as Demultiplexers, they can also be used to implement Boolean functions of n variables.
Consider the following truth table that describes a function of 4 Boolean variables.
MUX 16: 0 1 2 3 0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15
G 150
F
Vcc (^) D C B A
Figure 1: A 16 to 1 Multiplexer Implementation
A 16 to 1 Multiplexer with A , B , C , and D applied to its S 3 , S 2 , S 1 , and S 0 inputs respectively would select one of its 16 inputs for each of the 16 possible combinations of A , B , C , and D. We can implement the function described by the truth table by connecting a voltage source for logic level 1 or ground for a logic level 0 to each of the Multiplexer inputs corresponding to the required value of the function associated with the combination of A , B , C , and D that selected the input. Therefore, the inputs to the Multiplexer will be the same as the F entries in the truth table provided A , B , C , and D are connected to the Multiplexer select inputs in the right order. Consider what happens when, instead of using a 16 to 1 Multiplexer, we use an 8 to 1 Mux. If we choose to connect A , B , and C to the inputs of the Multiplexer, then for each combination of A , B and C ,
Logic Circuit Lab Spring 2003
although only one Mux input is selected, we need to realize two potentially different values of F. If they are different, they will be functions of D (either D or D ). To see this, we partition the truth table into sections where A , B and C have the same value. This is shown in Figure 2.
A B C D F 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 0 0 D 0 1 0 1 1 0 1 1 0 0 D 0 1 1 1 1 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 0 0 0 0 1 1 0 1 0 1 1 1 0 0 D 1 1 1 1 1
Vcc
D
A
B
C
F
MUX 8: 0 1 2 0 1 2 3 4 5 6 7 G^0 } 7
Figure 2: An 8 to 1 Multiplexer Implementation
This idea can be extended to a 4 to 1 Mux implementation. In this case we partition the table into sections for which A and B have the same value. This is shown in Figure 3. Now Multiplexer inputs will be either 1, 0 or some function of C and D. K-maps may be used to simplify the functions of C and D for each of the table partitions, but in the case of two variables, the functions are usually obvious. The final possibility, shown in Figure 4, is a 2 to 1 Mux implementation. In this case only A is used as a select input and the table is partitioned into two parts based on A. Inputs to the Mux will be functions of B , C and D. Here it is more likely that you will need to use K-maps to simplify the functions. It should be apparent that there is no explicit importance to the order of A , B , C and D in the truth table. If we rearranged them, we would have chosen different variables as Mux select inputs, and we might end up using less logic in the rest of the circuit. Consider rearranging the table so that B is the Mux select input. Using this approach, the realization shown in Figure 5 uses less hardware.
In larger designs you may want to perform the same operations on signals coming from a number of different sources, or share a resource, such as a Seven-Segment display or an ALU (Arithmetic Logical Unit). If this is the case Multiplexers and Decoders can be used to route data. When used in this fashion
Logic Circuit Lab Spring 2003
F
MUX 2: A 0}G^01 B D B C C D
0
1
Figure 4: A 2 to 1 Multiplexer Implementation
F
MUX 2: 0}G^01
0
1
B
C C A D
Figure 5: Another 2 to 1 Multiplexer Implementation
Logic Circuit Lab Spring 2003
Destination
Source X Source W
Select
Source M Source N Source O Source P
S0 S1 Source
Logic Circuit Lab Spring 2003
DP
A
E
F
DP
B G
D
C CA
A
CB CC CD CE CF CG
Figure 8: Seven Segment Display
In Lab 3 you learned how to create a Full Adder and then construct a four-bit Adder from 4 Full Adders. The same Adder can be used for two’s complement addition and subtraction. Recall that subtracting a positive number in two’s complement is the same as adding a negative number. So, to create a Subtracter one of the inputs of an Adder can be two’s complemented as shown in Figure 9. Two’s complementing
2’s Complement
"0001"
A - B
A
B
Figure 9: A Subtracter Circuit Using Two’s Complement
a number consists of inverting the bits and adding one. Implementing this method in hardware requires implementing a second Adder, an expensive task in terms of size and speed. A better way is to take the one’s complement (inverting the bits) of the subtrahend and take advantage of the carry-in bit of a Ripple-Carry Full Adder to add one as shown in Figure 10.
Logic Circuit Lab Spring 2003
1’s Complement
1
Cin A
B
A - B
Figure 10: A Subtracter Circuit Using One’s Complement
Pin # FPGA Pin # Function Pin # FPGA Pin # Function 1 GND 21 87 BTN 2 VU 22 86 BTN 3 VCC 23 85 BTN 4 122 LDG 24 84 BTN 5 121 NC 25 83 DP 6 120 LD8 26 80 SW 7 118 NC 27 79 CG 8 117 LD7 28 78 SW 9 115 NC 29 77 CF 10 114 LD6 30 75 SW 11 113 NC 31 74 CE 12 112 LD5 32 67 SW 13 103 A4 33 66 CD 14 102 LD4 34 65 SW 15 100 A3 35 63 CC 16 99 LD3 36 62 SW 17 96 A2 37 60 CB 18 95 LD2 38 59 SW 19 94 A1 39 58 CA 20 93 LD1 40 57 SW
Logic Circuit Lab Spring 2003
A B C D X(7-Seg) 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 - 0 0 0 0 0 0 0 0 1 1 0 0 1 0 2 0 0 1 1 3 0 1 0 0 4 0 1 0 1 5 0 1 1 0 6 0 1 1 1 7
Code (^7) Converter
A B C D
7-Segment
Minus
Figure 12: 2’s Complement to Seven-Segment Converter
Logic Circuit Lab Spring 2003
4 4-Bit Adder/ Subtracter
LED
Code
7
1 A
R
O
CA - CG
Converter B
A
Ctrl
4
4 LED
Figure 13: Adder/Subtracter and 7-Segment Decoder Block Diagram