
\chapter{Cube Calculus Machine}
% \setcounter{page}{26}
\label{CHEN-Chapter3}

The software-based approach is the simplest and cheapest way to realize 
cube calculus operations. Since the algorithm of a sequential cube 
calculus operation involves several levels of {\bf nested loops}, it leads to 
poor performance on general purpose computers. In some applications, 
such as logic minimization systems, or logic-based machine learning systems, 
there are so many cube calculus operations, that the software-based approach 
makes those applications unacceptable for practical sized problems due to
poor performance. For speeding up the cube calculus operations, the cube 
calculus machine was invented.

\section{Formalism for main algorithm for cube \\ calculus operation}
\label{CHEN-section3.1} 

The architecture of the Cube Calculus Machine (CCM) results from an attempt 
to optimize the execution of the most complex cube operation, sequential cube
calculus operations, like crosslink and sharp. Almost all cube calculus 
operations have two operand cubes described in Formulas~\ref{FORMULA-2.3}
and~\ref{FORMULA-2.4}. 

We re-write these two operand cubes in positional notation as:

\begin{align}
A &=x^{A_1}_1 x^{A_2}_2 \cdots x^{A_i}_i \cdots x^{A_n}_n\label{eq:ccm1}\\
B &=x^{B_1}_1 x^{B_2}_2 \cdots x^{B_i}_i \cdots x^{B_n}_n \nonumber
\end{align}

\noindent
where $A_i = (a_{i,1},a_{i,2},\cdots,a_{i,m},\cdots,a_{i,p_i})$, which
is the true set of literal $x_i^{A_i}$ in positional notation.
For each bit $a_{i,m}$ from $A_i$, $a_{i,m} \in \{0,1\}$. The bit $a_{i,m}$ 
represents the $m$-th possible value of the $i$-th variable. 
Similarly, $B_i = (b_{i,1},b_{i,2},\cdots,b_{i,m},\cdots,b_{i,p_i})$ and 
for each bit $b_{i,m}$ from $B_i$, $b_{i,m} \in \{0,1\}$. 
Example~\ref{CHEN-Example2.18} shows how to use this notation.

The sequential cube operations are generally described by Equation~\ref{CHEN-Equation2.12}. %%%%%%%%%%%%%%%
We can re-write the equation in positional notation as:

\begin{equation}
A\;(op)\; B=\vec{C} \label{eq:ccm2}
\end{equation}

\noindent
where resultant array of cubes $\vec{C}$ is:

\begin{align} 
\vec{C} = 
& \Big\{ X_1^{aft(A_1,B_1)} \cdots 
  X_{i-1}^{aft(A_{i-1},B_{i-1})}~
  X_{i}^{act(A_{i},B_{i})}~  X_{i+1}^{bef(A_{i+1},B_{i+1})}
  \cdots X_n^{bef(A_n,B_n)}  \nonumber \\
& \hspace{0.5in} \Big|\; \text{for such}\; i=1,2,\ldots,n,\;
               \text{that}\; relation(A_i,B_i)\;\text{is true} \Big\}
  \label{eq:ccm3}
\end{align}
 
\noindent where $bef$, $act$ and $aft$ are bitwise functions used to
calculate set operations {\it before}, {\it active} and {\it after}, respectively.
As discussed in section~\ref{CHEN-section2.4}, %%%%%%%%%%%%%%%%%%%%%%%%%%%%
an important property of output functions 
$bef$, $act$ and $aft$ is that they are {\bf bitwise functions}. 

As discussed in section~\ref{CHEN-section2.4.3}, %%%%%%%%%%%%%%%%%
the {\it relation} function is broken down 
into two parts: {\it partial relation} and {\it relation type}.
There are only two possible {\bf relation types}: $AND$ and $OR$. 
The {\it relation} can be described by:

\begin{align}
& relation(A_i,B_i) = \\ \label{eq:ccm4}
& \quad \begin{cases}
  rel(a_{i,1},b_{i,1}) + rel(a_{i,2},b_{i,2}) + \cdots + 
  rel(a_{i,p_i},b_{i,p_i}) 
  & \text{For $OR$ relation type} \\
  rel(a_{i,1},b_{i,1}) \cdot rel(a_{i,2},b_{i,2})  \cdots  
  rel(a_{i,p_i},b_{i,p_i}) 
  & \text{For $AND$ relation type}
 \end{cases} \nonumber
\end{align}

\noindent
where $rel$ is the {\it partial relation} and it is a bitwise function.

All simple combinational cube operations can be defined as a single 
set operation (see section~\ref{CHEN-section2.3.1}),%%%%%%%%%%%%%%%
so there is no need to define {\em before}, 
{\em active} and {\em after} functions. For consistency of description, 
however, we will assume that all variables in the case of the combinational cube calculus 
operations are of the {\em before} type. This way, the same computational mechanism 
can be used to calculate the combinational cube calculus operations. Therefore,
combinational operations can be described by the following equation:

\begin{equation}
A \; (op) \; B =
  X_1^{bef(A_1,B_1)} \cdots X_{i}^{bef(A_{i},B_{i})} \cdots
  X_n^{bef(A_n,B_n)}
  \label{eq:ccm5}
\end{equation}

All complex combinational cube operations are defined by two set operations
and one set relation (see section~\ref{CHEN-section2.3.2}). %%%%%%%%%%%%%%
For consistency of description, 
the complex combinational cube operations can be described by:

\begin{align}
A \; (op) \; B  = &
  X_1^{bef(A_1,B_1)} \cdots
  X_{k-1}^{bef(A_{k-1},B_{k-1})}~
  X_{k}^{act(A_{k},B_{k})}~
  X_{k+1}^{bef(A_{k+1},B_{k+1})}~
  \cdots \nonumber \\
& \cdots X_{l-1}^{bef(A_{l-1},B_{l-1})}~
  X_{l}^{act(A_{l},B_{l})}~
  X_{l+1}^{bef(A_{l+1},B_{l+1})}~
  \cdots
  X_n^{bef(A_n,B_n)}
  \label{eq:ccm6}
\end{align}

\noindent
where variables with indices $k$ and $l$ are special variables, and
are actived at the same time, the values of other variables are
calculated according to the $before$ function. The function $after$ 
is not used.

\begin{definition}
The variables whose pairs of literals ($x^{A_i}$, $x^{B_i}$) satisfy 
$relation(A_i,B_i)$ are said to be the {\bf specific variables}, and their
positions are said to be the {\bf specific positions}. The variable $x_i$
whose output function is {\bf active} function is said to be an 
{\bf active variable}.
\end{definition}

In the case of sequential cube operations, there is 
only one active variable at a time. In the case of complex combinational
cube operations, it is possible to have multiple active variables at the same time.

From the above discussion, we can see that these cube operations can
be described by functions $relation$, $before$, $active$ and
$after$, and have similar formulas.

\section{The general programmable patterns}
\label{CHEN-section3.2} 

The {\it bitwise} function (of length $k$) is the $k$-time repetition of
the same two-input, one-output Boolean function on argument vectors.
For instance, the bitwise function $\vec{C}=AND(\vec{A},\vec{B})$ is 
defined as follows:

\begin{equation*}
(c_1, c_2, \ldots, c_k) =
(AND(a_1,b_1), AND(a_2,b_2), \ldots, AND(a_k, b_k))
\end{equation*}

\noindent
where $(a_1,a_2,\ldots,a_k)$, $(b_1,b_2,\ldots,b_k)$ and 
$(c_1,c_2,\ldots,c_k)$ are the vectors $\vec{A}$, $\vec{B}$ and
$\vec{C}$, respectively.

In cube operations, there are four bitwise functions: {\bf before}, 
{\bf active}, {\bf after} and {\bf rel} (partial relation).

We can use a truth table to specify the output values for a Boolean
function in terms of the values of input variables. For a bitwise 
function, there are $2 \times 2 = 4$ combinations of values of the 
variables. Therefore, the bitwise function can be completely specified 
by its four output values. This is shown in Figure \ref{fig:ccm15}(a).

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/ccm15.eps}}}
\caption{Realizing an arbitrary function of two binary variables}
\label{fig:ccm15}
\end{figure}

An arbitrary Boolean function of two binary variables $a$ and $b$ can
be realized by a 4-to-1 multiplexer as shown in Figure \ref{fig:ccm15}(b).
The variables $a$ and $b$ are the {\bf control inputs of the multiplexer,}
the output values of the function are the {\bf data inputs of the multiplexer}.
The values of $a$ and $b$ will select the valid output values from the data inputs.

This general structure can be programmed to realize an arbitrary bitwise
function. For example, the output values of function $f(a,b)=a + b$ are
0111. Set $I_0I_1I_2I_3=0111$, the output of multiplexer is the function
of $f(a,b)~=~a+b$.

% All bitwise functions used in cube operations discussed in Chapter 2 
% are listed in Table \ref{tbl:ccop4}. 

We derived all output values of the bitwise functions of the cube operations
listed in Table \ref{tbl:ccop4}, the results are listed in Table \ref{tbl:ccm2}.
This calculation is very simple. For example, suppose the function is 
$f(a_i,b_i)~=~a_i \cdot \overline{b_i}$, then

\begin{align*}
  f(0,0) & ~=~ 0 \cdot \overline{0}~=~0 \\
  f(0,1) & ~=~ 0 \cdot \overline{1}~=~0 \\
  f(1,0) & ~=~ 1 \cdot \overline{0}~=~1 \\
  f(1,1) & ~=~ 1 \cdot \overline{1}~=~ 0 
\end{align*}

Therefore, the output values of function $f(a_i,b_i)~=~a_i \cdot \overline{b_i}$
are 0010.

\begin{table}[H]
%\begin{table}[h]
\caption{The Output Values of Bitwise Functions Used in Cube Operations}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|} \hline 
% title
  \multirow{2}{1in}{\centering {\bf Operation}}
& \multirow{2}{1in}{\centering {\bf Notation}}
& \multicolumn{2}{c|}{{\bf Relation}}  
& \multicolumn{3}{c|}{{\bf Output Function}} \\ \cline{3-7}
 & & $rel$ & $and/or$ & $before$ & $active$ & $after$ \\ \hline
% content
crosslink & $A \;\uplus\; B$ & 1110 & 1 & 0011 & 0111 & 0101 \\ \hline
sharp & $A \;\#_{basic}\; B$          & 0010 & 0 & 0011 & 0010 & 0011 \\ \hline
disjoint sharp & $A \;\#d_{basic}\; B$ & 0010 & 0 & 0011 & 0010 & 0001 \\ \hline
consensus & $A \;\ast_{basic}\; B$     & 1111 & 1 & 0001 & 0111 & 0001 \\ \hline
intersection & $A \;\cap\; B$   & --  & -- & 0001 & -- & -- \\ \hline
super cube & $A \;\cup\; B$     & --  & -- & 0111 & -- & -- \\ \hline
prime & $A \; ' \; B$           & 0001 & 0 & 0011 & 0111 & -- \\ \hline
cofactor & $A\, |_{basic}\, B$  & 1011 & 1 & 0001 & 1111 & -- \\ \hline
\end{tabular}
\end{center}
\label{tbl:ccm2}
\end{table}

Each row of Table \ref{tbl:ccm2} describes one cube operation. The operation
name, notation, the output value of {\it rel} (partial relation) function, 
{\it and\_or} (relation type), the output values of {\it before}, 
{\it active} and {\it after} functions are listed from left to right. 
The value of and\_or equals to 1 means that the relation type is of $AND$
type; otherwise, the relation type is of $OR$ type.

\section{The data path of CCM}
\label{CHEN-section3.3} 

Since the data path of CCM results from an attempt to optimize the 
execution of cube calculus operations, especially the sequential cube calculus 
operations, the CCM has been designed to directly implement Formulas
\ref{eq:ccm2} and \ref{eq:ccm3}. 

From Formula \ref{eq:ccm3}, it can be seen that one {\bf relation
function} and one of {\bf three output functions} ({\it bef}, {\it act}
and {\it aft}) are applied on every pair of literals ($x_i^{A_i}$,
$x_i^{B_i}$) in the same manner. This means that we can use one combinational
logic block to process every pair of literals {\bf in series}, or use
$n$ identical logic blocks to process all pairs of literals 
{\bf in parallel} (one pair of literals per logic block).
Obviously, you recognize that this second solution is the familiar to you
{\bf iterative network}. It has a better performance than the former because of its parallelism.

The CCM is realized using an iterative network. If
you forgot about iterative networks, please review them from 
Chapter~\ref{CHAPTER-ITERATIVE} before you will proceed any further.
Iterative networks are a very important subject.

\subsection{The algorithm of the CCM}
\label{CHEN-section3.3.1} 

As mentioned above, the CCM is realized with an iterative network.
The cell of this iterative network is more complex than those in the 
examples given in section~\ref{CHEN-section3.3.1}. %%%%%%%%%%%%%%
The cell of the iterative network consists
of a {\bf sequential logic block} and {\bf several combinational logic blocks},
as shown in Figure \ref{fig:iter4}. The inputs $A[i]$ and $B[i]$
are the pair of input literals. $C[i]$ is the output literal.
$Relation$, $bef$, $act$ and $aft$ are binary bits used to specify
these function. $clk$ and $reset$ are the clock and reset inputs
of the D flip-flops used in sequential logic block. The signal
{\bf next} ($next[i]$ and $next[i+1]$ in the figure) is the
{\bf propagation signal} (it will be discussed later). The signal $var[i]$ is generated by 
combinational logic block A, and represents whether the variable ($x_i$) 
is a special variable ($var[i]=1$) or not ($var[i]=0$).

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/iter4.eps}}}
\caption{An simplified iterative cell of the CCM}
\label{fig:iter4}
\end{figure}

For a sequential cube operation (section~\ref{CHEN-section2.2.3}) %%%%%%%%%%%%%
we know that every special
variable produces one resultant cube.

For a given special variable
(say $x_i$), the resultant cube is generated in the following manner:

\begin{itemize}
\item
The output literal $C_i$ is calculated by $act(A_i,B_i)$. 
\item
The output literal $C_k$ ($ 1 \leq k < i$) is calculated by $aft(A_k,B_k)$.
\item
The output literal $C_l$ ($i < l \leq n$)
is calculated by $bef(A_l,B_l)$. 
\item
An output literal is calculated by
combinational logic block B in Figure \ref{fig:iter4}.
\item
All output literals can be calculated in parallel with an iterative network.
\end{itemize}

\begin{definition}
A variable is to be called the {\bf active variable} when it is in active state.
\end{definition}

Now we need to find a way to activate special variables in series,
which means only one variable should be in an active state at a time, and all 
special variables become active one after another.
All other variables should know their relative position with respect to 
the current active variable, left or right.

Our solution to this problem is as follows:

\begin{itemize}
\item The propagation signal {\it next} activates the first special
      variable that it encounters. The signal {\it next} is propagated
      through combinational logic block $C$ in Figure \ref{fig:iter4}. The
      logic of the combinational logic block $C$ can be described by:
      \begin{equation}
         next[i+1] = act[i] + next[i] \cdot \overline{var[i]} \label{eq:next}
      \end{equation}
      where signal $act[i]$ is 1 when current state of the FSM is active
      (current state is represented by the signal $state[i]$).

\item Every variable (cell) has a simple {\bf Finite State Machine (FSM)}
      (the sequential logic block in the Figure \ref{fig:iter4}) to 
      memorize its relative position with respect to the active variable.
      This FSM has {\bf three states}: {\it after}, {\it active} and {\it before}, 
      which corresponds to the variable being on the left side of the
      active variable, the active variable itself, and the variables
      being on the right side of the active variable, respectively.

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/sm_fsm.eps,height=2.2in}}}
\caption{The SM chart of the FSM}
\label{fig:sm_fsm}
\end{figure}

      The state machine flowchart\cite{roth92} (or SM chart for short) 
      of the FSM is shown in Figure \ref{fig:sm_fsm}. The states 
      {\it bef}, {\it act} and {\it aft} are the short name of 
      states {\it before}, {\it active} and {\it after}, respectively.
      The numbers under the state names are the {\bf state assignments}
      (the {\bf encoding
      vectors}).  This state machine is realized by using D flip-flops with 
      {\bf asynchronous reset}, thus the reset
      inputs of the D flip-flops can be used to reset the FSM to {\it before}
      state. This reset logic is not shown in the SM chart. 
      The output of the FSM is $state[i]$ signal which represents
      the state of the FSM (the index indicates the index number of the cell).

      The signal $state[i]$ is used as the select inputs of the multiplexer 
      to select corresponding output function for combinational logic block $B$
      (see Figure \ref{fig:iter4}).
\end{itemize}

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/iter5.eps}}}
\caption{The iterative network of the CCM}
\label{fig:iter5}
\end{figure}

The whole iterative network is shown in Figure \ref{fig:iter5}. The inputs
$A[i]$, $B[i]$, $Relation$, $bef$, $act$, $aft$ come from the {\bf register file}
which is not shown in the figure, and the output $C[i]$ is not shown either.
The signal {\it request} is connected to the $clk$ input of the iterative cell.
The signals {\bf request} and {\bf reset} are generated by {\bf Operation Control
Unit (OCU)}.

The following example describes 
the procedure of executing a sequential cube operation by the {\bf core of
the CCM}, the {\bf sequential iterative network} (also called {\bf one-dimensional
cellular automaton}).

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/time0.eps}}}
\caption{Timing diagram of Example~\ref{CHEN-Example3.3}}
\label{fig:time0}
\end{figure}

\noindent
\begin{example}
~\label{CHEN-Example3.3}
\end{example}

\noindent
An example of a sequential cube operation is illustrated in 
Figure \ref{fig:time0}. In this example, there are two operand cubes,
each of them has 4 variables: $x_1$, $x_2$, $x_3$ and $x_4$.
In this case, variables $x_2$ and $x_4$ are the {\bf special variables}. 

Assume we have a CCM that has 4 iterative cells. In Figure \ref{fig:time0},
``cell[i] state" is the $state$ signal of the cell $i$; ``cell[i] state+"
is the next state signal of the cell $i$. ``var[i]" is the $var$ signal of
cell $i$, where $i=1,2,3,4$. With 4 iterative cells, the CCM has 5 
propagation signals $next$, $next[1]$ to $next[5]$.
%
This sequential cube operation takes 5 periods (ticks) of the clock. Now let us take
a close look at how the CCM works.

\begin{enumerate}
\item In period $T_1$:

      The inputs {\it relation}, {\it bef}, {\it act}, {\it aft} and 
      the operand cubes are applied in parallel and keep {\bf stable} during
      the whole cube operation. 

      After the operand cubes are applied, the combinational logic block $A$
      in each cell begins to evaluate signal $var[i]$. 
      Assuming that the worst-case delay of logic block $A$ is $t_A$, after
      the delay of $t_A$, all signals $var[i]$ ($i=1,2,3,4$) become stable
      and will keep stable if and only if the inputs of operand cubes and the
      function $relation$ keep stable. In this example, $var[1]=var[3]=0$,
      and $var[2]=var[4]=1$. The final states of $var$ signals are shown in
      Figure \ref{fig:time0}; the delay of $t_A$ is not shown in the figure.

      All FSMs are reset to {\it before} state by setting signal {\it reset}
      to 1 (see Figure \ref{fig:time0}). 

      The signal $next$[1] is set to 0. The signals $next[2]$ to $next[5]$ 
      became 0's (see Equation \ref{eq:next}).
      Since the states of FSMs are reset to the {\it before} state and
      all $next$ signals are 0's, the next states of all FSMs become 
      the {\it before} state (see Figure \ref{fig:sm_fsm}).

\item In period $T_2$:

      The signal $next[1]$ is set to 1.

      \underline{For the cell 1}, substitution $act[1]=0$, $next[1]=1$ and 
      $var[1]=0$ into Equation (\ref{eq:next}) gives: 
      \qquad $next[2] = act[1] + next[1] \cdot \overline{var[1]}
                           = 0 + 1 \cdot \overline{0} = 1$. 

      There is a delay of value 1 propagating from $nex[1]$ to $next[2]$,
      and the delay is shown in Figure \ref{fig:time0}. This delay comes from
      combinational logic that is described by Equation (\ref{eq:next}).
      
      The next state of the cell 1 is {\it after} 
      (see Figure \ref{fig:sm_fsm}).
      
      \underline{For the cell 2}, substitution $act[2]=0$, $next[2]=1$ and
      $var[2]=1$ into Equation (\ref{eq:next}) gives: 
      \qquad $next[3] = act[2] + next[2] \cdot \overline{var[2]}
                           = 0 + 1 \cdot \overline{1} = 0$. 

      The next state of the cell 2 is {\it active}
      (see Figure \ref{fig:sm_fsm}).

      \underline{For the cells 3 and 4}, since there is no change on 
      signal $next$ ($next[3]$ and $next[4]$ keep 0), the next state 
      of cells 3 and 4 are {\it before}.

\item In period $T_3$:

      There is a rising edge of signal {\it request}, then 
      all cells change to the next state determined at previous period $T_2$.
      As shown in Figure \ref{fig:time0}, the cell 1 goes to {\it after} 
      state, the cell 2 goes to {\it active}
      state, and the cell 3 and 4 keep {\it before} state. 

      At this time, 4 $state[i]$ ($i=1,2,3,4$) signals are used to select
      the corresponding output function. After that, the combinational
      logic block B in all cells begin to evaluate output literals $C[i]$ in
      parallel. Assume the clock-to-Q delay of the D flip-flops is $t_{FF}$,
      and the worse-case delay of the combinational logic blocks B is $t_B$.
      Thus, after the delay of $t_{FF} + t_B$, all output literals $C[i]$
      become stable, which means the first resultant cube is generated
      and can be read.

      \underline{For the cell 1}, the current state is {\it after}. 
      From the SM chart of the FSM we know that the cell 1 will keep 
      {\it after} state during the left time of the cube operation.

      \underline{For the cell 2}, the current state is {\it active}, 
      then $act[2]=1$. Using Equation (\ref{eq:next}) gives:
      \qquad $next[3] = act[2] + next[2] \cdot \overline{var}
                           = 1 + 0 \cdot \overline{1} = 1$. 

      The next state of the cell 2 is {\it after} state
      (see Figure \ref{fig:sm_fsm}).
      
      \underline{For the cell 3}, because the signal $next[3] = 1$ and 
      $var[3]=0$, using Equation (\ref{eq:next}) gives: 
      \qquad $next[4] = act[3] + next[3] \cdot \overline{var}
                           = 0 + 1 \cdot \overline{0} = 1$. 

      Because $next[3]=1$ and $var[3]=0$, the next state of the cell 3 is 
      {\it after} (see Figure \ref{fig:sm_fsm}).
   
      \underline{For the cell 4}, because $next[4]=1$ and $var[4]=1$, 
      using Equation (\ref{eq:next}) gives: 
      \qquad $next[5] = act[4] + next[4] \cdot \overline{var}
                           = 0 + 1 \cdot \overline{1} = 0$.

      The next state of the cell 4 is {\it active} because $next[3]=1$ and
      $var[3]=1$ (see Figure \ref{fig:sm_fsm}).

\item In period $T_4$:

      There is a rising edge of signal {\it request}, then 
      all cells change to the next state determined at previous period $T_3$.
      The cell 1 keeps {\it after} state, the cells 2 and 3 goes to 
      {\it after} state, and the cell 4 goes to {\it active} state. 

      At this time, 4 $state[i]$ ($i=1,2,3,4$) signals are used to 
      select the corresponding output function, and the second resultant 
      cube is generated and can be read.

      Because the cell 4 goes to {\it active} state, the signal $next[5]$
      becomes 1 (Equation \ref{eq:next}).

\item In period $T_5$:

      Since the value 1 reaches the last point of the propagation signal 
      $next$ ($next[5]$ in this example), the cube operation is completed.
\end{enumerate}

\subsection{The signal {\bf ready}}
\label{CHEN-section3.3.2} 

As mentioned in section~\ref{CHAPTER-ITERATIVE}, the disadvantage of the iterative network
is that the propagation signal must propagate through a large number
of cells, so the response time will be longer. The delay of propagational
signal $next$ reaching the first special variable it encountered is the following:

\begin{equation}
  T_{propagation} = t_{FF} + k \cdot t_C
\end{equation}

\noindent
where $t_C$ is the worse-case delay of the combinational logic block $C$, 
and $k$ is the number of cells the propagation signal going through.
It can be seen that the larger the $k$, the longer the propagation delay.

When $k$ is increased, the delay becomes longer. For the CCM working 
properly, we have two choices:
\begin{enumerate}
\item one choice is to {\bf slow the clock signal} which 
would slow down the entire CCM. 
\item the other choice is to use a $ready$ signal 
to tell the CU whether the ILU is ready or not, the CU generate $request$ 
signal only when the ILU is ready. The $ready$ signal is as follows:
\begin{align}
  subready[i] & = \overline{request} \cdot next[i] \cdot var[i] \\ 
  ready & = subready[1] + subready[2] + \cdots + subready[n] 
\end{align}
The $subready[i]$ signal is generated at the cell that represents a special
variable ($var=1$) and receives the $next$ signal. Any of $subready[i]$
signals becoming 1 means that the CCM is ready to output the result cube.
Since we don't want to slow down the entire CCM, as its speed is of the primary concern,
the second solution is used.

\section{Iterative Logic Unit and Iterative Cell}
\label{CHEN-section3.4} 

The iterative network and the iterative cell described in section~\ref{CHEN-section3.3} 
are called the {\bf Iterative Logic Unit (ILU)}
and the {\bf ITerative cell (IT)}, respectively. The ITs are
enumerated from left to right: IT[1], IT[2],\ldots,
IT[n]. The number of ITs is denoted by $n$. 

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/ccm8.eps,height=1.25in}}}
\caption{The rule of naming signals}
\label{fig:ccm8}
\end{figure}

Logic signals within each IT[i] have the index of $i$ (as a subscript).
{\bf Horizontal signals running from left} of IT (say IT[i]) to its right
neighbor IT[i+1] have the index of $i+1$; 
{\bf Horizontal signals running from right} of IT (say IT[i]) to its left
neighbor IT[i-1] have the index of $i-1$; 
{\bf Vertical signals} both coming into or leaving from IT[i] have index
of $i$. These principles of naming signals are shown in Figure \ref{fig:ccm8}.

\subsection{Handling multi-valued variables}
\label{CHEN-section3.4.1} 

In the previous section, we just stated that one cell of IT processes only a single 
variable. Since one cell processing one variable with arbitrary number
of possible values would be not practical, so in our design, one cell
(IT) can process {\bf one binary variable}. However, in addition, for 
processing variables with more than two possible values 
(the so-called {\bf multi-valued variables}), multiple $IT$s are combined together to 
process a multi-valued variable. 

Because the CCM is a hardware, when it has been realized, it has a
fixed number of iterative cells. When we use the CCM to solve a problem,
we can not always use all of its iterative cells. Sometimes, we just use part
of it. Therefore, we need a {\bf signal vector} to tell whether a given iterative
cell is used by an operation or not. This signal vector is called $water[i]$ 
where $i=1,2,\ldots,n$ ($w[i]$ for short). The signal $w[i]=1$ means
that IT[i] is not used, and it should be transparent to all signals
running horizontally (recall, that signals running horizontally are the signals running
between cells, like the signal $next$).

\noindent
\begin{example}
~\label{CHEN-Example3.4}
\end{example}

\noindent
Assume a CCM with 4 iterative cells. For a given
cube operation, only two iterative cells are needed. The corresponding 
signal $water$ should be

$\overbrace{0}^{w[1]}~\overbrace{0}^{w[2]}~\overbrace{1}^{[w[3]}~\overbrace{1}^{w[4]}$.

We use multiple iterative cells to handle a multi-valued variable. We
need a signal vector to tell where is the {\bf boundary of a multi-valued
variable}. This signal vector is $right\_edge[i]$ ($re[i]$ for short),
where $i=1,2,\ldots,n$. The signal $re[i]=1$ means
that IT[i] is the {\bf right edge of a variable}. If all variables are binary,
then all bits of $right\_edge$ are 1's. Since one iterative cell 
processes two possible values of a variable, we can process a multi-valued
variable with an {\bf even number of possible values}.

\noindent
\begin{example}
~\label{CHEN-Example3.5}
\end{example}

\noindent
Assume a CCM with 6 iterative cells. For a given
cube operation, there are 3 variables with 2, 4 and 6 possible values,
respectively. Therefore the signal $right\_edge$ is 

$\underbrace{\overbrace{1}^{re[1]}}_{variable 1}~
\underbrace{\overbrace{0}^{re[2]}~\overbrace{1}^{[re[3]}}_{variable 2}\;
\underbrace{\overbrace{0}^{re[4]}~\overbrace{0}^{re[5]}~\overbrace{1}^{[re[6]}
}_{variable 3}$. 

Since all iterative cells are used, so the signal $water$ is 000000.

Take $w[i]$ and $re[i]$ into account, for handling multi-valued variables, 
the $next$ signal is described now as:

\begin{equation}
next[i+1] = \overline{w[i]}\cdot 
            \big(act[i] + next[i]\cdot\overline{re[i]\cdot var[i]}\big)
            + w[i] \cdot next[i] 
\label{eq:next2}
\end{equation}

\noindent
which means that when the IT[i] is not used ($w[i]=1$), the iterative cell
is {\bf transparent} to the signal $next$. Otherwise, the $next$ signal will 
propagate till the right edge of the first special variable that it will encounter. 

Two more propagation signals $carry$ and $conf$ are used to combine
multiple iterative cells to process multi-valued variables. Let us
discuss first a simplified example that shows how to use these two signals.
Next the general equations for these two signals will be derived after the example.

\noindent
\begin{example}
~\label{CHEN-Example3.6}
\end{example}

\noindent
Three iterative cells are combined together to process 
a pair of operand literals of a 6-valued variable as shown in 
Figure \ref{fig:iter6}. The $water$ and $right\_edge$ signals are also
shown in the figure.

Now the problem is that no iterative cell receives all bits of operand cubes, 
then no single iterative cell can determine signal $var$ of the variable by 
itself (the signal $var$ represents whether the variable is a special 
variable or not). For a given {\bf OR\_type cube operation}, the signal $var$ 
should be (Equation \ref{eq:ccm4}):

\begin{equation}
  var = rel(a_1,b_1) +rel(a_2,b_2) +rel(a_3,b_3)
        +rel(a_4,b_4) +rel(a_5,b_5) +rel(a_6,b_6)
\end{equation}
Since a single iterative cell processes just two possible values, then we
can let them be:
\begin{align}
  carry[2] & = rel(a_1,b_1) +rel(a_2,b_2) \\
  carry[3] & = carry[2] + rel(a_3,b_3) +rel(a_4,b_4) \\
  carry[4] & = carry[3] + rel(a_5,b_5) +rel(a_6,b_6) 
\end{align}
Substituting Equations~\ref{CHEN-(3.13)},%%%%%%%%%%%
~\ref{CHEN-(3.14)} into~\ref{CHEN-(3.15)} gives:

\begin{equation}
  carry[4] = rel(a_1,b_1) +rel(a_2,b_2) +rel(a_3,b_3)
        +rel(a_4,b_4) +rel(a_5,b_5) +rel(a_6,b_6)
\label{CHEN-(3.16)}
\end{equation}

Comparing Equations~\ref{CHEN-(3.12)} and~\ref{CHEN-(3.16)}, we know that the signal $var$ is 
generated, and $var=carry[4]$. Please note that the signal $var$ is always 
finally generated at the last cell of a variable.  

All three cells that process the variable should know the signal $var$.
For the last cell of the variable (IT[3] in this example), 
$var[3]=carry[4]$. All other cells that process the same variable
receive the signal $var$ through the propagation signal $conf$ from
its successive cell. In other words, the signal $var$ is propagated back 
to the preceding cells through the iterative signal $conf$. This can
be described by:

\begin{equation}
 conf[2] = carry[4]  \quad
 var[2] = conf[2]  \quad
 conf[1] = var[2] \quad
 var[1] = conf[1]
\label{CHEN-(3.17)}
\end{equation}

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/iter6.eps}}}
\caption{Three iterative cells combined together to process a 6-valued
variable}
\label{fig:iter6}
\end{figure}

It can be seen that the signal $carry$ propagates from left to right
until the right edge of the variable in order to generate signal $var$
of the variable. Then signal $var$ is propagated back (from right to left)
through signal $conf$ (Equation~\ref{CHEN-(3.17)}). This propagation path is shown in 
Figure \ref{fig:iter6} by shadow big arrow.

For the {\bf AND\_type cube operation}, we only need to change ``+" to ``$\cdot$"
in the Equations~\ref{CHEN-(3.12)} to~\ref{CHEN-(3.16)}. 
% The information propagate from left to right through $carry$ and propagate
% from right to left through $conf$ in the same manner as OR\_type cube 
% operation.

Now we are ready to derive general formula for signals $carry[i]$,
$conf[i]$ and $var[i]$. The IT[i] processes two possible values of
a variable, then there are two partial relations in one iterative cell:

\begin{align}
  rel0[i] & = rel(a0[i], b0[i]) \\
  rel1[i] & = rel(a1[i], b1[i])
\end{align}

\noindent
where $a0[i]$ and $a1[i]$ are two input bits from operand literal $A$,
$b0[i]$ and $b1[i]$ are two input bits from operand literal $B$.
For AND type relation, signal $carry\_and$ (signal $carry$ for AND type
relation) can be described as:

\begin{equation}
carry\_and[i+1] =
 \begin{cases}
  rel0[i] \cdot rel1[i] & \text{if IT[i] is the first IT of a variable}\\
  rel0[i] \cdot rel1[i] \cdot carry[i] & \;\text{otherwise}
 \end{cases}
\label{eq:carryand}
\end{equation}

For OR type relation, signal $carry\_or$ (signal $carry$ for OR type relation) can be described as:

\begin{equation}
carry\_or[i+1] =
 \begin{cases}
  rel0[i] + rel1[i]  & \text{if IT[i] is the first IT of a variable} \\
  rel0[i] + rel1[i] + carry[i]  & \;\text{otherwise}
 \end{cases}
\label{eq:carryor}
\end{equation}

Signal $right\_edge$ can be used to determine whether or not
a given IT[i] is the first/last IT of a variable:

\begin{align}
 re[i] = 1   &\qquad\text{if IT[i] is the last IT of a variable} 
  \label{eq:lastcell} \\
 re[i-1] = 1 &\qquad\text{if IT[i] is the first IT of a variable}
  \label{eq:firstcell}
\end{align}

Because IT[1] is always the first IT of a variable, then

\begin{equation}
  re[0] \equiv 1
\end{equation}

Combining Equations (\ref{eq:carryand}) and (\ref{eq:firstcell}), we obtain

\begin{align}
 carry\_and[i+1] & = rel0[i] \cdot rel1[i] \cdot re[i-1] \label{eq:carryand2}\\
    & \quad + carry[i] \cdot rel0[i] \cdot rel1[i] \cdot \overline{re[i-1]}
     \nonumber \\
    & = rel0[i] \cdot rel1[i] \cdot
      (re[i-1] + carry[i] \cdot \overline{re[i-1]})
     \nonumber \\
    & = rel0[i] \cdot rel1[i] \cdot (re[i-1] + carry[i])
     \nonumber \\
    & = rel0[i] \cdot rel1[i] \cdot re[i-1]
        + rel0[i] \cdot rel1[i] \cdot carry[i] \nonumber
\end{align}

Combining Equation (\ref{eq:carryor}) and (\ref{eq:firstcell}), we obtain

\begin{align}
 carry\_or[i+1] & = (rel0[i] + rel1[i]) \cdot re[i-1] \label{eq:carryor2}\\
    & \quad    + (carry[i] + rel0[i] + rel1[i]) \cdot \overline{re[i-1]}
     \nonumber \\
    & = (rel0[i] + rel1[i]) \cdot re[i-1]
        + carry[i] \cdot \overline{re[i-1]} \nonumber \\
    & \quad + (rel0[i] + rel1[i]) \cdot \overline{re[i-1]}
     \nonumber \\
    & = rel0[i] + rel1[i] + carry[i] \cdot \overline{re[i-1]} \nonumber
\end{align}

The signal $carry[i+1]$ is obtained by combining $carry\_and$ and $carry\_or$ as:

\begin{align}
 carry[i+1] =&\; carry\_and[i+1] \cdot and\_or \\
             &\; + carry\_or[i+1] \cdot \overline{and\_or} \nonumber 
\end{align}

\noindent
where signal $and\_or$ represents the relation type of the cube operation.
$and\_or=1$ means that the cube operation is of AND type, otherwise,
the cube operation is of OR type. Because $carry\_or$ always equals 1 
whenever $carry\_and$ equals 1, by combining Equation 
(\ref{eq:carryand2}) and (\ref{eq:carryor2}), we obtain:

\begin{align}
 carry[i+1] =&\; carry\_and[i+1] \cdot and\_or \\
             &\; + carry\_or[i+1] \cdot \overline{and\_or} \nonumber \\
    =&\; carry\_and[i+1]
              + carry\_or[i+1] \cdot \overline{and\_or}  \nonumber\\
    =&\; rel0[i] \cdot rel1[i] \cdot re[i-1]
        + rel0[i] \cdot rel1[i] \cdot carry[i] \nonumber\\
     &\; + (rel0[i] + rel1[i]) \cdot \overline{and\_or}
     +carry[i] \cdot \overline{re[i-1]} \cdot \overline{and\_or} \nonumber 
\end{align}

As shown in Example~\ref{CHEN-Example3.6}, signal $conf$ can be generally described as:

\begin{equation}
 conf[i-1] = \label{eq:conf}
 \begin{cases}
  carry[i+1] & \quad\text{if IT[i] is the last IT of a variable} \\
  conf[i]    & \quad\text{otherwise}
 \end{cases}
\end{equation}

Combining Equation (\ref{eq:conf}) and (\ref{eq:lastcell}), we obtain:

\begin{align}
 conf[i-1] & = conf[i] \cdot \overline{re[i]} + carry[i+1] \cdot re[i]
\end{align}

The signal $var$ always comes from signal $conf$, which is:
\begin{equation}
  var[i] = conf[i-1]
\end{equation}

\noindent If we also take the signal $water$ into account, we obtain:

\begin{align}
carry[i+1]
 =&\; \overline{w[i]} \cdot \Big(rel0[i] \cdot rel1[i] \cdot re[i-1] \\
  &\hspace{0.5in}+rel0[i] \cdot rel1[i] \cdot carry[i] 
% \nonumber \\ &\hspace{0.5in}
+\big(rel0[i] + rel1[i]\big)\cdot\overline{and\_or}\nonumber\\
  &\hspace{0.5in} + carry[i] \cdot \overline{re[i-1]} \cdot 
                        \overline{and\_or}\,\Big) 
% \nonumber\\ &\; 
+ w[i] \cdot carry[i] \nonumber \\
 conf[i-1] =& \; \overline{w[i]}
            \cdot (conf[i] \cdot \overline{re[i]} + carry[i+1] \cdot re[i]) \\
            & + w[i] \cdot conf[i] \nonumber
\end{align}

\subsection{The design of an iterative cell}
\label{CHEN-section3.4.2} 

\begin{figure}[H]
\centerline{\hbox{\hspace*{0.8in}\psfig{figure=fig/ccm10b.eps,height=4in}}}
\caption{The block diagram of a Iterative Cell (IT)}
\label{fig:ccm10}
\end{figure}

Now we know how iterative network works and how to combine multiple
iterative cells to handle a multi-valued variable. This section will 
describe the details of the iterative cell that have not been discussed 
so far. The block diagram of one iterative cell is shown in Figure 
\ref{fig:ccm10}. As shown in the figure, one iterative cell can be divided 
into five blocks according to the function that they perform: 
IDENTIFY, STATE, OPERATION, COUNTER and EMPTY. All signals except the 
signals of COUNTER block in the figure were already discussed in the previous 
sections. The COUNTER block will be discussed in this section.

\subsubsection{OPERATION block} 

The operation block is the combinational logic block $B$ in Figure
\ref{fig:iter4}. This block creates bits of resultant cubes by 
performing the operation on bits of the argument cubes according to the 
state of $IT$. It takes the following inputs:
\begin{enumerate}
\item Two bits from operand literal $A[i]$ ($a0_i$, $a1_i$).
\item Two bits from operand literal $B[i]$ ($b0_i$ and $b1_i$).
\item Two bits signal $state[i]$ from block STATE.
\item 12 bits programmable inputs: 12 bits for functions $before$, $active$ and
      $after$ (4 bits each function).
\end{enumerate}

% \vspace{-20pt}
\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/ccm6.eps,height=2.5in}}}
\caption{Block OPERATION of IT}
\label{fig:ccm6}
\end{figure}

It has two-bit output $C[i]$ ($c0_i$ and $c1_i$). The realization of
OPERATION block follows the general programmable pattern (section~\ref{CHEN-section3.2}) and 
is shown in Figure \ref{fig:ccm6}. This design takes one 4-bit 4-to-1 
multiplexer and two 1-bit 4-to-1 multiplexers. 

The signal $state[i]$ selects one function from three possible programmable 
functions by using one 4-bit 4-to-1 multiplexer, then realizes this function
by using two 1-bit 4-to-1 multiplexers. Since there are only three possible
output functions, so the last data input of the 4-bit 4-to-1 multiplexer
is not used and is connected to a constant (0000 in the figure).

This is a general circuit for all kinds of cube calculus operations which 
can be described by Equations \ref{eq:ccm2} and \ref{eq:ccm3}. 
The output values of functions $before$, $active$ and $after$ of the cube 
operations described in Chapter~\ref{CHEN-CHAPTER2} are listed in Table \ref{tbl:ccm2}.

\subsubsection{Block STATE} 

The STATE block is the combination of the sequential logic block and 
combinational logic block $C$ in Figure~\ref{fig:iter4}. It has the 
following inputs:
\begin{enumerate}
\item signal $var[i]$ from IDENTIFY block.
\item signal $next[i]$ from preceding iterative cell.
\item global signals $reset$, $request$ and $prime$.
\end{enumerate}

The signal $prime$ is used in complex combinational cube operations.
As we discussed in section~\ref{CHEN-section3.3.2}, there is a FSM in this block and the
SM chart of the FSM was shown in Figure \ref{fig:sm_fsm}.

Since there are three states, this FSM can be realized by
using two D flip-flops. The current state of the FSM is represented by
the Q outputs of these two flip-flops, denoted by $state0[i]$ and $state1[i]$.
The next state of the FSM is represented by D inputs of these two
flip-flops, denoted by $ex0$ and $ex1$. This state machine can be described 
using the following formulas:

\begin{align}
bef[i] & = \overline{state1[i]} \cdot \overline{state0[i]} \\
act[i] & = \overline{state1[i]} \cdot state0[i] 
\end{align}

\begin{align}
aft[i] & = state1 \cdot \overline{state0[i]}  \\
ex0[i] & = bef[i] \cdot next[i] \cdot var[i] \\
ex1[i] & = act[i] + aft[i] + bef[i] \cdot next[i] \cdot \overline{var[i]}
\end{align}

\noindent The signal $selt1[i]$ and $selt0[i]$ can be described by:
\begin{align}
selt1[i] & = state1[i] \cdot \overline{prime} \\
selt0[i] & = state0[i] + var[i] \cdot prime 
\end{align}

\noindent
These two equations indicate that signal $selt[i]$ ($selt0[i]$ 
and $selt1[i]$) is set to 01 to select $active$ function for the 
ITs that are specific positions when ILU executes the complex combinational
cube operation (like prime). The signal $next[i+1]$ generated in this block
is described by Equation (\ref{eq:next2}).

\subsubsection{IDENTIFY block} 

The IDENTIFY block is the combinational logic block $A$ in Figure 
\ref{fig:iter4}. The details of this block are fully discussed in
section~\ref{CHEN-section3.4.1}. The counter signal $count$ generated in this block will
be discussed in the next section, COUNTER block.

\subsubsection{COUNTER block} 

The paper \cite{perk92} shows that in addition to cube calculus operations
presented in this book, the operation which take cubes as argument and
return a number as a result is necessary. The simplest of such operation
is {\bf calculating Hamming distance of two binary vectors}. All such operation
require the operation of {\bf counting}. In this simplified machine, we introduce counting,
but it is restricted only to very simple operation used in the
{\bf pre-processing of cubes}. This counting is done by COUNTER block.

The COUNTER block counts the number of specific variables which is
used in pre-relation/pre-operation (see section~\ref{CHEN-section3.5}). The signal $count[i]$
equals 1 in the last IT of the specific variables. It can be described by:

\begin{equation}
  count[i] = re[i] \cdot var[i]
\end{equation}
The $count[i]$ signal is generated in block IDENTIFY.

% There are two methods of counting, therefore, there are 
% two signals, $count0$ and $count1$, for these two kinds of counting. 
% The signal $count0$ equals one in all iterative cells where the relation
% is satisfied. It can be described by:
% \begin{equation}
%   count0[i] = (rel0[i] \cdot rel1[i]) \cdot and\_or +
%            (rel0[i] + rel1[i]) \cdot \overline{and\_or}
% \end{equation}
% The signal $count1[i]$ equals one in last IT of the specific variables. 
% It can be described by:
% \begin{equation}
%   count1[i] = re[i] \cdot var[i]
% \end{equation}
% These two signals are generated in block IDENTIFY. Signal $cnt\_mode$
% indicates the counting method that is used.

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/counter.eps,height=3.5in}}}
\caption{counter}
\label{fig:counter}
\end{figure}

The counter is realized by an iterative network. A 3-bit counter is shown
in Figure \ref{fig:counter}. The COUNT block is just a cell of the
{\bf iterative
network of the counter}. To minimize the necessary logic for the cell, 
the cell of the counter is based on the {\bf pseudo-random sequence generator}.
Figure \ref{fig:counter} (a) shows a cell; and Figure \ref{fig:counter} (c) 
shows the whole picture of the counter. This iterative counter can 
generate a fixed sequence of 7 numbers which is shown in Figure 
\ref{fig:counter}(b) (number 000 is not used). Therefore, this counter
can be used to count the number of 1's in signal vector $x$.

The count begins with all bits are 1's. As the bits are shifted, a series
of unique numbers will be generated and they are shown in Figure 
\ref{fig:counter} (b). Since there must always be at least one bit
equal to one in the pseudo-random counter, a $k$ bits counter can count 
from 0 to $2^k-2$. Therefore, a 3 bits counter can count from 0 to 6.

3 bits counter is sufficient for an ILU with 6 ITs. If all variables are 
binary, there are 6 specific positions at most. The counter must be able 
to signal 7 different numbers, to include the case where there are no 
specific positions.  A decoder is needed to convert the output of the 
last cell of counter to a binary number.

\subsubsection{EMPTY block} 

One of the main design objectives of the CCM design was not to generate {\bf empty cubes}. In
order to do this, in this design we simplified the previous designs from
\cite{coen93,foote94,zhou95}. This led us to design the EMPTY block 
presented here. The role of this block is to generate signal 
{\bf empty} to the control unit of the CCM informing whether the 
current resultant cube is a contradiction (empty cube) or not.
This signal is used by the control unit of the CCM to remove empty
cubes in the results, and makes the CCM not to generate empty cubes
(see section~\ref{CHEN-section5.4}).

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/empty.eps,width=4.5in}}}
\caption{Iterative network used to generate {\it empty} signal}
\label{fig:empty}
\end{figure}

The {\it empty} signal is generated by a iterative network shown in
Figure \ref{fig:empty}. The signal $empty\_carry[i]$ and $subempty[i]$ 
are as follows:
\begin{align}
  empty\_carry[i+1] 
   =& re[i-1] \cdot \overline{c0_i} \cdot \overline{c1_i} + \\
    & \overline{re[i-1]}\cdot empty\_carry[i]\cdot
      \overline{c0_i}\cdot\overline{c1_i}  \nonumber \\
  subempty[i] =& empty\_carry[i+1] \cdot re[i] \cdot \overline{w[i]}
\end{align}
The $empty$ signal is as follows:
\begin{equation}
  empty = subempty[1] + subempty[2] + \cdots + subempty[n]
\end{equation}
By comparing {\it empty} signal to {\it carry} signal, these equations
are not hard to understand.

\section{The architecture of the CCM}
\label{CHEN-section3.5} 

In our design, the cube calculus machine is a coprocessor to the host
computer. The simplified block diagram of the CCM is shown in Figure
\ref{fig:arch}; the thick arrow stands for data buses, and the thin 
arrow stand for control buses. As shown in the figure, the CCM 
communicates with the host computer through the input and the output FIFO.
The ILU can take the input from register file and memory, and can write
output to the register file\footnote{Actually, the ILU can write
output to only one register of the register file, see Chapter~\ref{CHEN-CHAPTER5} for detail.},
the memory, and the output FIFO. The ILU executes the cube operation
under the control of {\it Operation Control Unit} (OCU). The {\bf Global
Control Unit} (GCU) controls all parts of the CCM and let them work together.

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/arch.eps,width=4in}}}
\caption{The simplified block diagram of the CCM}
\label{fig:arch}
\end{figure}

Since the design of the GCU depends on the design of the entire CCM,
we will discuss the GCU in section~\ref{CHEN-section5.4} after the design of the 
CCM has been discussed in detail. In the next section, we will
discuss the function of the OCU. 

\section{The Operation Control Unit (OCU)}
\label{CHEN-section3.6} 

The ILU executes cube operations under the control of the operation control
unit (OCU) in our design; and the OCU is under the control of the GCU. 
The communication between the GCU and OCU is very simple: when the CCM is
ready to execute the cube operation, the GCU set the signal {\it ilu\_enable}
to 1 to tell the OCU to execute the cube operation; then the OCU controls 
the ILU to execute the cube operation; after the cube operation is done,
the OCU set the signal {\it ilu\_done} to 1 to tell the GCU that the cube
operation is done. This is illustrated in Figure \ref{fig:arch2}.

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/arch2.eps,width=2.25in}}}
\caption{The communication between the GCU and the OCU}
\label{fig:arch2}
\end{figure}

The algorithm of the CCM has been discussed in 
section~\ref{CHEN-section3.3.2}. The state diagram of OCU is shown in Figure
\ref{fig:state_ilu}. Now let us take a look at these states.

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/state_ilu.eps,height=3in}}}
\caption{The state diagram of the OCU}
\label{fig:state_ilu}
\end{figure}

\begin{itemize}
\item State S0:
This is the initial state of the OCU. The {\it clear} signal (see Figure
\ref{fig:iter5}) is set to 1. The {\it clear} signal is connected
to all synchronous reset inputs of the D flip-flops that are used to
realize the state machines inside ITs, therefore, all ITs are reset
to state {\it before}.

If the signal {\it ilu\_enable} is 1, then the OCU goes to state S1; 
otherwise, the OCU keeps in state S0.

When the CCM is used to calculate combinational cube operations (including
complex combinational cube operations), the OCU keeps in state S0 because
the GCU will keep the signal {\it ilu\_enable} to be 0. 

\item State S1:
The OCU let the ILU begin to execute the sequential cube operation by 
setting the signal $init$ (the first $next$ signal) to 1 in this state. 
After that, the OCU will
wait for signals $term$ (the last $next$ signal) and $ready$. If signal
$term$ becomes 1, which means the cube operation is done, then the
OCU goes to state S5. If signal $ready$ becomes 1 and signal $term$ keeps
0, then the OCU goes to state S2; otherwise (both signals keep 0), 
the OCU will keep in state S1.

\item State S2:
The OCU generates the first resultant cube by setting signal $request$ to 1;
and it also generates signals $write\_output$ to write the result out. 
The OCU will always go to state S3 from state S2.

\item State S3:
The OCU will wait for signals $term$ and $ready$ again. If signal
$term$ becomes 1, then the OCU goes to state S5; if signal $ready$
becomes 1 and signal {\it term} keeps 0), then the OCU goes to state S4;
otherwise (both signals keep 0), the OCU will keep in state S3.

\item State S4:
The OCU generates one resultant cube by setting signal $request$ to 1;
and it also generates signals $write\_output$ to write the result out. 
The OCU will always go to state S3 from this state.

\item State S5:
The OCU informs the GCU that the cube operation is done by setting the
signal {\it ilu\_done} to 1. The OCU will always go to state S0 from
this state.
\end{itemize}


\section{Pre-relation/Pre-operation}
\label{CHEN-section3.7} 

To explain the concept of pre-relation/pre-operation, let us take a
look at the sharp operation again.
The sharp operation is defined by Equations~\ref{CHEN-(2.12)} and
~\ref{CHEN-(2.13)}. It can 
be seen that we can not use Equation~\ref{CHEN-(2.13)} to carry out the operation
unless two operand cubes satisfy $A \cap B \neq \emptyset$ and $A \not\subseteq B$.
When $A \cap B~=~\emptyset$, the operation $A \# B~=~ A$; when $A \subseteq B$,
the operation $A \# B ~=~ \emptyset$. $A \cap B ~=~ \emptyset$ and $A \subseteq B$ are called
{\bf pre-relation} of the sharp operation; $A \# B~ =~ A$ and $A \# B~=~ \emptyset$
are called {\bf pre-operation} of the sharp operation. It can be seen
that the pre-operation is the output function when pre-relation is satisfied.

\begin{table}[H]
%\begin{table}[h]
\caption{Pre-relation and Pre-relation of the Cube Calculus Operations}
\begin{center}
\begin{tabular}{|c|c|c|} \hline
% title
{\bf Operation} & {\bf Pre-relation} & {\bf Pre-operation} \\ \hline
% content
\multirow{2}{1.5in}{\centering{sharp/disjoint sharp}}
     & $A \cap B = \emptyset$ & $A$ \\ \cline{2-3}
     & $A \subseteq B$ & $\emptyset$ \\ \hline
\multirow{2}{1.5in}{\centering{consensus}}
     & $distance(A,B) = 0$ & $A \cap B$ \\ \cline{2-3} 
     & $distance(A,B) > 1$ & $\emptyset$       \\ \hline
crosslink  & $degree(A) \neq degree(B)$ & $\emptyset$ \\ \hline
\end{tabular}
\end{center}
\label{tbl:prpo}
\end{table}

Some cube operations which have pre-relation and pre-operation are listed
in Table \ref{tbl:prpo}. The name, pre-relation and pre-operation of the 
operations are listed from left to right in the table, respectively.
It can be seen that some cube operations have two pre-relations and
pre-operations, such as the sharp and consensus operations.

As we discussed in section~\ref{CHEN-section3.4.2}, the COUNT block can count the number
of specific variables. In another words, it can count the number of
the pairs of literals $A_i$ and $B_i$ that satisfy the relation. If
the relation ($rel$ and $and\_or$) are substituted by the pre-relation,
the COUNT block can be used to count the number of the pairs of 
literals $A_i$ and $B_i$ that satisfy the pre-relation.

\noindent
\begin{example}
~\label{CHEN-Example3.7}
\end{example}


\noindent
For the pre-relation $A \cap B ~=~ \emptyset$, we can count the number 
(denoted by $k$) of the pairs of literals $A_i$ and $B_i$ that satisfy 
$A_i \cap B_i = \emptyset$. If $k > 0$, then $A \cap B = \o$, otherwise ($k=0$),
$A \cap B \neq \emptyset$. 

The pre-relation can be represented by {\bf partial pre-relation} 
({\bf prel}), {\bf partial pre-relation type} ({\bf pand\_or}), 
{\bf pre-relation compare type} ({\bf pcmp}) and {\bf pre-relation 
compare value} ({\bf pval}). 

\noindent
\begin{example}
~\label{CHEN-Example3.8}
\end{example}

\noindent
For the pre-relation shown in 
Example~\ref{CHEN-Example3.7}, {\it prel} is $\overline{a_i}+\overline{b_i}$; {\it pand\_or} is
$and$; {\it pcmp} is ``$>$"; and {\it pval} is 0 ($A \cap B = \emptyset$ is 
the relation of the crosslink operation, so {\it prel} and {\it pand\_or}
are the same as {\it rel} and {\it and\_or} of the crosslink operation, respectively).

The pre-operations listed in Table \ref{tbl:prpo} are bitwise functions.
The decomposed pre-relations and pre-operations of the sharp/disjoint sharp
and consensus operations are listed in table \ref{tbl:prpo2}. The crosslink
operation can not be decomposed in this way (It needs two carry signals to
compare the degrees of two operand cubes; but this simplified design of the
CCM has only one carry signal, see \cite{coen93}). Each row of the table 
describes one pair of pre-relation and pre-operation.

\begin{table}[H]
% \begin{table}[h]
\caption{Decomposed Pre-relation and Pre-operation of the Cube Operations}
% \renewcommand{\multirowsetup}{\centering}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|} \hline
% title
  \multirow{2}{1.5in}{\centering{\bf Operation}}
& \multicolumn{4}{c|}{{\bf Pre-relation}}
&  {\bf Pre-operation} \\ \cline{2-5}
 & $prel$ & $pand\_or$ & $pcmp$ & $pval$ & ($poper$) \\ \hline
% content
\multirow{2}{1.5in}{\centering{sharp/disjoint sharp}}
    & $\overline{a_i}+\overline{b_i}$ & and & $>$ & 0 & $a_i$ \\ \cline{2-6}
    & $a_i\overline{b_i}$        & or  & $=$ & 0 & $\emptyset$  \\ \hline
\multirow{2}{1.5in}{\centering{consensus}}
    & $\overline{a_i}+\overline{b_i}$ & and & =   & 0 & $a_i \cdot b_i$ \\ \cline{2-6}
    & $\overline{a_i}+\overline{b_i}$ & and & $>$ & 1 & $\emptyset$ \\ \hline
\end{tabular}
\end{center}
\label{tbl:prpo2}
\end{table}

The encoded pre-relations and pre-operations of the sharp/disjoint sharp
and consensus operations are listed in table \ref{tbl:prpo3}. 
The {\it prel} and pre-operation ({\it poper}) are decoded by their output
values. The encoding of {\it pand\_or} is the same as {\it and\_or}.
The encoding of {\it pcmp} is as follows: ``$<$" --- 00, ``=" --- 01 and
``$>$" --- 10. Each row of the table describes one pair of pre-relation 
and pre-operation.

\begin{table}[H]
%\begin{table}[h]
\caption{Encoded Pre-relation and Pre-operation of the Cube Operations}
% \renewcommand{\multirowsetup}{\centering}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|} \hline
% title
  \multirow{2}{1.5in}{\centering{\bf Operation}}
& \multicolumn{4}{c|}{{\bf Pre-relation}}
&  {\bf Pre-operation} \\ \cline{2-5}
 & $prel$ & $pand\_or$ & $pcmp$ & $pval$ & ($poper$) \\ \hline
% content
\multirow{2}{1.5in}{\centering{sharp/disjoint sharp}}
    & 1110 & 1 & 10 & 0 & 0101 \\ \cline{2-6}
    & 0010 & 0 & 01 & 0 & 0000 \\ \hline
\multirow{2}{1.5in}{\centering{consensus}}
    & 1110 & 1 & 01 & 0 & 0001 \\ \cline{2-6}
    & 1110 & 1 & 10 & 1 & 0000 \\ \hline
\end{tabular}
\end{center}
\label{tbl:prpo3}
\end{table}

\enlargethispage{10pt}
For realizing pre-relation/pre-operation, the ILU is modified as
shown in Figure \ref{fig:prpo}. Please note that only the modified
part is shown in the figure. This design is very straightforward. 
In this design, a cube operation can have at most two pairs
of pre-relation/pre-operation\footnote{
All cube operations presented in this book have at most two
pairs of pre-relation/pre-operation. It is easy to extend this
design to handle more than two pairs of pre-relation/pre-operation.},
and all pre-operations should be 
combinational operations, which means that the operation can be 
described as a bitwise function. Thus the signals $prel$, $pand\_or$, 
$pcmp$, $pval$ and $poper$ shown in the figure
have a suffix 1 or 2, which corresponds to the first or the second
pair of the pre-relation/pre-operation, respectively. All input 
signals come from the registers (see section~\ref{CHEN-section5.2.3}).

\begin{figure}[H]
\centerline{\hbox{\psfig{figure=fig/prpo.eps}}}
\caption{Realization of Pre-relation/Pre-operation}
\label{fig:prpo}
\end{figure}

The signal $prel\_sel$ (having 2 bits) is generated by 
the GCU (see section~\ref{CHEN-section5.4}).
% the control unit of the CCM (in this design, it is generated by the 
% BIU, see section~\ref{CHEN-section5.4}). 
When the CCM executes the first pre-relation/pre-operation, the signal
$prel\_sel=00$; when the CCM executes the second pre-relation/pre-operation,
the signal $prel\_sel=01$; otherwise, the signal $prel\_sel=10$.

The only output signal $prel\_res$ is the result of pre-relation.
When $prel\_res=1$, the pre-relation is satisfied, otherwise, the
pre-relation is not satisfied. This signal is used by the GCU 
(see section~\ref{CHEN-section5.4}).

If $prel\_sel=00 \;\text{or}\; 01$, and all ITs of the ILU are in
{\it before} state, then the cube operation is evaluated according to
the function $poper1$ or $poper2$, respectively.

Let us observe that among combinational cube operations that have
pre/relation/pre-operation, there exists certain subset operations,
like intersection and cofactor operations, can be characterized by
the following:
% For some combinational cube operations (including some complex 
% combinational cube operations), like intersection and cofactor operations,
% they do have pre-relation/pre-operation. But it can be seen that:
\begin{itemize}
\item These operations only have one pair of pre-relation/pre-operation,
      and the result of pre-operation is always an empty cube.
\item These operations can be always carried out by following the basic
      equation of the operation without checking the pre-relation. After
      that the EMPTY blocks will check whether the result is an empty
      cube or not.
\item These operations can be carried out using pre-relation/pre-operation,
      but it will take more time to execute this kind of operations 
      because the GCU will go through more states to check the
      pre-relation (see section~\ref{CHEN-section5.4}).
\end{itemize}
Based on these observations, this kind of operations will be carried out
without using pre-relation/pre-operation in this book.


