change direction of rotation, add c-flag support to Rotator ship
authoradam <adam@megacz.com>
Wed, 27 Aug 2008 03:23:12 +0000 (04:23 +0100)
committeradam <adam@megacz.com>
Wed, 27 Aug 2008 03:23:12 +0000 (04:23 +0100)
ships/Rotator.ship

index e12cddc..2e2270b 100644 (file)
@@ -11,7 +11,7 @@ out:  out
 
 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}
+the value {\tt in} is rotated {\it towards the least significant bit}
 by {\tt inAmount} bits and emitted at {\tt out}.
 
 The output is undefined if {\tt inAmount} is greater than or equal to
@@ -33,7 +33,7 @@ public void service() {
 
 == FPGA ==============================================================
 
-  reg [(`DATAWIDTH-1):0] out_d;
+  reg [(`DATAWIDTH):0] out_d;
   assign out_d_ = out_d;
 
   reg [5:0] shamt;
@@ -51,11 +51,11 @@ public void service() {
       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;
+        out_d <= { 1'b0, 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] };
+           out_d <= { out_d[0], out_d[0], out_d[`DATAWIDTH-1:1] };
            shamt <= shamt+1;
         end else begin
            inAmount_a <= 1;
@@ -70,17 +70,42 @@ public void service() {
 
 // expected output
 #expect 2
+#expect 0
+#expect -0x1000000000
+#expect 1
 #expect 44627559471
+#expect 0
 
 
 // ships required in order to run this code
 #ship debug        : Debug
 #ship rotator      : Rotator
 
-rotator.in:         set word= 1; deliver; set word= 21615257152;  deliver;
-rotator.inAmount:   set word= 1; deliver; set word= 20;           deliver;
-rotator.out:        set ilc=*;  collect, send to debug.in;
-debug.in:           set ilc=*;  recv, deliver;
+debug.in: set ilc=*;  recv, deliver;
+
+rotator.in:
+   set word=1;
+   deliver;
+   set word=1;
+   deliver;
+   set word=21615257152;
+   deliver;
+rotator.inAmount:
+   set word=36;
+   deliver;
+   set word=1;
+   deliver;
+   set word=17;
+   deliver;
+rotator.out:
+   set olc=3;
+   [Rq] collect, send to debug.in;
+   [Rq] set flags a=c, b=b;
+   [Rq] [!a] set word=0;
+   [Rq] [a]  set word=1;
+   [Rq] send to debug.in;
+   tail;
+
 
 
 == Contributors =========================================================