make dock counters as wide as the machine word
authorAdam Megacz <adam@megacz.com>
Fri, 31 Jul 2009 20:00:30 +0000 (13:00 -0700)
committerAdam Megacz <adam@megacz.com>
Fri, 31 Jul 2009 20:00:30 +0000 (13:00 -0700)
src/edu/berkeley/fleet/fpga/FpgaDock.java
src/edu/berkeley/fleet/interpreter/InterpreterDock.java
tests/dock/olc-long-count.fleet [new file with mode: 0644]

index b06bc68..61e8a56 100644 (file)
@@ -192,7 +192,7 @@ public class FpgaDock extends FleetTwoDock implements FabricElement {
             Module.SinkPort   ship_in       =  inbox ? createOutputPort("ship", fpga.getWordWidth()+1) : null;
 
             Module.Latch     ilc            = new Latch("ilc", fpga.SET_ILC_FROM_IMMEDIATE.valmaskwidth+1, 1);
-            Module.Latch     olc            = new Latch("olc", fpga.SET_OLC_FROM_IMMEDIATE.valmaskwidth, 1);
+            Module.Latch     olc            = new Latch("olc", fpga.getWordWidth(), 1);
             Module.Latch     flag_a         = new Latch("flag_a", 1);
             Module.Latch     flag_b         = new Latch("flag_b", 1);
             Module.Latch     flag_c         = new Latch("flag_c", 1);
@@ -234,7 +234,7 @@ public class FpgaDock extends FleetTwoDock implements FabricElement {
 
             WireValue decremented = new WireValue("decremented", Math.max(ilc.width,olc.width),
                                                   new SimpleValue("("+ondeck.testMask(fpga.SET_OLC_FROM_OLC_MINUS_ONE).getVerilogTrigger()+
-                                                                  " ? {1'b0, olc} : ilc)-1"));
+                                                                  " ? olc : ilc)-1"));
             WireValue data_latch_output_p = new WireValue("data_latch_output",
                                                            inbox ? fpga.getWordWidth()+1 : fpga.getWordWidth(),
                                                            (inbox
@@ -312,7 +312,7 @@ public class FpgaDock extends FleetTwoDock implements FabricElement {
                           new ConditionalAction(done_executing.invert(),
                                                 new AssignAction(ilc, new MuxValue(new TestValue(ilc, TestValue.TestType.EQ, magic_standing_value),
                                                                                    magic_standing_value,
-                                                                                   decremented))),
+                                                                                   decremented.getBits(ilc.width-1,0)))),
                           new ConditionalAction(ondeck.testMask(fpga.SET_OLC_FROM_DATA_LATCH),
                                                 new AssignAction(olc, new SimpleValue("data_latch_output"))),
                           new ConditionalAction(ondeck.testMask(fpga.SET_OLC_FROM_IMMEDIATE),
index 40e66b0..c2d3ed6 100644 (file)
@@ -219,7 +219,7 @@ class InterpreterDock extends FleetTwoDock {
                             case Immediate: olc = (int)set.immediate; break;
                             case DataLatch:
                                 olc = 0;
-                                for(int i=0; i<((FleetTwoFleet)getShip().getFleet()).SET_OLC_FROM_IMMEDIATE.valmaskwidth-1; i++)
+                                for(int i=0; i<getShip().getFleet().getWordWidth(); i++)
                                     if (dataLatch.get(i))
                                         olc |= (1 << i);
                                 break;
diff --git a/tests/dock/olc-long-count.fleet b/tests/dock/olc-long-count.fleet
new file mode 100644 (file)
index 0000000..4e74dad
--- /dev/null
@@ -0,0 +1,32 @@
+#expect 5
+#expect 5
+#expect 4
+
+#ship debug : Debug
+#ship fifo  : Fifo
+
+debug.in:
+  [*] set olc=1;
+  set word=65535;
+  set olc=word;
+  head;
+  recv word;
+  set olc--;
+  [d] abort;
+  [d] set ilc=*;
+  [d] recv, deliver;
+  tail;
+
+fifo.out:
+  [*] set olc=1;
+  set word=65537;
+  set olc=word;
+  set word=5;
+  head;
+  send to debug.in;
+  set olc--;
+  [d] abort;
+  [d] set word=4;
+  [d] send to debug.in;
+  tail;
+