0a620b2d2baf1d298a29aecacd2abd893fe9afdc
[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   input  [(`DATAWIDTH-1):0] in_d;
35   output [(`DATAWIDTH-1):0] out_d_;
36   input in_r;
37   output in_a_;
38   output out_r_;
39   input out_a;
40
41   fifo8x37 fifo8x37(clk, rst,
42                     in_r,  in_a_, in_d,
43                     out_r_, out_a, out_d_);
44
45
46 == Test =================================================================
47 // expected output
48 #expect 9
49
50 // ships required in order to run this code
51 #ship debug        : Debug
52 #ship fifo         : Fifo
53
54 debug.in:   set ilc=*;  recv, deliver;
55 fifo.in:
56   set word= 9;
57   deliver;
58   set ilc=63;
59   recv, deliver;
60   set ilc=37;
61   recv, deliver;
62
63 fifo.out:
64   set ilc=63;
65   collect, send to fifo.in;
66   set ilc=36;
67   collect, send to fifo.in;
68   collect, send to debug.in;
69
70
71
72 == Contributors =========================================================
73 Adam Megacz <megacz@cs.berkeley.edu>