disable Alu3 test temporarily (clogs switch fabric with two-instruction literals)
[fleet.git] / ships / Stack.ship
index 851607c..1143c5b 100644 (file)
@@ -7,18 +7,32 @@ data  out:  pop
 == Constants ========================================================
 
 == TeX ==============================================================
-A stack ship with capacity for at least 32 elements.
+A stack ship with capacity for at least 16 elements.
 
-Push operations are executed as soon as an inbound datum is {\tt
-deliver}ed on the {\tt push} port.  Completion of a push can be
-confirmed by sending a {\tt notify} token from the {\tt push} port.
+Push operations are executed as soon as an inbound datum is delivered
+to the {\tt push} port.  Completion of a push can be confirmed by
+sending a token from the {\tt push} port after {\tt deliver}ing.
 
 Pop operations are executed no earlier than the time at which the {\tt
 pop} port attempts to {\tt take} data from the ship.
 
 When the stack becomes full, it will simply not process any new {\tt
 push} operations.  When the stack becomes empty, it will simply not
-process any new {\tt pop} operations.
+process any new {\tt pop} operations.  Phrased another way, if a {\tt
+pop} is issued to an empty stack, that operation will wait for a {\tt
+push} to occur; at some point after that, the {\tt pop} will proceed
+to pop the pushed value.  There is no ``underflow'' or ``overflow.''
+
+\subsection*{To Do}
+
+There is some difficulty here when it comes to arbitration -- does the
+execution of the instruction after the {\tt deliver} to the {\tt push}
+port indicate that the value has been safely pushed?  This is much
+tricker than it seems.
+
+Perhaps there should be a single port, {\tt operation}, to which
+either a {\sc PUSH} or {\sc POP} command is sent.  This would simplify
+the arbitration issues.
 
 == Fleeterpreter ====================================================
     private ArrayList<Long> stack = new ArrayList<Long>();
@@ -72,15 +86,16 @@ process any new {\tt pop} operations.
 #expect 0
 
 debug.in:  [*] take, deliver;
-stack.push: [5] take, deliver; notify stack.pop;
 
 stack.pop: wait; [*] take, sendto debug.in;
 
-0: sendto stack.push;
-1: sendto stack.push;
-2: sendto stack.push;
-3: sendto stack.push;
-4: sendto stack.push;
+stack.push:
+  literal 0; deliver;
+  literal 1; deliver;
+  literal 2; deliver;
+  literal 3; deliver;
+  literal 4; deliver;
+  notify stack.pop;