Esempio n. 1
0
  /** Responsible for traversing within a Module */
  @Override
  protected void traverse(Module module) {
    // Define all feedback points as having 0 depth on their exits
    // in order to break the iterative computation.
    for (Component comp : module.getFeedbackPoints()) {
      for (Exit exit : comp.getExits()) {
        exitToGateDepthMap.put(exit, new Integer(0));
      }
    }

    if (!findUnknownGateDepthOnInputs(module)) {
      if (_schedule.db) _schedule.ln(_schedule.GDA, "Module Traversal " + module);
      if (isForward()) {
        traverseModuleForward(module, module.getFeedbackPoints());
      } else {
        traverseModuleReverse(module, module.getFeedbackPoints());
      }

      LinkedList<Component> revisitComponents = new LinkedList<Component>();
      while (true) {
        while (!unresolvedGateDepthComponents.isEmpty()) {
          if (unresolvedGateDepthComponents.peek().getOwner() == module) {
            revisitComponents.add(unresolvedGateDepthComponents.pop());
          } else {
            break;
          }
        }
        if (revisitComponents.isEmpty()) {
          break;
        }
        revisitUnknownGateDepthComponents(revisitComponents);
      }
    }
  }
Esempio n. 2
0
  protected Exit getSidebandExit(Component c) {
    Exit sideExit = c.getExit(Exit.SIDEBAND);
    if (sideExit == null) {
      sideExit = c.makeExit(0, Exit.SIDEBAND);
    }

    return sideExit;
  }
Esempio n. 3
0
 /** Graphs the incoming connections to a component's ports. */
 protected void graphEdges(Component component, Bus src) {
   ComponentNode componentNode = (ComponentNode) nodeMap.get(component);
   graphEdge(componentNode, component.getGoPort());
   for (org.xronos.openforge.lim.Port port : component.getDataPorts()) {
     if (port.getBus() == src) {
       graphEdge(componentNode, port);
     }
   }
 }
Esempio n. 4
0
  /**
   * Completes RegisterRead and RegisterWrite connections passed up to the top-level as side-band
   * ports and buses.
   *
   * @param design the Design which has Registers
   * @param frame the ConnectionFrame which describes the read/write connections
   */
  private void connectGlobalRegisters(Design design, ConnectionFrame frame) {
    // boolean isLittleEndian = EngineThread.getGenericJob()
    // .getUnscopedBooleanOptionValue(OptionRegistry.LITTLE_ENDIAN);

    for (Register register : design.getRegisters()) {
      List<Connection> readList = frame.getReadConnections(register);
      List<Connection> writeList = frame.getWriteConnections(register);

      if (readList.isEmpty() && writeList.isEmpty()) {
        continue;
      }

      Component regPhys = register.makePhysicalComponent(readList, writeList);
      if (register.getInputSwapper() != null) {
        design.getDesignModule().addComponent(register.getInputSwapper());
      }
      design.getDesignModule().addComponent(regPhys);
      if (register.getOutputSwapper() != null) {
        design.getDesignModule().addComponent(register.getOutputSwapper());
      }

      assert regPhys != null;

      if (!writeList.isEmpty()) {
        final Iterator<Port> writePortIter = regPhys.getDataPorts().iterator();
        for (Iterator<Connection> writeListIter = writeList.iterator(); writeListIter.hasNext(); ) {
          final RegisterWriteConnection writeConn = (RegisterWriteConnection) writeListIter.next();
          if (writeConn != null) {
            assert writePortIter.hasNext() : "Too few ports on register physical (enable)";
            final Port enablePort = writePortIter.next();
            assert writePortIter.hasNext() : "Too few ports on register physical (data)";
            final Port dataPort = writePortIter.next();
            enablePort.setBus(writeConn.getEnable());
            dataPort.setBus(writeConn.getData());
          }
        }
      }

      if (!readList.isEmpty()) {
        Bus registerResultBus = null;
        Exit physicalExit = regPhys.getExit(Exit.DONE);
        registerResultBus = physicalExit.getDataBuses().get(0);

        for (Connection connection : readList) {
          RegisterReadConnection rp = (RegisterReadConnection) connection;
          // The read connetion may be null because we had
          // to pad out the pairs in the connection list for
          // the referee.
          if (rp != null) {
            rp.getDataPort().setBus(registerResultBus);
          }
        }
      }
    }
  }
Esempio n. 5
0
 private int getMaxInputGateDepth(Component component) {
   int maxGateDepth = 0;
   component = (component instanceof InBuf) ? component.getOwner() : component;
   for (Port port : component.getPorts()) {
     if (port == component.getClockPort() || port == component.getResetPort()) {
       continue;
     }
     int gateDepth =
         port.isConnected() ? exitToGateDepthMap.get(port.getBus().getOwner()).intValue() : 0;
     maxGateDepth = Math.max(maxGateDepth, gateDepth);
   }
   return maxGateDepth;
 }
Esempio n. 6
0
  public void visit(Component component) {
    unbreakableGateDepth = Math.max(unbreakableGateDepth, component.getExitGateDepth());

    if (!findUnknownGateDepthOnInputs(component)) {
      preFilter(component);
      final Integer currentGateDepth =
          new Integer(getMaxInputGateDepth(component) + component.getExitGateDepth());
      for (Bus bus : component.getBuses()) {
        exitToGateDepthMap.put(bus.getOwner(), currentGateDepth);
      }
      if (currentGateDepth.intValue() >= taskMaxGateDepth) {
        taskMaxGateDepth = currentGateDepth.intValue();
      }
      if (_schedule.db)
        _schedule.ln(
            _schedule.GDA, component + ", current gate depth: " + currentGateDepth.intValue());
      postFilter(component);
    }
  }
Esempio n. 7
0
 private boolean findUnknownGateDepthOnInputs(Component component) {
   for (Port port : component.getPorts()) {
     // assert (port.isConnected() &&
     // this.exitToGateDepthMap.containsKey(port.getBus().getOwner()));
     if (port.isConnected() && !exitToGateDepthMap.containsKey(port.getBus().getOwner())) {
       unresolvedGateDepthComponents.push(component);
       return true;
     }
   }
   return false;
 }
Esempio n. 8
0
  private String showComponent(Component comp) {
    String ret = comp.toString();
    for (Port port : comp.getPorts()) {
      String value = port.getValue() == null ? "null" : port.getValue().debug();
      if (port == comp.getGoPort() || port == comp.getClockPort() || port == comp.getResetPort()) ;
      else ret = ret + " p:" + value;
      /*
       * if (port == getGoPort()) ret = ret + " go:" + val; else if (port
       * == getClockPort()) ret = ret + " ck:" + val; else if (port ==
       * getResetPort()) ret = ret + " rs:" + val; else ret = ret + " p:"
       * + val;
       */
    }
    for (Exit exit : comp.getExits()) {
      for (Bus bus : exit.getBuses()) {
        String value = bus.getValue() == null ? "null" : bus.getValue().debug();
        if (bus == exit.getDoneBus())
          // ret = ret + " done:" + val;
          ;
        else ret = ret + " data:" + value;
      }
    }

    return ret;
  }
Esempio n. 9
0
  /**
   * The Design should be the first Visitable that is visited by the GlobalConnector, indicating the
   * initialization of processing.
   *
   * @param design Description of Parameter
   */
  @Override
  public void visit(Design design) {
    if (_schedule.db) {
      _schedule.ln(_schedule.GVISIT, "visiting design " + design);
    }
    final GenericJob job = EngineThread.getGenericJob();

    this.design = design;

    beginFrame();
    traverse(design);
    connectGlobalRegisters(design, getFrame());
    generateKickers();

    if (job.getUnscopedBooleanOptionValue(OptionRegistry.NO_BLOCK_IO)) {
      connectTasks(design);
    }

    design.accept(new MemoryConnectionVisitor());
    // Connect all SimplePinRead and SimplePinWrite accesses to
    // their targetted pins.
    design.accept(new SimplePinConnector());

    // Connect clock and reset to all design module elements. Do
    // this last in case any of the other connectors add global
    // level stuff.
    for (Component designComp : design.getDesignModule().getComponents()) {
      // Find the clock domain for each design level element and
      // connect the clock and/or reset pins.
      final String domainSpec =
          (String)
              ((OptionString) EngineThread.getGenericJob().getOption(OptionRegistry.CLOCK_DOMAIN))
                  .getValue(designComp.getSearchLabel());
      assert domainSpec != null : "No clock domain specifier found for " + designComp;
      design.getClockDomain(domainSpec).connectComponentToDomain(designComp);
    }
  }
Esempio n. 10
0
  @SuppressWarnings("unchecked")
  @Override
  public Loop caseBlockWhile(BlockWhile blockWhile) {
    // Initialize members
    Map<Var, Port> inputs = new HashMap<Var, Port>();
    Map<Var, Bus> outputs = new HashMap<Var, Bus>();

    Map<Bus, Var> feedbackBusVar = new HashMap<Bus, Var>();
    Map<Bus, Var> completeBusVar = new HashMap<Bus, Var>();
    // -- Decision
    // Construct decision from the block while condition
    Block decisionBlock = null;
    Component valueComponent = new ExprToComponent().doSwitch(blockWhile.getCondition());

    Map<Var, Port> dBlockDataPorts = null;

    if (!(valueComponent instanceof Block)) {
      dBlockDataPorts = new HashMap<Var, Port>();
      Map<Var, Port> valueDataPorts =
          (Map<Var, Port>) blockWhile.getCondition().getAttribute("inputs").getObjectValue();
      decisionBlock = new Block(Arrays.asList(valueComponent));
      // Propagate DataPorts
      ComponentUtil.propagateDataPorts(decisionBlock, dBlockDataPorts, valueDataPorts);
      // Propagate DataBuses
      for (Bus dataBus : valueComponent.getExit(Exit.DONE).getDataBuses()) {
        Bus blockDataBus = decisionBlock.getExit(Exit.DONE).makeDataBus();
        Port blockDataBuspeer = blockDataBus.getPeer();
        ComponentUtil.connectDataDependency(dataBus, blockDataBuspeer, 0);
      }
    } else {
      decisionBlock = (Block) valueComponent;
      dBlockDataPorts =
          (Map<Var, Port>) blockWhile.getCondition().getAttribute("inputs").getObjectValue();
    }

    Component decisionComponent = ComponentUtil.decisionFindConditionComponent(decisionBlock);

    // Create decision
    Decision decision = new Decision(decisionBlock, decisionComponent);

    Debug.depGraphTo(decision, "deicions", "/tmp/decision1.dot", 1);

    // Propagate decisionBlockInputs to the decision one
    Map<Var, Port> dDataPorts = new HashMap<Var, Port>();
    ComponentUtil.propagateDataPorts(decision, dDataPorts, dBlockDataPorts);

    // -- Loop Body
    // Construct Loop Body Block from the block while blocks
    Map<Var, Port> blockDataPorts = new HashMap<Var, Port>();
    Map<Var, Bus> blockDataBuses = new HashMap<Var, Bus>();

    Module body =
        (Module)
            new BlocksToBlock(blockDataPorts, blockDataBuses, false)
                .doSwitch(blockWhile.getBlocks());

    // Loop body (While Body) inputs and outputs
    Map<Var, Port> lbDataPorts = new HashMap<Var, Port>();

    LoopBody loopBody = new WhileBody(decision, body);
    Debug.depGraphTo(loopBody, "loopBody", "/tmp/loopBody.dot", 1);
    // Propagate decision and body inputs to the loopBody
    // -- Propagate Decision data ports
    ComponentUtil.propagateDataPorts(loopBody, lbDataPorts, dDataPorts);

    // -- Propagate Body Blocks data ports
    ComponentUtil.propagateDataPorts(loopBody, lbDataPorts, blockDataPorts);

    // -- Complete Exit
    for (Var var : blockDataBuses.keySet()) {
      Type type = var.getType();
      Bus bus = blockDataBuses.get(var);
      // -- Make an complete exit data bus
      Bus cBus =
          loopBody
              .getLoopCompleteExit()
              .makeDataBus(var.getName() + "_fb", type.getSizeInBits(), type.isInt());
      // -- Connect
      Port cBusPeer = cBus.getPeer();
      ComponentUtil.connectDataDependency(bus, cBusPeer);
      // -- Save it to the feedbackBusVar
      completeBusVar.put(cBus, var);
    }

    // -- FeedBack Exit
    for (Var var : blockDataBuses.keySet()) {
      Type type = var.getType();
      // -- If the input does not exist create one because this is a
      // feedback
      if (!lbDataPorts.containsKey(var)) {
        Port lbPort =
            loopBody.makeDataPort(var.getName() + "_fb", type.getSizeInBits(), type.isInt());
        lbDataPorts.put(var, lbPort);
      }
      Bus bus = blockDataBuses.get(var);
      // -- Make an feedback exit data bus
      Bus fbBus =
          loopBody
              .getFeedbackExit()
              .makeDataBus(var.getName() + "_fb", type.getSizeInBits(), type.isInt());
      // -- Connect
      Port fbBusPeer = fbBus.getPeer();
      ComponentUtil.connectDataDependency(bus, fbBusPeer);
      // -- Save it to the feedbackBusVar
      feedbackBusVar.put(fbBus, var);
    }

    // -- From input to Complete Exit dependency
    for (Bus bus : completeBusVar.keySet()) {
      Var var = completeBusVar.get(bus);
      Port port = lbDataPorts.get(var);
      // -- Connect it
      Port busPeer = bus.getPeer();
      Bus portpeer = port.getPeer();
      ComponentUtil.connectDataDependency(portpeer, busPeer);
    }

    // Create Loop
    Loop loop = new Loop(loopBody);

    // -- Loop inputs comes from decision and body
    Set<Var> inVars = new HashSet<Var>();
    inVars.addAll(dDataPorts.keySet());
    inVars.addAll(lbDataPorts.keySet());

    for (Var var : inVars) {
      Type type = var.getType();
      Port dataPort = loop.makeDataPort(var.getName(), type.getSizeInBits(), type.isInt());
      inputs.put(var, dataPort);
    }

    // -- Init Dependencies
    Entry initEntry = loop.getBodyInitEntry();
    for (Var var : inputs.keySet()) {
      if (feedbackBusVar.containsValue(var)) {
        Port lPort = inputs.get(var);
        Port lbPort = lbDataPorts.get(var);
        Bus lPortPeer = lPort.getPeer();
        Dependency dep =
            (lbPort == lbPort.getOwner().getGoPort())
                ? new ControlDependency(lPortPeer)
                : new DataDependency(lPortPeer);
        initEntry.addDependency(lbPort, dep);
      }
    }

    // -- Feedback Dependencies
    Entry fbEntry = loop.getBodyFeedbackEntry();
    for (Bus bus : feedbackBusVar.keySet()) {
      Var var = feedbackBusVar.get(bus);
      Exit lfbExit = loop.getBody().getFeedbackExit();
      Port lbPort = lbDataPorts.get(var);

      // -- Create a feedback register
      Reg fbReg = loop.createDataRegister();
      fbReg.setIDLogical("fbReg_" + var.getName());
      // fbReg.getDataPort().setIDLogical(var.getName());
      // fbReg.getResultBus().setIDLogical(var.getName());

      // -- Dependencies
      Entry entry = fbReg.makeEntry(lfbExit);
      entry.addDependency(fbReg.getDataPort(), new DataDependency(bus));
      fbEntry.addDependency(lbPort, new DataDependency(fbReg.getResultBus()));
    }

    // -- Latch Dependencies
    Collection<Dependency> goInitDeps = initEntry.getDependencies(loop.getBody().getGoPort());
    Bus initDoneBus = goInitDeps.iterator().next().getLogicalBus();
    for (Var var : inVars) {
      if (!feedbackBusVar.containsValue(var)) {
        Port lPort = inputs.get(var);
        Bus lPortPeer = lPort.getPeer();

        // -- Create a latch
        Latch latch = loop.createDataLatch();
        latch.setIDLogical("latched_" + var.getName());

        // -- Dependencies
        Entry latchEntry = latch.makeEntry(initDoneBus.getOwner());
        latch.getDataPort().setIDLogical(var.getName());
        // -- Control dependency
        latchEntry.addDependency(latch.getEnablePort(), new ControlDependency(initDoneBus));
        // -- Data dependency in latch
        latchEntry.addDependency(latch.getDataPort(), new DataDependency(lPortPeer));
        // -- Data dependency out latch
        Bus latchResultBus = latch.getResultBus();
        latchResultBus.setIDLogical(var.getName() + "_result");

        Port lbPort = lbDataPorts.get(var);
        fbEntry.addDependency(lbPort, new DataDependency(latchResultBus));
      }
    }

    // -- Done Dependencies
    Entry outbufEntry = loop.getExit(Exit.DONE).getPeer().getEntries().get(0);
    for (Bus bus : loopBody.getLoopCompleteExit().getDataBuses()) {
      Var var = completeBusVar.get(bus);
      Type type = var.getType();
      Bus dataBus =
          loop.getExit(Exit.DONE).makeDataBus(var.getName(), type.getSizeInBits(), type.isInt());
      Port dataBusPeer = dataBus.getPeer();
      Dependency dep = new DataDependency(bus);
      outbufEntry.addDependency(dataBusPeer, dep);
      outputs.put(var, dataBus);
    }

    // -- Set control dependency
    Port lbDonePort = loopBody.getLoopCompleteExit().getDoneBus().getPeer();
    Bus lDoneBus = loop.getExit(Exit.DONE).getDoneBus();
    Dependency dep = new ControlDependency(lDoneBus);
    outbufEntry.addDependency(lbDonePort, dep);

    // -- IDSourceInfo
    Procedure procedure = EcoreHelper.getContainerOfType(blockWhile, Procedure.class);
    IDSourceInfo sinfo = new IDSourceInfo(procedure.getName(), blockWhile.getLineNumber());
    loop.setIDSourceInfo(sinfo);
    Debug.depGraphTo(loop, "loopBody", "/tmp/loop_new.dot", 1);

    // -- Set attributes
    blockWhile.setAttribute("inputs", inputs);
    blockWhile.setAttribute("outputs", outputs);
    return loop;
  }