Rochester Institute of Technology
RIT Scholar Works
Theses
Thesis/Dissertation Collections
2-5-1987
An expert system to optimize combinational logic
Gu-Ching Lin
Follow this and additional works at:
http://scholarworks.rit.edu/theses
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact
.
Recommended Citation
Rochester Institute of Technology
School of Computer Science and Technology
An Expert System To Optimize Combinational Logic
by
Gu-Ching Lin
A thesis, submitted to
The Faculty of the School of Computer Science and Technology;
in partial fulfillment of the requirements for the degree of
Master of Science in Computer Science
Approved by:
John L. Ellis
Professor John L. Ellis (Chairman)
John A. Biles
Professor John A. Biles
George A. Brown
Title of Thesis:
An
Expert System To Optimize Canbinational Logic
---~--~~---~---~--I
Gu~gLin
°-
prefer to
be
contacted each time a request for
reproduction is made.
I can
be
reached at the following address:
ABSTRACT
Twenty
to
fifty
percent of the active area of most semicustomintegrated
circuitsis
devoted to
combinational logic.Automating
the synthesis and optimization of combinational circuitry can
result
in
significantimprovements
in
both
the design cycle timeand the overall area of the
implementation.
This thesis presentsa rule-based system
that
optimizes combinationallogic
for
agiven
technology.
By
performing
Booleanfunction
minimization,decomposition,
logic
synthesis and a series of localtransformations4,
the system achieves area reductions and saves1.
Introduction
andBackground
1.1 Problem Statement
1.2 Previous Work
1.3 System Approach
2. Knowledge-Based
Expert
Systems2.1 Productions Systems
2.2
Applicability
of Knowledge-based System to LogicOptimization
2.3 Advantages and Disadvantages of Knowledge-Based Expert
Systems
3. System Implementation
3.1 Minimization
3.2 Decomposition
3.3 Synthesis
3.4 Optimization
3.4.1 Knowledge Base
3.4.2 Control Structure
3.5 Program Ogranization
3.6 Input and Output
4. Conclusions and Future Work
Appendix A. User's Manual
Appendix B. Example
Appendix C. Rule Base
Bibliography
1. Introduction and
Background
Optimization of combinatorial
logic
is
alengthy
anddifficult task
for
circuitdesigners.
Since a significantpercentage of most chips consists of combinatorial
logic,
this
optimization can take much
effort,
increasing
the overallturnaround
time
ofthe
design.
In addition, when anexisting
design
is
convertedfrom
onetechnology
to
another, circuitdesigners
have
to
reoptimize theexisting
implementation to
takefull advantage of the
target
technology. Often this optimizationis
not even performed,resulting
in unnecessarily
large and slowchips.
This thesis presents a rule-based expert system that
optimizes combinational
logic
for a specific target technology.The system consists of four modules, the minimization, decompos
ition,
and synthesis module are used to generate a minimized,multilevel netlist
describing
the targettechnology
foroptimization module, which performs subsitiutions of equivalent
gate configurations,
thereby
reducing
the overall area of theimplementation and
improving
the speed of the design.1.1 Problem Statement
One concept of automated logic
design
is
the conversionof a functional description
to
alogic
implementation.
While such(data
flow
design,
controllogic
design,
physicallayout,
etc.),
the
thesis
focus
here
is
on methodsprimarily
applicable tologic
optimization.
Current
techniques
for
automaticdesign
of controllogic
fall
into
twobroad
categories. Thefirst,
which we referto
astwo-level
design,
is
characterizedby
the use of a two-leveldisjunctive
form(DF)
as anintermediate
stagein
synthesis.Roughly
speaking,these
techniques
produce atwo-level
representation
for
afunction
whichis
to beimplemented
andminimize or optimize
it
further.
Theresulting
representationis
then factored
into
a network ofgates,
transistors,
PLA's orother functional units. The
key
observationconcerning
this styleof
design
is
that thereis
anintermediate
stage at which allinformation
about possible algorithms which might have beencontained
in
the original specification of the functionis
discarded.
Only
information
about the function to be computedis
retained.
This approach to automatic
design
has severaladvantages.
First,
minimization of the DF corresponds to anoptimization
in
the space of all algorithms for the givenfunction. This method therefore has the potential to uncover
extremely clever ways to
implement
thefunction
whichmay
havebeen
overlookedby
the designer.Second,
thereis
a firmtheoretical foundation underlying this methodology. There has
of this
theory
relates to atwo-level
representation. Forexample,
there are well understood techniquesfor
taking
advantage of "don't care"
information
during
minimization.There are also problems with
the
use oftwo-level
minimization
in
the automatic generation oflogic.
Truetwo-level
minimization algorithms require exponential
time;
however,
recently
a techniquehas
been
discovered,
ESPRESSO-IIC1,
whichin
actual examples, comes close
to
the
true minimum andhas
anacceptable
running
time. A more seriousdifficulty
is
that theresult of two-level minimization
is
a network of gates withunlimited fan-in. Current technologies have fan-in
limitations,
so the result of Boolean minimization cannot be
directly
realized
in
any
actual technology. The originaldesign
may
have had
implicit
information
aboutthe
sharing
ofintermediate
results which would
be
usefulin altering
the two-level design tomeet
technology
requirements,but,
in
the process ofputting
thedesign
into
DF and minimizing theDF,
thisinformation
has beenlost.
Rediscovering
thisinformation
in
order to construct a goodmultilevel design
is
thefactoring
problem, and currently thereis
a technique known as weakdivision6,
which takes a two-levelfunction and creates a multilevel
function
based on smallsubexpressions.
Thds second
category
of approaches to automatic designis
more closely relatedto
thestrategy
usedin
compilingtype
ofdesign methodology
as compiler-likedesign.
Inthis
type
of
design,
the specificationis
thought
of asboth
adescription
of
the
function
tobe
implemented
and as ahigh-level
description
of an algorithm
for
implementing
it,
andthroughout
thecompilation,
information
concerning
the
implied
algorithmis
retained whenever possible.
This class of
design
methodologies has advantages anddisadvantages,
which are almostcomplementary to
those ofthe
two-level approach. Their
primary
advantageis
thatinformation
implicit
in
the specificationis
retained throughout the designprocess. This permits
the
process to useinsights
which thedesigner
may
haveincluded
in
thedescription
while alsopermitting computational
efficiency
since thefactoring
problemis
largely
avoided.There are several disadvantages to this type of
approach.
First,
since no global optimization (in the sense ofBoolean minimization)
is
performed, theefficiency
of theeventual implementation
is
limited
by
the form of thespecification. For example,
it
is
unlikely
that a compiler-likemethod can accept a specification
for
a carry-chain adder andproduce the implementation of a carry-lookahead adder.
Second,
the available techniques for
dealing
withredundancy
and "don'tcare" are
in
theearly
stages of development.Finally,
thereis
no firm mathematical foundation underlying these approaches
in
1.2
Previous
WorkThe goal of
logic
synthesisis
to
acceptfunctional
specifications
for
ahardware
unit andto
generateautomatically
a
detailed,
technology-specific
implementation
comparablein
quality
tothat
of an experienced engineer. There hasbeen
muchwork on
automating
logic
design
andmany
effective toolshave
been developed to aid the
designer.
Early
work centered ondeveloping
algorithmsfor
translating
aboolean
functioninto
aminimum two-level network of
boolean
primitives14. Latter effortsattempted to raise the
level
of specification15. The resultswere
usually
more expensivethan
manualimplementations
and didnot take advantage of the target technology. For example, the
ALERT16
system was validated on an
existing
design,
the IBM1800,
and the
implementation
produced required 160% more circuits thanthe manual design.
In attempts to generate more efficient logic and to give
the user more control over the
implementation,
other strategieswere
tried;
computer design language simulation and booleantranslation. These constrain the specification language so that
there
is
nearly a one-to-one correspondencebetween
thespecification and the
implementation.
Of course, this constraintRecently,
interest
has
grownsignificantly
in
AIapplications of
digital
systemdesign.
DAS/Logic9(Design
Assistant
Series)
is
atool
being
developed
at CarnegieGroup
Inc. to aid
in
thedesign
ofintegrated
circuits. DAS/Logicis
arule-based system written
in
OPS52which refines a
textual
behavioral
description
to
a circuit schematic. The system'sinput
is
ahigh
level
language
description
ofthe
target
IC'sbehavior;
the output consists of a set of standard cells and an
interconnection
list.
The systemis
separatedinto
four
levels.
The first
level
is
the Behaviorallevel
,which describes theinput/
output behavior of adigital
system. The nextlevel
is
theGeneric Logic level.
Here,
the Behavioral descriptionis
translated
into
alogic
representation. In the thirdlevel,
theCommitted Logic
level,
the Generic Logic representationis
castinto
the appropriate primitive gatesfor
theimplementation
technology. For example, the Generic Logic structure
is
composedof AND and OR gates that correspond to
the
logical
form of theBehavioral description. At the Committed Logic
level,
the AND andOR gate structures are changed
into
NAND or NOR gates. The finallevel
is
the Standard Celllevel,
where the transistor circuitsrequired to
implement
a particularlogic
function are specified.A number of research groups are
currently
exploringknowledge based approaches to various aspects of VLSI. Here we
describe a knowledge based system called
REDESIGN10,
whichaltered
functional
specifications. Giventhe
redesigngoal,
the
system generates plausible
local
changesto
make withinthe
circuit,
ranks the changesbased
onimplementation
difficulty
and goal
satisfaction,
and checksfor
undesirable side effectsassociated with
the
changes. The system providesdesign
assistance
by
combining
casualreasoning,
analyzing
the
cause-effect relations of the circuits operation, with
functional
reasoning, and
analyzing
the purposes or roles of circuitcomponents. Circuit
knowledge
in
REDESIGNis
represented as anetwork of modules and
data
paths. The system wasdeveloped
atRutgers
University
and reached the stage of a research prototype.1.3 System Approach
Automating
the synthesis and optimization ofcombinational circuitry can result
in
significantimprovements
in
both the design cycle time and the overall
quality
of theimplementation. Standard
techniques,
such astwo-level
minimization
tools,
for performinglogic
level
reduction are a majorstep
in
thisdirection,
but
they
fail
to address the actualcircuit-level implementation. Such minimizers will
find
anoptimal implementa-tion
using
AND/OR gate,for
example, butThis
thesis
takes afour
step
approach to the synthesisand optimization problem
for
combinationallogic.
These steps are(Figure
1.1)
:.
minimizing
theBoolean
equations,
.
factoring
thetwo-level
functions
into
multilevelfunctions,
.
synthesizing
aninitial
network,
and.
optimizing the
networkfor
a giventechnology.
During
the minimizationphase,
the set of Booleanequations
describing
thedesired
functions
is
reducedusing
mathematical methods that
take
advantage of the "don't care"set.
The ESPRESSO-IIC program performs the reductions. In the second
phase, the equations are factored
using
a technique known as weakdivision,
which takes a two-level function and creates a multilevel function based on small subexpressions that occur often
in
the original function. This
tool
detects and eliminates multipleoccurrences of the same subexpression, otherwise
it
would resultin
duplicate logicin
the synthesized circuit.In the synthesis phase, an
initial
networkis
createdby
using
a NAND or NORimplementation
for
target technology.Finally,
this networkis
optimized for areaby
performing
aseries of local
transformations4'5
on the circuit. These
transformations are formulated as rules
to
be
applied to the|
BOOLEAN
FUNCTIONj
I
I
|
MINIMIZATION
f^I
I
'1
I
I
ESPRESSO-IIC|
|
DECOMPOSITION|
I
I
j
SYNTHESISI
|
. AND/OR|
.NAND/NOR^
I
I
j
OPTIMIZATION1
I
I
I
|
RULE LIBRARY|
I
I
LOCAL TRANSFORMATION
NAND/NOR GATE
2.
Knowledge-Based
ExpertSystems
In
recentyears,
researchin
the
field
of artificialintelligence
has
had
many
important
successes.Among
the mostsignificant of
these has
been the
development
of powerful newcomputer systems
known
as "expert" or "knowledge-based" systems.These programs are
designed
to represent andapply
factual
knowledge
in
specific areas of expertise to solve problems. Forexample, collaborative efforts
by
human
experts and systemdevelopers
have
resultedin
systemsthat
diagnosediseases,
configure computer
systems,
and prospectfor
minerals atperformance levels equal to or
surpassing
human expertise. Thepotential power of systems
that
can replicate expensive or rarehuman knowledge has led to a worldwide effort to extend and
apply
this technology.
An expert system
essentially
consists of a knowledgebase
and aninference
engine. The knowledgebase
contains factsand rules that use those facts as the basis
for
decision making.The inference engine contains an
interpreter
that decides how toapply
the rules toinfer
new knowledge and a scheduler thatdecides the order
in
which the rules should be applied. Thisorganization
is
shownin
Figure 2.1.FACTS
1"
I
RULES
KNOWLEDGE BASE
(Domain
Knowledge)
I
I
j
INTERPRETER|
I
I
1
I
I
SCHEDULERI
INFERENCE ENGINE
(General
Problem-sovling
Knowledge)
Figure 2. 1 The structure of an expert system
In expert system, knowledge
is
used to slove problem anddetermine new facts based upon what
is
already
known. Theknowledge should be efficiently usable and
easily
expandable.Knowledge,
therefore,
has to be represented for quick and easyretrieval, for ease
in
further expansion and modification, foruse
in
reasoning or solving a specific problem. In order tosatisfy the various requirements
for
the knowledge representation,
different techniques have to be usedfor
different types ofknowledge. There are three most
widely
usedin
current expertsystems are rules (the most popular), semantic nets and frames.24
Each technique provides the program with certain
benefits,
suchas
making
it
more efficient, moreeasily
understood,
ormore
The
inference
engine usesknowledge
in
theknowledge
base
to
solve a specific problemby
emulating
the
reasoning
process of a
humnan
expert. The approachto
solving
a problemconsists of
searching
a solutionfrom
a search space. In AIterminology,
the
set of all possible solutionsis
known
asthe
search space. The
inference
engine containsproblem-solving
strategies
that
useknowledge
in
theknowledge
base
to serchfor
a solution.
Recently,
the use ofknowledge-based
expert systemsin
digital
systemdesign has
grown. One ofthe
most successfulapplications of such systems
is
the Rl7system used at DEC to
configure
large
computer systems. The rest of this chapterfocuses on rule
base
systems and describes theapplicability
ofknowledge-based expert systems to
logic
design.
2 . 1 Productions systems
A production system consists of a rule base and a
control structure. The rule base
is
composed of a list ofproduction rules which are checked
repeatedly
until a conditionis
achieved or rejected. The controls structure determines whichrules should
be
executed next and executes the actions specifiedby
the rules.A production rule
is
a statement castin
the
form
"If
this
conditionholds,
thenthis
actionis
appropriate."The
Figure 2.2 and 2.3 show a
transformation
ruleis
encoded as aproduction rule
in
this system.B
"X-
r .J
Y
Figure 2.2 A
transformation
ruleIF
a NOR
inverter
is
connectedto
the output of a NORgate X and
input
to another NOR gate Y.THEN
remove the NOR
inverter
and NOR gate X from netlistand connect
input
A,Bto
NOR gate Y.Figure 2.3 A production rule
In the Figure
2-3,
the IF part ofthe
productions, called thecondition part, states the conditions that must
be
present forthe
productionto
be
applicable, andthe
THENpart,
called theThe control structure uses a rule
interpreter,
sometimesencoded
in
terms
of "metarules" tofind the
enabled rules and todecide
which rule to apply- Onebasic
controlstrategy
usedis
data
driven
or eventdriven
and startsfrom
the availableinformation
asit
comesin,
trying
todraw
conclusionsthat
areappropriate
to
the goals. Thisis
how
the systemin
this
thesis
works. In production systems this
is
called a forwardchaining
method of
inference.
We sometimes workthe
otherway,
however,
starting
from
a goal or expectation of whatis
to happen andworking
backwards,
looking
for
evidence that supports orcontradicts our expectation. This
is
called goaldriven
orexpectation driven and
in
production systemsit
is
referred to asbackward chaining, since
it
requireslooking
at the action partsof rules to
find
ones that would conclude the current goal, thenlooking
at the condition sides of those rules tofind
out whatconditions would make them execute, then
finding
other ruleswhose action parts conclude these conditions, and so on.
Data-driven approaches sometimes
have
the disadvantage ofgenerating
many
hypotheses notdirectly
related to the problemunder consideration, while goal-driven approaches have the
disadvantage of perhaps
becoming
fixed on aninitial
set ofhypotheses and
having difficulty
shifting
focus when the dataNot all expert system are rule-based.
Rule-based
systems are
particularly
attractive when much of the expertknowledge
in
thefield
comesfrom
empirical associations acquiredas a result of experience.
2.2
Applicability
ofKnowledge-Based
System to Logic OptimizationKnowledge-based expert systems are
very
costly
toimplement
at the present time. Thisis
mainly because:
thelack
of
knowledge
engineers and adequate sophisticated supporttools,
unfamiliarity
ofknowledge
engineers with the application area,and
unfamiliarity
of the expertsin
the
application area withknowledge-based expert system. These characteristics makes
it
necessary to evaluate the candidate application areas
very
carefully
in
terms of theapplicability
of the knowledge-basedexpert system approach. Two
key
ingredients
for
successfulapplication of knowledge-based expert systems has
been
suggestedby
the Stanford AI group8: attack problems amenable to thetechniques of applied
AI,
and consideronly
important,
difficult,
and high-value problems. We
look
at the above two requirementsin
the logic design area.1. Logic optimization
is
amenable to the techniques of applied ofAI.
.
By
accumulating design experience,knowledge-based
expert systems can
imitate
human
problemsolving
. Since optimization
techniques depend
heavily
onthe
targettechnology,
by
using
a rule-basedsystem,
optimization
for
different
technologies
involves
only
changing
the rulelibrary.
2. Logic optimization
is
animportant,
difficult
andhigh-value
problem.
. The
large
number of conferences organizedin
computer aideddesign
ofdigital
system,
andthe
enormousnumber of papers published
in
logic
circuitdesign
aretestimony
to theimportance
anddifficulty
of theproblem.
. Logic optimization
is
ahigh-value
problem becauseauotmatic optimization of
logic
circuits canimprove
both the logic area and
design
time.2.3 Advantages and Disadvantages of Knowledge-Based Expert System
In summary, the advantages of
knowledge-based
expertsystems include: the ease with which
human
knowledge can beencoded, the modularity and
incremental
development
of knowledge-based expert systems, the ease ofmodification,
and the capability
of knowledge-based expert systemsto
explain their decisions.Disadvantages
include:
their cost ofdevelopment,
the slowexecution speed with present
technology,
thedifficulty
ofextracting knowledge
from
humandesigners,
and the inefficienciesDespite their
disadvantages,
knowledge-based expertsystems
have
provento
be
a valuable approach and theircapabilities
increase
as more applications are attempted, as morepeople understand the nature of
these
systems, and as moresuitable
hardware
and software tools are developed.3. System
Implementation
Numerous tools are available
that
optimize andimplement
combinational
logic.
Most ofthese
toolsapply
at the Booleanlevel,
aretechnology-independent,
andgenerally
assume an AND/ORimplementation.
Suchtools
fail
to take advantage ofthe
varioustypes of gates available
in
a semicustomlibrary.
The needfor
more
flexible
andtechnology-oriented
tools was recognizedby
Darringer,
et al5., whoimplemented
adesign
system to performlocal transformations at various
levels
of abstraction. In thesystem built
for
thisthesis,
thelocal
transformations wereformulated as rules to optimize gate-level circuits for area
in
a given
technology,
and Prolog3 was selected as a formalism torepresent these rules for a rule-based system.
The system
is
divided
into
four main parts: aminimization, mathematical reduction module; a
decomposition,
multilevel function creation module; a synthesis, gate-level
implementation module; and an optimization,
local
transformationmodule. This chapter discusses these modules
in
detail anddescribes the rules that the system uses
to
perform optimization.The control structure that applies
local
transformations to the3.1 Minimization
The goal of
building
anoptimizing digital
circuit willrequire
the
efficient manipulation of Booleanlogic
functions,
iThe minimization module reduces
the
set of Boolean equationsdescribing
thelogic
by
using heuristics that
find
a minimal setof prime
implicants.
Infinding
this
minimalset,
the
moduletakes advantage of the
"don't
care"set of
the
function. TheESPRESSO-IIC program cteated
by
Brayton et al.in
1982,
performsthe reductions. The goals
in
thedesign
of ESPRESSO-II wereto build a logic minimization tool such that
in
most cases. the problem submitted
by
alogic
designer
could besolved with the use of
limited
computing
resources;. the final results would
be
close to a global optimum.Although ESPRESSO-II follows the basic techniques used
in
most minimizationtools,
generation of all primeimplicants
and extraction of a minimum prime cover, the algorithms employed
in
ESPRESSO-II are new and quite different. Efficient Booleanmanipulation
is
achieved through the "unate recursiveparadigm"27, which
is
employedin
complementation,tautology
andother algorithms. All of these algorithms make ESPRESSO-II as an
efficient minimization tool
for
logic
functions with more than3.2
Decomposition
One of the problems with
using
two-level minimizationis
that the result of
two-level
minimizationis
a network of gateswith unlimited
fan-in.
This part describes a techniquethat
reconstructs a multilevel
function
for
logic
design
by
identifying
subexpressions common
to
two
or more functions.By
creating
a newvariable
to
represent suchsubexpressions,
we also reduce thecomplexity
of the originalfunction
at the cost ofadding
a newintermediate
function.
Ingeneral,
this reduces the number oflogical components required to
implement
the set of functions.The decomposition approach
is
algebraic as opposed to Boolean.The result
is
an algorithm, which,by
successive substitutionof new variable
for
common subexpression, simplifies a set offunctions until
they
are "relative prime".Given a set of Boolean expressions, our aim
is
to pullout common subexpressions,
consisting
of two or more cubes (a setof variables) , until the expression
becomes
relatively
kernal(subexpression)
free. Itis
theneasy
to locate single cubesdividing
two or more functions.By
pulling
these out as well, wecan reduce our expression to a set whose
only
common divisors aresingle variables. At this point the expression can
be
implemented
independently
with no loss of efficiency; all global commonalityhas
been identified. Letf
andg
be expressions, and let vbe
a variable appearingin
neither. Letr(f,g)
denote the setf
-(f/9)9/
the remainder resulting from thedivision
off
by
g.Then
the
substitutions(v,g,f)
of vfor g
in
f
is
the expression(f/g)v
+ r(f,g). Ifg
is
A +B,
f
is
C(A +B)
+D,
thens(x,g,f)
= Cx + D. The
kernal
(common subexpression)
A
+ Bis
pulled outfrom
f
and g, and replacedby
a new variable x. The algorithmfor
computing
f/g
andkernal
are shownbelow.
To compute f/g:
1. Let
g
={a^}
andfor
eachi
seth^
={bj
|
ajbj
^ f).2. Set
f/g
=h^.
To compute
kernal
(f):We number the
literals
appearing
in
f
asli#l2
in-Let
kernal
(0,f)
=kernal
(f). Setkernal
(f)
= p.|
o|
= number of cubesin
f.kernal
(k,
f
)
:For
i
=k
+ 1 to nLet c =
f/li
if
|c|
> 2 andi
= n thenkernal(lj_,f)
= celse
if
|c|
> 2 thenkernal
(lj.,f)
=kernal
(i,c)
if
kernal(f)
(1
kernal
(liff)
=p
thenkernal
(f)
= kernal(f)
f\
kernal(li,f)
else
kernal
(f)
= kernal(f)
U kernal(li,f)
We now
describe
thefirst
step
ofdecomposition,
whichidentifies
expressionsconsisting
oftwo
or more cubes thatoccur
in
severalfunctions.
This processis
called"distillation"6.
The
Distill
Algorithm:
1. Generate all
kernals
for
eachfunction.
2. Select a pair
kernals
(k,k'),
whereke
f^t
k'e
f
j
,i
?
j,
. suchthat
|k
fi
k'|
> 2.if
no such pairexists,
stop.3. Record
(v,K
A
K')
for
some new variable v.4. Set
f^
= s(v,kfl k',fj.)
for
eachfunction.
5. Go to 1.
The total number of variables
in
thefunction
decreaseswith each pass,
hence
the algorithmterminates.
The particularpair k
A
k'selected
in
step
2 caninfluence
thequality
of,
theresulting decomposition. In the program, a useful heuristic
is
toselect the pair whose substitution most reduces the number of
variables appearing
in
the functions. Thisheuristic
wasimple
mented
by
recording each subexpression producedfrom
theinterse
ction of
kernals,
the subexpressionappearing
most oftenin
therecord
is
chosenfor
thestep
2.To complete
the
decomposition process, the next stepis
to
pull out those cubes consisting of morethan
two
variablesthat
existin
several functions. This processis
referred to as"condensation"6 .
The Condense Algorithm:
1. Select cubes, c6
f^
and c'6fj,
i
f
j#
such that|c
fi
c'|
> 2.if
no such pair exists, stop.2. Record
(v,c
A
C)
for
some new variable v.3. Set
f-[
= s(v,cA
c',^)
for
each function.4. Go
to
1.The total
decomposition
process consists of distillationfollowed
immediately
by
condensation. The pairs (v,cfi
C)
generated
by
condensation are added tothe
list
of(v,k
fi
k')
produced
by
distillation. Asbefore,
a selection heuristic canbe applied
in
step
1.Example: Let
f
= AB(C(D +E)
+ F +G)
+ H andg
= AI(C(D+E)
+ F +J)
+ KDistillation:
Pass 1:
kernal
(f)
= D +E;
kernal(g)
= D + E|k
fi
k'|
= D + E > 2set L = D + E
then
f
= AB(CL + F +G)
+ Hg
= AI(CL + F +J)
+ KPass 2: kernal
(f)
= CL + F + Gkernal
(g)
= CL + F + Jset M =
|kAk'|
= CL + F > 2then
f
= AB(M +G)
+ Hg
= AI(M +J)
+ KCondensation:
Pass 1: set N = ABM
C\
AIM = AM > 2then
f
= B(N +AG)
+ Hthen g
= I(N +AJ)
+ Kthe substitution
list
is:
L = D + EM = CL + F
N = AM
The
decomposition
takes
about 14 minutesfor
a combinationallogic
with 12 outputs, 37inputs
and 14 0 productterms,
but
therunning
timeis
mostly
spentin
doing
theintersection
for eachkernal.
Since wetry
to select a commonsubexpression that appears most often
in
thefunctions,
we need to generate all common subexpressions and compare each of themin
reducing the number of variables
in
thefunctions.
If we organizethese common subexpressions
according
to their appearance times andlet
the process goback to
step
2 to select the second order of subexpression aftersubstituting
a new variablefor
thefunctions,
then the running timeis
largely
reducedby
skipping a lot of time spentin
doing
theintersection.
When this algorithmis
applied to a sample with 29functions
having
23input
variables,
it
takes about 5 hours compared with the firstalgorithm which takes 13 hours to
decompose
this
sample. It savesup
to 70% of the CPU timein
the Pyramid 90/X. The savings oftime depends on the size of the
functions.
Ofcourse,
since thisresults
in many
morelogical
componentsthan the
first
algorithm.The algorithm
listed
below
is
called"fast
decomposition"and
the
first
algorithmis
called"optimal
decomposition".
The
Distill
Algorithm:
1. Generate all
kernals
for
eachfunction.
2. Select a
pair,
whereke
fi,
k'efj#
suchthat
|k
fi
k'|>2.
This process proceedsrepeatedly
untilevery
kernal
has
been
selected,
then these subexpressions
(|kfi
k'|)
are orderedaccording
to theirappearance
times.
If
no subexpression exists, stop.3. Select
first
commonubexpression,
if
no such commonsubexpression
exists,
go to 1.4. Record
(v,
k
fi
k')
for
some new variable v.5. Set
f^
=s(v,kfi
k',fi)
for each function.6. go to 2.
The first
step
of Condense algorithmis
also modified.1. Select cubes, c
f^,
c'e
f
j
, suchthat
|c
fi
c'|>2.
This process proceeds
repeatedly
untilevery
cube hasbeen
selected,then
these
subexpressions (|c(\
c'|)are ordered
according to
their appearance times,if
no subexpression
exists,
stop.Now we
look
another examplethat has
more structurethan
the
first
one. Theincoming
data
andresulting design
for
part ofa 16-bit
bus
structure are shownbelow.
The varl through var8 arenew variables and
the
common subexpressions associated withthem.
the
incoming
data:
f3
=h'i'j'k'r
+ e'f'ar + c'ap'r +b'ap'r
+d'ar
+aps +
h'i'jkr
+
h'ikl'r
+d'hjkl'r
+b'hjk'l'p'r
+ e'hjkl'f'r + c'hjkl'p'r +hjkl'ps
f4
=h'i'j'k't
+ c'ap't +b'ap't
+ e'f'at +d'at
+ apu +h'i'jkt
+
h'ikl't
+ e'hjkl'f't +d'hjkl't
+ c'hjkl'p't +b'hjkl'p't
+
hjkl'pu
f5
=h'i'j'k'v
+d'av
+b'ap'v
+ c'a p'v +e'f'av + apw + h'i'jkv
+
h'ikl'v
+ c'hjkl'p'v + e'hjkl'f'v +b'hjkl'p'v
+ d'hjkl'v+
jhkl'pw
f6
= h'i'j'k'x +d'ax
+ c'ap'x +b'ap'x
+ e'f'ax +apy
+ h'i'jkx+
h'ikl'x
+ c'hjkl'p'x +b'hjkl'p'x
+d'hjkl'x
+ e'hjkl'f'x +hjkl'py
f7 = h'i'j'kz + d'az +
b'ap'z
+ e'f'az + c'ap'z + apal +h'i'jkz
+ h'ikl'z + c'hjkl'p'z +
b'hjkl'p'z
+ e'hjkl'f'z +d'hjkl'z
+ hjkl'pal
f8
= h'i'j'k'bl + e'f'abl +d'abl
+ikl'bl + e'hjkl'f'bl
hjkl'p'bl +
hjkl'pcl
f9
= h'i'j'k'xl + ap'xl + apdl +h'i'jkxl
+h'ikl'xl
+ hjkl'p'xl hjkl'pdlflO
= h'i'j'k'el + ap'el + apyl +h'i'jkel
+hikl'el
+ hjkl'p'el+ hjkl'pyl
fll
= h'i'j'k'gl + ap'gl + apfl + h'i'jkgl +hikl'gl
+ hjkl'p'gl+ hjkl'pfl
fl2
= h'i'j'k'il + ap'il + aphl + h'i'jjil +h'ikl'il
+ hjkl'p'il hjkl'phlh'i'j'k'bl + e'f'abl +
d'abl
+ c'ap'bl + apcl +h'i'jkbl
+ h'ikl'bl + e'hjkl'f'bl +
d'hjkl'bl
+b'hjkl'p'bl
+ c'hjkl'p'bl +
hjkl'pcl
The results of
decomposition
are shownbelow.
Each ofthe
lines
numbered 1
throgh
8 gives a subexpression and the new variableassociated with
it.
Forexample,
the
line
numbered1
associatesthe new variable varl with the expression
j'k'+jk.
The variablevarl
is
usedin
place ofthe
expressionj'k'+jk
for
the functionsthat contain
the
expressionj'k+jk.
1. varl =
j
'k' +jk
2. var2 = a + hjkl'3. var3 = ikl' + varli'
4. var4 = b' + c'
5. var5 = e'f + d' + var4p'
6. var6 = var3h' +
var5var2
7. var7 = var2p' + var3h'
8. var8 =
var2p
f3
= var6r + var8sf4
= var6t + var8uf5
= var6v + var8wf6 = var6x +
var8y
f7 = var6z + var8al
f8 = var6bl + var8cl
f9
= var7xl + var8dlflO = var7el + var8yl
fll
= var7gl + var8fl3.3
SynthesisThe synthesis module
translates
a Boolean functioninto
a gate-level
implementation.
Two synthesis modules werebuilt,
one
that
generates anAND/OR
implementation
of thefunction
derived
from
the
previous module and one that generates a NANDor NOR
implementation
for
particulartarget
technology
from theAND/OR
implementation.
The
first
synthesis moduleis
relatively
straightforward and
implements
thefunction
as aninterconnected
netlist.The second synthesis module converts the netlist to a network
composed of NAND gates or NOR gates. This conversion
is
carriedout
by
using
F = (F')' and thenapplying
DeMorgan's laws:(Xx
+X2
+ +Xn)
' = Xx* x2'... Xn'(Xx X2
...Xn)
' = Xx' + X2' +
... + Xn'
The Figure 3.1 illustrates conversion of two-level forms.
A.
B
B
A+B
A4-B
AB
A-B"
tXj
B
AB
MD-'rO-O
A+B
AB
The
above conversion produces alot
of cascadedinverters
in
amultilevel netlist,
but
sincethe
double
inversion
does not altera
logic
function,
it
should not appearin
network. Inthis
module, the conversion
is
performedby
using
rules andby
passing
an output signal
to
the
nextlower
level,
so thatthe
cascadedinverters
are notfound
in
the
NAND/NOR
implementation.
Theoutput signal
tells
a gatethat
its
outputis
logic 0 or logic 1when
it
is
convertedfrom
AND/ORlogic to
NAND/NOR logic. Thenumber of gates cascaded
in
seriesbetween
a networkinput
andthe output
is
referred to as the number of 'levels' of gates. Thehighest
level
is
the network output. As shownin
Figure3.2,
thenetwork has 4
levels,
the first levelis
gates, the fouth levelis
gatel. The logic conversionis
started from the gates that arein
the highest level. The rulesfor
obtaining the NOR networkfrom a AND/OR netlist are as follow:
1. If the output signal
is
1 and the gateis
an AND gate,then change the AND gate to NOR gate and pass a 0
signal to the gates that are
in
the next lower level.2. If the output signal
is
0 and the gateis
an AND gate,then change the AND gate to NOR gate followed
by
a NORinverter,
and pass a 0 signal to the gates that arein
the next lower level.
3. If the output signal
is
1 and the gateis
an OR gate,then change the OR gate to NOR gate
followed
by
aNOR,
inverter,
and pass a1
signalto
the
gates that arein
4.
If
the
output signalis
0 andthe
gateis
an ORgate,
then
change the OR gateto
a NOR gate and pass a 1signal to the gates
that
arein
the
nextlower
level.
The rules
for
obtaining
the
NAND
networkfrom
AND/OR
implementation
areexactly
the
same asfor
NOR network except thesignal
is
as opposed asNOR
logic.
Afan-in
constrainthas
been
added
for
the
NANDimplementation
sothat
a NAND gate canhave
nomore
than
four
inputs
in
aNAND
gate. An example toillustrate
these rules
is
providedbelow.
Figure 3.2
is
traced
from
gate 1 whichis
an OR gatewith an output signal 1. After
applying
rule3,
gate 1is
changedto
a NOR gate followedby
a NORinverter,
and a signal 1is
passed to
level
3 whichincludes
gate 2 and gate 3. Since gate 2is
an AND gate with an output signal1,
rule 1is
selected andapplied
in
netlistresulting
in
a NOR gate and a signal 0 fornext
lower
level
(level2)
. Gate 4is
also an AND gate but withan output signal
0,
by
applying
rule2,
the AND gateis
replacedby
a NOR gate with aninverter
and a signal 0for
level
1. Rule 4translates gate 5
from
an OR gate to a NOR gate and passes signal1 to
input
variable A. The process backtracks toinput
variable Band finishes conversion
in
level
1. Since D and F are inputvariables, there
is
no gate connected to gate 2 and gate4,
theprocess goes back
to
gate 1. Beforegoing
to
gate 3it
should bementioned that the AND/OR implementation still exists
in
the datasignal
1
for
gate 5 that we mentionedbefore
still exists. Gate 5is
translated
to a NOR gate and aninverter
but
the NOR gate withinput
A,
B canbe
found
in
the
network,
soonly the
inverter
is
added
to
the
netlist. The processis
stopped until the NORA
B
o
$*te5
=o
F
J
6*fceA
rt
Gutel
Qatt^
Figure 3.2 before synthesis
A
B
o
butt*
M>xOlOiH
tot
&
_.fateJ
k>H>
XVy'/D^^O^-E^
Gate I
&ate$
3.4
Optimization
The optimization module performs a succession of
substitutions on an
existing
netlist,
similar to theway
anexperienced
designer
manipulates adesign
to achieve greaterefficiency. The module consists of a
knowledge
base
and a controlstructure.
The system optimizes a circuit
by
performing
a series oflocal
transformations
to that circuit. Inperforming
eachtransformation,
the program replaces a given configuration ofgates
by
anotherfunctionally
equivalent configuration of gates.These transformations are always applied
in
such away
as toreduce circuit areas and produce more optimal circuits. The
example of such a transformation rule was shown
in
chapter 2.The control structure of a rule-based system directs the
application of the rules.
During
the application, a meta-ruledetermines what rules or sequences of rules are applicable to the
circuit.
3.4.1 Knowledge-Base
In the system, a rule
is
a mechanism to replace aportion of a circuit
by
afunctionally
equivalentbut
moredesirable circuit portion. Rules are sorted as a netlist
describing
a target configurationto
be
recognizedin
the circuitand an associated action
detailing
how tobuild
the
configuration.
Substituting
the
replacement configurationfor the
target configuration
is
to reducethe
overall area ofthe
circuit.
During
the
building
ofthe
rulelibrary,
it
became
apparent
that
alarge
numbers of rulesdiffering
from each otherby
the number ofinput
variables existed. To reduce the number ofthese equivalent rules, we
incorporated
these
rulesto
a generalrule. A rule represented
in
Prolog
is
shownin
Figure 3.4. The"adjust_netlist"
clause removes the NOR
inverter
G2 and NOR gateG3 from netlist and connects the
input
variable A and B to NORgate Gl.
A
B
S3
A
c
o
nor_rule_l(X,Y)
:-node_(nor,Y,Z) ,
inverter
(nor, Y,Z)
,gate_(nor,Z,Vars) ,
adjust netlist(nor,X,Y,Vars) .
The rules within rule
library
are orderedby
their
desirability.A meta-rule
in
the systemdetermines the
appropriate order ofrules
based
on howmany
times a rulehas
been
usedin
the
circuit. There are sixteen rules
in
the system now (seeAppendix
C)
,half
for
NORimplementation
half
for
NAND. The controlstructure will use rules
from
thefirst
rule untilthere
is
noapplicable rule
in
the
knowledge base.
Although these rules arespecific
to
a giventechnology,
optimizationfor
different technologies
involves
only
changing
thelibrary
containing
the rules.3.4.2 Control Structure
A problem-solving that uses forward
reasoning
and whoseoperators each work
by
producting
a single new object a newstate
in
the databaseis
said to represent problemsin
a statespace representation.24
The problem of
producing
a state thatsatisfies a goal condition can now be formulated as the problem
of searching a graph to
find
a node whose associated statedescription satisfies the goal. The graph, which grows as the
search proceeds, will be referred to as a search graph or search
tree.
Optimization of combinational logic through successive
transformations can be translated to the problem of optimally
traversing
a state space. The nodes of this graph are theimplementations of the circuit, and the arcs represent rule
applications. The root of the tree corresponds
to
thecurrent
implementation.
Optimizationis
equivalentto
finding
a pathfrom
the
initial
circuit configuration to an optimal configuration.The process of
finding
this pathis
refered to as a state spacesearch. The state space search
strategy
usedin
this systemis
presented
below.
Thestrategy
usesheuristic
information
todecide which node to expand
next,
theinformation
is
providedby
a meta-rule.
select rule
for each rule R
in
some class Cfor
each gate Gin
the
circuitif
the targetfor
R matches at gate Gthen
apply
rule goback
to select ruleThe value of C controls what a given
technology
is
optimized. Forinstance,
when optimzing for NOR gate, the class of NOR rules areused. The first
step
of the system selectes rules based on theordering of the knowledge
base,
alwaysapplying
the firstapplicable rule
in
the knowledge. The above search strategyis
called a best-first search.
We use an example to explain how a state changes to
another, and how the state
describing
a targetconfiguration
matches the condition part of a
selected rule. The forward
chaining inference method will be
used to
implement
the matchingoperation;
it
starts from theavailable
information
andtry
toinfer
the conclusions that are appropriateto
the goal. When thesearch
function
is
called,
it is
given two arguments: arule,
anda gate at which the search
function
shouldbegin.
Figure
3.5shows a sample
netlist,
a portion of acircuit,
and a rule tobe
applied
in
that
circuit.In
searching,
the
controllerfirst
checks
if
gate Glis
a NOR gate. Ifso,
then
the
controllerselects one
input
from the
input
variables of gate Gl. If P2is
an
input
variablefor
gate Gl and connects to another NOR gateG2,
then the controller checksto
seeif
gate G2is
aninverter.
Since the G2
is
not aninverter,
the
searching
activity
fails.
Atthis point a condition cannot
be
met,
so the controllerback
tracks
by
returning
to thelast
selectionit
made andmaking
adifferent choice.
Backtracking
continues until the rule'scondition part has
been
satisfied,
or until all possible choiceshave
been
rejected. As this exampleillustrates,
the controllergoes
back
to Gl and takes another choice. P3is
an anotherinput
variable
for
gate Gl and connects to a NOR gate G3. Since thegate G3
is
aninverter
between gates G4 andGl,
the ruleis
executed and a replacement
function
is
called to perform atransformation
for
the circuit. The replacement functionis
contained
in
each transformation rule.In order to make the control structure more
flexible,
ameta-rule was implemented
in
the system. As noted above, themeta-rule determines appropriate order of the transformation
rules.
By
adjusting theserules,
control structure can be usedperhaps with a better result.
A sample netlist:
(nor,pl,p2,p3)
(nor,p2,p4,p5)
(nor,p3,p6)
(nor,p6,p7,p8)
A rule selected
by
control structure:nor_rule_l(X,Y)
:-node_(nor,Y,Z)
,inverter(nor,Y,Z)
,gate_(nor,Z,Vars)
adjust_netlist(nor,X,Y,Vars)
PI
P2
PL
PS
>
Gt-GZ
PC
Gl
P2
P3
Gl
PI
Nt'
PL.
P
O-i
PI
<*
PS'
P2
Gl
Pi
Figure 3.5 Logic optimization represented
in
state spacesearch, each circuit configuration
is
a state.3.5 Program Organization
The minimization module
is
writtenin
C,
and the othermodules are written
in
Prolog.
The reasonfor
thisdivision
is
that
the
minimization module uses ESPRESSO-IIC to performreduction, whcih manipulates matrices
during
minimization, andare much easier
to
implement
in
a conventionallanguage.
Theother modules are
implemented
in
Prolog
based onfollowing
observations: In
Prolog
it
is
easy
to
represent the functionalbehavior of gates, all the transformations needed for the system
can be entered as rules and
implemented
in
Prolog,
andProlog
provides an efficient pattern-directed
inference
tool.3. 6 Input and Output
The
input
of the systemis
in
sum of products functionset or
in
a truth tableincluding
input
and output variables. Thesystem output
is
in
form of a netlist which describes targetlogic
type,
output variables andinput
variables. Thefollowing
netlist
is
a sample output (Figure 3.6).(nor
,f
12,norl,nor2)
(nor,norl,gate22,il)
(nor,gate22,/p,var2,/hl)
(nor, /hi, hi)
(nor,/p,p)
(nor,var2 ,gate39,
a)
(nor,gate39,l,/k,/j,/h)
(nor,/k,k)
(nor,/j,j)
(nor,/h,h)
(nor,nor2,nor21,gate47,
gate46)
(nor,gate47,h,var3)
(nor,var3,gate41,gate40)
(
nor,gate41,i, varl)
(nor,varl,gate38,gate37
)
(nor,gate38,/k,/j)
(nor,gate37,k,
j)
(nor,gate40,l,/k,/i)
(nor,/i,i)
(nor,gate4
6,p,var2)
(nor,nor21,var2,
/hi
)
Figure 3.6 A sample output
4.
Conclusion
and Future WorkThis thesis
has
described
the
development
of a systemthat
is
capable ofautomatically synthesizing
andtransforming
functional
specificationsinto
gatelevel
implementations.
Thesystem
is
implemented
as a rule-based systembecause
it
workswithout an established algorithm and
is
easy
tomodify
according
to
the
target
technology. The system progresses throughfour
distinct
modulesduring
the
design
process:Minimization,
Decomposition,
Synthesis andOptimization.
Forlarger
examplesabove 100
gates,
the
system achieved area reductionsranging
from20% to 30%
from
unoptimized circuits, these results arecomparable to the result of manual optimization. The
flexibility
of the systemis
largely
due
toits
separationinto
independently
useful modules. Itmay be
usefor
translating
two-level
functions to a multilevelimplementation,
generating
acircuit, or
optimizing
anexisting
circuit. Inany
of theseapplications, the system saves valuable time and space.
Future work can
be
classifiedinto
two categories:enhancements to the system to
improve
its
present performance;and new approaches to logic
design.
1. An Additional feature to
improve
system performanceincludes
building
a ruleentry
module tohelp
userseasily
extend theknowledge base. The rule
entry
module would automaticallyaction
describing
how
to
replaceit
withthe
replacementconfiguration.
2. New approaches
include
extension ofthe
currentNAND/NOR
implementation
to other gates availablein
gate-array
orstandard cell
libraries,
and consideration of the fan-in andAppendix
A. User's ManualNAME
preopt
-generate
Prolog
acceptedform
from
truth table
SYNOPSIS
preopt
[file]
DESCRIPTION
preopt generates a
form
suitablefor
Prolog
from
a truthtable which
defines
a set of Booleanfunctions.
If no outputfile
is
specified,the
default
output file"_opt
"is
generated
(e.g.
test_opt)
. SinceProlog
does
not accept aperiod within
file
name,
allthe
file
nameincluding
aperiod will
be
changed to"_".
Input
to
preoptis
in
the
form
oftruth
table,
thatis
theoutput
from
Espresso-IIC program. Comments are allowed withinthe
input
by
placing
a pound sign(#)
as thefirst
characteron a
line.
Comments and unrecognizedkeywords
are passeddirectly
from
theinput
file
to outputfile.
Any
white-space(blanks,
tab,
etc.)
is
ignored.
Outputis
used asinput
for loqopt (see Figure A.l). The examplein
appendix B will showhow the program progresses.
The
following
keywords are reservedfor
the systemuse,
they
should not appear
in
theinput
file
for
input
variable orany
other variable.
key
words: gate(n), var(n),inv,
in,
out,
nor(n), nand(n), norgate(n), nandgate(n).the
(n)
means1,
2,
3 n. (e.g. varl,var2,
var3 varlO)SEE ALSO
NAME
logopt
-combinational
logic
optimizationSYNOPSIS
logopt
[option]
[type]
[file]
DESCRIPTION
logopt takes as
input
atwo-level
Boolean functionsoptimized
functional
equivalent netlist. The system consistsof
four
distinct
modules:minimization,
decomposition,
synthesis and optimization. The optimization module
is
implemented
by
a rule-based system.loqopt reads the file
provided,
performs the optimization forlogic
area, and writes an optimized netlist to a defaultoutput file "_out" (e.g.
test_out)
if
no output fileis
specified. The system generates a command file "_com"
(e.g.
test_com)
forProlog
programming,it
can be deletedafter running.
"type"
specifies the target
technology
for the system. Theallowed types are -nand for NAND gate, and -nor for NOR gate.
The output netlist
only
includes
NOR gateif
-nor typeis
specified.
"option" specifies boolean function decomposition which
creates multilevel function
by
identifying
common sub expressionfrom
a two-level function. The allowed optionsare -f
for
" fastdecomposition",
and -o for "optimaldecomposition". Although "fast decomposition" saves a lot of
1
1
BooleanFunction
j
1
|
Eqntottsir
1
1
Truth Table|
1
|
Espresso-IIC (Minimiz|
Truth Table|
|
After Minimization|
1
|
Preopt|
Prolog
|
|
Accepted Formj
1
|
Logopt(Optimization)
1
1
|
Netlist|
Appendix
B. ExampleExample 1
/* input data (sample, bol) */
r0 = b&c&d&e&h& ! i &
j
& k & ! 1 5 f 0 = b&c&d&t&h& ! i &j
& k & ! 1 ;1-0 = d&e&h&i&.j& k & ! 1 & o
; f 0 = d & f & h & i &
j
& k & ! 1 & o ;f0 =!d&e&h&i&j& k & ! 1 & r.i & n ; 1 W = ! d & f & h & i &
j
& k & ! 1 & m & n ;|-0 = a & b & c &