
\chapter{Selected Applications of Cube Calculus Machine}
\label{CHEN-Chapter9}

Many logic minimization software tools such as {\bf ESPRESSO}~\cite{brayton84},
{\bf MIS}, {\bf SIS}~\cite{sispaper} and {\bf EXORCISM-MV-2}~\cite{song93,song93b} may 
benefit from the introduction of the CCM. David W. Foote analyzed how much
the CCM can improve the performance of ESPRESSO-II in his 
thesis~\cite{foote94}. 

The CCM can be used to perform set operation, like set intersection, 
set union, set complement, and set relations such as subset as we
discussed in Chapter~\ref{CHEN-Chapter2}. The CCM can be seen as a machine for set-theoretical
problems when it is configured to process only one variable with many 
possible values. The Examples~\ref{CHEN-Example2.12}
to ~\ref{CHEN-Example2.15} are this kind of examples.

The CCM can also speed up the process of solving small size of the 
satisfiability problem and the tautology problem
\footnote
{Both satisfiability problem and tautology problem are NP-complete
problem, which means we are unlikely to find a polynomial-time
algorithm for solving it exactly. In practice, only small size
NP-complete problems can be solved and it may still be possible to find
near-optimal solutions in polynomial-time using approximation algorithm,
and the near-optimal solutions is often good enough. For more information
about NP-complete problem, please see \cite{algorithm89}.  } 
that are the two most fundamental combinational 
problems used in many research and application areas. As shown in 
\cite{perk98}, these two problems can be used to solve many other 
more complicated problems in CAD, Machine Learning and other fields.
The point here is that we speed up the process of solving small size of
these two problems by speeding up the very basic operator.

\section{Satisfiability Problem}
\label{CHEN-section9.1}

Given a product of terms, each term being a Boolean sum of literals;
the {\it satisfiability problem} is to find any product of literals that
satisfies all terms or prove that such product does not exist.

\noindent
\begin{example}
~\label{CHEN-Example9.1}
\end{example}

\noindent
Find all products of literals that let function 
$f(a,b,c,d) = (\overline{a}+b)(\overline{b}+c)(a+\overline{c})$ be 1.

\noindent
{\bf Solution.}

\noindent
It is very easy to rewrite this problem by multiplying out the
expression as follows:
\begin{align*}
f(a,b,c,d) 
&~ =~ (\overline{a}+b)(\overline{b}+c)(a+\overline{c}) \\
& ~=~ (\overline{a}~\overline{b}~+~\overline{a}c+bc)(a+\overline{c}) \\
& ~=~ abc+ \overline{a}~\overline{b}~\overline{c}
\end{align*}

% Now, remove the duplicated cubes, and use absorption law:
% \begin{equation*}
%  A + AB = A \qquad or \qquad A(A+B) = A
% \end{equation*}
% to simplify the function and obtain:
% \begin{align*}
% f(a,b,c,d) 
% & = ab+abc+ac+bc \\
% & = ab+ac+bc
% \end{align*}
% 
% Therefore, the products of literals that let function $f$ be 1 are $ab$,
% $ac$ and $bc$.

The Covering Problem is used in many two level logic minimization algorithms
(being various improvements and extensions of the classical
{\bf Quine-McCluskey algorithm}~\cite{coud94}) and it can be reduced to the
{\bf Petrick Function 
Minimization Problem}, a special case of satisfiability problem. This means 
that the Covering Problem can be solved by minimizing the Petrick Function.
Let us see the following example.
  
\noindent
\begin{example}
~\label{CHEN-Example9.2}
\end{example}

\noindent
The following is a covering table. The problem is to find the
smallest set of rows that covers all columns.

\begin{table}[H]
%\begin{table}[h]
\begin{center}
\begin{tabular}{c|cccccc} \hline
      & $C_1$ & $C_2$ & $C_3$ & $C_4$ & $C_5$ & $C_6$ \\ \hline
$R_1$ &   X   &   X   &       &   X   &       &   X   \\
$R_2$ &       &       &   X   &   X   &       &   X   \\
$R_3$ &   X   &   X   &       &       &       &       \\
$R_4$ &       &       &   X   &       &   X   &       \\ \hline
\end{tabular}
\end{center}
\end{table}

\noindent
{\bf Solution.}

\noindent
First, let us find all sets of rows that cover all columns.
The column $C_1$ is covered by rows $R_1$ and $R_3$;
the column $C_2$ is covered by rows $R_1$ and $R_3$; 
the column $C_3$ is covered by rows $R_2$ and $R_4$; 
the column $C_4$ is covered by rows $R_1$ and $R_2$; 
the column $C_5$ is covered by row $R_4$; 
the column $C_6$ is covered by rows $R_1$ and $R_2$; 
Therefore, the problem can be solved by solving the following Petrick function ($PF$):

\begin{align*}
PF \equiv 1 \equiv & (R_1+R_3)(R_1+R_3)(R_2+R_4)(R_1+R_2)(R_4)(R_1+R_2) \\
= & (R_1+R_3)(R_2+R_4)(R_1+R_2)(R_4) \\
= & (R_1R_2+R_1R_4+R_2R_3+R_3R_4)(R_1+R_2)(R_4) \\
  & \cdots \\
= & R_1R_4+R_1R_2R_4+R_1R_3R_4+R_2R_3R_4+R_1R_2R_3R_4
\end{align*}

The last sum shows that there are five sets of rows that cover all 
columns: \{$R_1$,$R_4$\}, 
\{$R_1$,$R_2$,$R_4$\}, \{$R_1$,$R_3$,$R_4$\}, \{$R_2$,$R_3$,$R_4$\} 
and \{$R_1$,$R_2$,$R_3$,$R_4$\}. Now use the absorption law $A + AB = A$
to simplify the decision function and obtain $PF = R_1R_4 + R_2R_3R_4$, which means 
\{$R_1$,$R_4$\} is the smallest set of rows that covers all columns.

The above example shows how to reduce the Covering Problem to the 
Petrick function problem. The CCM can be used to multiply out the 
function, then the function can be simplified by the software or 
Sorter/Absorber circuitry that you will find in Chapter~\ref{PAVEL-Chapter1},
~\cite{sorter}. It has to be kept in mind by the reader that
CCM was designed because real life covering problems have matrices
with hundreds of thousands of rows and columns. Because, however the 
number of variables in the CCM is limited, a large problem has to be
first decomposed to many smaller problems that fit the CCM word length
and can be solved by it sequentially.

\section{Tautology Problem}
\label{CHEN-section9.2}

The tautology problem is the verification a logic function to see if it
is always true or not.

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

\noindent
Is the function $f(a,b,c,d) = a+b+c+d$ a tautology (always be 1)?

\noindent
{\bf Solution.}

\noindent
If the function $f(a,b,c,d) \equiv 1$, this implies that
$1 \# f(a,b,c,d) = 0$, and the function $f(a,b,c,d)$ is a tautology. 
If $1 \# f(a,b,c,d) \neq 0$, then the function $f(a,b,c,d)$ is not a tautology.

Because $1 \# (a+b+c+d) = \overline{a}~\overline{b}~\overline{c}~\overline{d} \neq 0$, then
the function $f(a,b,c,d)$ is not a tautology. The CCM assembly program used
to solve this problem is very similar to the Example~\ref{CHEN-Example6.9}.


\section{Conclusions and Future Work on CCM}

The concept of Cube Calculus, Cube Calculus Machine and a complete
design of the Cube Calculus Machine have been presented in previous chapters. This is
the first complete design of the CCM that has been done so far.
Further work on CCM is being continued.
The design of the ILU presented above has been accomplished by
many students over the years~\cite{coen93,foote94,zhou95,CHEN}.
In the presented design some important
changes have beed done (like EMPTY block, Pre-relation/pre-operation logic block).

\section{Projects}
\begin{enumerate}
\item
Many variants of ILU have been 
described~\cite{coen93,foote94,zhou95}.
The pre-relation/pre-operation that were missing in~\cite{coen93,foote94,zhou95} have been designed
in~\ref{CHEN}. Can you simplify anything in the presented above machine still maintaining its complete
functionality?
\item
Using the VHDL code of CCM from next chapters, simulate it using
QuickHDL tool from Mentor Graphics.
If you have done changes, write them in VHDL and simulate as well. Draw conclusions.
\item
Extend the CCM assembly language for the CCM.
\item
Realize the test bench for your design.
Explore cube operations by using this model
using our encoding scheme of the CCM instructions.
You still need to think in terms of registers and 
individual instructions of the CCM. There are several 
complete examples given in this book, and they can be used by you as an introduction.
\item Improve and unify the descriptions of cube calculus from previous texts that
are not covered in the previous chapters.
\item Derived another formula for calculate cofactor operation by
using cube calculus than one from Equation~\ref{eq:cofactor}.
\item Mapp your design onto the DEC-PERLE-1 board.
Capture the entire design Xilinx Foundation software, and implement in
XC3090A FPGA chips using Xilinx M1 software.
\item Develop the CCM runtime library (see section~\ref{CHEN-section6.1}).
DEC C++ compiler is required.
\item
Build several complete demo applications of practical use such as tautology, satisfiability, or set covering.
\item Run the demos on benchmark functions.
\end{enumerate}


