Search in sources :

Example 1 with BubbleInformationContainer

use of com.bfh.logisim.designrulecheck.BubbleInformationContainer in project logisim-evolution by reds-heig.

the class AbstractHDLGeneratorFactory method GetInlinedCode.

public ArrayList<String> GetInlinedCode(String HDLType, ArrayList<String> ComponentIdentifier, FPGAReport Reporter, MappableResourcesContainer MapInfo) {
    ArrayList<String> Contents = new ArrayList<String>();
    String Preamble = (HDLType.equals(HDLGeneratorFactory.VHDL)) ? "" : "assign ";
    String AssignOperator = (HDLType.equals(HDLGeneratorFactory.VHDL)) ? " <= " : " = ";
    String OpenBracket = (HDLType.equals(HDLGeneratorFactory.VHDL)) ? "(" : "[";
    String CloseBracket = (HDLType.equals(HDLGeneratorFactory.VHDL)) ? ")" : "]";
    String Inversion = (HDLType.equals(HDLGeneratorFactory.VHDL)) ? "NOT " : "~";
    StringBuffer Temp = new StringBuffer();
    NetlistComponent comp = MapInfo.GetComponent(ComponentIdentifier);
    if (comp == null) {
        Reporter.AddFatalError("Component not found, bizar");
        return Contents;
    }
    ArrayList<String> bla = new ArrayList<String>();
    bla.addAll(ComponentIdentifier);
    bla.remove(0);
    BubbleInformationContainer BubbleInfo = comp.GetGlobalBubbleId(bla);
    if (BubbleInfo == null) {
        Reporter.AddFatalError("Component has no bubble information, bizar! " + bla.toString());
        return Contents;
    }
    /* The button is simple as it has only 1 pin */
    /*
		 * The bubble information presents the internal pin location, we now
		 * need to know the input pin index
		 */
    ArrayList<String> MyMaps = MapInfo.GetMapNamesList(ComponentIdentifier);
    if (MyMaps == null) {
        Reporter.AddFatalError("Component has no map information, bizar! " + ComponentIdentifier.toString());
        return Contents;
    }
    int BubbleOffset = 0;
    for (int MapOffset = 0; MapOffset < MyMaps.size(); MapOffset++) {
        String map = MyMaps.get(MapOffset);
        int InputId = MapInfo.GetFPGAInputPinId(map);
        int OutputId = MapInfo.GetFPGAOutputPinId(map);
        int NrOfPins = MapInfo.GetNrOfPins(map);
        boolean Invert = MapInfo.RequiresToplevelInversion(ComponentIdentifier, map);
        for (int PinId = 0; PinId < NrOfPins; PinId++) {
            Temp.setLength(0);
            Temp.append("   " + Preamble);
            if (InputId >= 0 && ((BubbleInfo.GetInputStartIndex() + BubbleOffset) <= BubbleInfo.GetInputEndIndex())) {
                Temp.append("s_" + HDLGeneratorFactory.LocalInputBubbleBusname + OpenBracket);
                Temp.append(BubbleInfo.GetInputStartIndex() + BubbleOffset);
                BubbleOffset++;
                Temp.append(CloseBracket + AssignOperator);
                if (Invert) {
                    Temp.append(Inversion);
                }
                Temp.append(HDLGeneratorFactory.FPGAInputPinName);
                Temp.append("_" + Integer.toString(InputId + PinId) + ";");
                Contents.add(Temp.toString());
            }
            Temp.setLength(0);
            Temp.append("   " + Preamble);
            if (OutputId >= 0 && ((BubbleInfo.GetOutputStartIndex() + BubbleOffset) <= BubbleInfo.GetOutputEndIndex())) {
                Temp.append(HDLGeneratorFactory.FPGAOutputPinName);
                Temp.append("_" + Integer.toString(OutputId + PinId) + AssignOperator);
                if (Invert) {
                    Temp.append(Inversion);
                }
                Temp.append("s_" + HDLGeneratorFactory.LocalOutputBubbleBusname + OpenBracket);
                Temp.append(BubbleInfo.GetOutputStartIndex() + BubbleOffset);
                BubbleOffset++;
                Temp.append(CloseBracket + ";");
                Contents.add(Temp.toString());
            }
        }
    }
    return Contents;
}
Also used : ArrayList(java.util.ArrayList) NetlistComponent(com.bfh.logisim.designrulecheck.NetlistComponent) BubbleInformationContainer(com.bfh.logisim.designrulecheck.BubbleInformationContainer) ConnectionPoint(com.bfh.logisim.designrulecheck.ConnectionPoint)

Aggregations

BubbleInformationContainer (com.bfh.logisim.designrulecheck.BubbleInformationContainer)1 ConnectionPoint (com.bfh.logisim.designrulecheck.ConnectionPoint)1 NetlistComponent (com.bfh.logisim.designrulecheck.NetlistComponent)1 ArrayList (java.util.ArrayList)1