Project Report - Southern Methodist University

advertisement
1
Total Symmetry Detection in
Combinational Circuits
Ilteris Murat Derici, Member, IEEE, Member, Upsilon Pi Epsilon
Southern Methodist University
iderici@engr.smu.edu

2n
Abstract
A Boolean function is totally symmetric if any permutation
of its inputs yield the same truth table which implies that
functions created by different permutations of the original
function are equivalent. Symmetry detection is very
important in digital circuit design. It is used in synthesis
for library mapping, exact minimization, and in
verification for equivalence checking, and signature alias
problem. In this paper, an implementation of total
symmetry detection will be discussed in detail along with
internal data structures which have been used, and
selected benchmark pla file’s results will be given.
I.
INTRODUCTION
There are different types of symmetry which are total,
partial, restricted input, hierarchical, group and rotational. A
function is symmetric in terms of variables x i and x j if we
swap them in the original function, and the resulting new
function is equivalent to the original function. The variables
which can be interchanged without affecting the output of the
original function form a symmetric set. If this set is the same
as the input set of a function, then the function is totally
symmetric. If there exists no maximal symmetric set, but there
are one or more symmetric sets which have at least two
elements, then the original function is said to be partially
symmetric in those symmetric sets. There are special cases
such that if we apply a permutation, then we should also apply
some other permutations; this is called restricted input
symmetry. An example for this is a multiplier circuit, or a
adder. Hierarchical-G symmetry ensures that there are
maximal symmetry sets which have at least two elements and
those sets can be interchanged without changing the behavior
of the function. If the union of symmetry sets give the input
set, and symmetry sets are disjoint, and each have two or more
elements in it, then it is called Group-G symmetry. Rotational
G-symmetry implies that there are symmetry sets which are
proper subsets of input set, and circularly interchanging those
yields the same function.
If a function has n inputs, then there are 2 possible
functions. The reason for the formula is if there are n inputs,
n
the truth table consists of 2 rows. Each row then can be
2n
assigned to either 0, or 1 which gives us 2
possible
functions out of n variables. If we check total symmetry among
n 1
those, we see that there are 2
totally symmetric functions.
In my implementation of total symmetry detection, my
program is reading in ASCII coded pla files which is a simple
representation of digital circuits, and converting rows of inputs
and outputs to P.C.N. which stands for positional cube
notation. P.C.N. is chosen to easily manipulate data internally.
Afterwards, total symmetry table is populated based on inputs.
Having built the table, the function is investigated for total
symmetry detection.
The idea behind the algorithm is based on combinations of
inputs. If we look at a truth table of function, we see that the
total number of rows is equal to summation of n choose 0, 1, 2
… n where n is the number of inputs. Actually, each row is a
combination of n. In order for a function to be totally
symmetric, if a combination of n chose x is covered by the
function, then all the combinations of n choose x should be
present. Otherwise, exchanging any two variables will result in
a different function. Having this knowledge gives us another
hint. If a function is symmetric, then all combinations of n
choose x are covered. This means that rows representing all
combinations will contribute equally to each column if we take
summation of columns. This property becomes useful in early
detection of symmetry. If column sums of truth table don’t
yield the same result, we can be sure that the given input set
cannot be symmetric as is. There are further investigations to
be done which will be discussed later. In terminology, each
combination is called a-number where a is the n choose x, x=a.
A function may not be totally symmetric, but its co-factors F 0 ,
and F 1 may be when Shannon expansion on a variable is
performed. My implementation also applies Shannon
expansion on the first variable if it finds that the original
function is not symmetric, and there exists a special case.
II. PLA FILE DESCRIPTION
2
There are many ways to represent digital circuits. VHDL,
Verilog. EDIF, CIF are a few of them. The pla file structure is
a simple one, and easy to understand; therefore, it suits for this
project’s purpose where importance is given to detecting
symmetry.
A pla file is a format for physical description of
programmable logic arrays. It is an ASCII file consisting of
lines each with a meaning. Lines starting with ‘#’ are
comments, and they are ignored. Lines starting with ‘.’ contain
control information such as the number of inputs, outputs, and
product terms. They’re not used in this project, so they are also
ignored. What is in interest of this project are and, or planes of
the pla which describe a product term. An and plane is
followed by a or plane. The and plane describes an input
combination. The or plane describes the output of each
function for the given input combination. A ‘0’ in the and
plane means that complemented version of a variable is used
whereas a ‘1’ means the variable is not complemented. An ‘x’,
’X’, ’-‘ means that both complemented and un-complemented
version of a variable should contribute to the same output. In a
nutshell, this input is unnecessary, or don’t care. A ‘1’ in the or
plane means that the output for the function for this product
term is ‘1’. A ‘0’ means that the output of the function is ‘0’
for this product term; therefore, it is in the off list of cubical
representation. If there is a ‘x’, ‘X’, or ‘-‘ in the or plane, we
can take the output of a function either ‘0’ or ‘1’. This concept
will help us in symmetry detection by choosing some of them
wisely. If a function is not symmetric with outputs only
consisting of ones, we will start choosing some of outputs
which are ‘x’, so that a-number values will be correct if
possible.
III. READING IN PLA FILE
The program locates a properties file in user’s home
directory. The file contains the location of the pla file and the
name of the file. Again, in this file, the user can turn on, or off
Shannon expansion, and, or using ‘X’ outputs for symmetry
detection. They are optional since they are still experimental
although they are tested very well.
Reading the file is done by ReadFile object. It ignores the
comment and control lines and only processes and, or planes.
When a row is read, it parses the and plane string, and or plane
string. It converts the character style into P.C.N. for each input
variable, and output. At the end, it creates an array of bytes for
both inputs and output. Afterwards, they are added to a linked
list which will be passed to other functions of the program.
The reason for converting data from character to P.C.N.
which is represented as a byte is improving the performance of
the program. We can use primitive and, or operations directly
instead of using look up tables to get the result after an
operation.
In P.C.N., a null value is represented by bit pattern ‘00’
which is equal to 0. ‘1’ is represented by bit pattern ‘01’
which is equal to 1. ‘0’ is represented by bit pattern ’10’ which
is equal to 2, and a don’t care ‘X’ is represented by bit pattern
‘11’ which is equal to 3.
IV. BUILDING SYMMETRY TABLE
Having read the file, the table consisting of minterms should
be built so that we can compute column sums, and a number
values appropriately. In order to do that, each row stored in
the linked list which is built during file read is iterated.
If output ‘X’‘s are assumed to be ‘0’, then inputs of rows
which have an output of ‘1’ are processed, the rest are ignored.
If output ‘X’‘s are also wanted to be processed in order to use
them in symmetry detection, then inputs of those rows are
stored in a different linked list beside the table.
When we read a cube, we should only add those newly
discovered minterms. To achieve this, we must use basic
P.C.N. operations such as sharp, dis-joint sharp, and
intersection. The sharp of cube A and B, returns only cubes
which are covered only by A. The dis-joint sharp of cube A,
and B, will also return the cubes only covering A, but the
resultant set is dis-joint. The intersection of cube A, and B will
give the cubes covered by both A, and B. Here are the
formulas for those operations:
Cube 1 =C1 = a 1 , a 2 , a 3 , … a n
Cube 2 =C2= b 1 , b 2 , b 3 … b n
C1 intersection C2 = a 1 &b 1 , a 2 &b 2 ,a 3 &b 3 ,… a n &b n
a 1 &~ b 1 , a 2 , a 3 , a n
#
C1 sharp C2 =
a 1 , a 2 &~ b 2 , a 3 , a n
…
a 1 , a 2 , a 3 &~ b 3 , a n
a 1 , a 2 , a 3 , a 4 & ~b n
a 1 &~ b 1 , a 2 , a 3 ,
…an
a 1 & b 1 , a 2 &~ b 2 , a 3 , …a n
C1 dis-joint # C2 =
…
a 1 & b 1 , a 2 & b 2 , a 3 &~ b 3 , a n
a 1 & b 1 , a 2 & b 2 , a 3 & b 3 , a n & ~b n
We can think of each cube as a set covering one or more
minterms.
3
this loop, we will loop again to the total number of don’t cares.
Here is the formula:
A
Value = ( L % 2
( i 1)
)/2
i
where i is current don’t care from 0 to # of don’t cares
C
B
This value will be put for don’t cares in each
position. Everything described so far is done by the Processor
object. When we find unique minterms, we add them to a
object named, MyTable which is a table used in symmetry
detection.
V. ALGORITHM FOR SYMMETRY DETECTION
Let us assume that the order we read in minterms is A, B,
and C. If we create minterms from each cube, then there might
be some redundant minterms which have been already added.
One approach could be adding A first, then B-A, and then
taking X=(C-A). After that operation X=X-(B-A)). This
approach is hard to program, but it will be memory efficient. If
we have another set D, then for D, we must find Y=D-A, then
Y=Y-(B-A), and Y=Y-X. As number of minterms increase, it
will be very hard to program it. Another difficulty here is
every dis-joint can return n number of cubes where n is equal
to the total number of variables. Therefore, this will also
increase complexity. An easy way to achieve the same
concept with a little bit less memory efficient way is every
time a new set is entered, take dis-joint sharp of it with the
previous ones. At the end, take intersection of all of them, so
when D is added, keep track of D-A, D-B, D-C by adding
them to a linked list. Afterwards, take intersection of D-A and
D-B, then this result is intersected with D-C. Now, we have the
cubes, we should find the minterms to be added to the table.
Since we’ve used dis-joint sharp operation, we can be assured
that every cube retuned is dis-joint with each other. Taking
intersection of them doesn’t change this situation. Actually,
this can be used to improve performance. When we have D-A,
we have n possible cubes. Again, D-B also have n number of
possible of cubes. If we take intersection of them, we need to
have a loop of size n, inside another of loop repeating n times.
Here, we use this knowledge to improve performance.
Whenever the inner loop intersecting the current cube of D-A
with every cube of D-B returns non-null, we can break the
loop since no other cube’s intersection can return a non-null
cube.
Having found the new cubes covered by this row, we should
find the minterms associated with them. If a cube doesn’t
contain any don’t cares, then it is actually a minterm. If it
contains 2 don’t cares, then it covers 4 minterms. The formula
n
is simple, and is equal to 2 . What we need to do here is
creating all mintems, and copying each variable from original
cube to each minterm position. This will give us somehow
correct minterms, but they will have don’t cares. We need to
change those don’t cares into ones, and zero’s. To do that, we
need to find the position of don’t cares once. We will loop
through total number of minterms which is is equal to L. Inside
After building the table, we apply the algorithm below to
find symmetry.
Step 1: Compute Column Sums
a)
If there are more than two distinct columns, then the
function is not symmetric.
b)
If the number of distinct column sums is equal to
two, we must compare their total with the number of
rows.
1)
2)
c)
If they are the same, we must complement
columns with smaller column sums. We may
also complement columns with higher
column sums, but the first approach will be
easier.
If they are not the same, then the function is
not symmetric.
If the number of distinct column sums is equal to
one, we must compare this distinct value with the
half of the total number of rows. Here, we do integer
division.
1) If they are equal, go to step 2
2) If they aren’t equal, go to step 3
Step 2: Compute row sums for a-numbers, and check for
dddfdd correct n choose a values.
a)
If values are correct, then the function is symmetric
b) If values aren’t correct, then the function isn’t
symmetric
Step 3: Compute row sums for a-numbers, and check for
ddddddcorrect n choose a numbers.
a)
If values are correct, then the function is symmetric.
4
b) If values aren’t correct, then expand function F about
any variable and repeat the process starting from step
1 for each co-factor
If output ‘X’ ‘s are ignored, algorithm works as is, and the
function is detected whether its is symmetric or not. If it is
symmetric which a-numbers are available, and whether some
variables are complemented or not are also found out. If we
would like utilize ‘X’ outputs, we store them in a linked list.
Again, at the beginning, when we check for symmetry by
ignoring them. If we find that it is symmetric, they are not
used. However, if a function is not symmetric, we find
minterms of those ‘X’ output, and choose those which are
useful to us. If one of those minterms is n choose 0, n choose
n, that minterm is definitely taken by my algorithm since there
can be only one of them, and by taking them I am increasing anumber symmetry which are 0 , n symmetry. For the rest of
those minterms, I check the corresponding n choose a value. If
it is zero in my table, I skip it. If the value is non zero, I
compare with the value that must be. If less , then I try to add
it to my table. What I mean by that is if it is already in the
table, it is ignored. Otherwise, it is added with the hope that it
will increase the n choose a value to what it must be. At the
end, all ‘X’ output rows will be processed, and symmetry
detection algorithm will be re-called.
Shannon decomposition is also done optionally. If we reach
step 3 – b, the function is decomposed into its co-factors F 0 ,
and F 1 on the first variable. For each co-factor, the symmetry
detection algorithm is re-called. This is done by creating two
symmetry tables from the original symmetry table which is
easy to do since we have all the original information readily
available. It is like putting those with ‘0’ inputs into a bag, and
those with ‘1’ inputs into another bag.
Shannon expansion, and ‘X’ output processing can be done
at the same time, or separately. If they’re done at the same
time, first ‘X’ output processing is performed, followed by
Shannon decomposition.
Here, I would like to talk about a few weaknesses of the
implementation with regard to discussions above. If a function
has more than 32 inputs, and a cube has 32, or more of them as
don’t cares, then there is no way to find minterms covered
since for each don’t care a left shift is required, and after 32
left shifts, an integer will wrap around to a negative value.
This problem also occurs when finding all combination values.
We use the previous combination values to find the next one
by adding some additions. If n is big, then n-1 combination can
result in an integer wrapping around to a negative value. To
consequently, the method which finds all combination values
first checks whether all values are positive. If not, then there is
no way to calculate the next combination.
When I was implementing sharp and dis-joint sharp
operations, I took advantage of similarities of them. Dis-joint
sharp is one step further of sharp operation. However, each
operation should discard cubes containing nulls. I provided
two sharp operations. One of them is discarding cubes with
nulls if wanted, the other is automatically discarding those
kind of cubes. The disjoint sharp is using the first sharp
method without discard operation. Consequently, I am
increasing cohesion within my class.
Here is the flow chart of execution of the program
INPUT
READ FIILE
PROCESS
OUTPUT
VI. CONCLUSION
The algorithm that we are using in symmetry detection is easy
to understand, and deterministic. Column sum additions give
us an early evaluation, and increase the speed. It also allows us
to find out whether some complemented variables give us a s
symmetric function. If the function passes the early evaluation,
row sums tell us whether it is symmetric or not. My
implementation also uses ‘X’ outputs info wisely if it is found
that the original function isn’t symmetric. We use those
minterms covered by ‘X’ output rows appropriately to help us
getting n choose a values. There is no smart way to choose
which variable to do Shannon expansion used in my
implementation. That is one of the weak sides.
VII. REFERENCES
[1] Mitch Thornton, Southern Methodist University
[2] Stacey Balamucki, Oakland University
[3] Dan Steffy, Oakland University
Download