From dc92ad7201a80a41ed032fca237dddf4f063cd36 Mon Sep 17 00:00:00 2001
From: Yann Herklotz <git@yannherklotz.com>
Date: Fri, 20 Nov 2020 10:53:58 +0000
Subject: Add algorithm

---
 algorithm.tex | 74 ++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 40 insertions(+), 34 deletions(-)

(limited to 'algorithm.tex')

diff --git a/algorithm.tex b/algorithm.tex
index 3c33757..6ebbdd9 100644
--- a/algorithm.tex
+++ b/algorithm.tex
@@ -137,10 +137,10 @@ An HTL program thus consists of two maps: a control map that describes how to ca
 \definecolor{control}{HTML}{b3e2cd}
 \definecolor{data}{HTML}{fdcdac}
 \begin{tikzpicture}
-  \fill[control,fill opacity=1] (6.5,0) rectangle (12,4);
-  \fill[data,fill opacity=1] (0,0) rectangle (5.5,4);
-  \node at (1,3.7) {\footnotesize Data Path};
-  \node at (7.5,3.7) {\footnotesize Control Logic};
+  \fill[control,fill opacity=1] (6.5,0) rectangle (12,5);
+  \fill[data,fill opacity=1] (0,0) rectangle (5.5,5);
+  \node at (1,4.7) {\footnotesize Data Path};
+  \node at (7.5,4.7) {\footnotesize Control Logic};
 
   \fill[white,rounded corners=10pt] (7,0.5) rectangle (11.5,2.2);
   \node at (8,2) {\tiny Next State FSM};
@@ -167,11 +167,12 @@ An HTL program thus consists of two maps: a control map that describes how to ca
   \draw[-{Latex[length=1mm,width=0.7mm]}] (7.45,-0.5) -- (7.45,0.5);
 
   \fill[white,rounded corners=10pt] (2,0.5) rectangle (5,3);
-  \filldraw[fill=white] (0.25,0.5) rectangle (1.5,3);
+  \filldraw[fill=white] (0.25,0.5) rectangle (1.5,2.75);
   \node at (2.6,2.8) {\tiny Update};
-  \node at (0.875,2.8) {\tiny \texttt{RAM}};
+  \node[align=center] at (0.875,2.4) {\tiny \texttt{RAM}\\[-1.5ex]\tiny\texttt{(Array)}};
   \node[scale=0.4] at (4.7,1.5) {\texttt{state}};
   \draw[-{Latex[length=1mm,width=0.7mm]}] (6,1.5) -- (5,1.5);
+  \draw[-{Latex[length=1mm,width=0.7mm]}] (6,1.5) -- (7,1.5);
   \node[scale=0.4,rotate=60] at (4.1,0.9) {\texttt{finished}};
   \node[scale=0.4,rotate=60] at (3.9,0.95) {\texttt{return\_val}};
   \node[scale=0.4,rotate=60] at (2.5,0.75) {\texttt{clk}};
@@ -182,34 +183,39 @@ An HTL program thus consists of two maps: a control map that describes how to ca
   \draw[-{Latex[length=1mm,width=0.7mm]}] (2.45,-0.5) -- (2.45,0.5);
   \draw[-{Latex[length=1mm,width=0.7mm]}] (2.65,-0.5) -- (2.65,0.5);
 
-  \node[scale=0.4] at (1.2,2.2) {\texttt{wr\_en}};
-  \node[scale=0.4] at (1.2,2) {\texttt{wr\_addr}};
-  \node[scale=0.4] at (1.2,1.8) {\texttt{wr\_data}};
-  \node[scale=0.4] at (1.2,1.4) {\texttt{r\_addr}};
-  \node[scale=0.4] at (1.2,1.2) {\texttt{r\_data}};
-
-  \node[scale=0.4] at (2.3,2.2) {\texttt{wr\_en}};
-  \node[scale=0.4] at (2.3,2) {\texttt{wr\_addr}};
-  \node[scale=0.4] at (2.3,1.8) {\texttt{wr\_data}};
-  \node[scale=0.4] at (2.3,1.4) {\texttt{r\_addr}};
-  \node[scale=0.4] at (2.3,1.2) {\texttt{r\_data}};
-
-  \draw[-{Latex[length=1mm,width=0.7mm]}] (2,2.2) -- (1.5,2.2);
-  \draw[-{Latex[length=1mm,width=0.7mm]}] (2,2) -- (1.5,2);
-  \draw[-{Latex[length=1mm,width=0.7mm]}] (2,1.8) -- (1.5,1.8);
-  \draw[-{Latex[length=1mm,width=0.7mm]}] (2,1.4) -- (1.5,1.4);
-  \draw[-{Latex[length=1mm,width=0.7mm]}] (1.5,1.2) -- (2,1.2);
-
-  %\filldraw[fill=white] (2.8,3.25) rectangle (4.2,4.75);
-  %\node at (3.5,4.55) {\tiny \texttt{Registers}};
-  %\draw[-{Latex[length=1mm,width=0.7mm]}] (2,2.4) -| (1.75,4) -- (2.8,4);
-  %\draw[-{Latex[length=1mm,width=0.7mm]}] (4.2,4) -- (5.25,4) |- (5,2.4);
-
-  %\node[scale=0.4] at (3.5,4.2) {\texttt{reg\_1}};
-  %\node[scale=0.4] at (3.5,4) {\texttt{reg\_2}};
-  %\node[scale=0.4] at (3.5,3.8) {\texttt{reg\_3}};
-  %\node[scale=0.4] at (3.5,3.6) {$\cdots$};
-  %\node[scale=0.4] at (3.5,3.4) {\texttt{reg\_8}};
+  \foreach \x in {0,...,2}
+  {\draw (0.25,1.25-0.25*\x) -- (1.5,1.25-0.25*\x); \node at (0.875,1.13-0.25*\x) {\tiny \x}}
+  \draw[-{Latex[length=1mm,width=0.7mm]}] (1.5,1.5) -- (2,1.5);
+  \draw[-{Latex[length=1mm,width=0.7mm]}] (2,1.75) -- (1.5,1.75);
+
+  %\node[scale=0.4] at (1.2,2.2) {\texttt{wr\_en}};
+  %\node[scale=0.4] at (1.2,2) {\texttt{wr\_addr}};
+  %\node[scale=0.4] at (1.2,1.8) {\texttt{wr\_data}};
+  %\node[scale=0.4] at (1.2,1.4) {\texttt{r\_addr}};
+  %\node[scale=0.4] at (1.2,1.2) {\texttt{r\_data}};
+  %
+  %\node[scale=0.4] at (2.3,2.2) {\texttt{wr\_en}};
+  %\node[scale=0.4] at (2.3,2) {\texttt{wr\_addr}};
+  %\node[scale=0.4] at (2.3,1.8) {\texttt{wr\_data}};
+  %\node[scale=0.4] at (2.3,1.4) {\texttt{r\_addr}};
+  %\node[scale=0.4] at (2.3,1.2) {\texttt{r\_data}};
+  %
+  %\draw[-{Latex[length=1mm,width=0.7mm]}] (2,2.2) -- (1.5,2.2);
+  %\draw[-{Latex[length=1mm,width=0.7mm]}] (2,2) -- (1.5,2);
+  %\draw[-{Latex[length=1mm,width=0.7mm]}] (2,1.8) -- (1.5,1.8);
+  %\draw[-{Latex[length=1mm,width=0.7mm]}] (2,1.4) -- (1.5,1.4);
+  %\draw[-{Latex[length=1mm,width=0.7mm]}] (1.5,1.2) -- (2,1.2);
+
+  \filldraw[fill=white] (2.8,3.25) rectangle (4.2,4.75);
+  \node at (3.5,4.55) {\tiny \texttt{Registers}};
+  \draw[-{Latex[length=1mm,width=0.7mm]}] (2,2.4) -| (1.75,4) -- (2.8,4);
+  \draw[-{Latex[length=1mm,width=0.7mm]}] (4.2,4) -- (5.25,4) |- (5,2.4);
+
+  \node[scale=0.4] at (3.5,4.2) {\texttt{reg\_1}};
+  \node[scale=0.4] at (3.5,4) {\texttt{reg\_2}};
+  \node[scale=0.4] at (3.5,3.8) {\texttt{reg\_3}};
+  \node[scale=0.4] at (3.5,3.6) {$\cdots$};
+  \node[scale=0.4] at (3.5,3.4) {\texttt{reg\_8}};
 \end{tikzpicture}
   \caption{The FSMD for our running example.\YH{Removed the register block because these are technically just internal to the update function.  Also not sure if we should keep the RAM block because it is a bit misleading as we don't use those signals to communicate with the RAM, instead we just use a RAM.}}\label{fig:accumulator_diagram}
 %\JW{Maybe replace `State' with `Current State'? And maybe `Calculate State' could be clearer as `Calculate Next State'?} \JW{Can state 15 (or should it be state 16??) have a dangling incoming arrow to indicate that it is the start state? And perhaps state 1 could have a double outline to indicate that it is an `accepting' state? Since there's space above the `Calculate State' box, I'd be mildly in favour of expanding that box a bit so that it included all 15 states explicitly (snaking back and forth).}\YH{If this is better I can mock up a tikz version of it maybe and fix the last bits then too.}
-- 
cgit 

