Search in sources :

Example 6 with MappingInfo

use of net.sourceforge.usbdm.deviceEditor.information.MappingInfo in project usbdm-eclipse-plugins by podonoghue.

the class ModelFactory method checkConflictsJob.

/**
 * Check for mapping conflicts
 *
 * <li>Multiple signals mapped to a single pin
 * <li>Signals mapped to multiple pins
 */
private void checkConflictsJob() {
    // System.err.println("checkConflictsJob()");
    testAndSetConflictCheckPending(false);
    /**
     * Used to check for multiple mappings to a single pin
     */
    Map<String, List<MappingInfo>> mappedSignalsByPin = new HashMap<String, List<MappingInfo>>();
    /**
     * Used to check for a signal being mapped to multiple pins
     */
    Map<String, List<MappingInfo>> mappedPinsBySignal = new HashMap<String, List<MappingInfo>>();
    for (MappingInfo mapping : fPinModel.getMappingInfos()) {
        mapping.setMessage("");
        if (!mapping.isSelected()) {
            continue;
        }
        /*
          * Check for multiple Signals => Pin
          */
        List<MappingInfo> signalsMappedToPin = addToMap(mappedSignalsByPin, mapping, mapping.getPin().getName());
        if (signalsMappedToPin != null) {
            // Signal previously mapped to this pin
            // Check if any conflicts between new signal mapping and existing ones
            // Note - Multiple signals may be mapped to the same pin without conflict
            // since some signals share a mapping.
            // Need to check the signalLists not the signals
            boolean conflicting = false;
            StringBuffer sb = null;
            for (MappingInfo other : signalsMappedToPin) {
                // Check for conflicts
                if (!mapping.getSignalList().equals(other.getSignalList())) {
                    // Not shared port mapping
                    conflicting = true;
                }
            }
            if (conflicting) {
                // Construct conflict message
                for (MappingInfo other : signalsMappedToPin) {
                    if (sb == null) {
                        sb = new StringBuffer();
                        sb.append("Error: (");
                    } else {
                        sb.append(", ");
                    }
                    sb.append(other.getSignalList());
                    sb.append("@" + other.getMux().name());
                }
                sb.append(") =>> ");
                sb.append(mapping.getPin().getName());
                sb.append("\nPin mapped to multiple signals");
                // Mark all conflicting nodes
                for (MappingInfo other : signalsMappedToPin) {
                    other.setMessage(sb.toString());
                }
            }
        }
        /*
          * Check for Signal => multiple Pins
          */
        List<MappingInfo> pinsMappedToSignal = addToMap(mappedPinsBySignal, mapping, mapping.getSignalList());
        // System.err.println("checkConflictsJob(): " + mapping);
        if (pinsMappedToSignal != null) {
            // Pins previously mapped to this signal
            // Construct conflict message
            StringBuffer sb = null;
            for (MappingInfo other : pinsMappedToSignal) {
                if (sb == null) {
                    sb = new StringBuffer();
                    sb.append(mapping.getSignalList() + " =>> (");
                } else {
                    sb.append(", ");
                }
                sb.append(other.getPin().getName());
            }
            // Multiple signals mapped to pin
            sb.append(")");
            sb.append("\nSignal mapped to multiple pins");
            // Mark all conflicting nodes
            for (MappingInfo other : pinsMappedToSignal) {
                other.setMessage(sb.toString());
            }
        }
    }
    for (IPage model : fModels) {
        model.updatePage();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) MappingInfo(net.sourceforge.usbdm.deviceEditor.information.MappingInfo)

Example 7 with MappingInfo

use of net.sourceforge.usbdm.deviceEditor.information.MappingInfo in project usbdm-eclipse-plugins by podonoghue.

the class SignalModel method getStatus.

/**
 * Get Message for model
 *
 * May return an error message from the pin mapping instead.
 */
@Override
Status getStatus() {
    Status rv = null;
    MappingInfo currentMapping = fSignal.getMappedPin();
    if (currentMapping != null) {
        rv = currentMapping.getMessage();
    }
    if (rv != null) {
        return rv;
    }
    return super.getStatus();
}
Also used : MappingInfo(net.sourceforge.usbdm.deviceEditor.information.MappingInfo)

Example 8 with MappingInfo

use of net.sourceforge.usbdm.deviceEditor.information.MappingInfo in project usbdm-eclipse-plugins by podonoghue.

the class LlwuValidate method doPinNames.

/**
 * Extract pin names and create LLWU pin and peripheral C enum tables.<br>
 * The description for pins is also annotated with the pin number found or (Reserved)<br>
 *
 * Tables are added to the following Peripheral Variables:
 *  <li>LlwuPins
 *  <li>LlwuPeripherals
 */
private void doPinNames() {
    final String RESERVED = "Reserved";
    if (donePinNames) {
        return;
    }
    donePinNames = true;
    StringBuilder sb = new StringBuilder();
    sb.append("/**\n" + " * LLWU pin sources\n" + " */\n" + "enum LlwuPin : uint32_t {\n");
    InfoTable pinTable = getPeripheral().getSignalTables().get(0);
    for (int index = 0; index < 32; index++) {
        String choiceName = "llwu_pe" + ((index / 4) + 1) + "_wupe" + index;
        ChoiceVariable choiceVar = safeGetChoiceVariable(choiceName);
        if (choiceVar == null) {
            continue;
        }
        String llwuPinName;
        if (index >= pinTable.table.size()) {
            // Pin not in table (doesn't exist)
            choiceVar.enable(false);
            llwuPinName = RESERVED;
        } else {
            // Look up possible pin mapping in table
            Signal signal = pinTable.table.elementAt(index);
            Pin mappablePin = null;
            if (signal != null) {
                TreeSet<MappingInfo> pinMappings = signal.getPinMapping();
                for (MappingInfo pinMapping : pinMappings) {
                    if (pinMapping.getMux() == MuxSelection.mux1) {
                        mappablePin = pinMapping.getPin();
                    }
                }
            }
            if (mappablePin == null) {
                // No mappable pin
                choiceVar.enable(false);
                llwuPinName = RESERVED;
            } else {
                // Mappable pin
                choiceVar.enable(true);
                llwuPinName = mappablePin.getName();
            }
        }
        if (llwuPinName != RESERVED) {
            String llwuPinLine = String.format("   LlwuPin_%-15s = %2d, //!< Wake-up pin LLWU_P%d\n", capitalCase(llwuPinName), index, index);
            sb.append(llwuPinLine);
        }
        choiceVar.setDescription(choiceVar.getDescription() + " - " + llwuPinName);
    }
    sb.append("};\n\n");
    StringVariable llwuPinsVar = new StringVariable("LlwuPins", getPeripheral().makeKey("LlwuPins"));
    llwuPinsVar.setValue(sb.toString());
    llwuPinsVar.setDerived(true);
    getPeripheral().addVariable(llwuPinsVar);
    sb = new StringBuilder();
    sb.append("/**\n" + " * LLWU peripheral sources\n" + " */\n" + "enum LlwuPeripheral : uint32_t {\n");
    for (int index = 0; index <= 7; index++) {
        String choiceName = "llwu_me_wume" + index;
        BooleanVariable choiceVar = safeGetBooleanVariable(choiceName);
        String llwuPeripheralName;
        if (choiceVar != null) {
            llwuPeripheralName = choiceVar.getDescription();
            String llwuPeripheralLine = String.format("   LlwuPeripheral_%-15s = (1<<%d), //!< Wake-up peripheral LLWU_M%dIF\n", capitalCase(llwuPeripheralName), index, index);
            sb.append(llwuPeripheralLine);
        }
    }
    sb.append("};\n\n");
    StringVariable llwuPeripheralsVar = new StringVariable("LlwuPeripherals", getPeripheral().makeKey("LlwuPeripherals"));
    llwuPeripheralsVar.setValue(sb.toString());
    llwuPeripheralsVar.setDerived(true);
    getPeripheral().addVariable(llwuPeripheralsVar);
}
Also used : Signal(net.sourceforge.usbdm.deviceEditor.information.Signal) Pin(net.sourceforge.usbdm.deviceEditor.information.Pin) BooleanVariable(net.sourceforge.usbdm.deviceEditor.information.BooleanVariable) InfoTable(net.sourceforge.usbdm.deviceEditor.information.Peripheral.InfoTable) StringVariable(net.sourceforge.usbdm.deviceEditor.information.StringVariable) ChoiceVariable(net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable) MappingInfo(net.sourceforge.usbdm.deviceEditor.information.MappingInfo)

Aggregations

MappingInfo (net.sourceforge.usbdm.deviceEditor.information.MappingInfo)8 Pin (net.sourceforge.usbdm.deviceEditor.information.Pin)5 MuxSelection (net.sourceforge.usbdm.deviceEditor.information.MuxSelection)4 Signal (net.sourceforge.usbdm.deviceEditor.information.Signal)4 ArrayList (java.util.ArrayList)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 BooleanVariable (net.sourceforge.usbdm.deviceEditor.information.BooleanVariable)1 ChoiceVariable (net.sourceforge.usbdm.deviceEditor.information.ChoiceVariable)1 DevicePackage (net.sourceforge.usbdm.deviceEditor.information.DevicePackage)1 Peripheral (net.sourceforge.usbdm.deviceEditor.information.Peripheral)1 InfoTable (net.sourceforge.usbdm.deviceEditor.information.Peripheral.InfoTable)1 StringVariable (net.sourceforge.usbdm.deviceEditor.information.StringVariable)1 PinCategory (net.sourceforge.usbdm.deviceEditor.model.ModelFactory.PinCategory)1 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)1