Professional Documents
Culture Documents
Yan Gu
What is Combinational Circuits?
Input Output
. Width .
. .
. .
Depth
An omega circuit
1 2 3
0
0
1
1
2
2
Row
3
3
4
4
5 5
6
6
7 7
3
Row
4
Butterfly circuit, has n inputs and n outputs, it consists of 1+logn columns, number
0,1,…,logn,whith n rows per column, numbered 0,1,…,n-1.let P(i,j) represent the processor in
row i and column j. for 0=<j<logn, P(i,j) is connected to P(i, j+1) and P(k,j+1), where the binary
representations of i and k Differ only in their jth least significant bit. The circuit has a depth of
1+logn, a width of n, and a size of n+nlogn. In the example of figure , n=8.
A merging circuit
2 1
4 2
7 3
8 4
1 5
3 6
5 7
6 8
a Merging circuit receives as input two sequences of data, each consisting of n/2
values sorted in nondecreasing order. It produces as output these two sequence
combined into a single sequence of n data values sorted in nondecreasing order.
One such circuit, known as the odd-even merging circuit, is shown for n =8. it
consists of logn stages, with at most n/2 processors per stage. each processor is a
comparator :it receives two values as input and produces the smaller of the two on
its top output line and larger on the bottom line. The circuit has a depth of logn, a
width of n/2, and a size of 1+(n/2)x((logn)-1).
An odd-even-merge sorting circuit
4 1
8
2
3
7
2
4
5
1
5
6
6 7
3 8
A (theoretically) efficient sorting circuit consists of a complete tree with leave, 1+logn
levels. And a total of 2n-1 nodes. each nonleaf node is circuit made of comparators. The
circuit in a node is capable of receiving a set of m numbers, 2=<m=<n, and splitting it into
two sets: the node’s top child receives a set of m/2 numbers, each of which is smaller than or
equal to the m/2 numbers st to the node’s bottom child. in this way, if n numbers in arbitray
order are fed to the root as input, they emerge from the leaves sorted in nondecreasing
order from top to bottom .this circuit, referred to as the sorting-by-splitting circuit, has a
depth of O(logn), a width of O(n), and a size of O(nlogn)
A memory access unit for the RAM
U000
U001
U010
U011
U100
Processor
U101
U110
Memory
MAU U111
In the RAM, there is one processor and a memory consisting of M locations .the model allows the
processor to specify an arbitrary memory location from which it wishes to read or to which it wishes to
write. The job of the MAU is to set up a path from the processor to the chosen memory location. a
MAU for the RAM can be implemented as a binary tree of switches. The tree’s root is connected to
the processor, and each of the leaves to a distinct memory location. The tree has 1+logM stages,
numbered 1, 2,..,1+logM, with the root at stage 1. the tree links are assumed to be two-way
communication lines, a switch can therefore send or receive a datum to or from one of its children and
parents. this MAU has depth O (logM) AND width O (M), since the tree has 2M -1 switches, its size is
O(M.)
A naive MAU for the PRAM
1 U1
1
2
P1 2
3
3
4
1
U2
2
1 3
P2 2
3 1
4 2 U3
3
1
2 1
P3 2 U4
3
4 3
MAU
M Memory Location
Processor Tree Memory Location Tree
In PRAM, there are N processor and M memory locations. The model allows each processor to specify an
Arbitrary memory location to which it wishes to gain access. several processors are allowed to read from or
Write into the same memory location. a MAU for the PRAM creates paths from the processors to the memory
Location. Each processor is connected to the root of a binary tree with M leaves numbered 1 to M, and each
Memory location U is connected to a binary tree with N leaves numbered 1 to N. the MAU has a width of
O(N x M), a depth of O(logM + logN), and a size of O(N x M).
An efficient MAU for the PRAM
U1
P1
U2
P2
. Sorting . . .
. Circuit . . .
. . . .
PN UM
N Processors
MAU Merging Circuit
M Memory Locations
An efficient MAU for the PRAM consists of a sorting circuit and a merging circuit, and
the merging Circuit receives tow sorted list to be merged: one is the output of sorting circuit, and
The second one is received from the shared memory. The merging circuit has no Output, take
place the data inside. The MAU has a width of O(m+n), a depth of O(logN)+O(log(M+N)),
a size of O(NlogN)+O((M+N)log(M+N)).
Sorting Circuits
1. Sorting by merging
The sequence to be sorted is divided into two subsequences of equal length. Each
of the two subsequences is now sorted recursively, finally, the two sorted
subsequences are merged into one sorted sequence.
2. Sorting by splitting
the sequence to be sorted is divided into two subsequences of equal length such
that each element of the first subsequence is smaller that or equal to each
element of second subsequence .this splitting operation is the then applied to each
of the two subsequence recursively. when the recursion terminates, the sequence
is in sorted order.
Sorting by merging
Assume to merge tow sorted sequences{x1, x2, …, xm} and {y1, y2, …, ym},
to form a single sorted sequence {z1, z2, …, z2m}.
In general, a circuit for merging sequences{x1, x2, …, xm} and {y1, y2, …, ym} is
obtained as follows:
1. The odd-indexed elements of the two sequences{x1, x3, …, xm-1} and {y1, y3, …,
ym-1} are merged to produce a sorted sequence {u1, u2,…, um}.
2. simultaneously, The even-indexed elements of the two sequences{x2, x4, …, xm}
and {y2, y4, …, ym} are merged to produce a sorted sequence {v1, v2,…, vm}.
3. Finally, the output sequence {z1, z2,…, z2m} is obtained from z1=u1, z2m =vm,
z2i=min(ui+1, vi), and z2i+1=max(ui+1, vi), for i=1, 2, …, m-1
z1
u1
z2
u2
X1 (m/2,m/2) z3
u3
X2 Merging …
…
X3 circuit zm-1
um-1
…
zm
um
Xm-1
v1 … zm+1
Xm
zm+2
v2
Y1
zm+3
v3
Y2
(m/2,m/2) … … …
Y3
… Merging vm-1
z2m-1
Ym-1 circuit vm
z2m
ym
1. Each (m/2, m/2)merging circuit views its input as two sequences , each indexed
from 1 to m/2.
2. Each (m/2, m/2)merging circuit uses two (m/4,m/4) merging circuits, followed by a
column of (m/2)-1 comparators
An (m, m) odd-even merging circuit has the depth of O(logm), the width of O(m), the
Size of O(mlogm)
Reference:
Answers:
1. The Size is defined as the number of components it uses;
The depth is the number of stages in the circuit----- that is , the
maximum number of components on a path from input to output.
The Width of a circuit is the maximum number of components in a
stage.
2. The product of the depth and width provides an upper bound on the
size of the circuit.