0% found this document useful (0 votes)
39 views9 pages

Questions

This document provides exercises related to combinational logic. It includes questions about boolean functions, combinational logic circuits, truth tables, sum-of-products and product-of-sums representations. There are questions about multiplexors, decoders, adders, overflow detection, and designing a combinational logic circuit for a 7-segment display encoder. Solutions are provided for each question.

Uploaded by

Cristian Mihai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
39 views9 pages

Questions

This document provides exercises related to combinational logic. It includes questions about boolean functions, combinational logic circuits, truth tables, sum-of-products and product-of-sums representations. There are questions about multiplexors, decoders, adders, overflow detection, and designing a combinational logic circuit for a 7-segment display encoder. Solutions are provided for each question.

Uploaded by

Cristian Mihai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 9

COMP 273, Winter 2016

Exercises 2 - combinational logic

Questions
1. How many boolean functions can be defined on n input variables?
2. Consider the function:
Y = (A B) + (A C) B
(a) Draw a combinational logic circuit that implements this function.
(b) Draw a truth table for this function.
(c) Write a sum-of-products representation of Y .
(d) Write a product-of-sums representation of Y .
3. Write
Y = A + (B C)
(a) as a sum-of-products where each product depends on all three variables A, B, C.
(b) as a product-of-sums where each sum depends on all three variables A, B, C.
4. Write a sum-of-products representation of the following circuit.
A

5. Write
Y = (A + B + C) (A + B + C)
as a sum-of-products.
6. Write a sum-of-products representation of the output Y of the following circuit, in terms of
the input variables A,B,C. The four gates below are NAND, XOR, OR, and AND.
Explain how this circuit could be considered as a read only memory.

last updated: 3rd Feb, 2016

COMP 273, Winter 2016

Exercises 2 - combinational logic

A
B

7. Draw a combinational logic circuit of an eight input multiplexor where the inputs
(D7 , D6 , D5 , D4 , D3 , D2 , D1 , D0 )
are each one bit variables. Label the values of inputs and outputs of each gate of the circuit,
assuming the eight inputs have the values (1, 0, 0, 1, 1, 1, 0, 0) respectively, and assuming D1 is
selected. [Do not draw the decoder circuit which is part of the multiplexor. Instead, merely
label the inputs and outputs of this decoder as part of the multiplexor.]
8. Consider the low order four bits of the adder/subtractor circuit shown below. Label all wires
(inputs, outputs) in the circuit by their value (0 or 1), assuming the circuit is computing
A B where A = 98 and B = 25. [Do not draw the entire circuit. Only consider the four
lowest order bits for this question.]
Binvert
C0
A0
M
U
X

B0

A1
M
U
X

B1

A2
M
U
X

B2

C1

B3

S1
C2

S2
C3

A3
M
U
X

S0

S3

C4

9. For the circuit in the previous question, give the values of (S3, S2, S1, S0) in the case that:
(a) A = 25, B = 39,
(b) A = 25, B = 39,
last updated: 3rd Feb, 2016

Binvert = 1

Binvert = 0
2

COMP 273, Winter 2016

Exercises 2 - combinational logic

10. Draw a combinational logic circuit of a four input multiplexor where the inputs (X3 , X2 , X1 , X0 )
are each one bit variables. Label the values of inputs and outputs of each gate of the circuit,
assuming the four inputs have the values (X3 , X2 , X1 , X0 ) = (1, 0, 0, 1) and assuming X1 is
selected. [Do not draw the decoder circuit which is part of the multiplexor.]
11. An example of an encoder that you should be familiar with is an output device (an LCD)
that displays a digit from {0, 1, ..., 8, 9}. The digit is defined by turning on a subset of the
following line segments. For example, when all seven of the line segments are on, the output
digit is 8, whereas when all lines except L2 are turned on, the output digit is 0.
Suppose that a user chooses a digit by pressing one of ten buttons. Construct a truth table
from which you could build a combinational circuit. (Dont build the circuit. Just build the
truth table.)
L1

L4
0

L2

L6

8 9
L5

L7
L3

12. If we add two signed numbers using our n-bit adder circuit, then the result might give an
error in the following sense: it could happen that we add two positive numbers and the result
is a negative number, or we add two negative numbers and the result is a positive number,
or we subtract a positive number from a negative number and the result is positive, or we
subtract a negative number from a positive number and the result is negative. In all these
cases, the error occurs because the adder defines addition on a circle, not on the (infinite) set
of integers.
For example, suppose n = 8 and consider adding 64 + 64, i.e. 64 = 010000002 in binary.
The result we wish is 128; however, if the result (100000002 ) is treated as signed then it is
interpreted as -128 (not 128).
Such errors are called overflow. We would like to detect such errors automatically.
Define a binary variable overf low which takes the value 1 when an overflow (error) occurs
and 0 when no overflow occurs (no error). This overflow variable depends on the four variables
Binvert, An1 , Bn1 and Cn1 .
Fill in the truth table below, showing how overflow depends on the four variables Binvert,
An1 , Bn1 , Sn1 . (Binvert says whether we are doing addition or subtraction.)
Hint: Consider the cases of addition and subtraction separately.
Binvert

An1

Bn1

last updated: 3rd Feb, 2016

Sn1

overf low

COMP 273, Winter 2016

Exercises 2 (solutions)

Solutions
1. When we have two input variables, the truth table has four rows. A boolean function assigns
one boolean value (Y) to each of these four rows. Thus, there are 24 possible boolean functions
of two input variables.
If there are n input variables, then the truth table has 2n rows. We can thus define 2(2
boolean functions on n variables.
2. (a)
A
B

(b)
A B
0 0
0 0
0 1
0 1
1 0
1 0
1 1
1 1

C
0
1
0
1
0
1
0
1

AB
0
0
0
0
0
0
1
1

AC
0
0
0
0
0
1
0
1

AC
1
1
1
1
1
0
1
0

B
1
1
0
0
1
1
0
0

(A C) B
1
1
0
0
1
0
0
0

Y = A B + (A C) B
1
1
0
0
1
0
1
1

(c) From the truth table we have:


Y =ABC +ABC +ABC +ABC +ABC
(d) Again from the truth table we have:
Y =ABC +ABC +ABC
De Morgans Laws now yields:
Y = Y = (A + B + C) (A + B + C) (A + B + C)

last updated: 3rd Feb, 2016

Y
0
0
1
1
0
1
0
0

n)

COMP 273, Winter 2016

Exercises 2 (solutions)

3. This question could be solved by building the truth table for the function Y = A + (B C)
and extracting the correct rows to obtain each of the answers:
A
0
0
0
0
1
1
1
1

B C
0 0
0 1
1 0
1 1
0 0
0 1
1 0
1 1

Y
0
1
0
0
1
1
1
1

(a) Taking the rows of the truth table where Y = 1 we have that
Y = (A B C) + (A B C) + (A B C) + (A B C) + (A B C)
(b) Taking the rows of the truth table with Y = 0 (or Y = 1) we have that
Y = (A B C) + (A B C) + (A B C)
Negating Y gives:
Y = (A B C) + (A B C) + (A B C)
Y = (A B C) (A B C) (A B C)
Y = (A + B + C) (A + B + C) (A + B + C)
4. Using a truth table and applying the sum-of-products technique gives (details omitted):
Y =ABC
5.
Y

= (A + B + C) (A + B + C)
= (A + B + C) + (A + B + C)
= ABC +ABC

6.
A B
0 0
0 0
0 1
0 1
1 0
1 0
1 1
1 1
last updated: 3rd Feb, 2016

C
0
1
0
1
0
1
0
1
5

AB
1
1
1
1
1
1
0
0

(A, B)
0
0
1
1
1
1
0
0

B+C
0
1
1
1
0
1
1
1

Y
0
0
1
1
0
1
0
0

COMP 273, Winter 2016

Exercises 2 (solutions)

Thus,
Y =ABC +ABC +ABC
To think of this circuit as a read only memory, the three input variables A, B, C need to
encode an address (from 0 to 7) and so we need to specify an ordering of these three input
variables. For example, if we associate (A, B, C) with (A2 , A1 , A0 ) and treat A2 A1 A0 as a
binary number in base 2, then (A, B, C) = (1, 0, 0) would encode the address 4, that is, (100)2
in binary, whereas if we we associated (A, B, C) with (A0 , A1 , A2 ) then (A, B, C) = (1, 0, 0)
would encode the address 1, that is, (001)2 in binary.
Note that since there is only one output variable Y , only one bit of data is stored at each of
the eight addresses in this read only memory.
7.
0

D0

D1

D2

0
0
0

0
0

D3

1
0

D4

0
0

D5

0
0

D6

0
1

D7

3to8 decoder

last updated: 3rd Feb, 2016

COMP 273, Winter 2016

Exercises 2 (solutions)

8. A = 98 in binary (signed) is . . . 0001100010, so four low order bits of A are 0010


B = 25 in binary (signed) is . . . 1111100111, so four low order bits of A are 0111
A B = 98 (25) = 123 = (001111011)2 , so four low order bits are 1011.
Verify that this is consistent with the 0s and 1s on the wires (which you can compute
indpendently by examining the sum and carry bits).
Binvert
1
1
0

A0
B0

1 M
U

+
0

0 X

1
A1
B1

1
1

M
U
X

0
1
1

+
0
0

1
A2
B2

1
1

M
U
X

1
A3
0 M
U

B3

+
0
0

+
1

1 X

ETC
9. (a) Since Binvert = 1, we are performing subtraction: A - B = 25 (39) = 39 25 = 14.
So the answer is 14 written in binary which is 00001110. The lower four bits are what
we want, i.e. (S3,S2,S1,S0) = (1,1,1,0).
(b) Since Binvert = 0, we are performing addition: A + B = 25 + 39 = 64. In binary this is
01000000. The lower four bits are what we want, i.e. (S3,S2,S1,S0) = (0,0,0,0).
last updated: 3rd Feb, 2016

COMP 273, Winter 2016

Exercises 2 (solutions)

10.
0
X0

1
1
0

X1

X2

X3

2to4
decoder

11. Each of the 10 digits has a 7 bit code, namely a subset of 7 line segments that is on.
0
1
0
0
0
0
0
0
0
0
0

1
0
1
0
0
0
0
0
0
0
0

2
0
0
1
0
0
0
0
0
0
0

3
0
0
0
1
0
0
0
0
0
0

4
0
0
0
0
1
0
0
0
0
0

5
0
0
0
0
0
1
0
0
0
0

6
0
0
0
0
0
0
1
0
0
0

7
0
0
0
0
0
0
0
1
0
0

8
0
0
0
0
0
0
0
0
1
0

9
0
0
0
0
0
0
0
0
0
1

L1 L2
1
0
0
0
1
1
1
1
0
1
1
1
1
1
1
0
1
1
1
1

L3 L4 L5
1
1
1
0
0
0
1
0
1
1
0
0
0
1
0
1
1
0
1
1
1
0
0
0
1
1
1
1
1
0

L6 L7
1
1
1
1
1
0
1
1
1
1
0
1
0
1
1
1
1
1
1
1

The above truth table only considers combinations of input values such that exactly one of
the inputs is 1. We could expand the truth table by adding another 1014 (that is, 210 10)
rows to each of the 17 columns, and filling the right side (L1 L7) of these new rows with 0s.
If we then built a circuit based on this truth table, then the circuit would produce an output
digit if and only if exactly one of the ten input variables were on. (If zero or more than input
variables was 1, then it wouldnt light up any of the segments.)
last updated: 3rd Feb, 2016

COMP 273, Winter 2016

Exercises 2 (solutions)

From the above truth table, we could build a combinational logic circuit having 10 inputs and
7 outputs. For example, we could construct a sum-of-products expression for each of the line
segments. L1 and L2 would be the sum of eight product terms, L3 and L4 would be the sum
of seven product terms, etc. Each of these product terms has 10 variables.
12. First consider addition (Binvert = 0), namely A + B. There are several cases:
if the two numbers are of opposite sign, then there can be no overflow (convince yourself).
if the two numbers are positive (An1 = 0, Bn1 = 0) then there is overflow if and only
if Sn1 = 1 which indicates a negative result.
if the two numbers are negative (An1 = 1, Bn1 = 1), then there is overflow if and only
if Sn1 = 0, i.e. a non-negative result.
Next consider subtraction (Binvert = 1), namely A B.
We use similar reasoning as above:
if A and B are of the same sign, then there is no overflow
if A > 0 (An1 = 0) and B < 0 (Bn1 = 1), then there is overflow if and only if Sn1 = 1
(a negative result)
if A < 0 and B > 0, then there is overflow if and only if Sn1 = 0 (a positive result).
Binvert
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1

An1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1

Bn1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1

last updated: 3rd Feb, 2016

Sn1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

Overflow
0
1
0
0
0
0
1
0
0
0
0
1
1
0
0
0

You might also like