3 == Ports ===========================================================
10 == TeX ==============================================================
12 The Rotator performs bitwise rotations of words. When a value is
13 present at both {\tt in} and {\tt inAmount}, both values are consumed,
14 the value {\tt in} is rotated {\it towards the most significant bit}
15 by {\tt inAmount} bits and emitted at {\tt out}.
17 The output is undefined if {\tt inAmount} is greater than or equal to
18 the number of bits in a word.
21 == Fleeterpreter ====================================================
23 public void service() {
24 if (box_inAmount.dataReadyForShip() && box_in.dataReadyForShip() && box_out.readyForDataFromShip()) {
25 long amount = box_inAmount.removeDataForShip();
26 long data = box_in.removeDataForShip();
27 long mask = ~((-1L) << getInterpreter().getWordSize());
29 box_out.addDataFromShip(((data << amount) | (data >> (getInterpreter().getWordSize()-amount))) & mask);
34 == FPGA ==============================================================
36 wire [`DATAWIDTH*2-1:0] double;
37 assign double = { in_d[`DATAWIDTH-1:0], in_d[`DATAWIDTH-1:0] };
39 always @(posedge clk) begin
43 if (!in_r && in_a) in_a <= 0;
44 if (!inAmount_r && inAmount_a) inAmount_a <= 0;
45 if (out_r && out_a) out_r <= 0;
46 if (in_r && !in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
50 out_d <= double >> (`DATAWIDTH - inAmount_d);
55 == Test ==============================================================
62 // ships required in order to run this code
64 #ship rotator : Rotator
66 rotator.in: literal 1; deliver; literal 21615257152; deliver;
67 rotator.inAmount: literal 1; deliver; literal 20; deliver;
68 rotator.out: [*] take, sendto debug.in;
69 debug.in: [*] take, deliver;
72 == Contributors =========================================================
73 Amir Kamil <kamil@cs.berkeley.edu>
74 Adam Megacz <megacz@cs.berkeley.edu>