use of com.cburch.logisim.std.io.DipSwitch in project logisim-evolution by reds-heig.
the class Netlist method ConstructHierarchyTree.
public void ConstructHierarchyTree(Set<String> ProcessedCircuits, ArrayList<String> HierarchyName, Integer GlobalInputID, Integer GlobalOutputID, Integer GlobalInOutID) {
if (ProcessedCircuits == null) {
ProcessedCircuits = new HashSet<String>();
}
/*
* The first step is to go down to the leaves and visit all involved
* sub-circuits to construct the local bubble information and form the
* Mappable components tree
*/
LocalNrOfInportBubles = 0;
LocalNrOfOutportBubles = 0;
LocalNrOfInOutBubles = 0;
for (NetlistComponent comp : MySubCircuits) {
SubcircuitFactory sub = (SubcircuitFactory) comp.GetComponent().getFactory();
ArrayList<String> MyHierarchyName = new ArrayList<String>();
MyHierarchyName.addAll(HierarchyName);
MyHierarchyName.add(CorrectLabel.getCorrectLabel(comp.GetComponent().getAttributeSet().getValue(StdAttr.LABEL).toString()));
boolean FirstTime = !ProcessedCircuits.contains(sub.getName().toString());
if (FirstTime) {
ProcessedCircuits.add(sub.getName());
sub.getSubcircuit().getNetList().ConstructHierarchyTree(ProcessedCircuits, MyHierarchyName, GlobalInputID, GlobalOutputID, GlobalInOutID);
}
int subInputBubbles = sub.getSubcircuit().getNetList().NumberOfInputBubbles();
int subInOutBubbles = sub.getSubcircuit().getNetList().NumberOfInOutBubbles();
int subOutputBubbles = sub.getSubcircuit().getNetList().NumberOfOutputBubbles();
comp.SetLocalBubbleID(LocalNrOfInportBubles, subInputBubbles, LocalNrOfOutportBubles, subOutputBubbles, LocalNrOfInOutBubles, subInOutBubbles);
LocalNrOfInportBubles += subInputBubbles;
LocalNrOfInOutBubles += subInOutBubbles;
LocalNrOfOutportBubles += subOutputBubbles;
comp.AddGlobalBubbleID(MyHierarchyName, GlobalInputID, subInputBubbles, GlobalOutputID, subOutputBubbles, GlobalInOutID, subInOutBubbles);
if (!FirstTime) {
sub.getSubcircuit().getNetList().EnumerateGlobalBubbleTree(MyHierarchyName, GlobalInputID, GlobalOutputID, GlobalInOutID);
}
GlobalInputID += subInputBubbles;
GlobalInOutID += subInOutBubbles;
GlobalOutputID += subOutputBubbles;
}
/*
* Here we processed all sub-circuits of the local hierarchy level, now
* we have to process the IO components
*/
for (NetlistComponent comp : MyComponents) {
if (comp.GetIOInformationContainer() != null) {
ArrayList<String> MyHierarchyName = new ArrayList<String>();
MyHierarchyName.addAll(HierarchyName);
MyHierarchyName.add(CorrectLabel.getCorrectLabel(comp.GetComponent().getAttributeSet().getValue(StdAttr.LABEL).toString()));
int subInputBubbles = comp.GetIOInformationContainer().GetNrOfInports();
if (comp.GetComponent().getFactory() instanceof DipSwitch) {
subInputBubbles = comp.GetComponent().getAttributeSet().getValue(DipSwitch.ATTR_SIZE);
}
int subInOutBubbles = comp.GetIOInformationContainer().GetNrOfInOutports();
int subOutputBubbles = comp.GetIOInformationContainer().GetNrOfOutports();
comp.SetLocalBubbleID(LocalNrOfInportBubles, subInputBubbles, LocalNrOfOutportBubles, subOutputBubbles, LocalNrOfInOutBubles, subInOutBubbles);
LocalNrOfInportBubles += subInputBubbles;
LocalNrOfInOutBubles += subInOutBubbles;
LocalNrOfOutportBubles += subOutputBubbles;
comp.AddGlobalBubbleID(MyHierarchyName, GlobalInputID, subInputBubbles, GlobalOutputID, subOutputBubbles, GlobalInOutID, subInOutBubbles);
GlobalInputID += subInputBubbles;
GlobalInOutID += subInOutBubbles;
GlobalOutputID += subOutputBubbles;
}
}
}
use of com.cburch.logisim.std.io.DipSwitch in project logisim-evolution by reds-heig.
the class MappableResourcesContainer method IsMappable.
public boolean IsMappable(Map<String, ArrayList<Integer>> BoardComponents, FPGAReport MyReporter) {
for (ArrayList<String> key : myMappableResources.keySet()) {
NetlistComponent comp = myMappableResources.get(key);
/*
* we have a special case: a pinbus of the toplevel, this one has
* never a mainmaptype, so we should skip the test
*/
if (!((comp.GetComponent().getFactory() instanceof Pin) && (comp.GetComponent().getEnd(0).getWidth().getWidth() > 1))) {
/* for each component we first check the main map type */
String MainMapType = comp.GetIOInformationContainer().GetMainMapType().toString();
if (BoardComponents.containsKey(MainMapType)) {
/* okay it exists lets see if we have enough of those */
if (BoardComponents.get(MainMapType).size() > 0) {
if (comp.GetComponent().getFactory() instanceof PortIO || comp.GetComponent().getFactory() instanceof DipSwitch) {
/* Care of Port and Dip as their size may vary */
int NrOfBCRequired = comp.GetIOInformationContainer().GetNrOfInports() + comp.GetIOInformationContainer().GetNrOfOutports() + comp.GetIOInformationContainer().GetNrOfInOutports();
int bestComponentIdx = getBestComponent(BoardComponents.get(MainMapType), NrOfBCRequired);
if (bestComponentIdx > -1) {
BoardComponents.get(MainMapType).remove(bestComponentIdx);
continue;
}
} else {
/*
* no Problem, we have enough of those , we allocate
* and decrease
*/
BoardComponents.get(MainMapType).remove(BoardComponents.get(MainMapType).size() - 1);
continue;
}
}
} else {
/*
* The board does not have the main type, hence we have
* anyways to use alternate mapping
*/
comp.ToggleAlternateMapping(key);
comp.LockAlternateMapping(key);
}
}
/* Here we check if the component can be mapped to an alternate map */
int AltMapId = 0;
String AltMapType;
boolean found = false;
do {
AltMapType = comp.GetIOInformationContainer().GetAlternateMapType(AltMapId).toString();
if (!AltMapType.equals(IOComponentTypes.Unknown.toString())) {
if (BoardComponents.containsKey(AltMapType)) {
int NrOfBCRequired = comp.GetIOInformationContainer().GetNrOfInports() + comp.GetIOInformationContainer().GetNrOfOutports() + comp.GetIOInformationContainer().GetNrOfInOutports();
if (NrOfBCRequired <= BoardComponents.get(AltMapType).size()) {
// NrOfBCRequired);
for (int i = 0; i < NrOfBCRequired; i++) {
BoardComponents.get(AltMapType).remove(BoardComponents.get(AltMapType).size() - 1);
}
found = true;
break;
}
}
}
AltMapId++;
} while (!AltMapType.equals(IOComponentTypes.Unknown.toString()));
if (!found) {
if (comp.AlternateMappingEnabled(key)) {
comp.UnlockAlternateMapping(key);
comp.ToggleAlternateMapping(key);
}
MyReporter.AddError("The Target board " + currentBoardName + " does not have enough IO resources to map the design!");
MyReporter.AddError("The component \"" + MapNametoDisplayName(GetMapNamesList(key, comp).get(0)) + "\" cannot be placed!");
return false;
}
}
return true;
}
Aggregations