NCC clean newCell
[fleet.git] / ships / Fifo.ship
1 ship: Fifo
2
3 == Ports ===========================================================
4 data  in:   in
5
6 data  out:  out
7
8 == Constants ========================================================
9
10 == TeX ==============================================================
11
12 The {\tt Fifo} ship is a simple fifo.  Word-sized delivered to the {\tt
13 in} port are enqueued into the fifo, and values which arrive at the
14 end of the fifo are provided to the {\tt out} port.
15
16 The internal capacity of the fifo is unspecified, but guaranteed to be
17 at least 16 words.
18
19 == Fleeterpreter ====================================================
20     private Queue<Long> fifo = new LinkedList<Long>();
21     public void service() {
22         if (box_in.dataReadyForShip()) {
23             fifo.add(box_in.removeDataForShip());
24         }
25         if (box_out.readyForDataFromShip() && fifo.size() > 0) {
26             box_out.addDataFromShip(fifo.remove());
27         }
28     }
29
30 == FleetSim ==============================================================
31
32 == FPGA ==============================================================
33
34 // not used
35
36 == Test =================================================================
37 // expected output
38 #expect 9
39
40 // ships required in order to run this code
41 #ship debug        : Debug
42 #ship fifo         : Fifo
43
44 debug.in:   set ilc=*;  recv, deliver;
45 fifo.in:
46   set word= 9;
47   deliver;
48   set ilc=63;
49   recv, deliver;
50   set ilc=37;
51   recv, deliver;
52
53 fifo.out:
54   set ilc=63;
55   collect, send to fifo.in;
56   set ilc=36;
57   collect, send to fifo.in;
58   collect, send to debug.in;
59
60
61
62 == Contributors =========================================================
63 Adam Megacz <megacz@cs.berkeley.edu>