09ab627e06691f654783f72de8f71180bb2374c9
[fleet.git] / chips / f2 / doc / am42 / am42.tex
1 \documentclass[10pt]{article}
2 \usepackage{palatino}
3 \usepackage{amsmath}
4 \usepackage{epsfig}
5 \usepackage{color}
6 \usepackage{bytefield1}
7 \usepackage{wrapfig}
8 \usepackage{stmaryrd}
9 \usepackage{subfigure}
10 \usepackage{syntax}
11 \usepackage{comment}
12 \usepackage{fancyhdr}
13 \usepackage{lastpage}
14 \usepackage{multirow}
15 \usepackage{multicol}
16 \usepackage{rotating}
17 \include{megacz}
18 \bibliographystyle{alpha}
19 \pagestyle{fancyplain}
20
21 \definecolor{light}{gray}{0.7}
22
23 \setlength{\marginparwidth}{1.2in}
24 \let\oldmarginpar\marginpar
25 \renewcommand\marginpar[1]{\-\oldmarginpar[\raggedleft\footnotesize #1]%
26 {\raggedright\footnotesize #1}}
27
28
29 \newcommand{\footnoteremember}[2]{
30   \footnote{#2}
31   \newcounter{#1}
32   \setcounter{#1}{\value{footnote}}
33 } \newcommand{\footnoterecall}[1]{
34   \footnotemark[\value{#1}]
35 }
36
37 %\pdfpagewidth 8.5in
38 %\pdfpageheight 11in 
39 %\topmargin 0in
40 \textheight 8.2in
41 %\textwidth 6.0in
42 %\oddsidemargin 0.25in
43 %\evensidemargin 0.25in
44 %\headwidth 6.0in
45 \def\to{\ $\rightarrow$\ }
46
47 \def\docnum{AM33}
48
49 \author{
50 \normalsize{
51 \begin{tabular}{c}
52 \end{tabular}}
53 }
54
55 \title{\vspace{-1cm}AM33: The FleetTwo Dock
56 \\
57 {\normalsize
58 Adam Megacz
59 }}
60
61 \begin{document}
62
63 \maketitle
64
65 \begin{abstract}
66 Changes:
67
68 \begin{verbatim}
69     - tokenhood as address bit
70     - signal/path boundary/etc
71   - Rename EPI and OD to something more meaningful
72   - Get rid of OD?
73   - get rid of shadow latch
74   - single counter
75   - figure out C-flag / signal bit situation
76     - single "predicate" flag
77   - Suggestion that there should be a "T" flag
78   - Get rid of "shadow latch" for literals?
79   - unify flags and signal bit by saying that the dock can see the upper X bits of a word?
80     - should have a way to set just the upper X bits of the word
81     - flags are actually part of the data latch!
82     - the signal bit(s) belong to the Destination (or is it the Path?)
83   - flushing situation
84   - How do you get a runtime count value to an input dock?
85   - Simplify the whole c-flag/signal-bit situation
86   - tokenhood should be LITERALLY an address bit!
87 \end{verbatim}
88
89 \begin{tabular}{rl}
90 \color{red}
91 09-Aug
92 & \color{red} Removed the explicit ``decrement loop counter'' instruction \\
93 & \color{red} Renamed {\tt D}-flag to {\tt Z}-flag \\
94 \color{red}
95 21-Jun
96 & \color{red} Moved the {\tt P} (predicate) field to the MSB end of the word \\
97 & \color{red} Changed to a single counter, full word width \\
98 & \color{red} Included one extra Marina erratum I had forgotten \\
99 & \color{red} Changed encoding of {\tt flush} to match internal encoding\\
100 \color{black}
101 25-May
102 & Added errata for Kessel counter on Marina test chip \\
103 18-May
104 & Added errata for Marina test chip \\
105 17-Feb
106 & Clarified setting of the {\tt C}-flag\color{black}\\
107 & Removed {\tt OS} bit\color{black}\\
108 & Changed instruction length from 26 bits to 25\color{black}\\
109 & Updated which bits are used when the {\tt Path} latch captures from the data predecessor\color{black}\\
110 05-Jan
111 & Fixed a one-word typo \\
112 02-Jan
113 & Added {\tt head} instruction \\
114 & Lengthened external encoding of {\tt tail} instruction by one bit \\
115 & Added {\tt abort} instruction \\
116 & Removed {\tt OS} field from instructions \\
117 & Renamed the {\tt Z}-flag (olc {\bf Z}ero) to the {\tt D}-flag (loop {\bf D}one)\\
118 19-Dec
119 & Updated diagram in section 3 to put dispatch path near MSB\\
120 & Changed DP[37:25] to DP[37:27]\\
121 & Added note on page 4 regarding previous\\
122 14-Nov
123 & Roll back ``Distinguish {\tt Z}-flag from OLC=0'' \\
124 & Clarify what ``{\tt X-Extended}'' means \\
125 & Change C-bit source selector from {\tt Di} to {\tt Dc} \\
126 07-Nov
127 & Distinguish {\tt Z}-flag from OLC=0\\
128 & Add {\tt flush} instruction\\
129 & Change {\t I} bit from ``Interruptable'' to ``Immune''\\
130 20-Sep
131 & Update hatch description to match \href{http://fleet.cs.berkeley.edu/docs/people/ivan.e.sutherland/ies50-Requeue.State.Diagram.pdf}{IES50} \\
132 28-Aug
133 & Note that decision to requeue is based on  value of OLC {\it before} execution\\
134 & Note that decision to open the hatch is based on value of {\tt OS} bit\\
135 %10-Jul
136 %& Added {\tt OLC=0} predicate \\
137 %& Eliminated {\tt TAPL} (made possible by previous change) \\
138 %& Expanded {\tt set} {\tt Immediate} field from 13 bits to 14 bits (made possible by previous change)\\
139 %09-Jul
140 %& Fixed a few typos \\
141 %& Added {\tt DataLatch}\to{\tt TAPL} (Amir's request) \\
142 %& Eliminate ability to predicate directly on {\tt C}-flag (Ivan's request) \\
143 %16-Jun
144 %& When a torpedo strikes, {\tt ILC} is set to {\tt 1} \\
145 %& Only {\tt move} can be torpedoed (removed {\tt I}-bit from {\tt set}/{\tt shift}) \\
146 %11-Jun
147 %& Changed all uses of ``Payload'' to ``Immediate'' \color{black} (not in red) \\
148 %& Reworked encoding of {\tt set} instruction \\
149 %\color{black} 
150 %06-Jun
151 %& Factored in Russell Kao's comments (thanks!)\\
152 %& Added mechanism for setting C-flag from fabric even on outboxes\\
153 %05-Jun
154 %& Made {\tt OLC} test a predicate-controlled condition\\
155 %& Rewrote ``on deck'' section \\
156 %& Added ``{\tt unset}'' value for {\tt ILC}\\
157 %& Changed {\tt DP} to {\tt DataPredecessor} for clarity\\
158 %\color{black}
159 %30-Apr
160 %& added comment about address-to-path ship \\
161 %& changed {\tt DST} field of {\tt set} instruction from 2 bits to 3 \\
162 %& changed the order of instructions in the encoding map \\
163 %23-Apr
164 %& added epilogue fifo to diagrams \\
165 %& indicated that a token sent to the instruction port is treated as a torpedo \\
166 %18-Apr
167 %& replaced {\tt setInner}, {\tt setOuter}, {\tt setFlags} with unified {\tt set} instruction \\
168 %& replaced {\tt literal} with {\tt shift} instruction \\
169 %17-Apr
170 %& Made all instructions except {\tt setOuter} depend on {\tt OLC>0}  \\
171 %& Removed ability to manually set the {\tt C} flag  \\
172 %& Expanded predicate field to three bits \\
173 %& New literals scheme (via shifting) \\
174 %& Instruction encoding changes made at Ivan's request (for layout purposes) \\
175 %& Added summary of instruction encodings on last page \\
176 %07-Apr
177 %& removed ``+'' from ``potentially torpedoable'' row where it does not occur in Execute  \\
178 %06-Apr
179 %& extended {\tt LiteralPath} to 13 bits (impl need not use all of them)  \\
180 %& update table 3.1.2  \\
181 %& rename {\tt S} flag to {\tt C}  \\
182 %& noted that {\tt setFlags} can be used as {\tt nop} \\
183 %29-Mar
184 %& removed the {\tt L} flag (epilogues can now do this) \\
185 %& removed {\tt take\{Inner|Outer\}LoopCounter} instructions \\
186 %& renamed {\tt data} instruction to {\tt literal} \\
187 %& renamed {\tt send} instruction to {\tt move} \\
188 %23-Mar
189 %& added ``if its predicate is true'' to repeat count \\
190 %& added note that red wires do not contact ships \\
191 %& changed name of {\tt flags} instruction to {\tt setFlags} \\
192 %& removed black dot from diagrams \\
193 %& changed {\tt OL} (Outer Loop participant) to {\tt OS} (One Shot) and inverted polarity \\
194 %& indicated that the death of the {\tt tail} instruction is what causes the hatch to be unsealed \\
195 %& indicated that only {\tt send} instructions which wait for data are torpedoable \\
196 %& added section ``Torpedo Details'' \\
197 %& removed {\tt torpedo} instruction \\
198 %12-Mar
199 %\color{black}
200 %& renamed loop+repeat to outer+inner (not in red) \\
201 %& renamed {\tt Z} flag to {\tt L} flag (not in red) \\
202 %& rewrote ``inner and outer loops'' section \\
203 %& updated all diagrams \\
204 %\color{black}
205 %7-Mar
206 %& Moved address bits to the LSB-side of a 37-bit instruction \\
207 %& Added {\it micro-instruction} and {\it composite instruction} terms \\
208 %& Removed the {\tt DL} field, added {\tt decrement} mode to {\tt loop} \\
209 %& Created the {\tt Hold} field \\
210 %& Changed how ReLooping works \\
211 %& Removed {\tt clog}, {\tt unclog}, {\tt interrupt}, and {\tt massacre} \\
212 \end{tabular}
213 \end{abstract}
214
215 \vfill
216
217 \begin{center}
218 \epsfig{file=all,height=1.5in}
219 \epsfig{file=overview-new,height=1.5in}
220 \end{center}
221
222 \pagebreak
223
224 \section{Overview of Fleet}
225
226 A Fleet processor is organized around a {\it switch fabric}, which is
227 a packet-switched network with reliable in-order delivery.  The switch
228 fabric is used to carry data between different functional units,
229 called {\it ships}.  Each ship is connected to the switch fabric by
230 one or more programmable elements known as {\it docks}.
231
232 A {\it path} specifies a route through the switch fabric from a
233 particular {\it source} to a particular {\it destination}.  The
234 combination of a path and a single word to be delivered is called a
235 {\it packet}.  The switch fabric carries packets from their sources to
236 their destinations.  Each dock has \color{red}four\color{black}\ 
237 destinations: one each for {\it instructions}, \color{red}{\it
238   torpedoes}, {\it tokens},\color{black}\ and {\it words}.  A Fleet is
239 programmed by depositing instruction packets into the switch fabric
240 with paths that will lead them to instruction destinations of the
241 docks at which they are to execute.
242
243 When a packet arrives at the instruction destination of a dock, it is
244 enqueued for execution.  Before the instruction executes, it may cause
245 the dock to wait for a packet to arrive at the dock's data destination
246 or for a value to be presented by the ship.  When an instruction
247 executes it may consume this data and may present a data value to the
248 ship or transmit a packet.
249
250 Packets sent to token and torpedo destinations carry no payload.  Such
251 packets consume less energy than instruction packets or word packets.
252
253
254 \begin{center}
255 \epsfig{file=overview-new,width=2.5in}\\
256 {\it Overview of a Fleet processor; dark gray shading represents the
257   switch fabric, ships are shown in light gray, and docks are shown in blue.}
258 \end{center}
259 \color{black}
260
261 \pagebreak
262
263 \section{The FleetTwo Dock}
264
265 The diagram below represents a conceptual view of the interface
266 between ships and the switch fabric; actual implementation circuitry
267 may differ.
268
269 \begin{center}
270 \epsfig{file=all,width=3.5in}\\
271 {\it An ``input'' dock and ``output'' dock connected to a ship.  Solid
272   blue lines carry either tokens or data words, red lines carry either
273   instructions or torpedoes, and dashed lines carry only tokens.}
274 \end{center}
275
276 Each dock consists of a {\it data latch}, which is as wide as a single
277 machine word and a circular {\it instruction fifo} of
278 instruction-width latches.  The values in the instruction fifo control
279 the data latch.  The dock also includes a {\it path latch}, which
280 stores the path along which outgoing packets will be
281 sent.
282
283 Note that the instruction fifo in each dock has a destination of its
284 own; this is the {\it instruction destination} mentioned in the
285 previous section.  A token sent to an instruction destination is
286 called a {\it torpedo}; it does not enter the instruction fifo, but
287 rather is held in a waiting area where it may interrupt certain
288 instructions (see the section on the {\tt move} instruction for further
289 details).
290
291 From any source to any dock's data destination there are
292 two distinct paths which differ by a single bit.  This bit is known as
293 the ``signal'' bit, and the routing of a packet is not affected by it;
294 the signal bit is used to pass control values between docks.  Note that paths
295 terminating at an {\it instruction} destination need not have a signal
296 bit.
297
298 \color{red}
299 Source-sequence guarantee.  Shared across instruction/torpedo (?) and
300 token/word destinations.
301 \color{black}
302
303 \pagebreak
304 \section{Instructions}
305
306 In order to cause an instruction to execute, the programmer must first
307 arrange for that instruction word to arrive in the data latch of some
308 output dock.  For example, this might be the ``data read'' output dock
309 of the memory access ship or the output of a fifo ship.  Once an
310 instruction has arrived at this output dock, it is {\it dispatched} by
311 sending it to the {\it instruction destination} of the dock at which
312 it is to execute.
313
314 Each instruction is 25\color{black}\ bits long, which makes
315 it possible for an instruction and an 12\color{black}-bit
316 path to fit in a single word of memory.  This path is the path from
317 the {\it dispatching} dock to the {\it executing} dock.
318
319 \vspace{0.5cm}
320
321 \setlength{\bitwidth}{3.5mm}
322 {\tt \footnotesize
323 \begin{bytefield}{37}
324   \bitheader[b]{0,24,25,36}\\
325   \bitbox{12}{dispatch path} 
326   \bitbox{25}{instruction} 
327 \end{bytefield}}
328 \color{black}
329
330 Note that the 12\color{black}\ bit {\tt dispatch path}
331 field is not the same width as the 13 bit {\tt Immediate} path field
332 in the {\tt move} instruction, which in turn may not be the same width
333 as the actual path latches in the switch fabric.
334
335 The algorithm for expanding a path to a wider width is specific to the
336 switch fabric implementation, and is not specified by this
337 document.\footnote{for the Marina experiment, the correct
338   algorithm is to sign-extend the path; the most significant bit of
339   the given path is used to fill the vacant bit of the latch} In
340 particular, because the {\tt dispatch path} field is always used to
341 specify a path which terminates at an instruction destination (never a
342 data destination), and because instruction destinations ignore the
343 signal bit, certain optimizations may be possible.
344
345 %\subsection{Life Cycle of an Instruction}
346 %
347 %The diagram below shows an input dock for purposes of illustration:
348 %
349 %\begin{center}
350 %\epsfig{file=in,width=4in}\\
351 %{\it an input dock}
352 %\end{center}
353 %
354 %\color{black}
355 %
356 %\begin{center}
357 %\epsfig{file=out,width=4in}\\
358 %{\it an output dock}
359 %\end{center}
360
361 %\subsection{Format of an Instruction}
362 %
363 %All instruction words have the following format:
364 %
365 %
366 %
367 %The {\tt P} bits are a {\it predicate}; this holds a code which
368 %indicates if the instruction should be executed or ignored depending
369 %on the state of flags in the dock.  Note that {\tt head} and {\tt
370 %tail} instructions do not have {\tt P} fields.
371
372
373 \subsection{Loop Counter}
374
375 A programmer can perform two types of loops: {\it inner} loops
376 consisting of only one {\tt move} instruction and {\it outer} loops of
377 multiple instructions of any type.  Inner loops may be nested within
378 an outer loop, but no other nesting of loops is allowed.
379
380 The dock has \color{red}one loop counter, called {\tt LC}.  It is the
381 same width as a word carried through the switch fabric (37 bits).
382
383 \color{black}
384
385 \subsection{Flags}
386
387 The dock has four flags: {\tt A}, {\tt B},
388 {\tt C}, and \color{red}{\tt Z}\color{black}.
389
390 \begin{itemize}
391 \item The {\tt A} and {\tt B} flags are general-purpose flags which
392       may be set and cleared by the programmer.
393
394 %\item
395 %
396 % The {\tt L} flag, known as the {\it last} flag, is set whenever
397 %      the value in the outer counter ({\tt OLC}) is one,
398 \color{black}
399 % indicating
400 %      that the dock is in the midst of the last iteration of an
401 %      outer loop.  This flag can be used to perform certain
402 %      operations (such as sending a completion token) only on the last
403 %      iteration of an outer loop.
404
405 \item The {\tt C} flag is known as the {\it control} flag, and may be
406       set by the {\tt move} instruction based on information from the
407       ship or from an inbound packet.  See the {\tt move} instruction
408       for further details.
409
410 \item The \color{red}{\tt Z}\color{black}\ flag is known as the
411       \color{red}{\it zero}\color{black}\ flag.  The \color{red}{\tt
412       Z}\color{black}\ flag is {\it set} whenever the {\tt LC} is zero.
413       In an actual implementation the \color{red}{\tt Z}\color{black}\ 
414       flag might require an actual latch; it might simply be derived
415       from the ``zeroness'' of the {\tt LC}.\color{black}
416
417 \end{itemize}
418
419 \subsection{Predication}
420
421 All instructions except for {\tt head} and {\tt tail} have a three-bit
422 field marked {\tt P}, which specifies a {\it predicate}.
423
424 \begin{center}
425 \setlength{\bitwidth}{5mm}
426 {\tt{\footnotesize{
427 \begin{bytefield}{25}
428   \bitheader[b]{0,21,22,24}\\
429   \bitbox{3}{P} 
430   \bitbox[tbr]{22}{} 
431 \color{black}
432 \end{bytefield}}}}
433 \end{center}
434
435 The predicate determines which conditions must be true in order for
436 the instruction to execute; if it is not executed, it is simply {\it
437   ignored}.  The table below shows what conditions must be true in
438 order for an instruction to execute:
439
440 \begin{center}
441 \begin{tabular}{|r|l|}\hline
442 Code       & Execute if \\\hline
443 {\tt 000:} & {\tt Z=0}\   and {\tt A=0} \\
444 {\tt 001:} & {\tt Z=0}\   and {\tt A=1} \\
445 {\tt 010:} & {\tt Z=0}\   and {\tt B=0} \\
446 {\tt 011:} & {\tt Z=0}\   and {\tt B=1} \\
447 {\tt 100:} & Unused  \\
448 {\tt 101:} & {\tt Z=1}\   \\
449 {\tt 110:} & {\tt Z=0}\   \\
450 {\tt 111:} & always  \\
451 \hline\end{tabular}
452 \end{center}
453
454 \pagebreak
455
456 \begin{wrapfigure}{r}{40mm}
457   \begin{center}
458 \epsfig{file=requeue,height=1.5in}\\
459   \end{center}
460   \caption{{\it the requeue stage}}
461 \end{wrapfigure}
462
463 \subsection{The Requeue Stage}
464
465 The requeue stage has two inputs, which will be referred to as the
466 {\it enqueueing} input and the {\it recirculating} input.  It has a
467 single output which feeds into the instruction fifo.
468
469 The requeue stage has two states: {\sc Updating} and {\sc
470   Circulating}.
471
472 \subsubsection{The {\sc Updating} State}
473
474 On initialization, the dock is in the {\sc Updating} state.  In this
475 state the requeue stage is performing three tasks:
476 \begin{itemize}
477 \item it is draining the
478 previous loop's instructions (if any) from the fifo
479 \item it is executing any ``one
480 shot'' instructions which come between the previous loop's {\tt tail}
481 and the next loop's {\tt head}
482 \item it is loading the instructions of
483 the next loop into the fifo.
484 \end{itemize}
485
486 In the {\sc Updating} state, the requeue stage will accept any
487 instruction other than a {\tt tail} which arrives at its {\it
488   enqueueing} input, and pass this instruction to its output.  Any
489 instruction other than a {\tt head} which arrives at the {\it
490   recirculating} input will be discarded.
491
492 Note that when a {\tt tail} instruction arrives at the {\it
493   enqueueing} input, it ``gets stuck'' there.  Likewise, when a {\tt
494   head} instruction arrives at the {\it recirculating} input, it also
495 ``gets stuck''.  When the requeue stage finds {\it both} a {\tt tail}
496 instruction stuck at the {\it enqueueing} input and a {\tt head}
497 instruction stuck at the {\it recirculating} input, the requeue stage
498 discards both the {\tt head} and {\tt tail} and transitions to the
499 {\sc Circulating} state.
500
501 \subsubsection{The {\sc Circulating} State}
502
503 In the {\sc Circulating} state, the dock repeatedly executes the set
504 of instructions that are in the instruction fifo.
505
506 In the {\sc Circulating} state, the requeue stage will not accept
507 items from its {\it enqueueing} input.  Any item presented at the {\it
508   recirculating} input will be passed through to the requeue stage's
509 output.
510
511 When an {\tt abort} instruction is executed, the requeue stage
512 transitions back to the {\sc Updating} state.  Note that {\tt abort}
513 instructions include a predicate; an {\tt abort} instruction whose
514 predicate is not met will not cause this transition.
515
516 \color{black}
517
518
519 \pagebreak
520 \section{Instructions}
521
522 %The dock supports four instructions:
523 %{\tt move} (variants: {\tt moveto}, {\tt dispatch}),
524 %{\tt shift},
525 %{\tt set}, and
526 %{\tt tail}.
527 %\color{black}
528
529
530 \subsection{{\tt move}}
531
532 \newcommand{\bitsMove}{\setlength{\bitwidth}{5mm}
533 {\tt
534 \begin{bytefield}{25}
535   \bitheader[b]{14-21}\\
536 \color{light}
537   \bitbox{3}{P} 
538 \color{black}
539 \color{red}
540   \bitbox{1}{0} 
541   \bitbox{1}{R} 
542   \bitbox{1}{I} 
543 \color{black}
544   \bitbox{1}{\tt Ti}
545   \bitbox{1}{\tt Di}
546   \bitbox{1}{\tt Dc}
547   \bitbox{1}{\tt Do}
548   \bitbox{1}{\tt To}
549   \bitbox[l]{19}{}
550 \end{bytefield}}
551
552 \begin{bytefield}{25}
553   \bitheader[b]{0,12,13}\\
554   \bitbox[1]{10}{\raggedleft {\tt moveto} ({\tt Immediate\to Path})}
555   \bitbox[r]{1}{}
556   \bitbox{1}{\tt 1}
557   \bitbox{13}{\tt Immediate}
558 \end{bytefield}
559
560 \begin{bytefield}{25}
561   \bitheader[b]{11,12,13}\\
562   \bitbox[1]{10}{\raggedleft {\tt dispatch} ({\footnotesize {\tt DataPredecessor[37:26\color{black}]\to Path}})\ \ }
563   \bitbox[r]{1}{}
564   \bitbox{1}{\tt 0}
565   \bitbox{1}{\tt 1}
566 \color{light}
567   \bitbox[trb]{12}{}
568 \color{black}
569 \end{bytefield}
570
571 \begin{bytefield}{25}
572   \bitheader[b]{11,12,13}\\
573   \bitbox[1]{10}{\raggedleft {\tt move} ({\tt Path} unchanged):}
574   \bitbox[r]{1}{}
575   \bitbox{1}{\tt 0}
576   \bitbox{1}{\tt 0}
577 \color{red}
578   \bitbox{1}{\tt 0}
579 \color{light}
580   \bitbox[trb]{11}{}
581 \color{black}
582 \end{bytefield}
583
584 }
585 \bitsMove
586
587 \begin{itemize}
588 \item {\tt Ti} - Token Input: wait for the token predecessor to be full and drain it.
589 \item {\tt Di} - Data Input: wait for the data predecessor to be full and drain it.
590 \item {\tt Dc} - Data Capture: pulse the data latch.
591 \item {\tt Do} - Data Output: fill the data successor.
592 \item {\tt To} - Token Output: fill the token successor.
593 \end{itemize}
594
595 The data successor and token successor must both be empty in order for
596 a {\tt move} instruction to attempt execution.
597
598 \color{red}
599 If the {\tt S} bit is set (not shown -- there is no space left!), the
600 {\tt move} instruction will subtract one from the {\tt LC} counter
601 each time it executes.
602 NOTE: the flavor of {\tt set} instruction which decrements the counter
603 is now unnecessary; we can simply use a ``do-nothing {\tt move}'' with
604 the {\tt S}-bit set for that.
605
606 If the {\tt R} bit is set, the {\tt move} instruction will execute
607 repeatedly until its predicate no longer holds (or a torpedo strikes).
608 An ``infinite'' or ``standing'' move can be achieved by setting the
609 {\tt R} bit and clearing the {\tt S} bit.
610 \color{black}
611
612 \subsection*{Torpedoes}
613
614 The {\tt I} bit stands for {\tt Immune}, and indicates if the
615 instruction is immune to torpedoes.  If a {\tt move} instruction which
616 is not immune is waiting to execute and a torpedo is lying in wait,
617 the torpedo {\it strikes}.  \color{red}When a torpedo strikes, the
618 {\tt move} instruction and the torpedo are both consumed and the {\tt
619   LC} is set to zero.\color{black}
620
621 \subsection*{The C Flag}
622
623 Every time the {\tt move} instruction executes, the {\tt C} flag may
624 be set:
625
626 \begin{itemize}
627 \item At an {\it input} dock the {\tt C} flag is set to the signal bit
628       of the incoming packet.
629
630 \item At an {\it output} dock the {\tt C} flag is set to a value
631       provided by the ship if the {\tt Dc} bit is set.  If the {\tt
632       Dc} bit is not set, the {\tt C} flag is set to the signal bit of
633       the incoming packet.
634 \end{itemize}
635 \color{black}
636
637 \subsection*{Flushing}
638
639 The {\tt flush} instruction is a variant of {\tt move} which is valid
640 only at input docks.  It has the same effect as {\tt deliver}, except
641 that it sets a special ``flushing'' indicator along with the data
642 being delivered.
643
644 \newcommand{\bitsFlush}{\setlength{\bitwidth}{5mm}
645 {\tt
646 \begin{bytefield}{25}
647   \bitheader[b]{14-18}\\
648   \bitbox[r]{6}{\raggedleft{\tt flush\ \ }}
649   \bitbox{1}{\tt 0}
650   \bitbox{1}{\tt 0}
651   \bitbox{1}{\tt 1}
652   \bitbox{1}{\tt 0}
653   \bitbox{1}{\tt 0}
654 \color{red}
655   \bitbox{1}{\tt 0}
656   \bitbox{1}{\tt 0}
657   \bitbox{1}{\tt 1}
658 \color{black}
659   \bitbox{11}{}
660 \end{bytefield}}}
661 \bitsFlush
662
663 When a ship fires, it must examine the ``flushing'' indicators on the
664 input docks whose fullness was part of the firing condition.  If all
665 of the input docks' flushing indicators are set, the ship must drain
666 all of their data successors and take no action.  If some, but not
667 all, of the indicators are set, the ship must drain {\it only the data
668   successors of the docks whose indicators were {\bf not} set}, and
669 take no action.  If none of the flushing indicators was set, the ship
670 fires normally.
671
672 \color{black}
673
674 \pagebreak
675
676 \subsection{{\tt set}}
677
678 The {\tt set} command is used to set the data latch, the flags, or the
679 loop counter.
680
681 \newcommand{\bitsSet}{
682 {\tt
683 \begin{bytefield}{25}
684   \bitheader[b]{19-21}\\
685 \color{light}
686   \bitbox{3}{P} 
687 \color{black}
688 \color{red}
689   \bitbox{1}{1}
690   \bitbox{1}{0} 
691   \bitbox{1}{1} 
692 \color{black}
693 \color{light}
694   \bitbox{4}{Dest} 
695   \bitbox{3}{Src} 
696   \bitbox{12}{} 
697 \color{black}
698 \end{bytefield}}
699
700 \begin{bytefield}{25}
701   \bitheader[b]{0,11-18}\\
702   \bitbox[1]{5}{\raggedleft {\tt Immediate}\to{\tt LC}}
703   \bitbox[r]{1}{}
704   \bitbox{4}{\tt 1000\color{black}}
705   \bitbox{3}{\tt 100}
706   \color{red}
707   \bitbox{12}{\tt Immediate}
708   \color{black}
709 \end{bytefield}
710
711 \begin{bytefield}{25}
712   \bitheader[b]{12-18}\\
713   \bitbox[1]{5}{\raggedleft {\tt Data Latch}\to{\tt LC}}
714   \bitbox[r]{1}{}
715   \bitbox{4}{\tt 1000\color{black}}
716   \bitbox{3}{\tt 010}
717   \bitbox{12}{}
718 \end{bytefield}
719
720 \begin{bytefield}{25}
721   \bitheader[b]{0,13-18}\\
722   \bitbox[1]{5}{\raggedleft \footnotesize {\tt Sign-Extended Immediate}\to{\tt Data Latch}}
723   \bitbox[r]{1}{}
724   \bitbox{4}{\tt 0010\color{black}}
725   \bitbox{1}{\begin{minipage}{0.5cm}{
726 \begin{center}
727 \tt{\footnotesize{Si
728
729 \vspace{-2mm}gn}}
730 \end{center}}
731 \end{minipage}}
732   \bitbox{14}{\tt Immediate}
733 \end{bytefield}
734
735 \begin{bytefield}{25}
736   \bitheader[b]{0,5,6,11,15-18}\\
737   \bitbox[1]{5}{\raggedleft {\tt Update Flags}}
738   \bitbox[r]{1}{}
739   \bitbox{4}{\tt 0001\color{black}}
740   \bitbox{3}{}
741   \bitbox{6}{\tt nextA}
742   \bitbox{6}{\tt nextB}
743 \end{bytefield}
744 \color{black}
745 }
746 \bitsSet
747
748 The FleetTwo implementation is likely to have an unarchitected
749 ``literal latch'' at the on deck ({\tt OD}) stage, which is loaded
750 with the possibly-extended literal {\it at the time that the {\tt set}
751   instruction comes on deck}.  This latch is then copied into the data
752 latch when a {\tt set Data Latch} instruction
753 executes.
754
755 The {\tt Sign-Extended Immediate} instruction copies the {\tt
756 Immediate} field into the least significant bits of the data latch.
757 All other bits of the data latch are filled with a copy of the
758 bit marked ``{\tt Sign}.''
759 \color{black}
760
761 Each of the {\tt nextA} and {\tt nextB} fields has the following
762 structure, and indicates which old flag values should be logically
763 {\tt OR}ed together to produce the new flag value:
764
765 \begin{center}
766 {\tt
767 \begin{bytefield}{6}
768   \bitheader[b]{0-5}\\
769   \bitbox{1}{${\text{\tt A}}$}
770   \bitbox{1}{$\overline{\text{\tt A}}$}
771   \bitbox{1}{${\text{\tt B}}$}
772   \bitbox{1}{$\overline{\text{\tt B}}$}
773   \bitbox{1}{${\text{{\tt C}\ }}$}
774   \bitbox{1}{$\overline{\text{{\tt C}\ }}$}
775 \end{bytefield}}
776 \end{center}
777
778 Each bit corresponds to one possible input; all inputs whose bits are
779 set are {\tt OR}ed together, and the resulting value is assigned to
780 the flag.  Note that if none of the bits are set, the value assigned
781 is zero.  Note also that it is possible to produce a {\tt 1} by {\tt
782   OR}ing any flag with its complement, and that {\tt set Flags} can
783 be used to create a {\tt nop} (no-op) by setting each flag to itself.
784
785
786 \color{black}
787
788 \pagebreak
789 \subsection{{\tt shift}}
790
791 \newcommand{\shiftImmediateSize}{19}
792
793 Each {\tt shift} instruction carries an immediate of \shiftImmediateSize\ 
794 bits.  When a {\tt shift} instruction is executed, this immediate is copied
795 into the least significant \shiftImmediateSize\  bits of the data latch,
796 and the remaining most significant bits of the data latch are loaded
797 with the value formerly in the least significant bits of the data latch.
798 In this manner, large literals can be built up by ``shifting'' them
799 into the data latch \shiftImmediateSize\ bits at a time.
800
801 \newcommand{\bitsShift}{
802 \setlength{\bitwidth}{5mm}
803 {\tt
804 \begin{bytefield}{25}
805   \bitheader[b]{0,18-21}\\
806 \color{light}
807   \bitbox{3}{P} 
808 \color{black}
809 \color{red}
810   \bitbox{1}{1} 
811   \bitbox{1}{0} 
812   \bitbox{1}{0} 
813 \color{black}
814   \bitbox{\shiftImmediateSize}{Immediate} 
815 \end{bytefield}}
816 }
817 \bitsShift
818
819 The FleetTwo implementation is likely to have an unarchitected
820 ``literal latch'' at the on deck ({\tt OD}) stage, which is loaded
821 with the literal {\it at the time that the {\tt shift} instruction
822   comes on deck}.  This latch is then copied into the data latch when
823 the instruction executes.
824
825 \color{black}
826
827 \subsection{{\tt abort}}
828 \newcommand{\bitsAbort}{\setlength{\bitwidth}{5mm}
829 {\tt
830 \begin{bytefield}{25}
831   \bitheader[b]{18-21}\\
832 \color{light}
833   \bitbox{3}{P} 
834 \color{black}
835 \color{red}
836   \bitbox{1}{1} 
837   \bitbox{1}{1} 
838   \bitbox{1}{0} 
839 \color{black}
840   \bitbox{1}{0} 
841 \color{light}
842   \bitbox[tbr]{18}{}
843 \end{bytefield}}}
844 \bitsAbort
845
846 An {\tt abort} instruction causes a loop to exit; see the section on
847 the Requeue Stage for further details.
848
849 \subsection{{\tt head}}
850 \newcommand{\bitsHead}{
851 \setlength{\bitwidth}{5mm}
852 {\tt
853 \begin{bytefield}{25}
854   \bitheader[b]{18-21}\\
855 \color{light}
856   \bitbox{3}{} 
857 \color{black}
858 \color{red}
859   \bitbox{1}{1}
860   \bitbox{1}{1}
861   \bitbox{1}{1}
862 \color{black}
863   \bitbox{1}{0}
864 \color{light}
865   \bitbox[tbr]{18}{} 
866 \end{bytefield}}}
867 \bitsHead
868
869 A {\tt head} instruction marks the start of a loop; see the section on
870 the Requeue Stage for further details.
871
872 \color{black}
873 \subsection{{\tt tail}}
874 \newcommand{\bitsTail}{
875 \setlength{\bitwidth}{5mm}
876 {\tt
877 \begin{bytefield}{25}
878   \bitheader[b]{18-21}\\
879 \color{light}
880   \bitbox{3}{} 
881 \color{black}
882 \color{red}
883   \bitbox{1}{1}
884   \bitbox{1}{1}
885   \bitbox{1}{1}
886 \color{black}
887   \bitbox{1}{1}
888 \color{light}
889   \bitbox[tbr]{18}{} 
890 \end{bytefield}}}
891 \bitsTail
892
893 A {\tt tail} instruction marks the end of a loop; see the section on
894 the Requeue Stage for further details.
895
896 \color{black}
897 %\pagebreak
898 %\subsection{{\tt takeOuterLoopCounter}}
899 %
900 %\setlength{\bitwidth}{5mm}
901 %{\tt
902 %\begin{bytefield}{25}
903 %  \bitheader[b]{16-19,21}\\
904 %\color{light}
905 %  \bitbox{1}{A}
906 %  \bitbox{1}{OS} 
907 %  \bitbox{2}{P}
908 %\color{black}
909 %  \bitbox{3}{000}
910 %  \bitbox{1}{0}
911 %  \bitbox{2}{11}
912 %\color{light}
913 %  \bitbox[tbr]{16}{} 
914 %\color{black}
915 %\end{bytefield}}
916 %
917 %This instruction copies the value in the outer loop counter {\tt OLC}
918 %into the least significant bits of the data latch and leaves all other
919 %bits of the data latch unchanged.
920 %
921 %\subsection{{\tt takeInnerLoopCounter}}
922 %
923 %\setlength{\bitwidth}{5mm}
924 %{\tt
925 %\begin{bytefield}{25}
926 %  \bitheader[b]{16-19,21}\\
927 %\color{light}
928 %  \bitbox{1}{A}
929 %  \bitbox{1}{OS} 
930 %  \bitbox{2}{P}
931 %\color{black}
932 %  \bitbox{3}{???}
933 %  \bitbox{1}{?}
934 %  \bitbox{2}{??}
935 %\color{light}
936 %  \bitbox[tbr]{16}{} 
937 %\color{black}
938 %\end{bytefield}}
939 %
940 %This instruction copies the value in the inner loop counter {\tt ILC}
941 %into the least significant bits of the data latch and leaves all other
942 %bits of the data latch unchanged.
943 %
944 %
945 %
946 %%\pagebreak
947 %%\subsection{{\tt interrupt}}
948 %%
949 %%\setlength{\bitwidth}{5mm}
950 %{\tt
951 %\begin{bytefield}{25}
952 %  \bitheader[b]{0,5,16-19,21}\\
953 %\color{light}
954 %  \bitbox{4}{} 
955 %\color{black}
956 %  \bitbox{3}{000} 
957 %  \bitbox{1}{1}
958 %  \bitbox{2}{00}
959 %\color{light}
960 %  \bitbox[tbr]{16}{} 
961 %\end{bytefield}}
962 %
963 %When an {\tt interrupt} instruction reaches {\tt IH}, it will wait
964 %there for the {\tt OD} stage to be full with an instruction that has
965 %the {\tt IM} bit set.  When this occurs, the instruction at {\tt OD}
966 %{\it will not execute}, but {\it may reloop} if the conditions for
967 %relooping are met.
968 %\footnote{The ability to interrupt an instruction yet have it reloop is very
969 %useful for processing chunks of data with a fixed size header and/or
970 %footer and a variable length body.}
971 %
972 %
973 %\subsection{{\tt massacre}}
974 %
975 %\setlength{\bitwidth}{5mm}
976 %{\tt
977 %\begin{bytefield}{25}
978 %  \bitheader[b]{16-19,21}\\
979 %\color{light}
980 %  \bitbox{4}{} 
981 %\color{black}
982 %  \bitbox{3}{000} 
983 %  \bitbox{1}{1}
984 %  \bitbox{2}{01}
985 %\color{light}
986 %  \bitbox[tbr]{16}{} 
987 %\color{black}
988 %\end{bytefield}}
989 %
990 %When a {\tt massacre} instruction reaches {\tt IH}, it will wait there
991 %for the {\tt OD} stage to be full with an instruction that has the
992 %{\tt IM} bit set.  When this occurs, all instructions in the
993 %instruction fifo (including {\tt OD}) are retired.
994 %
995 %\subsection{{\tt clog}}
996 %
997 %\setlength{\bitwidth}{5mm}
998 %{\tt
999 %\begin{bytefield}{25}
1000 %  \bitheader[b]{16-19,21}\\
1001 %\color{light}
1002 %  \bitbox{4}{} 
1003 %\color{black}
1004 %  \bitbox{3}{000} 
1005 %  \bitbox{1}{1}
1006 %  \bitbox{2}{10}
1007 %\color{light}
1008 %  \bitbox[tbr]{16}{} 
1009 %\color{black}
1010 %\end{bytefield}}
1011 %
1012 %When a {\tt clog} instruction reaches {\tt OD}, it remains there and
1013 %no more instructions will be executed until an {\tt unclog} is
1014 %performed.
1015 %
1016 %\subsection{{\tt unclog}}
1017 %
1018 %\setlength{\bitwidth}{5mm}
1019 %{\tt
1020 %\begin{bytefield}{25}
1021 %  \bitheader[b]{16-19,21}\\
1022 %\color{light}
1023 %  \bitbox{4}{} 
1024 %\color{black}
1025 %  \bitbox{3}{000} 
1026 %  \bitbox{1}{1}
1027 %  \bitbox[lrtb]{2}{11}
1028 %\color{light}
1029 %  \bitbox[tbr]{16}{} 
1030 %\color{black}
1031 %\end{bytefield}}
1032 %
1033 %When an {\tt unclog} instruction reaches {\tt IH}, it will wait there
1034 %until a {\tt clog} instruction is at {\tt OD}.  When this occurs, both
1035 %instructions retire.
1036 %
1037 %Note that issuing an {\tt unclog} instruction to a dock which is not
1038 %clogged and whose instruction fifo contains no {\tt clog} instructions
1039 %will cause the dock to deadlock.
1040
1041 \pagebreak
1042 \section*{Marina Errata}
1043
1044 The following additional restrictions have been imposed on the dock in
1045 the Marina test chip:
1046
1047 \subsection*{All Versions}
1048
1049 \begin{enumerate}
1050
1051 \item
1052 A Marina dock initializes with the {\tt ILC}, {\tt OLC}, and flags in
1053 an indeterminate state.
1054
1055 \item
1056 The instruction immediately after a {\tt move} instruction must not be
1057 a {\tt set flags} instruction which utilizes the {\tt C}-flag (the
1058 value of the {\tt C}-flag is not stable for a brief time after a {\tt
1059   move}).
1060
1061 \color{red}
1062
1063 \item
1064 If a {\tt move} instruction is torpedoable (ie it has the {\tt I} bit
1065 set to {\tt 0}), it {\it must} have either the {\tt Ti} bit or {\tt
1066   Di} bit set (or both).  It is not permitted for a torpedoable {\tt
1067   move} to have both bits cleared.
1068
1069 \color{black}
1070
1071 \end{enumerate}
1072
1073
1074 \subsection*{Marina with Ivan's Counter}
1075
1076 \begin{enumerate}
1077
1078 \item
1079
1080 A torpedoable {\tt move} instruction must not be followed immediately
1081 by a {\tt set olc} instruction or another torpedoable {\tt move}.
1082
1083 \item
1084
1085 This document specifies that when a torpedoable {\tt move} instruction
1086 executes successfully, the \color{red}{\tt Z}\color{black} flag is unchanged.  In Marina, when
1087 a torpedoable {\tt move} instruction executes successfully, it causes
1088 the \color{red}{\tt Z}\color{black} flag to be set if the {\tt OLC} was zero and causes it to
1089 be cleared if the {\tt OLC} was nonzero.  Thus, in the following
1090 instruction sequence:
1091
1092   \begin{verbatim}
1093   head;
1094   [*] set olc=1;
1095       send token to self:i;
1096   [T] recv token;
1097   [*] send token to self;
1098   [T] recv token;
1099   [*] abort;
1100   tail;
1101   \end{verbatim}
1102
1103 Will leave the \color{red}{\tt Z}\color{black} flag {\it set} on Marina, whereas a strict
1104 implementation of this document would leave it cleared.
1105
1106 In practice, this distinction rarely matters.
1107
1108 \end{enumerate}
1109
1110 \subsection*{Marina with Kessels Counter}
1111
1112 With the Kessels counter, the \color{red}{\tt Z}\color{black}-flag {\it is exactly equal to}
1113 the zeroness of the {\tt OLC}; it cannot be ``out of sync'' with it.
1114
1115 \begin{enumerate}
1116
1117 \item
1118 Every ``load OLC'' instruction must be predicated on the \color{red}{\tt Z}\color{black}-flag
1119 being {\it set}.  This is a sneaky way of forcing the programmer to
1120 ``run down'' the counter before loading it, because Kessels' counter
1121 does not support ``unloading.''
1122
1123 \item
1124 Every ``decrement OLC'' instruction must be predicated on the {\tt
1125   D}-flag being {\it cleared}.  This way we never have to check if the
1126 counter is already empty before decrementing.
1127
1128 \item
1129 The instruction after a torpedoable {\tt move} must not be predicated
1130 on the \color{red}{\tt Z}\color{black}-flag being {\it set} (it may be predicated on the {\tt
1131   D}-flag being {\it cleared}.  This is because, while the move
1132 instruction is waiting to execute, the \color{red}{\tt Z}\color{black}-flag will be cleared,
1133 and the predicate stage believes that it can skip the instruction even
1134 though {\tt do[ins]} is still high (I think this is dumb).
1135
1136
1137 \end{enumerate}
1138
1139 \color{black}
1140
1141 \pagebreak
1142 \section*{Instruction Encoding Map\color{black}}
1143
1144
1145 \vspace{3mm}\hspace{-1cm}{\tt move}\hspace{1cm}\vspace{-6mm}\\
1146 \bitsMove
1147 \bitsFlush
1148
1149 \vspace{3mm}\hspace{-1cm}{\tt shift}\hspace{1cm}\vspace{-6mm}\\
1150 \bitsShift
1151
1152 \vspace{3mm}\hspace{-1cm}{\tt set}\hspace{1cm}\vspace{-6mm}\\
1153 \bitsSet
1154
1155 \vspace{3mm}\hspace{-1cm}{\tt abort}\hspace{1cm}\vspace{-6mm}\\
1156 \bitsAbort
1157
1158 \vspace{3mm}\hspace{-1cm}{\tt head}\hspace{1cm}\vspace{-6mm}\\
1159 \bitsHead
1160
1161 \vspace{3mm}\hspace{-1cm}{\tt tail}\hspace{1cm}\vspace{-6mm}\\
1162 \bitsTail
1163
1164
1165 %\pagebreak
1166 %\epsfig{file=all,height=5in,angle=90}
1167
1168 %\pagebreak
1169 %\subsection*{Input Dock}
1170 %\epsfig{file=in,width=8in,angle=90}
1171
1172 %\pagebreak
1173 %\subsection*{Output Dock}
1174 %\epsfig{file=out,width=8in,angle=90}
1175
1176
1177 %\pagebreak
1178 %\epsfig{file=ports,height=5in,angle=90}
1179
1180 %\pagebreak
1181 %\epsfig{file=best,height=5in,angle=90}
1182
1183
1184 \end{document}