Está en la página 1de 42

STLD

Unit 4b : Threshold Logic

Electronics and Communication Engineering


Geethanjali College of Engineering and Technology
Cheeryal (V), Keesara (M), Medchal Dt. – 501301

Email: gcetstld@gmail.com

Prepared by : Prof. K S Rao, E C E Dept


Topics:
 Threshold Element
 Capabilities and Limitations of Threshold Logic
 Elementary properties
 Synthesis of Threshold Networks
 Unate function

 Linear seperability

 Identification and realization of Threshold


functions
 Map based synthesis of two-level Threshold

networks
Prepared by : Prof. K S Rao 2
Reference Books:

Text Books:
 Switching and Finite Automata Theory
second edition by Zvi Kohavi – Chapter 7

Prepared by : Prof. K S Rao 3


Introductory Concepts
Threshold Element or Gate:
x1
w1

x2 w2 T y

wn
xn
Example: y = f (x1,x2,x3) =  (1,2,3,6,7) = x1’x3 + x2

x1
-1

x2 2 1_ y
2
1
4 x3
Prepared by : Prof. K S Rao
Capabilities and Limitations of
Threshold Logic
Threshold gate: Comparing the conventional gates,
• More powerful than conventional gates because it can realize
a larger class of functions
• Any conventional gate can be realized with a threshold gate
• Thus, threshold gates are functionally complete

Example: NAND implementation


x1
-1
-11_ y
2
-1
x2

Every switching function can be implemented using threshold elements only

5
Prepared by : Prof. K S Rao
Capabilities and Limitations of
Threshold Logic

OR Gate AND Gate

NOR Gate NOT Gate


Realization of XOR Gate using single
Realization of Basic Gates Threshold function is not possible.
6
Prepared by : Prof. K S Rao
Is Every Switching Function Realizable
by One Threshold Element?
Answer: No
Example: Let f(x1,x2,x3,x4) = x1x2 + x3x4
• Output value must be 1:
for x1x2x3’x4’, (min-term 12),
and x1’x2’x3x4 (min-term 3)

• Output value must be 0:


for x1’x2x3’x4 (max-term5), x1x2’x3x4’ (max-term 10)
• Since the requirements in the inequalities are conflicting, no threshold value
can satisfy them. Thus, every switching function is not realizable by a single
threshold element Prepared by : Prof. K S Rao
Basic Problem of Threshold Logic

Given a switching function f(x1,x2, …,xn): Determine whether it is realizable by a


single threshold element, and if it is, find appropriate weights and threshold
• Such a function is called a Threshold function
Straightforward approach: Solve a set of 2n linear, simultaneous inequalities
Example: Let f(x1,x2,x3) = ∑ (0,1,3)
Combination 0: T must be negative
Combinations 2, 4: w2, w1 must be negative
Combinations 3, 5: w2 must be greater than w1; Combination 1: w3 is greater than
or equal to T; Thus, w3 T > w2 > w1; w1 = -2, w2 = -1, w3 = 1, T = -1/2


8
Prepared by : Prof. K S Rao
x
Elementary Properties

Weight-threshold vector: V = {w1,w2, …,wn;T}


Let f (x1,x2, …,xn) be realized by V1 = {w1,w2, …,wj, …,wn; T}.
If xj is complemented, it can be realized by V2 = {w1,w2, …,-wj,
…,wn; T-wj} with inputs x1,x2, …,xj’, …,xn
From V1:

When V2 replaces V1 and xj’ replaces xj: where g is realized by V2


g and f are identical: since the equations reduce to each other
for both xj = 0 and xj = 1 by a value wj.

9
Prepared by : Prof. K S Rao
Important Conclusions

If a function is realizable using a single threshold element,


then by an appropriate choice of complemented and
uncomplemented input variables: a realization with any
sign distribution is possible.

Corollary: If a function is realizable by a single threshold


element, then it is realizable by an element with only
positive weights.

10
Prepared by : Prof. K S Rao
x
Important Property

If f(x1,x2, …,xn) is realizable by a single threshold element with


V1 = {w1,w2, …,wn; T}, then its complement is realizable by a single
threshold element with V2 = {-w1,-w2, …,-wn; -T}
From V1: Multiplying both sides by -1:

Thus, f’ is realizable by V2

11
Prepared by : Prof. K S Rao
Synthesis of Threshold Networks

Unate functions: Function f(x1,x2, …,xn) is positive (negative) in


variable xi if there exists a disjunctive or conjunctive expression for
the function in which xi only appears in uncomplemented
(complemented) form
If f is either positive or negative in xj: It is said to be unate in xi
Example: f = x1x2’ + x2x3’ is positive in x1 and negative in x3, but not
unate in x2
If f(x1,x2, …,xn) is unate in each of its variables: then it is called unate
Example: f = x1’x2 + x1x2x3’ is unate since it can be simplified to x1’x2 +
x2x3’
Example: f = x1x2’ + x1’x2 is not unate in either variable
12
Prepared by : Prof. K S Rao
X
Unate Functions

If f(x1,x2, …,xn) is positive in xi: then it can be expressed as

and vice versa


If f(x1,x2, …,xn) is negative in xi: then it can be expressed as

and vice versa

13
Prepared by : Prof. K S Rao
Geometric Representation
A single variable function can be represented by a Straight line.
A two variable function can be represented by a plane.
A three variable function can be represented by a cube.
A four variable function can be represented by a cube inside other cube.
The requirement in all the above representations is - any two side by side
vertices should differ by one bit change only.
If we mark the true vertices and the false vertices on the Geometric
representation, and if all true vertices can be separated from the false
vertices by a line on a plane or by a plane in a cube, then that function is
known as linearly separable and it can be implemented by a Threshold
function.

Prepared by : Prof. K S Rao


Geometric Representation
Two variable functions (a plane):
10 10 10
11 11 11

00 01 00 01 00 01
Not Linearly
OR Gate AND Gate XOR Gate .
Separable15
Linearly separable and implementable.
Three variable functions (a cube):

Four variable
function (a
cube in another
cube)

15
Prepared by : Prof. K S Rao
Geometric Representation
n-cube: contains 2n vertices, each of which represents an
assignment of values to n variables and thus corresponds to a
minterm
• a line is drawn between every pair of vertices which differ
in just one variable
• a plan is identified between four vertices which differ in
two variables.
Vertices for which the
function is 1 (0) called: true
(false) vertices
Example: Three-cube representation
If
forthis
f =cube
x’y’ +isxz
separatable by a hyper
plane, such that all the true vertices
fall one side of this cut plane and all
false vertices are on other side of this
cut plane, then that function is
16
realizable with Threshold gates. Prepared by : Prof. K S Rao
x
Partial Ordering
Partial-ordering relation between vertices of the n-cube:
(a1,a2, …,an)  (b1,b2, …,bn)
if and only if for all i, ai  bi
• Partially ordered set of vertices: a lattice
• (0,0, …,0): least vertex
• (1,1, …,1): greatest vertex
• Some pair of variables incomparable: e.g., (0,0, …,0,1) and (1,0, …,0,0)

Without loss of generality: concentrate on positive unate functions


Example: relabel x1’x2x3’ + x2x3’x4 as x1x2x3 + x2x3x4
• By reconverting the latter: possible to determine the original function

17
Prepared by : Prof. K S Rao
Unate Function Theorem
Theorem 1: f(x1,x2, …,xn) is unate if and only if it is not a tautology and the above
partial ordering exists, such that for every pair of vertices, (a1,a2, …,an) and
(b1,b2, …,bn), if (a1,a2, …,an) is a true vertex and
(b1,b2, …,bn) (a1,a2, …,an), then (b1,b2, …,bn) is also a true vertex of f

Minimal true vertex: A true vertex Si is said to be minimal if no other true
vertex Sj < Si

Maximal false vertex: A false vertex Si is said to be maximal if no other


false vertex Sj > Si

Example: For x1x2 + x3x4


• Minimal true vertices: S1 = (1,1,0,0), S2 = (0,0,1,1)
• Thus, every vertex greater than S1 or S2 must be a true vertex: e.g., (1,1,1,0),
(0,1,1,1)
– These vertices correspond to x1x2x3 and x2x3x4, which are covered by f

18
Prepared by : Prof. K S Rao
Linear Separability
For an n-cube representation for threshold functions:
linear equation given by (w1x1 + w2x2 + … + wnxn = T)
corresponds to an (n - 1)-dimensional hyperplane that cuts through
the n-cube
• Since f = 0 when w1x1 + w2x2 + … + wnxn < T,
and f = 1 when w1x1 + w2x2 + … + wnxn > T
the hyperplane separates the true vertices from the false ones
Such a function is called a linearly separable function
• Thus, every threshold function is linearly separable, and vice
versa

19
Prepared by : Prof. K S Rao
Linear Separability

linearly separable in two dimensions

not linearly separable.


Prepared by : Prof. K S Rao
Theorems

Theorem 2: Every threshold function is unate.


But every Unate function is not Threshold function.
Theorem 3: Given an expression for a unate switching
function, f(x1,x2, …,xn), replace xj by xk’, resulting in f(x1,x2,
…,xn). If g is not a threshold function, then neither is f

Example: Let f = x1x2 + x3x4


• To determine if f is a threshold function: replace x2 by
x3’
• This results in g = x1x3’ + x3x4
• Since g is not unate in x3, it is not a threshold function
• Hence, neither is f

Prepared by : Prof. K S Rao


21
Identification and Realization of
Threshold Functions
Procedure:
1. Test the given function f for unateness.
2. If it is unate, convert it into another function g that is
positive in all its variables.
3. Find all minimal true and maximal false vertices of g
4. Derive and solve a system of pq inequalities, corresponding
to the p minimal true and q maximal false vertices
- For minimal true vertex A = {a1,a2, …,an}
- and maximal false vertex B = {b1,b2, …,bn},
Write w1a1 + w2a2 + … + wnan > w1b1 + w2b2 + … + wnbn

22
Prepared by : Prof. K S Rao
Identification Example

Example 1: Given f = x1x2x3’x4 + x2x3’x4’


1. Reduce to f = x1x2x3’ + x2x3’x4’, which is unate
2. g = x1x2x3 + x2x3x4 (positively unate)
3. Minimal true vertices: (1,1,1,0), (0,1,1,1);
Maximal false vertices: (1,1,0,1), (1,0,1,1), (0,1,1,0)
4. p = 2 and q = 3 yields 6 inequalities:

5. Necessary constraints that must be satisfied: V = {1,2,2,1; 9/2} for g


=> V = {1,2,-2,-1; 3/2} for f
23
Prepared by : Prof. K S Rao
Synthesis of Threshold Functions
X1
Threshold gate for X
g function: 2 1
2
g = x1x2x3 + x2x3x4 T=9/2 g
2
x1 1
x3
x2
1
x4 g function
2
T=3/2 f
-2
-1 Threshold gate for f function:
x3 f = x1x2x3’+ x2x3’x4’
Negate the weights of X3 and X4
x4 f function and modify T value by reducing
these weights.T = 9/2 – 2 – 1=3/2
Prepared by : Prof. K S Rao
General Synthesis Procedure

Procedure:
1. Start with a multi-output algebraically-factored switching
network G
2. Process each primary output of G
• If the node represents a binate function, split into
multiple nodes and process recursively
• If the node is unate and is also a threshold function,
save it in the threshold network and process its input
nodes recursively
• Else, split the unate node into two or more nodes
that are threshold functions
3. Terminate procedure when all the nodes in G are
25
mapped to threshold nodes Prepared by : Prof. K S Rao
Synthesis of Threshold Functions

Ex 2: Generate Threshold logic for f = Σ (0,1,3,4,5,6,7,12,13)


x1x2
x1x2
00 01 11 10 00 01 11 10
X3x4
8 X3x4
1 0 1 4 1 12
0
00 00 0 0 0 4 1 12 8
9
01 1 1 1 5 1 13
01 1
15 11
0 1 0 5 1 13 9
11 1 3 1 7 11 1 1
0 3 1 7 15 11
10 2
1 6
14 10 10
0 2 1 6 1 14 1 10

f = x1’x3’ + x2x3’ + x1’x4 + x1’x2


It is an Unate function.
Converting it into positive Threshold function,
g= x1x3 + x2x3 + x1x4 + x1x2
Minimum True Vertices are : (0,1,1,0), (1,0,1,0), (1,0,0,1), 1,1,0,0)
Maximum False Vertices are : (0,0,1,1), (0,1,0,1), (1,0,0,0)

Prepared by : Prof. K S Rao


Synthesis of Threshold Functions

1  W2 + W3 W3 + W4 5
2  W1 + W3 T W2 + W4 6
3  W1 + W4 W1 7
4  W1 + W2
All weights are +ve. Let W4 = 1,
1 & 5  W2 > W4
W2 = W3 = 2, W1 = 3
1 & 6  W3 > W4
T = Average of [Minimum value of left of the
2 & 5  W1 > W4
above 1, 2, 3 & 4 + Maximum value of the
2 & 6  W1 > W2 x1
right of 5, 6 & 7]. i.e.
2 & 7  W3 > 0 x2 g
T = [4 + 3]/2 = 7/2. 3
3 & 5  W1 > W3
2
3 & 6  W1 > W2 T=7/2
3 & 7  W4 > 0 2
4 & 7  W2 > 0 1
x3

x4
Prepared by : Prof. K S Rao
Synthesis of Threshold Functions
Threshold gate for
f function: x1
f = x1’x3’ + x2x3’ + x1’x4 + x1’x2

i.e. X1 and x3 weights are x2


to be negated and T value is to be -3
reduced by this negated 2
value. T = 5/2 – 3 - 2 = -5/2 T=-5/2
f

-2
1
x3

x4 f function

Prepared by : Prof. K S Rao


Synthesis of Threshold Functions

Ex 3: Determine whether the function


f = ∑(2,3,6,7,10,12,14,15) is Threshold or not? Get the Threshold logic
realization.
Map for f (consisting of g and h)
x1x2
00 01 11 10 x1x2 Map for g
00 01 11 10
X3x4
8
0 4 1 12 X3x4
8
00 5 9
0 4 12
1 13 00
01 1
5
13
9
1 1 1 11 01
11 3 7 15
11
11 1 3 1 7 1 15
10 1 2 1 6 1 14 1 10
10 1 2 1 6 14 10
Map for gΦ g
x1x2 g = x1’x3 + x2x3x4
h gΦ = x1x3 + x2x3x4
00 01 11 10
X3x4
0 0 0 4 0 8
Minimum True vertices are (0,1,1,1)
0
and (1,0,1,0)
00 12

01 0 1 0 5 0 9
11
0 13
Maximum False vertices are
0 1 1 1 11
10
3 7 15
(0,0,1,1),(0,1,1,0) and (1,1,0,1)
0 2 0 6 1 14 1 10 Prepared by : Prof. K S Rao
Synthesis of Threshold Functions

Weights for gØ W3 + W4 5
1  W2 + W3 + W4 T W2 + W3 6
2  W1 + W3 W1 + W2 + W4  7
Let W2 = W4 = 1, W1 = 2, W3 = 3
T = Average of [Minimum value of left of
the above 1, & 2 + Maximum value of the
1 & 7  W3 > W1 right of 5, 6 & 7]. i.e.
1 & 6  W4 > 0 T = [5 + 4]/2 = 9/2. x
1 & 5  W2 > 0
x 1
2 & 5  W1 > W4 2 gØ
2 1
2 & 6  W3 > W2 T=9/2
2 & 7  W3 > W2+W4 3
x 1
Threshold gate for
gØ function: 3
x gØ function
gΦ = x1x3 + x2x3x4 4
Prepared by : Prof. K S Rao
Synthesis of Threshold Functions
x1
Threshold gate for
g function:
x2
g = x1’x3 + x2x3x4
-2
1
T=5/2
g

3
1
x3

x4 g function

Prepared by : Prof. K S Rao


Synthesis of Threshold Functions

Map for h: h = x1x2x4’ + x1x2x3 + x1x2x4’ - It is unate function.


hØ = x1x2x4 + x1x2x3 + x1x3x4 - Positive threshold function.
Map for h : Map for hØ:
x1x2 00 01 11 10 x1x2
00 01 11 10

X3x4
8 X3x4
0 4 1 12 0 0 0 4 0 12 0 8
00 5 9 00
1 13
01 01 0 1 0 5 1 13 0 9
1 11
11 3 7 15
11 0 3 0 7 1 15 1 11
10 2 6 1 14 1 10 10 0 2 0 6 1 14 0 10

Minimum True Vertices are : (1,0,1,1), (1,1,1,0) and (1,1,0,1)


Maximum False Vertices are : (1,0,0,1), (1,0,1,0), (0,1,1,1) and (1,1,0,0)

Prepared by : Prof. K S Rao


Synthesis of Threshold Functions
For hø function where hØ = x1x2x4 + x1x2x3 + x1x3x4 :
1  W1 + W3 + W4 W1 + W4 4
2  W1 + W2 + W3 T W1 + W3 5
3  W1 + W2 +W4 W2 +W3+ W4  6
W1 + W2 7
1 & 4  W3 > 0
1 & 5  W4 > 0 Let W2 = W3 = W4 = 1, W1 = 2
1 & 6  W1 > W2 T = Average of [Minimum value of left of
2 & 4  W2 + W3 > W4 the above 1, & 2 + Maximum value of
2 & 5  W1 > W4 the right of 5, 6 & 7]. i.e.
2 & 7  W3 > 0 T = [4 + 3]/2 = 7/2.
3 & 4  W2 > 0
3 & 5  W2 + W4 > W3 For h function where
3 & 6  W1 > W3 h = x1x2x4’ + x1x2x3 + x1x3x4’ :
3 & 7  W4 > 0
W2 = W3 = 1, W1 = 2; W4 = -1 and
T = 7/2 -1 = 5/2
Prepared by : Prof. K S Rao
Synthesis of Threshold Functions
Two level threshold function realization:
x1 x1

x2 x2
-2 2
1 1
T=5/2 T=5/2 f function
3
1
3
-1
1
x3
x3
h function
x4 g function x4

Prepared by : Prof. K S Rao


Map-based Synthesis of Two-level
Threshold Networks
Decomposition of non-threshold functions: into two or more factors
that are threshold functions
Admissible pattern: a pattern of 1 cells that can be realized by a
single threshold element
 An admissible pattern may be in any position on the map
 An admissible pattern for functions of three variables is also an
admissible pattern for functions of four or more variables
 Since the complement of a threshold function is also a threshold
function, patterns of 0 cells are also admissible
 Select a minimal number of admissible patterns such that each 1
cell is covered by at least one admissible pattern
1 1 1 1 1

1 1 1 1 1 1 1 1

1 1 1
Prepared by : Prof. K S Rao
Synthesis of Multi-level
Majority/Minority Networks
Realizable pattern: pattern of 1 cells realizable by a majority gate
• For three-input positive functions: 10 realizable patterns
• Removing the restriction that function be positive: 38 realizable
patterns
x1x2 x1x2 x1x2
x3 00 01 11 10 x3 00 01 11 10 x3 00 01 11 10

0 1 1 0 1 1 0

1 1 1 1 1 1 1 1 1 1 1

x1 = M(x1, 1, 0) = M(x1, 0, 1) x2 = M(1, x2, 0) = M(0, x2,1) x3 = M(1, 0, x3) = M(0, 1, x3)

x1x2 x1x2 x1x2


x3 00 01 11 10 x3 00 01 11 10 x3 00 01 11 10

0 1 1 0 1 1 1 0 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1

x2 + x3 = M(1, x2, x3) x1 + x2 = M(x1, x2, 1) x1 + x3 = M(x1, 1, x3)

x1x2 x1x2
x3 00 01 11 10 x3 00 01 11 10

0 1 0

1 1 1 1 1

x1x2= M(x1, x2, 0) x1x3= M(x1, 0, x3)

x1x2 x1x2
x3 00 01 11 10 x3 00 01 11 10

0 0 1

1 1 1 1 1 1 1 36
x2x3= M(0, x2, x3) Prepared by : Prof. K S Rao
x1x2 + x1x3 +x2x3 = M(x1, x2, x3)
Another Synthesis Example
Example: For f(x1,x2,x3,x4) = (3,5,7,10,12,14,15),
find a minimal
x1 x2
x3 x4
threshold-logic realization x1
x3
00 01 11 10 x4
00 1 x1
x2
x4
01 1 x2
x3 f
x4
11 1 1 1
x1
x2
x4
10 1 1
x1
x3
x4
(a) Map showing a minimal set of prime (b) AND-OR realization of f
implicants which cover f.

x1 x2
x3 x4 00 01 11 10

00 1 x1 x1

x2 x2
01 1 -1 2
1 g 1
1 1 1
2 32 2 f
1 2 1 2
11 1 1 1 x3 2 -1
x3

1 1 x4 x4
10
(d) A threshold-logic realization of f

(c) Map showing the admissible pattern


realized by each threshold element. Prepared by : Prof. K S Rao
x
Synthesis Example
Example: Consider f = x1’x2’x3’ + x1’x2x3 + x1x2x3’ + x1x2’x3
• Naïve approach: decompose network into two-input AND and OR gates and
replace each such gate by a reduced majority gate
• However, if we make full use of the three inputs of a majority gate: only four
gates necessary
• Minority network: can be obtained from a majority network using De Morgan’s
theorem

x1
x2 x1 f1
x2 M x1 f1
x3
x3 x2 m
x1 x3
x2 x1 f2
x3 x2 M M f x1 f2
x1 x3 x2 m m f
f
x2 x3
x1 f3
x3 x2 x1
M f3
x1 x3 x2 m
x2 x3
x3
(b) (c)
(a)

38
Prepared by : Prof. K S Rao
x
General Synthesis Procedure
Procedure:
1. Start with a multi-output algebraically-factored switching network G
2. Decompose G into a network in which nodes have at most three inputs
• If the node represents a majority function, move on to the next node
• If a common literal exists in all the product terms of the node
function, factor it out and perform AND/OR mapping on it
• If a common literal does not exist, check to see if the node can be
implemented with fewer than four AND/OR nodes
• Else, map the node onto at most four majority gates using a
Karnaugh-map based procedure
Example: Consider f = x1x2’+ x2’x3
• With AND/OR mapping, three majority gates are
needed:
– f1 = x1x2’, f2 = x2’x3, f = f1 + f2
• However, since literal x2’ can be factored out: f = f1x2’
where f1 = x1+x3
– This requires only two majority gates 39
Prepared by : Prof. K S Rao
x
K-map based Procedure

Given the map of a node function n with at most three


0
inputs: 1
1. Find a realizable pattern f1
2. Find a second realizable pattern f2 based on f1 and n
3. Find the third realizable pattern f3 based on f1, f2 and n
– Realizable patterns chosen such that n = M(f1,f2,f3) = f1f2+f2f3+f1f3
4. f1 may contain makeup minterms that are not minterms of n
– A minterm (maxterm) of n must also be a minterm (maxterm) of
at least two of the three functions, f1, f2 and f3
– Enforce rule by defining two sets:  0and  1
» For finding f2: if a minterm (maxterm) of n is not a minterm
(maxterm) of f1, add it to (  1 )
» For finding f3: if a minterm (maxterm) of n is not a minterm
(maxterm) of both f1 and f2: add it to (  0)
5. On failure to find f3, backtrack to find new f2
40
Prepared by : Prof. K S Rao
x
Synthesis Example
Example: Consider f = x1’x2’x3’ + x1’x2x3 + x1x2x3’ + x1x2’x3
x1x2
Step 1: find f1
x1x2 Compute1
x1x2
x3 00 01 11 10 x3 00 01 11 10 00 01 11 10
x3
0 1 1 0 1 1 1 0

1 1 1 1 1 1 1

n = x1x2 x3 + x1 x2x3 + x1 x2x3 + x1 x2x3 f1 = x1 x2+ x2x3 + x1x3= M(x1, x2, x3)
(a) (b) (c)
x1 f1
x2 M
Compute 0 x1x2 Step 2: find f2 Update 1 x3
x1x2 x1x2
00 01 11 10 x3 00 01 11 10 00 01 11 10 x1
x3 x3 f2
x2 M M f
0 0 0 1 0 1
x3

1 1 1 1 1 x1 f3
1 1
x2 M
f2 = x1x2+ x2 x3+ x1x3 = M(x1, x2, x3) x3
(d) (e) (f)

x1x2 Update 0 x1x2 Step 3: find f3


00 01 11 10 x3 00 01 11 10
x3
0 0 0 1 1 1

1 0 1 1

f3 = x1x2 + x2 x3+ x1x3 = M(x1, x2, x3)


(g) (h)
41
Prepared by : Prof. K S Rao
Threshold Logic

Prepared by : Prof. K S Rao

También podría gustarte