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().getWordWidth());
29 box_out.addDataFromShip(((data << amount) | (data >> (getInterpreter().getWordWidth()-amount))) & mask);
34 == FPGA ==============================================================
36 reg [(`DATAWIDTH-1):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
56 end else if (in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin
58 out_d <= { out_d[`DATAWIDTH-2:0], out_d[`DATAWIDTH-1] };
68 == Test ==============================================================
76 // ships required in order to run this code
78 #ship rotator : Rotator
80 rotator.in: set word= 1; deliver; set word= 21615257152; deliver;
81 rotator.inAmount: set word= 1; deliver; set word= 20; deliver;
82 rotator.out: set ilc=*; collect, send to debug.in;
83 debug.in: set ilc=*; recv, deliver;
86 == Contributors =========================================================
87 Amir Kamil <kamil@cs.berkeley.edu>
88 Adam Megacz <megacz@cs.berkeley.edu>