Boolean Logic Theory.pptx

Report 2 Downloads 135 Views
ECSE  323     Digital  System  Design   Winter  2011  

 

Boolean  Logic  Theory    

Prof.  Warren  Gross          

 Material  used  in  this  set  of  slides  was  based    on   Fundamentals  of  Digital  Logic  with  VHDL  Design   by  S.  Brown  and  Z.  Vranesic        

1  

Textbook  Reading   •  This  topic  will  cover  Chapters  2  (IntroducEon  to   Logic  Circuits)  and  parts  of  Chapter  4  (OpEmized   ImplementaEon  of  Logic  FuncEons)  in  the   textbook.   •  First,  we  will  look  at  the  basics  of  logic  circuits.   We  will  cover  all  of  Chapter  2.   –  We  will  not  cover  SecEons  2.9  and  2.10  NOW,  but  we   will  come  back  and  cover  them  in  a  couple  of  weeks   when  we  study  design  using  CAD  tools  and  the  VHDL   hardware  descripEon  language.   2  

x  =  0  

x  =  1  

S   x  

S   Battery  

x    

Light  

3  

S   Power   supply  

x    

Light  

4  

Power   supply  

S  

S  

x1    

x2    

 

 

Light  

(a) The logical AND function (series connection)   S   x1    

 

Power   supply  

S  

Light  

x2       (b) The logical OR function (parallel connection)   5  

S  

Power   supply  

X  1    

S  

S  

X  3    

Light  

X2      

L(x1, x2, x3) = ?

6  

R  

Power   supply  

x    

S  

Light  

L(x) = ?

7  

x 1     x 2    

x 1     x 2     x 1   ⋅   x   2   ⋅   …   ⋅  x   n    

x 1   ⋅   x   2     x n     (a) AND gates  

x 1     x 2    

x 1     x 2    

x 1   +    x 2    

x 1   +    x 2   +    …+    x n    

x n     (b) OR gates   x  

x  

(c) NOT gate   8  

Truth  Tables  

  •  Completely  defines  a  logic  funcEon   •  Size  grows  exponenEally  in  number  of  input  variables   •  N  input  variables  à  2N  rows  in  the  truth  table  

Truth  Table  for  Three-­‐input  AND  and  OR  operaEons      

9  







x1



0

0

1

1

x2



0→

1



0



1



1→

1



0



0



A

1→

1



0



1



f

0→

0



0



1



B

Network that implements

f(x1, x2)

=

x

1

0

x

1

2

0

A

1

0

B

1

0

f

1

0

Time







Timing diagram



•  functional behavior

•  no delay between change of input values and corresponding change in output values

10  

x1



f

x2



f

=

x1



+ x

1



⋅ x

2



x

1

g

x

2

g

=

x

+ x



1

2

•  FuncEonally-­‐equivalent  networks   –  Many  ways  to  implement  the  same   logic  funcEon,  each  one  has  a  cost   –  Example  cost:  #  of  logic  gates  +  #   inputs  to  all  of  the  logic  gates   11  

Boolean  FuncEons   •  Need  a  way  to  manipulate  Boolean  funcEons   –  E.  g.  to  show    

x¯1 + x1 · x2 = x¯1 + x2 •  Truth  tables  too  cumbersome  (large  and  Eme-­‐ consuming  to  produce  for  complex  funcEons)   •  Goal:  Manipulate  and  transform  logic   funcEons  to  find  the  least  costly   implementaEon  (logic  minimiza?on)   12  

Boolean  Algebra   •  George  Boole  (1849)   –  applied  to  circuits  built  out  of  switches  by  Claude   Shannon  in  the  1930’s  

•  All  Boolean  operaEons  are  performed  on  the   set  {0,1}   –  AND,  OR,  and  NOT  

•  HunEngton’s  basic  postulates  are  sufficient  to   define  the  algebra   13  

HunEngton’s  Basic  Postulates   5a.  

x  *  0    =  0  

5b.  

x  +  1  =  1  

8a.  

x  *  x’  =0  

8b.  

x  +  x’  =  1  

10a.  

x  *  y  =  y  *  x  

10b.  

x  +  y  =  y  +  x  

12a.  

x  *  (y  +  z)  =  x  *  y  +  x  *  z  

12b.  

x  +  y  *  z  =  (x  +  y)  *  (x  +  z)  

DominaEon  

CommutaEve  

DistribuEve  

14  

Principle  of  Duality   •  Why  are  the  basic  postulates  listed  in  pairs  (e.g.  5a,  5b?)     •  The  Dual  of  any  statement  in  Boolean  algebra  is  a  statement  obtained  from  the   original  one  by  interchanging  operands   +  and   * ,  and  their  idenEty   elements   0  and   1

•  The  polarity  of  the  variables  are  unchanged   •  Example:   –  If  S  =  AB  +  AC  +  B C  then  Sd  =  (A+B)(A+C)(B +C)  

•  Theorem:  Dual  of  any  theorem  in  Boolean  algebra  is  also  a  theorem   –  If  any  statement  is  a  consequence  of  axioms  of  Boolean  algebra,  then  dual  is  also  a   consequence  of  those  axioms.  Duals  can  be  proven  by  using  duals  of  each  step  of   proof  of  original  statement   •  Note:  In  general        S          �=            S        d        .  Also,  in  general  Sd    is  not  a  negaEon  of  S.   15  

Examples  of  Principle  of  Duality   •  Write  the  dual  of  each  of  the  Boolean  equaEons:   –  a)  (A  *  1)  *  (0  +  A )  =  0   •  SoluEon:  To  obtain  the  dual  equaEon,  interchange   +  and   * ,  and  interchange   0  and   1 .          (A  +  0)  +  (1  *  A )  =  1  

–  b)  A  +  A B  =  A  +  B   •  SoluEon:  First  write  equaEon  using   *  to  obtain  A  +  (A  *  B)  =  A  +  B.  Then  dual  is  A  *  (A  +  B)  =   A  *  B,  which  can  be  wriien  as  A(A  +  B)  =  AB  

•  Use  of  brackets   –  When  no  brackets  used,  then  the  precedence  of  operaEons  is:   •  NOT  ( )  –  highest  priority   •  AND  (*)   •  OR  (+)  –  lowest  priority  

–  When  brackets  are  used,  then  operaEons  in  brackets  have  the  highest  priority   •  The  most  inner  brackets  is  executed  first   16  

•  The  textbook  lists  17  properFes  in  SecFon  2.5   •  learn  them  well,  they  are  very  useful    !  

Boolean  Axioms   1a.  

  0  *  0  =  0    

1b.   1  +  1  =  1   2a.   1  *  1  =  1  

Single  Variable   Theorems   5a.   x  *  0  =  0   5b.   x  +  1  =  1   6a.   x  *  1  =  x   6b.   x  +  0  =  x  

2b.   0  +  0  =  0  

7a.   x  *  x  =  x  

3a.   0  *  1  =  1  *  0  =  0  

7b.   x  +  x  =  x  

3b.   1  +  0  =  0  +  1  =  1  

8a.   x  *  x’  =  0  

4a.   If  x  =  0,  then  x’  =  1  

8b.   x  +  x’  =  1  

4b.   If  x  =  1  then  x’  =  0  

9.  

x’’  =  x   17  

Two  and  Three  Variable  ProperEes   10a.   10b.   11a.   11b.   12a.   12b.   13a.   13b.  

x  *  y  =  y  *  x   x  +  y  =  y  +  x   x  *  (y  *  z)  =  (x  *  y)  *z   x  +  (y  +  z)  =  (x  +  y)  +  z   x  *  (y  +  z)  =  x  *  y  +  x  *  z   x  +  y  *  z  =  (x  +  y)  *  (x  +  z)   x  +  x  *  y  =  x   x  *  (x  +  y)  =  x  

CommutaEve   AssociaEve   DistribuEve   AbsorpEon  

18  

Two  and  Three  Variable  ProperEes   14a.   x  *  y  +  x  *  y’  =    x   14b.   (x  +  y)  *  (x  +  y’)  =  x   15a.   (x  *  y  )’  =  x’  +  y’   15b.   16a.   16b.   17a.   17b.  

(x  +  y)’  =  x’  *  y’   x  +  x’  *  y  =  x  +  y   x  *  (x’  +  y)  =  x  *  y   x  *  y  +  y  *  z  +  x’  *  z  =  x  *  y  +  x’  *  z   (x  +  y)  *  (y  +  z)  *  (x’+z)  =  (x  +  y)  *  (x’  +z)  

Combining   DeMorgan’s   Theorem  

Consensus  

19  

ComplementaEon   De  Morgan’s  Theorem    (x  *  y)’  =  x’  +  y’              

 

 (x  +  y)’  =  x’  *  y’  

The  complement  !F  of  a  funcEon  F  is  obtained  by  changing       –  –  –  –  – 

True  variables      by      complemented  variables   Complemented  variables  by  true  variables   Boolean  constants    0,  1  by    1,  0    respecEvely   Operator  “•“  by    “+“     Operator  “+“  by    “•“  

  EXAMPLE:                                                            

 

 F  =  A  B    +    !C      !F  =  (!A  +  !B)  •  C  

20  

Examples   • 

Prove:                    (x       1

+ x3 ) · (x¯1 + x¯3 ) = x1 · x¯3 + x¯1 · x3

21  

f (x1 , x2 , x3 ) = x1 · x¯3 + x¯2 · x¯3 + x1 · x3 + x¯2 · x3 = x¯1 · x¯2 + x1 · x2 + x1 · x¯2

(1) (2)

22  

Venn  Diagrams   •  Visual  aid     •  Venn  diagrams  provide  a   good  intuiEve   understanding  of  how   logic  expressions  may  be   equivalent  

(a) Constant 1  

(b) Constant 0  

x   x  

x   x  

(c) Variable x     x  

y  

(e) x  ⋅  y     x  

y  

(g) x  ⋅  y    

(d) x     x  

y  

(f) x   +   y     x  

y   z  

(h)  x⋅  y  +  z     23  

Synthesis  using  AND/OR/NOT   •  Create  a  product  term  that  has  a  value  of  1   for  each  valuaEon  for  which  the  output   funcEon  f  has  to  be  1.     –  Take  the  logical  sum  of  these  product  terms  to   realize  f.   x 0 0 1 1

y 0 1 0 1

f 0 1 1 0

x y

f(x,y) =

x y

f 24  

Synthesis  of  Logic  FuncEons   •  We  will  now  develop  a  formal  synthesis   method     •  Minterms   –  A  product  term  in  which  each  of  the  n  variables   appears  once    

•  Maxterm   –  The  complement  of  minterms   •  Use  De  Morgans  theorem   25  

Three-­‐variable  minterms  and  maxterms.   26  

Sum-­‐of-­‐Products  Form   •  A  funcEon  f  can  be  represented  by  an   expression  that  is  a  sum  of  minterms  (products)   –  Each  minterm  is  ANDed  with  the  value  of  f  for  the   corresponding  valuaEon  of  the  input  variable  

•  If  each  product  term  is  a  minterm  à  canonical   sum-­‐of-­‐products  form   •  SOP  or  canonical  SOP  are  not  necessarily   minimal  implementaEons    

f  =  m0  *  1  +  m1  *  1  +  m2  *  0  +  m3  *  1        =  m0  +  m1  +  m3        =  x1’x2’  +  x1’x2  +  x1x2   27  

28  

Product-­‐of-­‐Sums  Form   •  • 

Dual  of  sum-­‐of-­‐products   f  ’  can  be  represented  by  sum  of  minterms  for  which  f  ’  =  1  à  rows  where  f  =  0   –  Then  take  complement  to  find  a  representaEon  of  f  

 

29  

   

x2

 

f

    x  1   x3

 

(a) A minimal sum-of-products realization

    x  3   x1

 

f

   

x2

 

(b) A minimal product-of-sums realization

In  general,  the  cost  of  the  SOP  and  POS  forms  are  NOT  equal  !!  

30  

Synthesis  using  NAND  /  NOR   Gates   A B Z

A B Z

0 0 1

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 0

NOR

NAND

NAND  /  NOR  gates  are  simpler  to  realize  in  CMOS  technology  than  AND/OR  gates   (we  will  see  this  in  the  next  topic)   31  

x 1     x 2    

x 1    

x 1     x 2    

x 2     (a)   x 1   x   2     =

x 1     x 2    

  x 1    +  x 2    

x 1    

x 1     x 2    

x 2     (b)   x 1    +

 x 2     =   x 1   x   2    

DeMorgan’s  theorem  in  terms  of  logic  gates.   32  

        x3     x4     x5     x1 x2

        x3     x4     x5     x1 x2

        x3     x4     x5     x1 x2

NAND-­‐NAND  network   Using  NAND  gates  to  implement  a  sum-­‐of-­‐products.  

33  

x 1    

x 1    

x 3    

x 3    

x 5    

x 5    

x 2     x 4    

x 2     x 4    

x 1     x 2     x 3     x 4     x 5    

NOR-­‐NOR  network   Using  NOR  gates  to  implement  a  product-­‐of  sums.  

34  

x1       x2      

f  

x3     (a) POS implementation  

x1       x2      

f  

x3       (b) NOR implementation   35  

x1       f  

x2       x3     (a) SOP implementation  

x1       f  

x2       x3       (b) NAND implementation  

36  

Examples   •  The  textbook  has  several  other  examples  in   Chapter  2,  it  is  worthwhile  to  go  over  them   •  SecEons  2.8  and  2.12  have  some  more  useful   examples  

37  

Logic  MinimizaEon   •  This  sub-­‐topic  covers  parts  of  Chapter  4  of  the   textbook  (4.1  –  4.5,  4.8,  4.9,  4.11)   •  We  will  come  back  and  cover  4.6  and  4.7   when  we  look  at  combinaEonal  circuits  

38  

Logic  MinimizaEon   •  It  is  easy  to  find  the  canonical  SOP  or  POS  form  of   a  logic  funcEon   •  Finding  minimal  realizaEons  not  so   straighporward   –  Boolean  algebra  transformaEon  can  be  tedious  and   are  impracEcal  for  funcEons  with  a  large  number  of   input  varables  

•  We  will  study  opEmizaEon  techniques   –  Karnaugh  map   –  Tabular  method  (more  suitable  for  CAD  tools)   39  

Karnaugh  Map   •  Key  idea  in  minimizaEon  is  to  reduce  the   number  of  product  (or  sum)  terms,  and  the   number  of  variables  in  each  term.   •  Karnaugh  map  is  a  graphical  technique  that   makes  it  easy  to  use  the  combining  property:     14a.      x  *  y  +  x  *  y’  =    x   14b.      (x  +  y)  *  (x  +  y’)  =  x   40  

41  

Two-­‐Variable  Map   x1     x2     0   0  

m0    

0   1  

m1    

1   0  

m2    

1   1  

m3    

(a) Truth table  

x   x2     1  

0  

1  

0   m0     m2     1   m1     m3    

(b) Karnaugh map  

LocaEon  of  two-­‐variable  minterms.   42  

x2

f  =  x1’x2’  +  x1’x2  +  x1x2  

x1 1

0

1

0

1

0

1

1

1

f = x2 + x1

•   If  a  variable  is  included  in  all  its  possible  values  in  a  grouping,  then  it  can  be  removed   •   Find  the  smallest  number  of  product  terms  that  cover  the  funcEon   •   Draw  the  largest  possible  rectangular  groupings   •   cost  of  each  of  the  product  terms  should  be  as  low  as  possible   •   Two  variable  map  à  can  have  groups  of  1,  2  or  4  minterms   •   group  of  1:  2  literals  in  the  product  term   •   group  of  2:  1  literal   •   group  of  4:  0  literals  (the  trivial  funcEon  f  =  1)    

43  

Three-­‐Variable  Map   x1 x2 x3 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0

m0 m1 m2

1 1 1

m7

m3 m4 m5 m6

(a) Truth table

x3

x1 x 2 00

01

11

10

0

m0

m2

m6

m4

1

m1

m3

m7

m5

(b) Karnaugh map •   Label  with  Gray  Code   •   Columns  1  and  4  differ  only  in  x1  à  adjacent   •   Groups  of  1,  2,  4,  (8)   44  

x1    x2    

x3    

00  

01  

11  

10  

0  

0  

0  

1  

1  

1  

1  

0  

0  

1  

00  

01  

11  

10  

0  

1  

1  

1  

1  

1  

0  

0  

0  

1  

f   =   x1    x3    +  x2    x3    

x1    x2    

x3    

f   =   x3    +   x1    x2    

45  

Four-­‐Variable  Map  

x3 x 4

x3

x1 x2 00

01

11

10

00 m0

m4 m12 m8

01 m1

m5 m13 m9

11 m3

m7 m15 m11

m2

m6 m14 m10

10 •   Groups  of  1,  2,  4,  8,  (16)   •     4,  3,  2,  1,  (0)  literals  

x1

x2

x4

46  

x1  x   2     x3  x   4     00   01   11  

10  

x1  x   2     x3  x   4     00   01   11  

10  

00   0  

0  

0  

0  

00   0  

0  

0  

0  

01   0  

0  

1  

1  

01   0  

0  

1  

1  

11   1  

0  

0  

1  

11   1  

1  

1  

1  

10  

0  

0  

1  

10  

1  

1  

1  

1  

f 1    =  x2  x   3    + x   1  x   3  x   4     x1  x   2     x3  x   4     00   01   11  

10  

1  

f 2    =  x3    + x   1  x   4     x1  x   2     x3  x   4     00   01   11  

10  

00   1  

0  

0  

1  

00   1  

1  

1  

0  

01   0  

0  

0  

0  

01   1  

1  

1  

0  

11   1  

1  

1  

0  

11   0  

0  

1  

1  

10  

1  

0  

1  

10  

0  

1  

1  

1  

f 3    =  x2  x   4    + x   1  x   3    + x   2  x   3  x   4    

0  

x1  x   2     f 4    =  x1  x   3    + x   1  x   3    +   or   x2  x   3     47  

Five-­‐Variable  Map   x 3 x4

x1 x2 00

01

11

10

00

x3 x4

x1 x 2 00

01

11

00

01

1

1

1

01

1

11

1

1

11

1

1

10

1

1

10

1

1

x5 = 0

10

1

x5 = 1

f 1 = x1 x3 + x1 x3 x4 + x 1 x2 x3 x 5 48  

MinimizaEon  Strategy   Terminology   •  Literal:    Each  appearance  of  a  variable  either  in  true  or  complemented  form   –  e.g.  x1x2’x3  has  3  literals   –  x1’x3x4’x6  has  4  literals  

•  Implicant:    A  product  term  that  indicates  the  input  valuaEon(s)  for  which  a   given  funcEon  f  is  equal  to  1  is  called  an  implicant  of  f.   –  Example  :  the  minterms  are  the  most  basic  implicants  (that  consist  of  n  literals)  

 

x3

x1 x 2 00

01

11

10

0

1

1

0

0

1

1

1

1

0

x1

x2 x3

11  possible  implicants  

49  

Terminology   •  Prime  Implicant:  An  implicant  is  called  a  prime  implicant  if  it  cannot  be   combined  into  another  implicant  that  has  fewer  literals.   –  i.e.  if  you  delete  a  literal  in  a  prime  implicant,  it  is  no  longer  a  valid  implicant   –  Karnaugh  map  is  one  way  to  find  the  prime  implicants  (the  largest  groupings)    

x3

x1 x 2 00

01

11

10

0

1

1

0

0

1

1

1

1

0

x1

x2 x3

x1’  and  x2x3  are  prime  implicants     x1’x3  is  not  a  prime  implicant  (e.g.   you  can  delete  x3)  

50  

Terminology   •  A  cover  is  a  collecEon  of  implicants  that  account  for  all  valuaEons  for   which  a  given  funcEon  is  equal  to  1.   •  Most  funcEons  have  a  number  of  different  covers   –  E.g.  Set  of  all  minterms  for  which  f  =  1  is  a  cover   –  E.g.  Set  of  all  prime  implicants  is  a  cover  

•  Want  to  choose  a  cover  that  has  the  lowest  cost   –  #  gates  +  total  #  of  inputs  to  all  gates   –  Assume  primary  inputs  are  available  in  both  true  and  complemented  form  at   zero  cost   –  If  an  inversion  is  needed  inside  the  circuit,  the  corresponding  NOT  gate  and  its   input  is  included  in  the  cost   51  

MinimizaEon  Procedure   •  Find  the  minimum-­‐cost  subset  of  the  prime   implicants  that  will  cover  the  funcEon   –  Some  may  have  to  be  included    (essen3al  prime   implicants)  while  for  others  there  may  be  a  choice   –  To  choose  which  of  the  non-­‐essenEal  prime   implicants  to  include  in  the  cover  we  usually  use  a   heurisEc   •  A  heurisEc  does  not  consider  ALL  the  possibiliEes,  but   results  in  a  good  result  most  of  the  Eme   •  CAD  tools  make  use  of  many  heurisEcs   52  

x3 x4

f  (  x1,…,  x4)  =  Σ  m(2,  3,  5,  6,  7,  10,  11,  13,  14)    

x 1 x2 00

01

11

10

00

x 1 x2 x4

01

1

11

1

1

10

1

1

x1 x3

x2 x3 x4

1 1 1

1

x3 x4

x2 x 3 •   5  prime  implicants   •   EssenEal  prime  implicants    (include  a  minterm  only  covered  by  one  PI)   •   m7  not  covered  by  the  essenEal  prime  implicants   •   m7  can  be  covered  by  either  x1’x3  or  x1’x2x4.  Choose  x1’x3  because  of   lower  cost.   53  

MinimizaEon  Procedure   1.  Generate  the  set  of  prime  implicants  for  f   2.  Find  the  set  of  essenEal  prime  implicants   3.  If  the  set  of  essenEal  prime  implicants  covers  f  then   choose  this  set.  Otherwise  determine  the   nonessenEal  prime  implicants  that  should  be  added   to  for  a  complete  minimum-­‐cost  cover   •  A  heurisEc:  select  one  non-­‐essenEal  prime  implicant  in   the  cover  and  find  the  rest  of  the  cover.   •  Next,  assume  it  is  not  in  the  cover  and  find  another   cover.  Choose  the  cover  with  the  lowest  cost.   54  

f    (  x1,…,  x4)  =    Σ  m(0,  4,  8,  10,  11,  12,  13,  15)     Only  x3’x4’  is  essenEal  –  include  in  cover  

x3 x4

x x2 1

00 00

1

01 1

11 1

01

1

11

1

10

10 1

x3 x4 x1 x2 x3

1

x1 x2 x4 x1 x3 x4

1

x 1 x2 x 3

x1 x 2 x4 One  choice  (include  x1x2x3’):  f  =  x3’x4’  +  x1x2x3’  +  x1x3x4  +  x1x2’x3    

Another  choice  (do  not  include  x1x2x3’):  f  =  x3’x4’  +  x1x2x4  +  x1x2’x3    (lower  cost)  

55  

x  1 x   2    

x 3   x   4    

00  

00  

01  

1  

1  

11  

x 1   x   3   x   4    

1  

01  

x 2   x   3   x   4    

1   1  

11   10  

10  

1  

1  

x 1   x   3   x   4    

1   x 2   x   3   x   4    

x 1   x   2   x   4    

x1   x   2   x   4     x 1   x   2   x   3    

x 1   x   2   x   3    

•   f  (  x1,…,  x4)  =  Σ  m(0,  2,  4,  5,  10,  11,  13,  15)   •   All  prime  implicants  are  non-­‐essenEal   •   Choose  any  prime  implicant  and  then  exclude  it  –  both  alternaEves  (blue           and  black  sets  of  prime  implicants)  are  of  equal  cost  in  this  example  

56  

MinimizaEon  of  POS  Forms   •  CAD  tools   usually   synthesize  both   the  SOP  and  POS   forms  and  select   the  one  with  the   lowest  cost  

f  (x1,  x2,  x3)  =  Π  M(4,  5,  6)                                            =  (x1’  +  x2)(x1’  +  x3)  

x3

x1 x 2 00

01

11

10

0

1

1

0

0

1

1

1

1

0

( x1 + x 3 )

( x1 + x2 )

57  

Incompletely  Specified  FuncEons   x   x   x 3   x   4     1   2   00  

01  

11  

10  

00  

0  

1  

d  

0  

01  

0  

1  

d  

0  

11  

0  

0  

d  

0  

10  

1  

1  

d  

1  

x 2  x   3     x 3  x   4    

10  

00   0  

1  

d  

0  

01   0  

1  

d  

0  

11  

0  

0  

d  

0  

10  

1  

1  

d  

1  

–  “Don’t-­‐care”  condiEon  

•  Can  assign  the  funcEon  value  to   give  the  lowest  cost  circuit  

–  (can  make  different  choices  for  the   SOP  and  POS  forms)  

(a) SOP implementation  

x  x   x3  x  4     1  2   00   01   11  

•  Certain  input  combinaEons  many   be  known  to  never  happen  

( x  2    + x   3  )     ( x  3    + x   4  )    

(b) POS implementation  

f  (  x1,…,  x4)  =    Σ  m(2,  4,  5,  6,  10)  +  D(12,  13,  14,  15)  

58  

MulEple-­‐Output  Circuits   x2     x3     x4    

•  SomeEmes,  circuits  share   some  of  the  same  logic  gates   and  can  be  combined    

x1     x3     x1     x3    

•  One  strategy:  find  minimum-­‐ cost  realizaEon  of  f1  and  f2  and   the  share  the  common   product  terms   x   x   x 3    x 4     1   2   00  

00  

01  

01  

11   1  

10   1  

1  

1  

1  

11  

1  

1  

10  

1  

1  

(a) Function  

f  1  

f 1    

(c) Combined circuit for   f 1    and  f 2    

x   x   x 3    x 4     1   2   00  

f 2    

x2     x3     x4    

00  

01  

01   11  

1  

1  

10  

1  

1  

(b) Function  

11   1  

10   1  

1  

1  

1   f  2  

59  

                                                           

x3 x4

00

01

00 01

1

1

11

1

1

10

1

11

x1 x2

00

01

00 01

1

1

11

1

1

10

1

                                           

x1 x4 x1 x2 x4 x1 x2 x3 x4 x2 x4

00

01

00

1

11

                                     

x1 x2

x3 x4

10

1

(a) Optimal realization of f x3 x4

                                                                       

                                     

x1 x2

01

1

11

1

10

1

11

10

1

1

1

1

(b) Optimal realization of

3

x1 x2

x3 x4

10

00

01

00

1 1

01

1

11

1

10

(c) Optimal realization of f

3

and

f

4

together

 

1

f

f

Cost  =  29    (no  sharing)  

f4

11

10

1

1

1

1

Cost  =  23    (sharing)  

    3

    4

           

(d) Combined circuit for f

3

and

f

4

60  

 Another  strategy:  finding  opEmal  realizaEons  of  f3  and  f4  independently  is  not  a  good  idea  in  this  case  

Cubical  RepresentaEon   •  Karnaugh  map  is  only  useful  for  minimizing  funcEons   of  a  small  number  of  variables   •  We  will  study  more  a  systemaEc  algebraic  opEmizaEon   technique   •  There  are  many  techniques  based  on  cubical   representa3on   –  Truth  table   –  Algebraic  expression   –  Venn  Diagram   –  Karnaugh  map   –  Cubical  representaEon  

•  Cubical  representaEon  is  used  in  modern  CAD  tools   61  

2-­‐Cube   •  •  • 

Map  a  funcEon  of  n  variables  onto  an  n-­‐ dimensional  cube  (n-­‐cube)   An  edge  joins  two  verEces  for  which  the   labels  differ  in  the  value  of  only  one  variable   Finding  edges  for  which  f  =  1  is  equivalent   to  applying  the  combining  property  (14a)   –  Same  as  finding  pairs  of  adjacent  cells  for  which   f  =  1  in  a  Karnaugh  map  

• 

f  =  {1x,  x1}  à  f  =  x1  +  x2  

01   x2    

x1  

11  

1x   x1    

00  

10  

x1     x2    

f  

0   0   1   1  

0   1   1   1  

0   1   0   1  

f  (x1,  x2)  =  Σ  m(1,  2,  3).   62  

3-­‐Cube   f  =  {xx0,  10x}  =  x3’  +  x1x2’  is  least-­‐expensive  

f    (x1,  x2,  x3)  =  Σ  m(0,  2,  4,  5,  6)  

Some  possible  representaEons:     f  =  {000,010,100,101,110}        =  {0x0,  1x0,  101}        =  {x00,x10,101}          =  {x00,x10,10x}        =  {xx0,10x}      

63  

4-­‐Cube  

64  

n-­‐cube   •  It  is  impracEcal  to  draw  a  cube  of  more  than  4-­‐ dimensions,  but  it  is  easy  to  extend  the  concept  to  n-­‐ dimensions.   •  n-­‐cubes  contain  lower  dimensional  cubes  (which   contain  lower  dimensional  cubes…)   •  2k  adjacent  verEces  –  k-­‐cube   –  Vertex:  0-­‐cube   –  Edge:  1-­‐cube   –  Side:  2-­‐cube   –  etc…  

•  The  largest  possible  k-­‐cubes  that  exist  for  a  given   funcEon  are  its  prime  implicants  !   65  

Quine-­‐McCluskey  Method   •  A  tabular  method  based  on  cubical   representaEon   •  The  tabular  form  is  more  suited  to   implementaEon  in  a  computer  algorithm   •  Two-­‐steps   1.  GeneraEon  of  Prime  Implicants   2.  DeterminaEon  of  a  Minimum  Cover  

66  

GeneraEon  of  Prime  Implicants   •  Prime  Implicants  are  the  largest  possible  k-­‐cubes  for   which  either  f  =  1  or  f  is  unspecified  (don’t-­‐care)   •  Assume  f  and  it’s  don’t-­‐cares  are  specified  as  minterms     –  Write  down  the  verEces  of  f  

•  Key  idea:  compare  verEces  in  pairwise  fashion  to  see  if   they  can  be  combined  into  larger  cubes  

–  Then  see  if  these  cubes  can  be  combined  into  larger  cubes,   etc…keep  going  unEl  you  find  the  prime  implicants  

•  Two  cubes  that  are  idenEcal  in  all  variables   (coordinates)  except  one,  for  which  one  cube  has  the   value  0  and  the  other  has  1,  then  these  cubes  can  be   combined  into  a  larger  cube.  

67  

Example  1   •  f(x1,x2,x3,x4)  =  {1000,1001,1010,1011}   •  Cubes  1000  and  1001  differ  only  in  one   variable  (x4)   –  Combine  into  new  cube  100x  

•  Cubes  1010  and  1011  can  be  combined  into   101x   •  Combine  100x  and  101x  into  10xx   •  f  =  x1x2’   68  

Example  2   •   Group  the  minterms  such  that  the  cubes  in  each  group  have  the   same  number  of  1s  and  sort  the  groups  by  the  number  of  1s   •   Only  need  to  compare  each  cube  in  a  group  with  all  the  cubes  in  the   immediately  preceding  group   •   Place  a  check  if  a  (k-­‐1)-­‐cube  is  included  in  a  k  cube  

List 1(0-­‐cubes)   0

0 0 0 0

4 8

0 1 0 0 1 0 0 0

10 12

1 0 1 0 1 1 0 0

11 13

1 0 1 1 1 1 0 1

15

1 1 1 1

List 2  (1-­‐cubes)   0,4 0,8

0 x 0 0 x 0 0 0

8,10 4,12 8,12

1 0 x 0 x 1 0 0 1 x 0 0

10,11 12,13

1 0 1 x 1 1 0 x

11,15 13,15

1 x 1 1 1 1 x 1

f  (  x1,…,  x4)  =    Σ  m(0,4,8,10,11,12,13,15)  

List 3(2-­‐cubes)   0,4,8,12

x x 0 0

The  cubes  without  a  check   are  the  prime  implicants  of  f     P  =  {10x0,  101x,  110x,  1x11,                  11x1,  xx00}          =  {p1,p2,p3,p4,p5,p6}  

69  

DeterminaEon  of  a  Minimum  Cover   •  Find  a  minimum-­‐cost  cover  for  f   •  Assume  that  the  cost  is  directly  proporEonal  to  the  number  of   inputs  to  all  gates     –  i.e.  the  number  of  literals  in  the  prime  implicants  

•  Construct  a  prime-­‐implicant  cover  table  

–  A  row  for  each  prime  implicant   –  A  column  for  each  minterm  to  be  covered   –  Put  checks  to  indicate  the  minterms  covered  by  each  prime  implicant  

•  If  there  is  a  single  check  in  some  column,  then  the  prime  implicant   that  covers  the  minterm  of  this  column  is  essen?al  and  it  must  be   included  in  the  final  cover  

–  Remove  the  rows  corresponding  to  the  essenEal  prime  implicants  and   the  columns  of  the  minterms  associated  with  them  

70  

Prime   implicant   p 1    

Minterm   0   4   8   10   11   12   13   15  

1   0   x   0  

p 2    

1   0   1   x  

p 4    

1   x   1   1  

p 3     p 5     p 6    

1   1   0   x   1   1   x   1   x   x   0   0   Initial prime implicant cover table  

Prime   implicant   p 1    

Minterm   10   11   13   15  

p 2     p 3     p 4     p 5     After the removal of essential prime implicants   71  

Row-­‐Dominance   • 

p1  only  covers  minterm  10  while  p2   covers  both  minterm  10  and  minterm   11   –  p2  dominates  p1   –  Cost  of  p2  is  the  same  as  p1  therefore   choose  p2  rather  than  p1  and  remove  p1   from  the  table  

•  • 

•  •  • 

p5  dominates  p3   –  Remove  p3  

Must  choose  p2  to  cover  minterm  10   and  p5  to  cover  minterm  13  which   takes  care  of  covering  minterm  11  and   minterm  15   Final  cover  is  C  =  {p2,p5,p6}  =  {101x, 11x1,xx00}     f  =  x1x2’x3  +  x1x2x4  +  x3’x4   Do  not  remove  a  dominated  row  if  the   cost  of  its  prime  implicant  is  less  than   that  of  the  dominaEng  row’s  prime   implicant  

Prime   implicant   p 1    

Minterm   10   11   13   15  

p 2     p 3     p 4     p 5    

Prime   implicant  

Minterm   10   11   13   15  

p 2     p 4     p 5     After the removal of dominated rows   72  

Example  3  –  Column  Dominance   •  f  (  x1,…,  x4)  =    Σ  m(0,2,5,6,7,8,9,13)  +  D(1,12,15)   •  P  =  {00x0,0x10,011x,x00x,xx01,1x0x,x1x1}  =  {p1,p2,p3,p4,p5,p6,p7}   •  Do  not  include  don’t  care  minterms  in  the  prime  implicant  cover  table    since   they  don’t  need  to  be  covered   List 1

List 2

0

0 0 0 0

1 2 8

0 0 0 1 0 0 1 0 1 0 0 0

5 6 9 12

0 0 1 1

7 13

0 1 1 1 1 1 0 1

15

1 1 1 1

1 1 0 1

0 1 0 0

1 0 1 0

List 3

0,1 0,2 0,8

0 0 0 x 0 0 x 0 x 0 0 0

1,5 2,6 1,9 8,9 8,12

0 0 x 1 1

x x 0 0 x

0 1 0 0 0

1 0 1 x 0

5,7 6,7 5,13 9,13 12,13

0 0 x 1 1

1 1 1 x 1

x 1 0 0 0

1 x 1 1 x

7,15 13,15

x 1 1 1 1 1 x 1

0,1,8,9

x 0 0 x

1,5,9,13 8,9,12,13

x x 0 1 1 x 0 x

5,7,13,15

x 1 x 1

73  

                           

    0   0   x   0   0   x   1   0   0   1   1   x   x   0   0   x   x   x   0   1   1   x   0   x   x   1   x   1  

Prime implicant

p1 p2 p3 p4 p5 p6 p7

0

 

2

 

5

 

     

Minterm 6 7

    0   0   x   0   0   x   1   0   0   1   1   x   x   0   0   x   x   x   0   1   1   x   0   x   x   1   x   1  

Prime implicant

                           

Row  p4  dominates  p6   and  p7  dominates  p5  

0

 

2

 

                       

0

 

2

 

(c) After the removal of rows

 

9

 

 

13

     

Minterm 5 6

7

   

 

p 5 and

8

 

  p     6

•   Column  13  dominates   column  5  

 

     

Minterm 5 6

(b) After the removal of columns 9 and 13 Prime implicant p1 p2 p3 p4 p7

 

•   Remove  the   dominaFng  column  (9)  

(a) Initial prime implicant cover table

p1 p2 p3 p4 p5 p6 p7

8

•   Column  9  dominates   column  8  

7

 

8

 

•   Remove  column  13  

                 

     

Prime implicant p1 p2 p3

Minterm 2 6

   

(d) After including in the cover

      p    

p 4 and

C  =  {p2,p4,p7}          =  {0x10,x00x,x1x1}    

7

f  =  x1’x3x4’  +  x2x3’  +  x2x4  

74  

Example  4   •  No  essenEal  prime   implicants  or  dominaEng   rows  or  columns   •  All  prime  implicants  have   equal  cost   •  Use  branching   –  Choose  any  prime   implicant,  say  p3  and   include  it  in  cover,   compute  rest  of  cover   and  its  cost   –  C1  =  {p1,p3,p4}   –  Now,  find  a  new  cover   excluding  p3  and   compare  costs   –  C2  =  {p1,  p5}  =  Cmin  

75  

Quine-­‐McCluskey  Summary   1.  2.  3.  4. 

5.  6. 

Start  with  list  of  cubes  that  represent  minterms  where  f  =  1  or  don’t  care.   Generate  the  prime  implicants  by  successive  pairwise  comparisons  of  the   cubes.   Derive  a  cover  table  which  indicates  minterms  where  f  =  1  that  are   covered  by  each  prime  implicant.   Include  the  essenEal  prime  implicants  (if  any)  in  the  final  cover  and  reduce   the  table  by  removing  both  these  prime  implicants  and  the  covered   minterms.   Use  the  concept  of  row  and  column  dominance  to  reduce  the  table   further.  A  dominated  row  is  only  removed  if  the  cost  of  its  prime  implicant   is  greater  than  or  equal  to  the  cost  of  the  dominaEng  row’s  prime   implicant.   Repeat  steps  3  and  4  unEl  the  cover  table  is  empty  or  no  further  reducEon   of  the  table  is  possible.   If  the  reduced  cover  table  is  not  empty,  then  use  the  branching  approach   to  determine  the  remaining  prime  implicants  that  should  be  included  in  a   minimum  cost  cover.   76  

PracEcal  LimitaEons  of  Quine-­‐ McCluskey   •  FuncEons  are  seldom  defined  in  the  form  of   minterms,  the  are  usually  given  as  algebraic   expressions  or  sets  of  cubes   –  List  of  minterms  may  be  very  large  

•  Many  comparisons   –  Slow  

•  Cover  table  is  computaEonally  expensive  

77