ship: Rotator == Ports =========================================================== in: in in: inAmount out: out == TeX ============================================================== The Rotator performs bitwise rotations of words. When a value is present at both {\tt in} and {\tt inAmount}, both values are consumed, the value {\tt in} is rotated {\it towards the most significant bit} by {\tt inAmount} bits and emitted at {\tt out}. The output is undefined if {\tt inAmount} is greater than or equal to the number of bits in a word. == Fleeterpreter ==================================================== public void service() { if (box_inAmount.dataReadyForShip() && box_in.dataReadyForShip() && box_out.readyForDataFromShip()) { long amount = box_inAmount.removeDataForShip(); long data = box_in.removeDataForShip(); long mask = ~((-1L) << getInterpreter().getWordWidth()); data = data & mask; box_out.addDataFromShip(((data << amount) | (data >> (getInterpreter().getWordWidth()-amount))) & mask); } } == FPGA ============================================================== reg [(`DATAWIDTH-1):0] out_d; assign out_d_ = out_d; reg [5:0] shamt; initial shamt = 0; wire shamt_eq; assign shamt_eq = (shamt[5:0] == (inAmount_d[5:0])); always @(posedge clk) begin if (!rst) begin `reset end else begin if (!in_r && in_a && !inAmount_r) in_a <= 0; if (!inAmount_r && inAmount_a) inAmount_a <= 0; if (out_r && out_a) out_r <= 0; if (in_r && !in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin in_a <= 1; out_d <= in_d; shamt <= 0; end else if (in_a && inAmount_r && !inAmount_a && !out_r && !out_a) begin if (!shamt_eq) begin out_d <= { out_d[`DATAWIDTH-2:0], out_d[`DATAWIDTH-1] }; shamt <= shamt+1; end else begin inAmount_a <= 1; out_r <= 1; end end end end == Test ============================================================== // expected output #expect 2 #expect 44627559471 // ships required in order to run this code #ship debug : Debug #ship rotator : Rotator rotator.in: literal 1; deliver; literal 21615257152; deliver; rotator.inAmount: literal 1; deliver; literal 20; deliver; rotator.out: [*] take, sendto debug.in; debug.in: [*] take, deliver; == Contributors ========================================================= Amir Kamil Adam Megacz