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 least 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().getWordWidth());
29 box_out.addDataFromShip(((data << amount) | (data >> (getInterpreter().getWordWidth()-amount))) & mask);
34 == FPGA ==============================================================
36 reg [(`DATAWIDTH):0] out_d;
37 assign out_d_ = out_d;
43 assign shamt_eq = (shamt[5:0] == (inAmount_d[5:0]));
45 always @(posedge clk) begin
50 if (!in_r_ && in_a && !inAmount_r) in_a <= 0;
51 if (!inAmount_r_ && inAmount_a) inAmount_a <= 0;
52 if (out_r && out_a) out_r <= 0;
53 if (in_r && !in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
55 out_d <= { 1'b0, in_d };
57 end else if (in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
59 out_d <= { out_d[0], out_d[0], out_d[`DATAWIDTH-1:1] };
69 == Test ==============================================================
81 // ships required in order to run this code
83 #ship rotator : Rotator
85 debug.in: set ilc=*; recv, deliver;
103 [Rq] collect, send to debug.in;
104 [Rq] set flags a=c, b=b;
105 [Rq] [!a] set word=0;
107 [Rq] send to debug.in;
112 == Contributors =========================================================
113 Amir Kamil <kamil@cs.berkeley.edu>
114 Adam Megacz <megacz@cs.berkeley.edu>