1 #import edu.berkeley.fleet.ships
3 //#ship math : ArithmeticShip
4 #ship helper : FifoShip
5 #ship source : FifoShip
8 #ship fetch : FetchShip
9 #ship tokensource : TokenSourceShip
11 // NOTE: "accept" is a synonym for "move" it is less confusing in the case
12 // of inboxes, but is otherwise identical
16 //////////////////////////////////////////////////////////////////////////////
17 // The following three instructions simply produce one hundred "3"s
18 // and put them into fifo "a". Ignore the switch-fabric clogging
19 // issue here; this is just setup for the rest of the code.
22 copy helper.out -[10]-> source.in
23 discard helper.out -> ()
26 //////////////////////////////////////////////////////////////////////////////
27 // set up a counting move of 10 items from source.out to dest.in, but require
28 // flow control tokens (10 items is too many to send at once)
30 triggered move source.out -[10]-> dest.in
33 //////////////////////////////////////////////////////////////////////////////
34 // The next instruction tears down the "default" standing move on dest.in
35 // and uses the resulting tokens to prime source.out's pump. Once that
36 // has been kicked off, any subsequent incoming items will generate tokens
37 // which are sent back to the source outbox
39 nop+ack dest.in -[3]-> source.out
40 accept+ack dest.in -[7]-> source.out
41 accept dest.in -[3]-> source.out
42 nop+ack dest.in -> fetch.release // then release the fetch
43 accept dest.in -[*]-> () // and return the fabric to normal
45 { tokensource.out -> halt.in } -> fetch.codebag // termination codebag