Exemple #1
0
  /**
   * DOCUMENT ME!
   *
   * @param call DOCUMENT ME!
   */
  @Override
  public void visit(Call call) {
    if (_schedule.db) {
      _schedule.ln(_schedule.GVISIT, "visiting call " + call);
    }

    beginFrame();
    call.getProcedure().accept(this);
    ConnectionFrame procedureFrame = endFrame();

    // record duplicates of the procedure's connections
    // Some connections contain the same buses (done & address)
    // which we only want 1 new port for not multiples...
    Map<ID, ID> duplicatedMap = new HashMap<ID, ID>();
    // for (Iterator resources =
    // procedureFrame.getConnectedResources().iterator();
    // resources.hasNext();)
    // {
    // Resource resource = (Resource)resources.next();
    for (Resource resource : procedureFrame.getConnectedResources()) {
      Collection<Connection> readConnections = procedureFrame.getReadConnections(resource);
      for (Connection read : readConnections) {
        Connection duplicate = read.duplicate(call, duplicatedMap);
        mapPortsAndBuses(call, duplicate, read);
        recordRead(duplicate, call);
      }

      Collection<Connection> writeConnections = procedureFrame.getWriteConnections(resource);
      for (Connection write : writeConnections) {
        Connection duplicate = write.duplicate(call, duplicatedMap);
        mapPortsAndBuses(call, duplicate, write);
        recordWrite(duplicate, call);
      }
    }
  }
Exemple #2
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);
          }
        }
      }
    }
  }
Exemple #3
0
  /**
   * Utility method for wiring up the reads and writes captured in a frame to appropriate ports and
   * buses on a procedure.
   *
   * @param body DOCUMENT ME!
   * @param register DOCUMENT ME!
   * @param subFrame DOCUMENT ME!
   */
  private void connectRegister(Module body, Register register, ConnectionFrame subFrame) {
    // wire all the reads to a new port on the procedure's body
    List<Connection> readList = subFrame.getReadConnections(register);
    if (!readList.isEmpty()) {
      Port resourceRead = body.makeDataPort(Component.SIDEBAND);
      Bus resourceReadBus = resourceRead.getPeer();
      resourceReadBus.setIDLogical(register.showIDLogical() + "_read");
      resourceReadBus.setSize(register.getInitWidth(), Register.isSigned());

      recordRead(new RegisterReadConnection(register, resourceRead));

      for (Connection readConnections : readList) {
        RegisterReadConnection rp = (RegisterReadConnection) readConnections;
        rp.getDataPort().setBus(resourceReadBus);
      }
    }

    // wire the writes. a single write goes directly, multiple go through a
    // gateway
    List<Connection> writeList = subFrame.getWriteConnections(register);
    if (!writeList.isEmpty()) {
      Exit bodyExit = getSidebandExit(body);
      Bus writeEnable = bodyExit.makeDataBus(Component.SIDEBAND);
      writeEnable.setIDLogical(register.showIDLogical() + "_enable");
      writeEnable.setSize(1, false);
      // Port writeEnablePort = writeEnable.getPeer();
      Bus writeData = bodyExit.makeDataBus(Component.SIDEBAND);
      writeData.setIDLogical(register.showIDLogical() + "_write");
      writeData.setSize(register.getInitWidth(), Register.isSigned());

      recordWrite(new RegisterWriteConnection(register, writeEnable, writeData));

      if (writeList.size() == 1) {
        RegisterWriteConnection edp = (RegisterWriteConnection) writeList.get(0);
        writeEnable.getPeer().setBus(edp.getEnable());
        writeData.getPeer().setBus(edp.getData());
      } else {
        RegisterGateway regGateway = new RegisterGateway(writeList.size(), register);
        writeEnable.getPeer().setBus(regGateway.getGlobalEnableBus());
        writeData.getPeer().setBus(regGateway.getGlobalDataBus());
        Iterator<Port> gatewayLocalEnablePortIter = regGateway.getLocalEnablePorts().iterator();
        Iterator<Port> gatewayLocalDataPortIter = regGateway.getLocalDataPorts().iterator();

        // Wires up RegisterGateway's enable ports paired with data
        // ports.
        int pairCount = 0;
        for (Connection connection : writeList) {
          RegisterWriteConnection edPair = (RegisterWriteConnection) connection;
          edPair.getEnable().setIDLogical(register.showIDLogical() + "_we_" + pairCount);
          gatewayLocalEnablePortIter.next().setBus(edPair.getEnable());
          edPair.getData().setIDLogical(register.showIDLogical() + "_data_" + pairCount);
          gatewayLocalDataPortIter.next().setBus(edPair.getData());
          // edPair.getSize().setIDLogical(register.showIDLogical() +
          // "_size_" + pairCount);
          // ((Port)gatewayLocalSizePortIter.next()).setBus(edPair.getSize());
          pairCount++;
        }

        body.addComponent(regGateway);
      }
    }
  }