public class FunnelModule extends Module {
- public FunnelModule() {
+ public FunnelModule(Fpga fpga) {
super("funnel");
- Module.SinkPort outp = createOutputPort("out", WIDTH_PACKET, "");
- Module.SourcePort in1p = createInputPort("in1", WIDTH_PACKET);
- Module.SourcePort in2p = createInputPort("in2", WIDTH_PACKET);
- new Event(new Object[] { in1p, outp },
+ Module.SinkPort outp = createOutputPort("out", fpga.WIDTH_PACKET);
+ Module.SourcePort in1p = createInputPort("in1", fpga.WIDTH_PACKET);
+ Module.SourcePort in2p = createInputPort("in2", fpga.WIDTH_PACKET);
+
+ // FIXME: biased towards in2p side
+ new Event(new Object[] { in1p, outp, "!"+in2p.isFull() },
new Action[] { in1p, outp,
new AssignAction(outp, in1p) });
new Event(new Object[] { in2p, outp },
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) {
- super(thisModule, new FunnelModule());
- p1.connect(this.getInputPort("in1"));
- p2.connect(this.getInputPort("in2"));
+ public FunnelInstance(Fpga fpga, Module thisModule, Module.SourcePort p1, Module.SourcePort p2) {
+ super(thisModule, new FunnelModule(fpga));
+ 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());
+ public FunnelInstance(Fpga fpga, Module thisModule, FabricElement in1, FabricElement in2) {
+ super(thisModule, new FunnelModule(fpga));
this.in1 = in1;
this.in2 = in2;
in1.addOutput(this, this.getInputPort("in1"));
public void addInput(FabricElement in, Module.Port source) {
throw new RuntimeException("cannot add inputs to a funnel once constructed");
}
- public FpgaPath getPath(FabricElement dest, BitVector signal) {
+ public int getPathLength(FpgaDestination dest) { return out.getPathLength(dest)+1; }
+ public FpgaPath getPath(FpgaDestination dest, BitVector signal) {
return out.getPath(dest, signal);
}
}