80dcebc70c662a5091be77cc09db2fb300cbc18f
[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   wire in_a__;
35   wire out_r__;
36
37   fifo8x37 fifo8x37(clk, rst,
38                     in_r,    in_a__, in_d,
39                     out_r__, out_a,  out_d_);
40
41   always @(posedge clk) begin
42     if (!rst) begin
43       `reset
44     end else begin
45       `flush
46       out_r <= out_r__;
47       in_a  <= in_a__;
48     end
49   end
50
51
52 == Test =================================================================
53 // expected output
54 #expect 9
55
56 // ships required in order to run this code
57 #ship debug        : Debug
58 #ship fifo         : Fifo
59
60 debug.in:   set ilc=*;  recv, deliver;
61 fifo.in:
62   set word= 9;
63   deliver;
64   set ilc=63;
65   recv, deliver;
66   set ilc=37;
67   recv, deliver;
68
69 fifo.out:
70   set ilc=63;
71   collect, send to fifo.in;
72   set ilc=36;
73   collect, send to fifo.in;
74   collect, send to debug.in;
75
76
77
78 == Contributors =========================================================
79 Adam Megacz <megacz@cs.berkeley.edu>