Docsity

Implementing Combinational Circuits - Lab 4 | ECE 241, Lab Reports of Electrical and Electronics Engineering

Toggle sidebar
bg1
COE/EE 244
Logic Circuit Lab Lab #4; Page 1/11
Spring 2003
Implementing Combinational Circuits
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 2ncode converters or as
Demultiplexers, they can also be used to implementBoolean functions of nvariables.
1 Multiplexers Used in Boolean Functions
Consider the following truth table that describes a function of 4 Booleanvariables.
ABCDF
00000
00010
00101
00111
01000
01011
01100
01111
10000
10010
10101
10111
11000
11010
11100
11111
MUX 16:1
0
1
2
3
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
G0
15
F
Vcc D
C
B
A
}
Figure 1: A 16 to 1 Multiplexer Implementation
A 16 to 1 Multiplexer with A,B,C, and Dapplied to its S3,S2,S1, and S0inputs respectively would
select one of its 16 inputs for each of the 16 possiblecombinations 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 Dthat selected the input. Therefore, the inputs to the
Multiplexer will be the same as the Fentries in the truth table provided A,B,C, and Dare connected to
the Multiplexer select inputs in the rightorder.
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 Cto the inputs of the Multiplexer, then for each combination of A,Band C,
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Implementing Combinational Circuits - Lab 4 | ECE 241 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

Logic Circuit Lab Spring 2003

Implementing Combinational Circuits

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.

1 Multiplexers Used in Boolean Functions

Consider the following truth table that describes a function of 4 Boolean variables.

A B C D F

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.

2 Multiplexers as Data Selectors

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

A B C D F
0 0 1 0 1 BC BD
1 0 1 0 1 BC CD

F

MUX 2: A 0}G^01 B D B C C D

0

1

Figure 4: A 2 to 1 Multiplexer Implementation

B C D A F
0 0 1 0 0 C
1 0 1 0 1 D  A C 

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

4Y-1Y
EN
S
4Y-1Y
EN
S
4A-1A 4B-1B 4A-1A 4B-1B

Destination

Source X Source W

Select

4A-1A
EN
S
4A-1A
EN
S
4B-1B 4B-1B

Source M Source N Source O Source P

D3 D2 D1 D
4Y 3Y 2Y 1Y 4Y 3Y 2Y 1Y
S0 S

S0 S1 Source

1 N
O
M
(a)

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

5 Subtracter

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

7 The Lab

  1. Implement and simulate the Adder/Subtracter circuit you designed in question 1. You do not need to create the adder; use the “ADD4” part supplied in the Xilinx ISE Tools. Obtain a printout of the timing simulation waveform and compare it with the table in preliminary question 1 and hand it in with the lab report.
  2. Implement and simulate the code converter you designed in question 2. You can use the D4 16E in the Xilinx ISE Tools. Obtain a printout of the timing simulation waveform and compare it with your truth table and hand it in with the lab report.
  3. Combine the two circuits as shown in Figure 13, and show the Addition/Subtraction on the 7 segment display. For simplicity use the LED1 as the minus sign and use LED2 as the overflow indicator. Implement and pass off the entire design.

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