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 long res = ((data >> amount) | (data << (getInterpreter().getWordWidth()-amount))) & mask;
30 box_out.addDataFromShip(res, (res & (1L << (getInterpreter().getWordWidth()-1)))!=0);
35 == FPGA ==============================================================
37 reg [(`WORDWIDTH):0] out_d;
38 assign out_d_ = out_d;
47 assign shamt_eq = (shamt[5:0] == (inAmount_d[5:0]));
49 always @(posedge clk) begin
55 if (`in_full && `inAmount_full && `out_empty) begin
57 out_d <= { 1'b0, in_d };
60 end else if (!shamt_eq) begin
61 out_d <= { out_d[0], out_d[0], out_d[`WORDWIDTH-1:1] };
73 == Test ==============================================================
85 // ships required in order to run this code
87 #ship rotator : Rotator
89 debug.in: set ilc=*; recv, deliver;
108 collect, send to debug.in;
117 == Contributors =========================================================
118 Amir Kamil <kamil@cs.berkeley.edu>
119 Adam Megacz <megacz@cs.berkeley.edu>