Docsity

Boolean Logic Synthesis: From RTL to Logic Gates using Prime Implicants and Unate Covering, Study notes of Design and Analysis of Algorithms

Toggle sidebar
bg1
Module-III
Lecture-I, II and III
Two level Boolean Logic Synthesis
1 Introduction
In the last two modules, we discussed that in case of digital VLSI design we start with
high-level system specifications, which are transformed into optimal Register
Transfer Level (RTL) circuits using High Level Synthesis (HLS) algorithms. The
optimizations can be in terms of area, speed, power, testability etc., although we have
discussed only about area and speed. Once the RTL circuit is available, we need to
transform it to gate level design, which can then be processed by backend algorithm;
this process is called Logic Synthesis. Formally speaking, Boolean logic synthesis is
a process by which an abstract form of desired circuit behavior, typically RTL, is
transformed into a design implementation in terms of logic gates and flip-flops [1].
This module is dedicated to logic synthesis of combinational and sequential circuits.
It may be noted that two levels of logic are minimum required to implement an
arbitrary Boolean function. Generally, we assume that the primitives are AND and
OR gates and Inverters. AND gates are used at the first level and OR gates are used in
the second level. Inverters may be present at some inputs of the gates of the first
level, but it is not considered as an additional level. Many other choices are also
possible namely, using OR gates at first level and AND gates in the second, using
NOR and NAND gates etc. It is also possible to implement a circuit in more than two
levels, however, it is more complex procedure. In this triple lecture, we will first
discuss two level logic synthesis procedures. Latter in this module, we will discuss
multilevel synthesis.
There are two main reasons why we may want to implement a circuit in two levels,
rather than multiple levels namely, speed of operation and simplicity of the
algorithms. However, in practical cases two level implementation may not be
possible. Reducing the number of levels increase the fanin and fanout counts of gates.
Gates having high fanins and fanouts are slow. Therefore, design libraries do not
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53

Partial preview of the text

Download Boolean Logic Synthesis: From RTL to Logic Gates using Prime Implicants and Unate Covering and more Study notes Design and Analysis of Algorithms in PDF only on Docsity!

Module-III

Lecture-I, II and III

Two level Boolean Logic Synthesis

1 Introduction

In the last two modules, we discussed that in case of digital VLSI design we start with high-level system specifications, which are transformed into optimal Register Transfer Level (RTL) circuits using High Level Synthesis (HLS) algorithms. The optimizations can be in terms of area, speed, power, testability etc., although we have discussed only about area and speed. Once the RTL circuit is available, we need to transform it to gate level design, which can then be processed by backend algorithm; this process is called Logic Synthesis. Formally speaking, Boolean logic synthesis is a process by which an abstract form of desired circuit behavior, typically RTL, is transformed into a design implementation in terms of logic gates and flip-flops [1]. This module is dedicated to logic synthesis of combinational and sequential circuits.

It may be noted that two levels of logic are minimum required to implement an arbitrary Boolean function. Generally, we assume that the primitives are AND and OR gates and Inverters. AND gates are used at the first level and OR gates are used in the second level. Inverters may be present at some inputs of the gates of the first level, but it is not considered as an additional level. Many other choices are also possible namely, using OR gates at first level and AND gates in the second, using NOR and NAND gates etc. It is also possible to implement a circuit in more than two levels, however, it is more complex procedure. In this triple lecture, we will first discuss two level logic synthesis procedures. Latter in this module, we will discuss multilevel synthesis. There are two main reasons why we may want to implement a circuit in two levels, rather than multiple levels namely, speed of operation and simplicity of the algorithms. However, in practical cases two level implementation may not be possible. Reducing the number of levels increase the fanin and fanout counts of gates. Gates having high fanins and fanouts are slow. Therefore, design libraries do not

generally have gates with more than four fanins; this requires multiple level synthesis. Figure 1 illustrates this fact. Say we have a Boolean function as fx 1. 2. 3. 4. 5. 6 x x x x xx 7. 8. 9. 10. 11. 12 x x x x x. If we want to have two level implementation, then as shown in Figure 1(a) then we need an AND gate having 6 fanins. If we have gates with 3 maximum fanins, a multilevel implementation is shown in Figure 1 (b). x2^ x x x x x

(a) Two level Implementation

x8x x x x x

x x

x x

x

x

x x x x x

x (a) Multi-level Implementation Figure 1. Two level and multi-level implementation of a Boolean function

However, two-level implementation is important to be studied. Two-level implementations are easier to design and analyze because the solution space is greatly restricted. Further, before the development of CMOS logic gates, Boolean functions were realized using Programmable Logic Array (PLAs) and Programmable Array Logic (PALs) [2]. These programmable arrays can implement any combinational logic circuit. Broadly speaking, they have a set of programmable AND planes, which connect to a set of programmable OR planes; this arrangement is two level AND-OR realization that can implement functions in terms of sum of products. In addition, the

2 Representation: Sums of Products and Products of Sums

We know that input/output of an RTL circuit can be represented by a Boolean function. In logic synthesis, we need to design a circuit to implement the Boolean function. It may be noted that more the number of terms (will be defined precisely latter) in the function, more the number of gates in the circuit. Therefore, the primary objective of logic synthesis is to determine a minimal gate representation of the function; this is called “minimizing Boolean functions”. From the context of two level implementation, our objective is to find the simplest two-level formula that represents a given function. Simplicity is measured, in terms of the number of gates and gate inputs of the circuit. Now we formally define a two-level formulae. Formula consists of constants, variables, parentheses and operators. A letter is a constant or a variable. A literal is a letter or its complement. For example, for 0,1,x,y are letters and 0,1, x , x ', y 'are literals; 0,1 are constant literals and x ', y ' variable literals. The following definitions are introduced.

Definition 1: A product term is a formula of one of the following forms:  1  a variable literal  a conjunction of variable literals where no letter appears more than once.

Definition 2: A sum term is a formula of one of the following forms:  0;  a variable literal  a disjunction of variable literals where no letter appears more than once. For example, x. y 'is a product term, xy 'is a sum term and x 'is both. On the other hand, x. '^ x^ is neither product terms nor sum term, because the letter x appears twice and the term reduces to 0.

Definition 3: A Sum of Products (SOP) formula is one of the following:  0;  a product term;  a disjunction of product terms. Example, fx y. ' yz

The cost of a SOP formula is determined by the number of product terms and the number of literals. Broadly, speaking, number of product terms determine the number of AND gates and number of literals determine the number of inputs of a gate. fx y. ' yz has two product terms and four literals.

Definition 4: A Product of Sums (POS) formula is one of the following:  1;  a sum term;  a conjunction of sum terms. Example, f  ( xy ').( yz )

The cost of a POS formula is determined by the number of sum terms and the number of literals. Broadly, speaking, number of sum terms determine the number of OR gates and number of literals determine the number of inputs of a gate. f  ( xy ').( yz )has two sum terms and four literals.

A two-level formula is either a SOP or a POS. The two forms are, one is the dual of the other [1], which can be shown by De-Morgan’s theorem. In this module, we will restrict all our discussions on SOP based representation of a Boolean formula.

3.1 Determining Prime Implicants The key result for the minimization of two-level Boolean formula is due to Quine [3,4], as given in Theorem 1.

Theorem 1: If cost of a Boolean function depends on literals then a minimal SOP must always consist of a sum of prime implicants.

Proof : Let us assume that f is an SOP which is minimal and one (product) term is non-prime. Another SOP formula f 1  f exists, that can be obtained by replacing the non-prime implicant by a prime implicant that contains it. The cost does not increase and the formula is equivalent to the original one. So, we reach a contradiction i.e., f is an SOP which is minimal and all terms are prime implicants. For example, let SOP representation of f ( , x y ) be xx y '. A prime implicant of f is y. The SOP representation can be changed as xy , where we have replaced x ' y with y ; y includes x ' y. So the new SOP is rewritten by saving one literal.

Therefore, we may state from the Prime Implicant Theorem that minimal Boolean SOP representation always contains prime implicants only. Therefore, as the next step we discuss how to derive all the prime implicants of a given function. Later, we shall see how to select a subset of minimum cost from all the prime implicants. Now we will study the tabular scheme to determine prime implicants.

3.1.1 Determining Prime Implicants by Tabular Method Before discussing the tabular method, we introduce the concept of consensus between two terms.

Definition 8: Given a Boolean function in SOP form XyXy ', where X is a product term not having variable y , then consensus can be applied on the two terms Xy Xy , 'to generate X (  XyXy '); X is the consensus term containing both Xy Xy , '. This is also called distance-1 merging. In other words, pairs of terms that differ in exactly one letter, which must appear complemented in one term and un-complemented in the other, are used for consensus.

Given a Boolean formula in SOP form we need to determine the prime implicants. The steps of tabular method are given below.

  1. Express the function in minterm canonical form
  2. Consider all pairs of adjacent terms, i.e., the pairs of terms to which consensus can be applied. The consensus terms are implicants of the function though not necessarily prime. All terms that form these new consensus terms are included in the new terms, and hence they are not prime. We mark the old terms as non-prime and are not used for further consensus.
  3. The new terms are added to the SOP and steps 1,2 are repeated till no more consensus terms can be found
  4. All terms that are absorbed (or contained) by the new terms are marked as non-primes. Finally, the terms that are not marked constitute all the prime implicants of the function.

Now we illustrate the scheme using an example. Consider the SOP: f ( w x y z , , , )  x y ' '  wxyx yz ' '. The function in minterm canonical form is as follows:

w x y z ' ' ' '(not prime) w x y '^ '^ ' w x y z ' ' ' (not prime) ' ' ' ' ' '

wx y z w x yz ' ' ' '

wx y z wx yz wxyz ' wxyz Table 2. Entry after consensus of w x y z ' ' ' 'and w x y z ' ' '

The same process is repeated for all terms (immediately successive group) of Table 1. Table 3 illustrates the situation after consensus is performed on all terms of Table 1. w x y z ' ' ' '(not prime) ' ' ' ' ' ' ' ' '

w x y x y z w x z w x y z ' ' ' (not prime) ' ' '(not prime) ' ' '(not prime)

wx y z w x yz

x ' y z ' ' ' ' '

wx y wx z x ' yz ' ' ' (not prime) ' '(not prime)

wx y z wx yz

wyz '

wxyz '(not prime) wxy wxyz (not prime) Table 3. Entry after consensus of all terms of Table 1.

It may be noted that the second column is also divided based on the number of complemented alphabets in the terms. As in the case of column 1 of Table 1, the same procedure is repeated for elements of column 2 of Table 3; this generates column 3 as shown in Table 4.

It may be noted that fourth column cannot be created as no terms of column 3 (Table 4) has consensus. So here, we have four prime implicants as wyz ', wxy x y , ' ', x z ' '.

w x y z ' ' ' '(not prime) ' ' ' (notprime) ' ' ' (notprime) ' ' ' (notprime)

w x y x y z w x z

x y x z

w x y z ' ' ' (not prime) ' ' '(not prime) ' ' '(not prime)

wx y z w x yz

x ' y z ' (not prime) ' ' (not prime) ' ' (not prime)

wx y wx z x ' yz '(not prime) ' ' (not prime) ' '(not prime)

wx y z wx yz

wyz '

wxyz '(not prime) wxy wxyz (not prime) Table 4. Entry after consensus of all terms of column 2 of Table 3.

It my be noted that the function considered in the example was completely specified, i.e., there was no don’t care terms. If the function is incompletely specified then we follow the same procedure discussed above (for completely specified functions), however, we drop the mean terms that contain only don’t care minterms. Specifically, a product term is a prime implicant of an incompletely specified function if it is a prime implicant of the function and contains at least one minterm which is not don’t care. Now we will consider the following example, which illustrates tabular method for incompletely specified functions.

Consider the function written in SOP form f ( , x y z , )  x z ' '  xyz '  d xy z ( ' '  xy z ' ).

3.1.2 Determining Prime Implicants by Iterated Consensus The tabular method discussed above is based on the application of the Quine’s theorem. The tabular method is simple, however, it requires the minterm canonical form to start with, which is exponential in number of input variables (alphabets). To cater to this issue, iterated consensus method does not expand the product terms (of SOP) to minterms. Instead, consensus is made between all pairs of product terms. The consensus terms of all pairs of terms that are not contained in some other term are added to the equation. The new terms are compared to the existing terms and among themselves to see if more new consensus terms can be generated. All terms that are contained in some other term are removed. Once no more new terms can be generated, the SOP comprises of only prime implicants. Generation of prime implicants by iterated consensus follows from the following theorem (Theorem 2).

Definition 9: An SOP formula is complete sum if it comprises all the prime implicants of the function it represents.

Theorem 2 : A SOP formula is a complete sum if and only if:

  1. No term includes any other term.
  2. The consensus of any two terms of the formula either does not exist or is contained in some term of the formula. We will not prove the theorem formally; for a formal proof, the reader is referred to [6]. We only highlight the basic philosophy behind the proof. Suppose a SOP representing a function is not a complete sum, because there is one prime implicant of the function that does not appear in the SOP (and all other terms are prime implicants). Therefore, the remaining prime implicant must be covered by two or more of the prime implicants in the SOP. Suppose for simplicity let us assume that there are two such prime implicants p 1 (^) and p 2. If we add the consensus term of p 1 (^) and p 2 , we get another term that covers the missing prime implicant.

The theorem suggests a simple procedure (steps given below) to generate all the primes of a function, called iterated consensus.

  1. Start from an arbitrary SOP formula and add the consensus terms of all pairs of terms that are not contained in some other term.
  2. The new terms are compared to the existing terms and among themselves to see if new consensus terms can be generated (and added). All terms that are contained in some other term are removed.
  3. Repeat step 2 until no more new terms are created. The steps generate a complete sum (i.e., all prime implicants)

As an example, consider the SOP for the function f ( , x y z , )  x z ' '  xyz '  xy z ' '  xy z ' (it is the same function used in the last section, however, now the don’t care terms are made minterms). Steps of iterative consensus for the function are discussed below.

  1. Consensus of x ' z ' and xyz '(1st^ two terms) generates yz ', which contains

xyz '. By eliminating xyz ' and adding yz ', we have fx z ' '  xy z ' '  xy z '  yz '

  1. Consensus of x ' z 'and xy z ' 'will generate y ' z ', which contains xy z ' '. By

eliminating xy z ' 'and adding y ' z ', we have fx z ' '  xy z '  yz '  y z ' '.

  1. x ' z 'and xy z ' do not have consensus
  2. x ' z 'and yz 'do not have consensus; xy z ' and yz 'do not have consensus
  3. yz 'and y z ' 'generates z '. yz ', y z ' ' and x ' z ' are in z '. By eliminating

yz ', y z ' 'and x ' z 'and adding z ', we have fxy z '  z '.

  1. Consensus between xy z ' and z 'generates xy ', which contains xy z '.

Eliminating xy z ' and adding xy 'we get fxy '  z '. Now fxy '  z ' is the complete sum as no more new terms can be created. It may be noted that xy 'and z 'are the prime implicants; same

4 Selecting a Subset of Primes In the last section, we discussed techniques to generate prime implicants from a given SOP Boolean equation. Now, we need to select a subset of the prime implicants that cover all the minterms. The approach of minimizing a SOP formula based on computing all primes and then selecting some of them to form a cover is called Quine-McCluskey procedure. In this section, we will discuss Quine-McCluskey procedure and illustrate the same using examples. Let us consider the following SOP formula: f ( , x y z , )  yzx y '  y z ' '  xyzx z ' '  x y z ' ' '. The complete sum for the function (i.e., in terms of prime implicants) is f ( , x y z , )  x y '  x z ' '  y z ' ' yz. The condition that any subset of primes must satisfy the Boolean formula is that, each minterm (for which the function is 1) is to be included in at least one prime implicant, which is in the subset. A subset of (prime) implicants that satisfies this requirement is called a SOP cover of the function, or simply a cover. The concept of “cover” can be represented by a constraint matrix. Each column of the constraint matrix corresponds to a prime implicant and each row corresponds to a minterm. Let C be the constraint matrix and let cij be the element in row i and column j ; cij  1 (0), if the j -th prime covers (does not cover) the i -th minterm. In the example, let us represent the prime implicants as follows. ' ........PI ' '.......PI ' '.......PI ..........PI

x y x z y z yz Now the matrix C is as follows:

PI1 PI2 PI3 PI

x y z x yz x yz xyz xy z

Given the constraint matrix, we need to find a subset of columns of minimum cost that covers all the rows. In other words, for every row there must be at least one selected column with a 1 in that row. In the example, we note that, columns PI3 and PI4 must be part of every solution, because the last two rows are singletons. If a row is a singleton, there is only one column that may cover it and that column must be selected. It may also be noted that prime implicates corresponding to PI3 (and PI4) are essential because they comprise minterm xyz (and xy z ' ') which is not in amy

other prime implicant. When we select some columns, we simplify the constraint matrix accordingly, by eliminating the selected columns and the rows covered by them; if we select PI3 and PI4 then the resultant constraint matrix is as follows. PI1 PI xy z ' 1 1

From the resultant matrix, we can easily see that a complete solution may be obtained by adding either PI1 or PI2 to PI3 and PI4. In the first case we obtain f ( , x y z , )  x y '  y z ' ' yz in the second, we obtain f ( , x y z , )  x z ' '  y z ' ' yz. In

this case, both the solutions involve same number of literals. However, in a general case, we select the solution involving minimum literals. Let us consider an arbitrary constraint matrix as shown below. PI1 PI2 PI3 PI minterm1 1 1 0 0 minterm2 0 1 1 0 minterm3 0 0 1 1 minterm4 1 0 0 1

“rows covered” for which the matrix has cij  1. We can proceed similarly for the

other rows. The expressions thus obtained are switching functions that must all be 1 for a solution to be valid. Hence, their product must be 1. We can therefore write the following equation as an equivalent to the constraint matrix (PI2+PI3).(PI1+PI2).(PI1+PI4).PI3.PI

This equation is called the constraint equation of the covering problem (represented by the constrained matrix). The covering problem can be stated in this setting as the problem of finding an assignment of zeroes and ones to the variables that is a solution to the constraint equation and that is of minimum cost. Cost is predefined on the variables depending on the literals in the corresponding prime implicant.

We may note that all variables in the constraint equation are un-complemented. This is not a coincidence, but rather a direct consequence of the way the equation is built; we do not put the concept “not considering a column” in the equation. A formula where no letter appears with both phases is said unate. A non-unate formula is called binate. Because of the form of the constraint equation that we get, the covering problem we are dealing with is sometimes called unate covering. In the next sub- section we will discuss the unate covering problem.

4.1 Unate Covering Problem The Unate Covering Problem (UCP) can be defined in terms of both a constraint matrix and a constraint equation. As we will solve the UCP using constraint matrix, we will define the problem only in that from; for the constraint equation based formulation the reader is refereed to [7].

Definition 10: Let M be a matrix of m rows and n columns, for which M (^) ij is either 0 or 1. The unate covering problem involves finding a minimum cardinality column subset S , such that for all such that for all S '  (^) jS ' M (^) ij  1,   i {1, 2,... m } | S | | S ' |. In other words, the columns in the set S “cover” M in the sense, that every row of M contains a 1-entry in at least one of the columns of S , and there is no smaller set S 'which also covers M.

To solve the unate covering problem, the constraint matrix can be simplified by considering three factors namely,  Columns that have singleton rows are mandatory to be taken in the cover. All rows covered by such columns can be deleted and so do the columns. The unate covering can be then carried out in the reduced matrix. The procedure is called elimination of rows covered by “essential columns”. For example, in the matrix given below, PI4 is an essential column. PI1 PI2 PI3 PI minterm1 1 1 0 0 minterm2 0 1 1 0 minterm3 0 0 1 1 minterm4 0 0 0 1

PI4 also covers minterm3. The resultant simplified matrix (after elimination of rows covered by essential column PI4) is give below.