update ships for 1.0 overhaul
[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 in0_a;
35   wire out0_r;
36   wire [(`DATAWIDTH-1):0] out0_d;
37
38   fifo8 fifo8(clk, rst,
39               in_r,  in0_a, in_d,
40               out0_r, out_a, out0_d);
41
42   always @(posedge clk) begin
43     if (!rst) begin
44       `reset
45     end else begin
46     in_a <= in0_a;
47     out_r <= out0_r;
48     out_d <= out0_d;
49     end
50   end
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:   [*] take, deliver;
61 fifo.in:
62   literal 9;
63   deliver;
64   load repeat counter with 63;
65   take, deliver;
66   load repeat counter with 37;
67   take, deliver;
68
69 fifo.out:
70   load repeat counter with 63;
71   take, sendto fifo.in;
72   load repeat counter with 36;
73   take, sendto fifo.in;
74   take, sendto debug.in;
75
76
77
78 == Contributors =========================================================
79 Adam Megacz <megacz@cs.berkeley.edu>