\frame
{
- TODO: Impure (stateful) example.
+ \frametitle{Multiply-accumulate}
+ \begin{columns}
+ \begin{column}{5cm}
+ \begin{block}{}
+ \begin{tabular}{lll}
+ Input A & Input B & Output \\
+ \hline
+ 1 & 1 & 0 \\
+ 1 & 2 & 1 \\
+ 1 & 1 & 3 \\
+ 2 & 2 & 4 \\
+ \end{tabular}
+ \end{block}
+ \end{column}
+ \begin{column}{5cm}
+ \begin{figure}
+ TODO: Image of MAC with internal register
+ \end{figure}
+ \end{column}
+ \end{columns}
+}
+
+\note[itemize]
+{
+ \item Next sheet: MAC circuit and I/O values
+ \item MAC is common circuit
+ \item Multiplies pairs, one pair at a time
+ \item Stores sum so far
+ \item Not pure!
+ \item Depends on inputs \emph{and} current register value
+ \item Solution: Put register value (state) in argument
}
+\frame
+{
+ \frametitle{Multiply-accumulate}
+ \begin{columns}
+ \begin{column}{5cm}
+ \begin{block}{}
+ \vspace{-0.5cm}
+\begin{verbatim}
+mac (a, b) (State s) = let
+ sum = s + (a * b)
+in (State sum, sum)
+\end{verbatim}
+ \end{block}
+ \end{column}
+ \begin{column}{5cm}
+ \begin{figure}
+ TODO: Image of MAC with external register
+ \end{figure}
+ \end{column}
+ \end{columns}
+}
+
+\note[itemize]
+{
+ \item Next sheet: MAC implementation
+ \item Current state as argument (annotated)
+ \item Two parts in the result: New state and output
+ \item Register is placed ``outside''
+ \item We want it inside!
+ \item Annotation allows compiler to put it inside
+}
+
+\begin{frame}[fragile]
+ \frametitle{Simulating}
+
+ \begin{block}{Recursive run function}
+ run f (i:is) s = let
+ (o, s') = f i s
+ in o : (run f is s')
+ \end{block}
+
+ \begin{block}{Remember \texttt{mac}}
+\vspace{-0.5cm}
+\begin{verbatim}
+mac (a, b) (State s) = let
+ sum = s + (a * b)
+in (State sum, sum)
+\end{verbatim}
+ \end{block}
+\end{frame}
+
\note[itemize]
{
- \item TODO
+ \item Next sheet: run function
+ \item Used for simulation only
+ \item Recursion ``stores'' state
+ \item Each recursion step, \texttt{f} is evaluated once.
}
- \subsection{\clash}
+ \subsection{\texorpdfstring{\clash{}}{CLasH}}
\frame{
\begin{center}