massive overhaul of fpga code
[fleet.git] / src / edu / berkeley / fleet / fpga / FunnelModule.java
index bda75e8..49679a5 100644 (file)
@@ -15,12 +15,16 @@ import static edu.berkeley.fleet.fpga.verilog.Verilog.*;
 
 public class FunnelModule extends Module {
 
+    private static final int WIDTH = WIDTH_PACKET;
+
     public FunnelModule() {
         super("funnel");
-        Module.SinkPort    outp = createOutputPort("out", WIDTH_PACKET, "");
+        Module.SinkPort    outp = createOutputPort("out", WIDTH, "");
         Module.SourcePort  in1p = createInputPort("in1", WIDTH_PACKET);
         Module.SourcePort  in2p = createInputPort("in2", WIDTH_PACKET);
-        new Event(new Object[] { in1p, outp },
+
+        // FIXME: biased towards in2p side
+        new Event(new Object[] { in1p, outp, "!"+in2p.getReq() },
                   new Action[] { in1p, outp,
                                  new AssignAction(outp, in1p) });
         new Event(new Object[] { in2p, outp },
@@ -32,12 +36,12 @@ public class FunnelModule extends Module {
         private FabricElement in1 = null;
         private FabricElement in2 = null;
         public FabricElement out = null;
-        public Module.Port getOutputPort() { return getOutputPort("out"); }
+        public Module.SourcePort getOutputPort() { return getOutputPort("out"); }
         public Module.Port getInputPort()  { throw new RuntimeException("funnel has multiple inputs"); }
-        public FunnelInstance(Module thisModule, Module.Port p1, Module.Port p2) {
+        public FunnelInstance(Module thisModule, Module.SourcePort p1, Module.SourcePort p2) {
             super(thisModule, new FunnelModule());
-            p1.connect(this.getInputPort("in1"));
-            p2.connect(this.getInputPort("in2"));
+            if (p1 != null) p1.connect(this.getInputPort("in1"));
+            if (p2 != null) p2.connect(this.getInputPort("in2"));
         }
         public FunnelInstance(Module thisModule, FabricElement in1, FabricElement in2) {
             super(thisModule, new FunnelModule());