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