ECE 5745 Complex Digital ASIC Design Topic 12: Synthesis Algorithms Christopher Batten

School of Electrical and Engineering Cornell University

http://www.csl.cornell.edu/courses/ece5745 RTL to Logic Synthesis Technology-Independent Synthesis Technology-Dependent Synthesis Course Structure

Prereq Part 2 Computer Digital CMOS Architecture Circuits

PP Part 1 ASIC Design Overview MM

Part 3 CAD Algorithms

ECE 5745 T12: Synthesis Algorithms 2 / 43 • RTL to Logic Synthesis • Technology-Independent Synthesis Technology-Dependent Synthesis Part 3: CAD Algorithms

Topic 12 Topic 13 Synthesis Algorithms Physical Design Automation

Placement

RTL to Logic RTLSynthesis to Logic Synthesis Global x = a'bc + a'bc' Routing y = b'c' + ab' + ac Technology Independent Synthesis x = a'b y = b'c' + ac Technology Detailed Dependent Routing Synthesis

ECE 5745 T12: Synthesis Algorithms 3 / 43 • RTL to Logic Synthesis • Technology-Independent Synthesis Technology-Dependent Synthesis Step 1: Single Assignment Form

1 //1b inputs:y,z,a,q For each output, create exactly 2 //2b inputs:f one assignment that is a function 3 //3b inputs:g,c,b,e 4 only of the inputs 5 wire x = y && z; 6 1 wire x = y && z; 7 wire [2:0] b 2 8 = (a) ? {2'b0,x} : c; 3 wire [2:0] b 9 4 = (a) ? {2'b0,x} : c; 10 wire [2:0] d, h; 5 11 always @(*) begin 6 wire [2:0] d 12 7 = (q) ? 3'b101 13 d = b + e; 8 : ((a) ? {2'b0,x} : c) 14 if(q)d=3 'b101; 9 + e; 15 10 16 if(f) 11 wire [2:0] h 17 h = 3'b0; 12 = (f) ? 3'b0 : ( g << 1 ); 18 else 19 h = g << 1; 20 21 end ECE 5745 T12: Synthesis Algorithms 4 / 43 • RTL to Logic Synthesis • Technology-Independent Synthesis Technology-Dependent Synthesis Step 2: Bit Blast Outputs

1 //1b inputs:y,z,a,q Generate separate assignment for each 2 //2b inputs:f bit, removes arithmetic operators leaving 3 //3b inputs:g,c,b,e 4 only boolean operators (assume ternary 5 wire x = y && z; operator is short hand for equivalent 6 boolean operator) 7 wire [2:0] b 8 = (a) ? {2'b0,x} : c; 9 1 wire x = y && z; 10 wire [2:0] h 2 11 = (f) ? 3'b0 3 wire b[0] = (a) ? x : c[0]; 12 : ( g << 1 ); 4 wire b[1] = (a) ? 1'b0 : c[1]; 5 wire b[2] = (a) ? 1'b0 : c[2]; 6 7 wire h[0] = (f[0]|f[1]) ? 1'b0 : 1'b0; 8 wire h[1] = (f[0]|f[1]) ? 1'b0 : g[0]; 9 wire h[2] = (f[0]|f[1]) ? 1'b0 : g[1];

ECE 5745 T12: Synthesis Algorithms 5 / 43 • RTL to Logic Synthesis • Technology-Independent Synthesis Technology-Dependent Synthesis RTL Datapath Synthesis

wire [15:0] a= b + c;

Ripple-Carry

Carry Lookahead Parallel-Prefix Tree-Based Adapted from [Weste’11]

ECE 5745 T12: Synthesis Algorithms 6 / 43 • RTL to Logic Synthesis • Technology-Independent Synthesis Technology-Dependent Synthesis

DWBB Quick Reference <= + - * <= < > + >= - * < > >= Arith Example from DW01_add DesignWare Foundation Adder Building Blocks DW01_add Adder O Parameterized word length DesignWare O Carry-in and carry-out signals

A CI SUM RTL Datapath

B CO Synthesis directly Table 1-1 Pin Description transforms arithmetic Pin Name Width Direction Function A width bit(s) Input Input data operators into B width bit(s) Input Input data CI 1 bit Input Carry-in technology SUM width bit(s) Output Sum of (A + B + CI) CO 1 bit Output Carry-out independent Table 1-2 Parameter Description optimized gate-level Parameter Values Description width ≥1 Word length of A, B, and SUM netlists

Table 1-3 Synthesis Implementationsa

Implementation Function License Feature Required rpl Ripple-carry synthesis model none cla Carry-look-ahead synthesis model none pparch Delay-optimized flexible parallel-prefix DesignWare

a. During synthesis, Design Compiler will select the appropriate architecture for your constraints. However, you may force Design Compiler to use one of the architectures described in this table. For more details, please refer to the DesignWare Building Block IP User Guide. Adapted from [Synopsys’11]

ECE 5745 T12: Synthesis Algorithms 7 / 43

32 Synopsys, Inc. September 2011 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Part 3: CAD Algorithms

Topic 12 Topic 13 Synthesis Algorithms Physical Design Automation

Placement

RTL to Logic Synthesis Global x = a'bc + a'bc' Routing y = b'c' + ab' + ac TechnologyTechnology IndependentIndependent SynthesisSynthesis x = a'b y = b'c' + ac Technology Detailed Dependent Routing Synthesis

ECE 5745 T12: Synthesis Algorithms 8 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Technology-Independent Synthesis

I Two-level boolean minimization – based on assumption that reducing the number of product terms in an equation and reducing the size of each product term will result in a smaller/faster implementation

I Optimizing finite-state machines – look for equivalent FSMs (i.e., FSMs that produce the same outputs give the same sequence of inputs) that have fewer states

I FSM state encodings – minimize implementation area (= size of state storage + size of logic to implement next state and output functions).

Note that none of these optimizations are completely isolated from the target technology, but experience has shown that it’s advantageous to reduce the size of the problem as much as possible before starting the technology-dependent optimizations.

ECE 5745 T12: Synthesis Algorithms 9 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Method Review

I 1. Choose an element of ON-set not already covered by an implicant I 2. Find “maximal” groups of 1’s and X’s adjacent to that element. Remember to consider top/bottom row, left/right column, and corner adjacencies. This forms prime implicants.

I Repeat steps 1 and 2 to find all prime implicants I 3. Revise the 1’s elements in the K-map. If covered by single prime implicant, it is essential, and participates in the final cover. The 1’s it covers do not need to be revisited.

I 4. If there remain 1’s not covered by essential prime implicants, then select the smallest number of prime implicants that cover the remaining 1’s

ECE 5745 T12: Synthesis Algorithms 10 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Karnaugh Map Method Example

Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 11 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Quine-McCluskey (QM) Method

I Quine-McCluskey method is an exact alogorithm which finds a minimum-cost sum-of-products implementation of a boolean function I Four main steps . 1. Generate prime implicants . 2. Construct prime implicant table . 3. Reduce prime implicant table a. Remove essential prime implicants b. Row dominance c. Column dominance d. Iterate at this step until no further reductions . 4. Solve prime implicant table

ECE 5745 T12: Synthesis Algorithms 12 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis QM Example #1 – Step 1 Prime Term Generation Start by expressing your Boolean function using 0- W X Y Z label 0 0 0 0 0 terms (product terms with no don’t care care entries). 0 1 0 1 5 For compactness the table for example 4-input, 1- 0 1 1 1 7 1 0 0 0 8 output function F(w,x,y,z) shown to the right includes 1 0 0 1 9 only entries where the output of the function is 1 and 1 0 1 0 10 1 0 1 1 11 we’ve labeled each entry with it’s decimal equivalent. 1 1 1 0 14 1 1 1 1 15 Look for pairs of 0-terms that differ in only one bit position and merge them in a 1-term (i.e., a term that has exactly one ‘–’ entry). Next 1-terms are examined in pairs to see if the can be merged into 2-terms, etc. Mark k-terms that get merged into (k+1) terms so we can discard them later. 1-terms: 0, 8 -000 [A] 2-terms: 8, 9,10,11 10--[D] 5, 7 01-1 [B] 10,11,14,15 1-1-[E] 7,15 -111 [C] 8, 9 100- 8,10 10-0 3-terms: none! 9,11 10-1 10,11 101- Label unmerged terms: 10,14 1-10 Example due to these terms are prime! Srini Devadas 11,15 1-11 14,15 111- 6.371 – Fall 2002 09/13/02 AdaptedL04 – from Synthesis [Terman’02] 9

ECE 5745 T12: Synthesis Algorithms 13 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis QM Example #1 – Step 2, Step 3a Prime Term Table

An “X” in the prime term table in row R and column C signifies that the 0- term corresponding to row R is contained by the prime corresponding to column C.

A B C D E Goal:Goal: select select the the minimum minimum 0000 X . . . . A is essential set of primes (columns) 0101 . X . . . B is essential set of primes (columns) 0111 . X X . . suchsuch that that there there is is at at least least 1000 X . . X . one “X” in every row. This 1001 . . . X . D is essential one “X” in every row. This 1010 . . . X X isis the the classical classical minimum minimum 1011 . . . X X coveringcovering problem. problem. 1110 . . . . X E is essential 1111 . . X . X

Each row with a single X signifies an essential prime term since any prime implementation will have to include that prime term because the corresponding 0-term is not contained in any other prime. In this example the essential primes “cover” all the 0-terms.

Adapted from [Terman’02]

ECE 57456.371 – Fall 2002 T12: Synthesis09/13/02 Algorithms L04 – Synthesis14 10 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Column Dominance

I 5 prime implicants, each essential covers 2 ON-set minterms A B I A’C’D’ and ACD are essential 00 01 11 10 prime implicants, must be in 00 110 0 final cover essential 01 0 110 I Pick min subset of remaining CD 3 prime implicants which 11 0 0 11 covers ON-set 10 0000

Karnaugh map with set of prime implicants: illustrating "column dominance"

Column Dominance

Consider the following Karnaugh map of a 4-input Boolean function:Adapted from [Nowick’12] ECE 5745 There are 5 primeT12: implicants, Synthesis Algorithms each of which covers 2 ON-set minterms. First,15 w /e 43 note that two implicants are essential prime implicants: A!C!D! and ACD. These implicants must be added to the final cover. There are 3 remaining prime implicants. We must pick a minimum subset of these to cover the uncovered ON-set minterms. Here is the prime implicant table for the Karnaugh map. The 5 prime implicants are listed as columns, and the 6 ON-set minterms are listed as rows.

A!C!D! A!BC! BC!D ABD ACD (0,4) (4,5) (5,13) (13,15) (11,15) 0 X 4 XX 5 XX 11 X 13 XX 15 XX

We cross out columns A!C!D! and ACD and mark them with asterisks, to indicate that these are essential. Each row intersected by one of these columns is also crossed out, because that minterm is now covered. At this point, prime implicant BC!D covers 2 remaining ON-set minterms (5 and 13). However, prime implicant A!BC! covers only one of these (namely, 5), as does ABD (namely, 13). Therefore we can always use BC!D instead of either A!BC or ABD, since it covers the same minterms. That is, BC!D column-dominates A!BC, and BC!D column-dominates ABD. The dominated prime implicants can be crossed out, and only column BC!D remains.

2 essential

A B 00 01 11 10

00 110 0 essential

01 0 110 CD

11 0 0 11

10 0000

Karnaugh map with set of prime implicants: illustrating "column dominance"

Column Dominance

Consider the following Karnaugh map of a 4-input Boolean function: There are 5 prime implicants, each of which covers 2 ON-set minterms. First, we note that two implicants are essential prime implicants: A!C!D! and ACD. These implicants must be added to the final cover. There are 3 remaining prime implicants. We must pick a minimum subset of these to cover the uncovered ON-set RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis minterms. Column DominanceHere is the prime implicant table for the Karnaugh map. The 5 prime implicants are listed as columns, and the 6 ON-set minterms are listed as rows.

I Cross out columns A’C’D’ and A!C!D! A!BC! BC!D ABD ACD ACD since they are essential (0,4) (4,5) (5,13) (13,15) (11,15) 0 X Each row intersected by one 4 XX I 5 XX of the essential prime 11 X columns is also crossed out 13 XX 15 XX because that minterm is already covered We cross out columns A!C!D! and ACD and mark them with asterisks, to indicate that these are essential. Each row intersected by one of these columns is also crossed out, because that minterm is now covered. I BC’D covers minterm 5 and 13, butAt this A’BC’ point, only prime covers implicant mintermBC!D covers 5 2 and remaining ON-set minterms (5 and 13). However, prime implicant A BC covers only one of these (namely, 5), as does ABD (namely, 13). Therefore we can ABD only covers minterm 13 ! ! always use BC!D instead of either A!BC or ABD, since it covers the same minterms. That is, BC!D column-dominates A!BC, and BC!D column-dominates ABD. The dominated prime implicants can be I BC’D column dominates A’BC’ andcrossed ABD, out, dominated and only column primeBC!D remains. implicants can be crossed out

I Only column BC’D remains 2

Adapted from [Nowick’12]

ECE 5745 T12: Synthesis Algorithms 16 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Row Dominance

I 4 prime implicants, no A B essential prime implicants 00 01 11 10 I Pick min subset of the 4 − 0 0 0 prime implicants to cover the 00 5 ON-set minterms no essential 01 1 1 −− prime implicants CD

11 11 0 0

10 1 − 00

Karnaugh map with set of prime implicants: illustrating "row dominance"

Adapted from [Nowick’12]

ECE 5745 Row DominanceT12: Synthesis Algorithms 17 / 43

Consider the following Karnaugh map of a 4-input Boolean function:

There are 4 prime implicants: A!B!, C!D, A!D and A!C. None of these is an essential prime implicant. We must pick a minimum subset of these to cover the 5 ON-set minterms. Here is the prime implicant table for the Karnaugh map. The 4 prime implicants are listed as columns, and the 5 ON-set minterms are listed as rows.

A!B! C!DA!DA!C (1,2,3) (1,5) (1,3,5,7) (2,3,7) 1 XX X 2 XX 3 XXX 5 XX 7 XX

Note that row 3 is contained in three columns: A!B!, A!D, and A!C. Row 2 is covered by two of these three columns: A!B! and A!C, and row 7 is also covered by two of these three columns: A!D and A!C. In this case, any prime implicant which contains row 2 also contains row 3. Similarly, any prime implicant which contains row 7 also contains row 3. Therefore, we can ignore the covering of row 3: it will always be covered as long as we cover row 2 or row 7. To see this, note that row 3 row dominates row 2, and row 3 row dominates row 7. The situation is now the reverse of column dominance: we cross out the dominating (larger) row. In this case, row 3 can be crossed out; it no longer needs to be considered. Similarly, row 1 row dominates row 5. Therefore row 1 can be crossed out. We are guaranteed that row 1 will still be covered, since any prime implicant which covers row 5 will also cover row 1.

3 A B 00 01 11 10

00 − 0 0 0 no essential 01 1 1 −− prime implicants CD

11 11 0 0

10 1 − 00

Karnaugh map with set of prime implicants: illustrating "row dominance"

Row Dominance

Consider the following Karnaugh map of a 4-input Boolean function:

There are 4 prime implicants: A!B!, C!D, A!D and A!C. None of these is an essential prime implicant. We RTL to Logic Synthesis • Technology-Independentmust Synthesis pick• a minimumTechnology-Dependent subset of Synthesis these to cover the 5 ON-set minterms. Here is the prime implicant table for the Karnaugh map. The 4 prime implicants are listed as columns, and the 5 ON-set minterms are listed as Row Dominancerows.

I Row 3 is contained in 3 A!B! C!DA!DA!C columns: A’B’, A’D, and A’C (1,2,3) (1,5) (1,3,5,7) (2,3,7) 1 XX X I Row 2 is covered by two of 2 XX these three columns, so any 3 XXX prime implicant which 5 XX contains row 2 also contains 7 XX row 3

I Row 7 is covered by two of these threeNote that columns, row 3 is so contained any prime in three columns: A!B!, A!D, and A!C. Row 2 is covered by two of these implicant which contains row 7 alsothree contains columns: rowA! 3B! and A!C, and row 7 is also covered by two of these three columns: A!D and A!C. In this case, any prime implicant which contains row 2 also contains row 3. Similarly, any prime implicant I Thus we can ignore row 3, it will alwayswhich contains be covered row 7 as also long contains as cover row 3. Therefore, we can ignore the covering of row 3: it will always be row 2 or row 7 covered as long as we cover row 2 or row 7. To see this, note that row 3 row dominates row 2, and row 3 row dominates row 7. The situation is now the reverse of column dominance: we cross out the dominating Cross out row 3, similarly row 1 dominates row 5 so cross out row 1 I (larger) row. In this case, row 3 can be crossed out; it no longer needs to be considered. Adapted from [Nowick’12]

ECE 5745 T12: SynthesisSimilarly, Algorithms row 1 row dominates row 5. Therefore18 / 43 row 1 can be crossed out. We are guaranteed that row 1 will still be covered, since any prime implicant which covers row 5 will also cover row 1.

3 Column I Column II 0 0000 √ (0,2) 00-0 2 0010 √ (0,8) -000 8 1000 √ (2,6) 0-10 5 0101 √ (2,10) -010 6 0110 √ (8,10) 10-0 10 1010 √ (8,12) 1-00 12 1100 √ (5,7) 01-1 7 0111 √ (5,13) -101 13 1101 √ (6,7) 011- 14 1110 √ (6,14) -110 15 1111 √ (10,14) 1-10 (12,13) 110- (12,14) 11-0 (7,15) -111 (13,15) 11-1 (14,15) 111-

RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Combine Pairs of Products from Column II QM Example #2 – Step 1 A check (√) is written next to every product which can combined with another product.

Column I Column II Column III 0 0000 √ (0,2) 00-0 √ (0,2,8,10) -0-0 2 0010 √ (0,8) -000 √ (0,8,2,10) -0-0 8 1000 √ (2,6) 0-10 √ (2,6,10,14) –10 5 0101 √ (2,10) -010 √ (2,10,6,14) –10 6 0110 √ (8,10) 10-0 √ (8,10,12,14) 1–0 10 1010 √ (8,12) 1-00 √ (8,12,10,14) 1–0 12 1100 √ (5,7) 01-1 √ (5,7,13,15) -1-1 7 0111 √ (5,13) -101 √ (5,13,7,15) -1-1 13 1101 √ (6,7) 011- √ (6,7,14,15) -11- 14 1110 √ (6,14) -110 √ (6,14,7,15) -11- 15 1111 √ (10,14) 1-10 √ (12,13,14,15) 11– (12,13) 110- √ (12,14,13,15) 11– (12,14) 11-0 √ (7,15) -111 √ Eliminate redundant (13,15) 11-1 √ entries in table (14,15) 111- √

Adapted from [Nowick’12]

ECE 5745 Column III contains a numberT12: Synthesis of duplicate Algorithms entries, e.g. (0,2,8,10) and (0,8,2,10).19 / Duplicate 43 entries appear because a product in Column III can be formed in several ways. For example, (0,2,8,10) is formed by com- bining products (0,2) and (8,10) from Column II, and (0,8,2,10) (the same product) is formed by combining products (0,8) and (2,10). Duplicate entries should be crossed out. The remaining unchecked products cannot be combined with other products. These are the prime implicants: (0,2,8,10), (2,6,10,14), (5,7,13,15), (6,7,14,15), (8,10,12,14) and

5 (12,13,14,15); or, using the usual product notation: B!D!, CD!, BD, BC, AD! and AB.

Step 2: Construct Prime Implicant Table.

B!D! CD! BD BC AD! AB (0,2,8,10) (2,6,10,14) (5,7,13,15) (6,7,14,15) (8,10,12,14) (12,13,14,15) 0 X 2 XX 5 X 6 XX 7 XX 8 X X 10 XX X 12 XX 13 X X 14 XXXX 15 XX X

Step 3: Reduce Prime Implicant Table. RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Iteration #1. QM Example #2 – Step 2, Step 3a (i) Remove Primary Essential Prime Implicants B D ( ) CD BD( ) BC AD AB ! ! ∗ ! ∗ ! (0,2,8,10) (2,6,10,14) (5,7,13,15) (6,7,14,15) (8,10,12,14) (12,13,14,15) ( )0 X ◦ 2 XX ( )5 X ◦ 6 XX 7 XX 8 X X 10 XX X 12 XX 13 X X 14 XXXX 15 XX X * indicates an essential prime implicant indicates a distinguished row, i.e. a row covered by only 1 prime implicant ◦

In step #1, primary essential prime implicants are identified. These are implicants which will appear in any Adapted from [Nowick’12] solution. A row which is covered by only 1 prime implicant is called a distinguished row. The prime im- ECE 5745plicant which covers it is an essentialT12: prime Synthesis implicant Algorithms. In this step, essential prime implicants20 / are 43 identified

6 and removed. The corresponding column is crossed out. Also, each row where the column contains an X is completely crossed out, since these minterms are now covered. These essential implicants will be added to the final solution. In this example, B!D! and BD are both primary essentials.

(ii) Row Dominance The table is simplified by removing rows and columns which were crossed out in step (i). (Note: you do not need to do this, but it makes the table easier to read. Instead, you can continue to mark up the original table.)and removed. The corresponding column is crossed out. Also, each row where the column contains an X is completely crossed out, since these minterms are now covered. These essential implicants will be added to the final solution. In this example, B!D! and BD are both primary essentials. CD! BC AD! AB (2,6,10,14) (6,7,14,15) (8,10,12,14) (12,13,14,15) RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis (ii)6 Row DominanceXX 12 XX The14 table isXX simplified by removing rows X and columns X which were crossed out in step (i). (Note: you do not need to do this, butQM it makes Example the table easier to read. #2 Instead, – you Step can continue 3b, to mark 3c, up the 3a original table.) Row 14 dominates both row 6 and row 12. That is, row 14 has an “X” in every column where row 6 has an “X” (and, in fact, row 14 has “X”’s in other columns as well). Similarly,3.b row Row 14 has in Dominance “X” in every column – row 14 where rowCD 12! has an “X”.BC Rows 6 and AD 12 are! said to beABdominated by row 14. (2,6,10,14) (6,7,14,15) (8,10,12,14) (12,13,14,15) dominates both row 6 and 12; A dominating6 XXrow can always be eliminated. To see this, note that every product which covers row 6 also covers12 row 14. That is, if some productXX covers row 6, row 14 is guaranteedremoveto be row covered. 14 Similarly, since ifany some product14 whichXX covers row 12 will also cover X row 14. Therefore, X row 14product can be crossed covers out. row 6, row 14 is guaranteed to be covered (iii)Row Column 14 dominates Dominanceboth row 6 and row 12. That is, row 14 has an “X” in every column where row 6 has an “X” (and, in fact, row 14 has “X”’s in other columns as well). Similarly, row 14 has in “X” in every column CD BC AD AB 3.c Column Dominance – column where row 12! has an “X”. Rows 6 and 12! are said to be dominated by row 14. (2,6,10,14) (6,7,14,15) (8,10,12,14) (12,13,14,15) CD’ dominates column BC (actually A 6dominatingXXrow can always be eliminated. To see this, note that every product which covers row 6 also covers12 row 14. That is, if some productXX covers row 6, row 14 is guaranteedthey co-dominateto be covered. Similarly, each any other); product whichIteration covers row #2. 12 will also cover row 14. Therefore, row 14remove can be crossed column out. BC since it is

Column CD!(i)dominates Removecolumn SecondaryBC. Essential That is, column PrimeCD Implicants! has an “X”redundant in every row where with column columnBC has CD’ an(iii) “X”. Column In fact, Dominance in this example, column BC also dominates column CD!, so each is dominated by the other. CD!( ) AD!( ) (Such columns are said to co-dominate∗∗ each∗∗ other.) Similarly, columns AD! and AB dominate each other, (2,6,10,14) (8,10,12,14) 3.a Remove Essential Prime and each isCD dominated! byBC the other. AD! AB ( )6 X (2,6,10,14)◦ (6,7,14,15) (8,10,12,14) (12,13,14,15) Implicants – second iteration of A dominated column( )12 can always be eliminated.X To see this, note that every row covered by the dominated 6 XX◦ column is also covered by the dominating column. For example, C Dstepcovers 3, every both row which remainingBC covers. prime 12 ** indicates a secondary essentialXX prime implicant ! Therefore, the dominating column can always replace the dominatedimplicants column, so the dominated are essential column is crossed out. Inindicates this example, a distinguishedCD! and BC rowdominate each other, so either column can be crossed out (but Column CD◦dominates column BC. That is, column CD has an “X” in every row where column BC has not both). Similarly,! AD! and AB dominate each other, so! either columnF = can B’D’ be crossed + BD out. + CD’ + AD’ an “X”. In fact, in this example, column BC also dominates column CD!, so each is dominated by the other. In iteration #2 and beyond, secondary essential prime implicants are identified. These are implicants which (Such columns are said to co-dominate each other.) Similarly, columns AD! and AB dominate each other,Adapted from [Nowick’12] and each is dominatedwill appear by in theany other.solution, given the choice of column-dominance used in the previous steps (if 2 columns ECE 5745 co-dominated each other in a previousT12: step, Synthesis the choice Algorithms of which was deleted can affect what is an “essential” 21 / 43 A dominatedatcolumn this step). can Asalways before, be eliminated.a row which To is covered see this, by note only that 1 primeevery rowimplicant covered is ca bylled the a dominateddistinguished row. The column is alsoprime covered implicant by the which dominating covers column. it is a (secondary) For example, essentialC!D covers prime implicant every row. which BC covers. Therefore, the dominating column can always replace the dominated column, so the dominated column is Secondary essential prime implicants are identified and removed. The corresponding columns are crossed crossed out. In this example, CD! and BC dominate7 each other, so either column can be crossed out (but not both). Similarly,out. Also,AD each! and rowAB wheredominate the columneach other, contains so either an X columnis completely can be crossed crossed out. out, since these minterms are now covered. These essential implicants will be added to the final solution. In this example, both CD! and AD! are secondary essentials.

Step 4: Solve Prime Implicant Table.

No other rows remain to be covered, so no7 further steps are required. Therefore, the minimum-cost solution consists of the primary and secondary essential prime implicants B!D!, BD, CD! and AD!:

F = B!D! + BD + CD! + AD!

8 Example #2:

F (A, B, C, D)=Σm(0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)

RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Step 1: Generate Prime Implicants. Example #2: QM Example #3 – Step 2 Use the method described in Example #1.

F (A, B, C, D)=Σm(0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13) Step 2: Construct Prime Implicant Table.

A!D! B!D! C!D! A!CB!CA!BBC! AB! AC! 0 XXX 2 XX XX 3 XX Step 1: Generate Prime Implicants.4 XX XX 5 XX 6 XXX Use the method described in Example7 #1. XX 8 XX XX 9 XX 10 XXX 11 XX Step 2: Construct Prime Implicant12 Table.XXX 13 XX

Adapted from [Nowick’12] A!D! B!D! ECEC 5745!D! StepA!CB 3: Reduce!CA Prime Implicant!T12:BBC Synthesis Table. Algorithms! AB! AC! 22 / 43 0 XXXIteration #1. 2 XX(i) Remove XX Primary Essential Prime Implicants 3 ThereXX are no primary essential prime implicants: each row is covered by at least two products. 4 XX XX 5 XX 6 XXX 7 XX 8 XX XX 9 XX 10 XXX 11 XX

12 XXX9 13 XX

Step 3: Reduce Prime Implicant Table. Iteration #1. (i) Remove Primary Essential Prime Implicants There are no primary essential prime implicants: each row is covered by at least two products.

9 (ii) Row Dominance

A!D! B!D! C!D! A!CB!CA!BBC! AB! AC! 0 XXX 2 XX XX (ii) Row Dominance 3 XX 4 AXX!D! B!D! C!D! A!CB!CA XX!BBC! AB! AC! 50 XXX XX 62 XXXXX XX 73 XX 84 XXXX XX XX 95 XXXX 106 XXXXXX 117 XXXX 128 RTL to LogicXX SynthesisXXX• Technology-Independent XX Synthesis • Technology-Dependent Synthesis 139 XXXX 10 XXX 11 XX There are many instancesQM of Examplerow dominance. Row 2 #3 dominates – Step3, 4 dominates 3a, 5, 6 dominates 3b, 7, 3c, 8 dominates 3a 12 XXX 9, 10 dominates 11, 12 dominates 13. Dominating rows are removed. 13 XX I(iii)3a. Column No Dominance essential prime implicants There are many instances of row dominance. Row 2 dominates 3, 4 dominates 5, 6 dominates 7, 8 dominates A!D! B!D! C!D! A!CB!CA!BBC! AB! AC! I9, 1003b. dominatesXXX Row 11, dominance: 12 dominates 13. Dominating 2>3, rows 4> are5, removed. 6>7, 8>9, 10>11, 12>13 3 XX (iii) Column Dominance 5 XX 7 A!D! B!D! C!D! AXX!CB!CA!BBC! AB! AC! 90 XXX XX 113 XXXX 135 XXXX 7 XX Columns9 A!D!, B!D! and C!D! each dominate one another. WeXX can remove any two of them. 11 XX Iteration13 #2. XX (i) Remove Secondary Essential Prime Implicants Columns A!D!, B!D! and C!D! each dominate one another. We can remove any two of them. A D ( ) A CBCABBC AB AC ! ! ∗∗ ! ! ! ! ! ! 3.c Column Dominance – column ( )0 X Iteration◦ #2. 3 XX A’D’, B’D’, and C’D’ dominate each (i) Remove Secondary Essential Prime Implicants 5 XX A D ( ) A CBCABBC AB AC other; remove any two of them 7 ! ! ∗∗ XX! ! ! ! ! ! ( )09 X XX ◦ 113 XXXX3.a Remove Essential Prime 135 XXXXImplicants – second iteration of 7 XX ** indicates9 a secondary essential prime implicant XX step 3, remove A’D’ indicates11 a distinguished rowXX Adapted from [Nowick’12] ◦ 13 XX ECE 5745 T12: Synthesis Algorithms 23 / 43

Product** indicatesA!D a! is secondary a secondary essential essential prime prime implicant implicant; it is removed from the table. indicates a distinguished row ◦ 10

Product A!D! is a secondary essential prime implicant; it is removed from the table.

10 (ii) Row Dominance

No further row dominance is possible.

(iii) Column Dominance

No further column dominance is possible.

RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis

Step 4:QM Solve Example Prime Implicant #3 – Step Table. 4

A!CB!CA!BBC! AB! AC! 3 XX 5 XX 7 XX 9 XX 11 XX 13 XX

No essentialThere prime are implicants; no additional no row secondary dominance; essential no column prime dominance implicants, and no further row- or column-dominance is Cyclic coveringpossible. problem The remaining – can be solved covering using problem a branch-and-bound is called a cyclic covering problem. A solution can be obtained usingsearch one of technique two methods: (see notes (i) Petrick’s for details) method or (ii) the branching method. We use Petrick’s method below; see Devadas et al. and Hachtel/Somenzi books for a discussion of the branching method.

Adapted from [Nowick’12] ECE 5745 Petrick’s MethodT12: Synthesis Algorithms 24 / 43

In Petrick’s method, a Boolean expression P is formed which describes all possible solutions of the table. The prime implicants in the table are numbered in order, from 1 to 6: p1 = A!C, p2 = B!C, p3 = A!B, p4 = BC!, p5 = AB!, p6 = AC!. For each prime implicant pi, a Boolean variable Pi is used which is true whenever prime implicant pi is included in the solution. Note the difference!: pi is an implicant, while Pi is a corresponding Boolean proposition (i.e., true/false statement) which has a true (1) or false (0) value. Pi =1means “I select prime implicant pi for inclusion in the cover”, while Pi =0means “I do not select prime implicant pi for inclusion in the cover.

Using these Pi variables, a larger Boolean expression P can be formed, which captures the precise conditions for every row in the table to be covered. Each clause in P is a disjunction (OR) of several possible column selections to cover a particular row. The conjunction (AND) of all of these clauses is the Boolean expression P , which describes precisely the conditions to be satisfied for all rows are covered. For the above prime implicant table, the covering requirements can be captured by the Boolean equation:

P =(P1 + P2)(P3 + P4)(P1 + P3)(P5 + P6)(P2 + P5)(P4 + P6)

If Boolean variable P =1, each of the disjunctive clauses is satisfied (1), and all rows are covered. In this case, the set of Pi!s which are 1 indicate a valid cover using the corresponding selection of primes pi! s

11 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Heuristic Espresso Method

I Quine-McCluskey . Number of prime implicants grows rapidly with number of inputs . Finding a minimum cover is NP-complete (i.e., computationally expensive) I Espresso . Don’t generate all prime implicants (i.e., QM step 1) . Carefully select a subset of primes that still covers ON-set . Heuristically explore space of covers . Similar in spirit (but more structured) to finding primes in K-map

Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 25 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Redundancy in Boolean Space

I Every point in boolean space is an assignment of values to variables I Redundancy involves inclusion or covering in boolean space I Irredundant cover has no redundancy 001 011 001 011

101 111 101 111

000 010 000 010

100 110 100 110

g = AB'C, h = AB' f = AC, g = B'C', h = AB' g is redundant h is redundant Can exhaustively check if each prime is redundant with any other prime Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 26 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Irredundant Covers vs. Minimal Covers

I Irredundant cover is not necessarily a minimal cover I Can use reduce, expand, remove redundancy operations to explore space of irredundant covers BC BC A 00 01 11 10 A 00 01 11 10 0 110 0 0 110 0 1 1 1 0 0 1 1 1 0 0

Original Irredundant Cover Reduce F = B'C + A'C + AB'C' F = AB'C + A'C + AB'C'

BC BC A 00 01 11 10 A 00 01 11 10 0 110 0 0 110 0 1 1 1 0 0 1 1 1 0 0

Expand New Irredundant Cover F = AB' + A'C + AB'C' F = AB' + A'C Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 27 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Espresso Algorithm

I 1. EXPAND implicants (choice of which implicants requires heuristic) I 2. REMOVE-REDUNDANCY I 3. REDUCE implicants (choice of which implicants requires heuristic) I 4. EXPAND implicants (choice of which implicants requires heuristic) I 5. REMOVE-REDUNDANCY I 6. Goto step 3

Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 28 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Espresso Example

Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 29 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Espresso Example

Adapted from [Zhou’02]

ECE 5745 T12: Synthesis Algorithms 30 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Two-LevelTwo-Level Logic versus vs. Multi-Level Multilevel Logic

2-Level:

f1 AB AC AD

f2 AB AC AE 6 product terms which cannot be shared. 24 in static CMOS

Multi-level:

Note that B + C is a common term in f1 and f2

K = B + C 3 Levels

f1 AD 20 transistors in static CMOS not counting inverters f2 = AK + AE

Adapted from [Devadas’06] 4 ECE 5745 T12: Synthesis Algorithms 31 / 43 RTL to Logic Synthesis • Technology-Independent Synthesis • Technology-Dependent Synthesis Two-Level Logic vs. Multi-Level Logic

I Two-Level Logic . At most two gates between primary input and primary output . Real life circuits: programmable logic arrays . Exact optimization methods: well-developed, feasible . Heuristic methods also possible I Multi-Level Logic . Any number of gates between primary input and primary output . Most circuits in real life are multi-level . Smaller, less power, and (in many cases) faster . Exact optimization methods: few, high complexity, impractical . Heuristic methods pretty much required

ECE 5745 T12: Synthesis Algorithms 32 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Part 3: CAD Algorithms

Topic 12 Topic 13 Synthesis Algorithms Physical Design Automation

Placement

RTL to Logic Synthesis Global x = a'bc + a'bc' Routing y = b'c' + ab' + ac Technology Independent Synthesis x = a'b y = b'c' + ac Technology Detailed TechnologyDependent Routing DependentSynthesis Synthesis

ECE 5745 T12: Synthesis Algorithms 33 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Technology Mapping

I Once minimized logic equations, next step is to map each equation to the gates in the target standard cell library I ClassicDAG approach Covering uses DAG covering (K. Keutzer) . “Normal Form” : use basic gates (e.g., 2-input NAND gates, inverters) . Represent logic equations as input netlist in normal form (subjective DAG) . RepresentSound each Algorithmic library gate in normal approach form (primitive DAG) . GOAL: Find a min cost covering of subjective DAG by primitive DAGs NP-hard optimization problem I Sound algorithmic approach, but is NP-hard optimization problem multiple fanout

Adapted from [Devadas’06] ECE 5745 Tree covering heuristic:T12: Synthesis Algorithms If subject and primitive34 / 43 DAGs are trees, efficient algorithm can find optimum cover in linear time dynamic programming formulation

25 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Tree Heuristic Transformation

If subject and primitive DAGs are trees, efficient algorithm can find optimum cover in linear time via dynamicResulting programming, Trees so use tree Partitioningcovering a heuristic Graph approach by partitioning graph into subtrees Break at multiple fanout points

Original Graph Partitioned Graph 27

26

Adapted from [Devadas’06]

ECE 5745 T12: Synthesis Algorithms 35 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis •

TechnologyMapping Mapping Example Example

Problem statement: find an “optimal” mapping of this circuit:

Into this library:

Adapted from [Terman’02,Devadas’06] Example due to ECE 5745 T12: Synthesis Algorithms 36 / 43 Kurt Keutzer

6.371 – Fall 2002 09/13/02 L04 – Synthesis 14 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Primitive DAGs for Standard-Cell Library Gates Primitive DAGs for library gates

Adapted from [Terman’02,Devadas’06] 6.371 – Fall 2002 09/13/02 L04 – Synthesis 15 ECE 5745 T12: Synthesis Algorithms 37 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Possible Covers Possible Covers

Hmmm. Seems promising but is there a systematic and efficient way to arrive at the optimal answer?

Adapted from [Terman’02,Devadas’06] 6.371 – Fall 2002 09/13/02 L04 – Synthesis 16 ECE 5745 T12: Synthesis Algorithms 38 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • UseUse dynamic Dynamic Programming!programming!

Principle of optimality: Optimal cover for a tree consists of a best match at the root of the tree plus the optimal cover for the sub-trees starting at each input of the match.

Best cover for this match uses best X covers for P, X & Y

Z Y Complexity:Complexity: ToTo determinedetermine thethe optimaloptimal covercover forfor aa treetree wewe onlyonly needneed toto considerconsider aa best-cost match at the root of the best-cost match at the root of the P treetree (constant(constant timetime inin thethe numbernumber ofof matchedmatched cells),cells), plusplus thethe optimaloptimal covercover forfor thethe subtreessubtrees starting starting atat Best cover for this eacheach inputinput toto ththee matchmatch (constant(constant match uses best time in the fanin of each match) time in the fanin of each match) covers for P & Z O(N)O(N)

Adapted from [Terman’02,Devadas’06] 6.371 – Fall 2002 09/13/02 L04 – Synthesis 17 ECE 5745 T12: Synthesis Algorithms 39 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • OptimalOptimal tree Tree Coveringcovering Exampleexample

09/13/02 6.371 – Fall 2002 Adapted from [Terman’02,Devadas’06]L04 – Synthesis 18

ECE 5745 T12: Synthesis Algorithms 40 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Optimal Tree Covering Example Example (II)

Adapted from [Terman’02,Devadas’06] 6.371 – Fall 2002 09/13/02 L04 – Synthesis 19 ECE 5745 T12: Synthesis Algorithms 41 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Optimal Tree Covering Example Example (III)

This matches our earlier intuitive cover, but accomplished systematically.

Refinements: timing optimization incorporating load-dependent delays, optimization for low power.

6.371 – Fall 2002 09/13/02 Adapted from [Terman’02,Devadas’06]L04 – Synthesis 20 ECE 5745 T12: Synthesis Algorithms 42 / 43 RTL to Logic Synthesis Technology-Independent Synthesis • Technology-Dependent Synthesis • Acknowledgments

I [Weste’11] N. Weste and D. Harris, “CMOS VLSI Design: A Circuits and Systems Perspective,” 4th ed, Addison Wesley, 2011. I [Synopsys’11] “DesignWare Datapath and Building Block IP: Quick Reference,” Synopsys, 2011. I [Zhou’02] H. Zhou, Northwestern ECE 303 Advanced Digital Design, Lecture Slides, 2002. I [Terman’02] C. Terman and K. Asanovic,´ MIT 6.371 Introduction to VLSI Systems, Lecture Slides, 2002. I [Nowick’12] S. Nowick, “The Quine-McCluskey Method,” Columbia CSEE E6861y Computer-Aided Design of Digital Systems, Handout, 2012. I [Devadas’06] S. Devadas, “VLSI CAD Flow: Logic Synthesis, Placement, and Routing,” MIT 6.375 Complex Digital Systems Guest Lecture Slides, 2006.

ECE 5745 T12: Synthesis Algorithms 43 / 43