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; }
protected Bus duplicateBus(Component c, Bus bus) { Exit exit = getSidebandExit(c); Bus dup = exit.makeDataBus(Component.SIDEBAND); dup.setIDLogical(ID.showLogical(bus)); dup.copyAttributes(bus); return dup; }
/** * 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); } } } } }
/** * 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); } } }
/** * 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()); } } } } } } }