public FPGAIOInformationContainer( IOComponentTypes Type, BoardRectangle rect, BoardDialog parent) { MyType = Type; MyIdentifier = -1; MyRectangle = rect; MyPinLocations = new HashMap<Integer, String>(); NrOfPins = 0; MyPullBehavior = PullBehaviors.Unknown; MyActivityLevel = PinActivity.Unknown; MyIOStandard = IoStandards.Unknown; MyDriveStrength = DriveStrength.Unknown; if (IOComponentTypes.SimpleInputSet.contains(Type)) { if (MyType.equals(IOComponentTypes.DIPSwitch) || MyType.equals(IOComponentTypes.PortIO)) { GetSizeInformationDialog(parent); } GetSimpleInformationDialog(parent); return; } MyType = IOComponentTypes.Unknown; }
private ArrayList<String> GetXilinxUCFStrings(String direction, int StartId) { ArrayList<String> Contents = new ArrayList<String>(); StringBuffer Temp = new StringBuffer(); Integer start = 0; Integer end = NrOfPins; ArrayList<String> labels = null; if (MyType.equals(IOComponentTypes.PortIO)) { labels = PortIO.GetLabels(IOComponentTypes.GetNrOfFPGAPins(MyType)); } else if (MyType.equals(IOComponentTypes.LocalBus)) { labels = ReptarLocalBus.GetLabels(); if (direction.equals("in")) { end = IOComponentTypes.GetFPGAInputRequirement(MyType); } else if (direction.equals("out")) { // TODO: YSY Contents.add( "NET \"FPGA_LB_OUT_0\" LOC = \"R24\" | IOSTANDARD = LVCMOS18 ; # SP6_LB_WAIT3_o"); Contents.add("NET \"FPGA_LB_OUT_1\" LOC = \"AB30\" | IOSTANDARD = LVCMOS18 ; # IRQ_o"); return Contents; // start = IOComponentTypes.GetFPGAInputRequirement(MyType); // end = start + // IOComponentTypes.GetFPGAOutputRequirement(MyType); } else if (direction.equals("inout")) { start = IOComponentTypes.GetFPGAInputRequirement(MyType) + IOComponentTypes.GetFPGAOutputRequirement(MyType); end = start + IOComponentTypes.GetFPGAInOutRequirement(MyType); } } else if (MyType.equals(IOComponentTypes.DIPSwitch)) { labels = DipSwitch.GetLabels(IOComponentTypes.GetNrOfFPGAPins(MyType)); } else if (MyType.equals(IOComponentTypes.SevenSegment)) { labels = SevenSegment.GetLabels(); } else if (MyType.equals(IOComponentTypes.RGBLED)) { labels = RGBLed.GetLabels(); } for (int i = start; i < end; i++) { Temp.setLength(0); Temp.append("LOC = \"" + MyPinLocations.get(i) + "\" "); if (MyPullBehavior != PullBehaviors.Unknown && MyPullBehavior != PullBehaviors.Float) { Temp.append("| " + PullBehaviors.getContraintedPullString(MyPullBehavior) + " "); } if (MyDriveStrength != DriveStrength.Unknown && MyDriveStrength != DriveStrength.DefaulStength) { Temp.append( "| DRIVE = " + DriveStrength.GetContraintedDriveStrength(MyDriveStrength) + " "); } if (MyIOStandard != IoStandards.Unknown && MyIOStandard != IoStandards.DefaulStandard) { Temp.append("| IOSTANDARD = " + IoStandards.GetConstraintedIoStandard(MyIOStandard) + " "); } Temp.append(";"); if (labels != null) { Temp.append(" # " + labels.get(i)); } String NetName = ""; if (direction == "in") { NetName = HDLGeneratorFactory.FPGAInputPinName + "_" + Integer.toString(StartId + i - start); } else if (direction == "inout") { NetName = HDLGeneratorFactory.FPGAInOutPinName + "_" + Integer.toString(StartId + i - start); } else { NetName = HDLGeneratorFactory.FPGAOutputPinName + "_" + Integer.toString(StartId + i - start); } // String NetName = (InputPins) ? // HDLGeneratorFactory.FPGAInputPinName + "_" + // Integer.toString(StartId + i) // : HDLGeneratorFactory.FPGAOutputPinName + "_" + // Integer.toString(StartId + i); Contents.add("NET \"" + NetName + "\" " + Temp.toString()); } return Contents; }
public Element GetDocumentElement(Document doc) { if (MyType.equals(IOComponentTypes.Unknown)) { return null; } try { Element result = doc.createElement(MyType.toString()); result.setAttribute( BoardWriterClass.LocationXString, Integer.toString(MyRectangle.getXpos())); Attr ypos = doc.createAttribute(BoardWriterClass.LocationYString); ypos.setValue(Integer.toString(MyRectangle.getYpos())); result.setAttributeNode(ypos); Attr width = doc.createAttribute(BoardWriterClass.WidthString); width.setValue(Integer.toString(MyRectangle.getWidth())); result.setAttributeNode(width); Attr height = doc.createAttribute(BoardWriterClass.HeightString); height.setValue(Integer.toString(MyRectangle.getHeight())); result.setAttributeNode(height); if (NrOfPins == 1) { Attr loc = doc.createAttribute(BoardWriterClass.PinLocationString); loc.setValue(MyPinLocations.get(0)); result.setAttributeNode(loc); } else { Attr NrPins = doc.createAttribute(BoardWriterClass.MultiPinInformationString); NrPins.setValue(NrOfPins.toString()); result.setAttributeNode(NrPins); for (int i = 0; i < NrOfPins; i++) { String PinName = BoardWriterClass.MultiPinPrefixString + Integer.toString(i); Attr PinX = doc.createAttribute(PinName); PinX.setValue(MyPinLocations.get(i)); result.setAttributeNode(PinX); } } if (MyDriveStrength != DriveStrength.Unknown) { Attr drive = doc.createAttribute(DriveStrength.DriveAttributeString); drive.setValue(DriveStrength.Behavior_strings[MyDriveStrength]); result.setAttributeNode(drive); } if (MyPullBehavior != PullBehaviors.Unknown) { Attr pull = doc.createAttribute(PullBehaviors.PullAttributeString); pull.setValue(PullBehaviors.Behavior_strings[MyPullBehavior]); result.setAttributeNode(pull); } if (MyIOStandard != IoStandards.Unknown) { Attr stand = doc.createAttribute(IoStandards.IOAttributeString); stand.setValue(IoStandards.Behavior_strings[MyIOStandard]); result.setAttributeNode(stand); } if (MyActivityLevel != PinActivity.Unknown) { Attr act = doc.createAttribute(PinActivity.ActivityAttributeString); act.setValue(PinActivity.Behavior_strings[MyActivityLevel]); result.setAttributeNode(act); } return result; } catch (Exception e) { /* TODO: handle exceptions */ logger.error( "Exceptions not handled yet in GetDocumentElement(), but got an exception: {}", e.getMessage()); } return null; }
public FPGAIOInformationContainer(Node DocumentInfo) { /* * This constructor is used to create an element during the reading of a * board information xml file */ MyType = IOComponentTypes.Unknown; MyIdentifier = -1; MyRectangle = null; MyPinLocations = new HashMap<Integer, String>(); NrOfPins = 0; MyPullBehavior = PullBehaviors.Unknown; MyActivityLevel = PinActivity.Unknown; MyIOStandard = IoStandards.Unknown; MyDriveStrength = DriveStrength.Unknown; IOComponentTypes SetId = IOComponentTypes.getEnumFromString(DocumentInfo.getNodeName()); if (IOComponentTypes.KnownComponentSet.contains(SetId)) { MyType = SetId; } else { return; } NamedNodeMap Attrs = DocumentInfo.getAttributes(); int x = -1, y = -1, width = -1, height = -1; for (int i = 0; i < Attrs.getLength(); i++) { Node ThisAttr = Attrs.item(i); if (ThisAttr.getNodeName().equals(BoardWriterClass.LocationXString)) { x = Integer.parseInt(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(BoardWriterClass.LocationYString)) { y = Integer.parseInt(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(BoardWriterClass.WidthString)) { width = Integer.parseInt(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(BoardWriterClass.HeightString)) { height = Integer.parseInt(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(BoardWriterClass.PinLocationString)) { NrOfPins = 1; MyPinLocations.put(0, ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(BoardWriterClass.MultiPinInformationString)) { NrOfPins = Integer.parseInt(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().startsWith(BoardWriterClass.MultiPinPrefixString)) { String Id = ThisAttr.getNodeName().substring(BoardWriterClass.MultiPinPrefixString.length()); MyPinLocations.put(Integer.parseInt(Id), ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(DriveStrength.DriveAttributeString)) { MyDriveStrength = DriveStrength.getId(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(PullBehaviors.PullAttributeString)) { MyPullBehavior = PullBehaviors.getId(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(IoStandards.IOAttributeString)) { MyIOStandard = IoStandards.getId(ThisAttr.getNodeValue()); } if (ThisAttr.getNodeName().equals(PinActivity.ActivityAttributeString)) { MyActivityLevel = PinActivity.getId(ThisAttr.getNodeValue()); } } if ((x < 0) || (y < 0) || (width < 1) || (height < 1)) { MyType = IOComponentTypes.Unknown; return; } boolean PinsComplete = true; for (int i = 0; i < NrOfPins; i++) { if (!MyPinLocations.containsKey(i)) { logger.warn("Bizar missing pin {} of component!", i); PinsComplete = false; } } if (!PinsComplete) { MyType = IOComponentTypes.Unknown; return; } if (MyType.equals(IOComponentTypes.DIPSwitch) || MyType.equals(IOComponentTypes.PortIO)) { MyType.setNbSwitch(NrOfPins); } MyRectangle = new BoardRectangle(x, y, width, height); }