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
49 if (!in_r && in_a && !inAmount_r) in_a <= 0;
50 if (!inAmount_r && inAmount_a) inAmount_a <= 0;
51 if (out_r && out_a) out_r <= 0;
52 if (in_r && !in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
54 out_d <= { 1'b0, in_d };
56 end else if (in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
58 out_d <= { out_d[0], out_d[0], out_d[`DATAWIDTH-1:1] };
68 == Test ==============================================================
80 // ships required in order to run this code
82 #ship rotator : Rotator
84 debug.in: set ilc=*; recv, deliver;
102 [Rq] collect, send to debug.in;
103 [Rq] set flags a=c, b=b;
104 [Rq] [!a] set word=0;
106 [Rq] send to debug.in;
111 == Contributors =========================================================
112 Amir Kamil <kamil@cs.berkeley.edu>
113 Adam Megacz <megacz@cs.berkeley.edu>