예제 #1
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);
          }
        }
      }
    }
  }
예제 #2
0
  /**
   * Creates Pins on the design to connect each task's I/O.
   *
   * @param design the Design to be connected
   */
  @SuppressWarnings("deprecation")
  private void connectTasks(Design design) {
    // Map kickers = new HashMap();

    for (Task task : design.getTasks()) {
      Call call = task.getCall();

      // Note: when creating the InputPins, they are based on the related
      // procedure port instead of the call port, because the InputPin
      // needs
      // the Port's peer bus to get sizing information

      // might have a this port
      if (task.getCall().getThisPort() != null) {
        int width = task.getCall().getThisPort().getValue().getSize();

        /*
         * The base address of the top level object reference is always
         * 0, since it isn't actually stored in memory.
         */
        Constant constant = new SimpleConstant(0, width, false);
        task.setHiddenConstant(constant);
      }

      // If module_builder, then publish the ports, and don't use a kicker
      if (EngineThread.getGenericJob()
          .getUnscopedBooleanOptionValue(OptionRegistry.MODULE_BUILDER)) {
        // get the entry method
        EntryMethod em = call.getProcedure().getEntryMethod();

        Port go = call.getGoPort();
        if (go.isUsed()) {
          Pin p = connectInputPin(design, call, go, call.getGoName());
          if (em != null) {
            p.setApiPin(em.getGoPin());
          }
        }

        List<Port> dataPorts = new ArrayList<Port>(call.getDataPorts());

        // 'this' port is handled specially.
        dataPorts.remove(call.getThisPort());
        int index = 0;
        for (Port port : dataPorts) {
          if (port.getTag().equals(Component.NORMAL)) {
            if (port.isUsed()) {
              Pin p = connectInputPin(design, call, port, null);
              if (em != null) {
                p.setApiPin(em.getArgPin(index));
              }
            }
          }

          index++;
        }

        Exit exit = call.getExit(Exit.DONE);
        Bus done = exit.getDoneBus();
        if (done.isUsed()) {
          OutputPin pin = connectOutputPin(design, call, done, call.getProcedure().getDoneName());
          if (em != null) {
            pin.setApiPin(em.getDonePin());
          }
        }

        for (Bus bus : exit.getDataBuses()) {
          if (bus.getTag().equals(Component.NORMAL)) {
            if (bus.isUsed()) {
              OutputPin pin =
                  connectOutputPin(design, call, bus, call.getProcedure().getResultName());
              if (em != null) {
                pin.setApiPin(em.getResultPin());
              }
            }
          }
        }
      }
    }
  }