1 // A bubble sort implementation.
2 // This only works for 6 input elements. To change the number of input
3 // elements, modify the counts in the lines marked below.
4 // Author: Amir Kamil <kamil@cs.berkeley.edu>
7 #import edu.berkeley.fleet.ships
23 // for debugging; the solution should work with any set of numbers
34 fifo1.in: [*] take, deliver;
35 fifo2.in: [*] take, deliver;
36 debug.in: [*] take, deliver;
37 alu.in1: [*] take, deliver;
38 alu.in2: [*] take, deliver;
39 blu.in1: [*] take, deliver;
40 blu.in2: [*] take, deliver;
41 fifo3.out: [*] wait, take, sendto mem.inCBD;
42 mem.inCBD: [*] take, deliver;
45 // this code needs flow control
48 fifo1.out: take, sendto alu.in1.max;
51 (*) take, sendto alu.in2;
55 (*) take, sendto alu.in1.max;
56 (*) sendto blu.in1.min;
58 blu.out: [5] take, sendto fifo2.in; // count = num - 1
65 0: sendto alu.in2; // flush
66 0: sendto blu.in2; // flush
74 fifo2.out: [6] take, sendto fifo1.in; // count = num
80 SENDDONE: sendto fifo3.in;
81 ITER: sendto fifo2.in;
85 (6) take, sendto fifo3.in; // count = num
86 (6) sendto fifo2.in; // count = num
87 (6) take, sendto fifo3.in; // count = num
88 (6) sendto fifo2.in; // count = num
90 fifo3.in: take, deliver, notify fifo2.out;
91 [12] take, deliver; // count = 2 * num
94 // send done cbd into fifo3
97 DONE: sendto fifo3.in;
98 fifo2.out: [2] dismiss;
100 fifo3.in: take, deliver;
106 fifo1.out: [6] take, sendto debug.in; // count = num