Search in sources :

Example 1 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class Netlist method GetHiddenSinkNets.

private ArrayList<ConnectionPoint> GetHiddenSinkNets(Net thisNet, Byte bitIndex, ArrayList<Component> SplitterList, Component ActiveSplitter, Set<String> HandledNets, Boolean isSourceNet) {
    ArrayList<ConnectionPoint> result = new ArrayList<ConnectionPoint>();
    /*
		 * to prevent deadlock situations we check if we already looked at this
		 * net
		 */
    String NetId = Integer.toString(MyNets.indexOf(thisNet)) + "-" + Byte.toString(bitIndex);
    if (HandledNets.contains(NetId)) {
        return result;
    } else {
        HandledNets.add(NetId);
    }
    if (thisNet.hasBitSinks(bitIndex) && !isSourceNet) {
        ConnectionPoint SolderPoint = new ConnectionPoint(null);
        SolderPoint.SetParrentNet(thisNet, bitIndex);
        result.add(SolderPoint);
    }
    /* Check if we have a connection to another splitter */
    for (Component currentSplitter : SplitterList) {
        if (ActiveSplitter != null) {
            if (currentSplitter.equals(ActiveSplitter)) {
                continue;
            }
        }
        List<EndData> ends = currentSplitter.getEnds();
        for (byte end = 0; end < ends.size(); end++) {
            if (thisNet.contains(ends.get(end).getLocation())) {
                /* Here we have to process the inherited bits of the parent */
                byte[] BusBitConnection = ((Splitter) currentSplitter).GetEndpoints();
                if (end == 0) {
                    /* this is a main net, find the connected end */
                    Byte SplitterEnd = BusBitConnection[bitIndex];
                    /* Find the corresponding Net index */
                    Byte Netindex = 0;
                    for (int index = 0; index < bitIndex; index++) {
                        if (BusBitConnection[index] == SplitterEnd) {
                            Netindex++;
                        }
                    }
                    /* Find the connected Net */
                    Net SlaveNet = null;
                    for (Net thisnet : MyNets) {
                        if (thisnet.contains(ends.get(SplitterEnd).getLocation())) {
                            SlaveNet = thisnet;
                        }
                    }
                    if (SlaveNet != null) {
                        if (SlaveNet.IsRootNet()) {
                            /* Trace down the slavenet */
                            result.addAll(GetHiddenSinkNets(SlaveNet, Netindex, SplitterList, currentSplitter, HandledNets, false));
                        } else {
                            result.addAll(GetHiddenSinkNets(SlaveNet.getParent(), SlaveNet.getBit(Netindex), SplitterList, currentSplitter, HandledNets, false));
                        }
                    }
                } else {
                    ArrayList<Byte> Rootindices = new ArrayList<Byte>();
                    for (byte b = 0; b < BusBitConnection.length; b++) {
                        if (BusBitConnection[b] == end) {
                            Rootindices.add(b);
                        }
                    }
                    Net RootNet = null;
                    for (Net thisnet : MyNets) {
                        if (thisnet.contains(currentSplitter.getEnd(0).getLocation())) {
                            RootNet = thisnet;
                        }
                    }
                    if (RootNet != null) {
                        if (RootNet.IsRootNet()) {
                            result.addAll(GetHiddenSinkNets(RootNet, Rootindices.get(bitIndex), SplitterList, currentSplitter, HandledNets, false));
                        } else {
                            result.addAll(GetHiddenSinkNets(RootNet.getParent(), RootNet.getBit(Rootindices.get(bitIndex)), SplitterList, currentSplitter, HandledNets, false));
                        }
                    }
                }
            }
        }
    }
    return result;
}
Also used : EndData(com.cburch.logisim.comp.EndData) Splitter(com.cburch.logisim.circuit.Splitter) ArrayList(java.util.ArrayList) InstanceComponent(com.cburch.logisim.instance.InstanceComponent) Component(com.cburch.logisim.comp.Component)

Example 2 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class Netlist method HasHiddenSource.

private boolean HasHiddenSource(Net thisNet, Byte bitIndex, List<Component> SplitterList, Component ActiveSplitter, Set<String> HandledNets) {
    /*
		 * to prevent deadlock situations we check if we already looked at this
		 * net
		 */
    String NetId = Integer.toString(MyNets.indexOf(thisNet)) + "-" + Byte.toString(bitIndex);
    if (HandledNets.contains(NetId)) {
        return false;
    } else {
        HandledNets.add(NetId);
    }
    if (thisNet.hasBitSource(bitIndex)) {
        return true;
    }
    /* Check if we have a connection to another splitter */
    for (Component currentSplitter : SplitterList) {
        if (currentSplitter.equals(ActiveSplitter)) {
            continue;
        }
        List<EndData> ends = currentSplitter.getEnds();
        for (byte end = 0; end < ends.size(); end++) {
            if (thisNet.contains(ends.get(end).getLocation())) {
                /* Here we have to process the inherited bits of the parent */
                byte[] BusBitConnection = ((Splitter) currentSplitter).GetEndpoints();
                if (end == 0) {
                    /* this is a main net, find the connected end */
                    Byte SplitterEnd = BusBitConnection[bitIndex];
                    /* Find the corresponding Net index */
                    Byte Netindex = 0;
                    for (int index = 0; index < bitIndex; index++) {
                        if (BusBitConnection[index] == SplitterEnd) {
                            Netindex++;
                        }
                    }
                    /* Find the connected Net */
                    Net SlaveNet = null;
                    for (Net thisnet : MyNets) {
                        if (thisnet.contains(ends.get(SplitterEnd).getLocation())) {
                            SlaveNet = thisnet;
                        }
                    }
                    if (SlaveNet != null) {
                        if (SlaveNet.IsRootNet()) {
                            /* Trace down the slavenet */
                            if (HasHiddenSource(SlaveNet, Netindex, SplitterList, currentSplitter, HandledNets)) {
                                return true;
                            }
                        } else {
                            if (HasHiddenSource(SlaveNet.getParent(), SlaveNet.getBit(Netindex), SplitterList, currentSplitter, HandledNets)) {
                                return true;
                            }
                        }
                    }
                } else {
                    ArrayList<Byte> Rootindices = new ArrayList<Byte>();
                    for (byte b = 0; b < BusBitConnection.length; b++) {
                        if (BusBitConnection[b] == end) {
                            Rootindices.add(b);
                        }
                    }
                    Net RootNet = null;
                    for (Net thisnet : MyNets) {
                        if (thisnet.contains(currentSplitter.getEnd(0).getLocation())) {
                            RootNet = thisnet;
                        }
                    }
                    if (RootNet != null) {
                        if (RootNet.IsRootNet()) {
                            if (HasHiddenSource(RootNet, Rootindices.get(bitIndex), SplitterList, currentSplitter, HandledNets)) {
                                return true;
                            }
                        } else {
                            if (HasHiddenSource(RootNet.getParent(), RootNet.getBit(Rootindices.get(bitIndex)), SplitterList, currentSplitter, HandledNets)) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : EndData(com.cburch.logisim.comp.EndData) Splitter(com.cburch.logisim.circuit.Splitter) ArrayList(java.util.ArrayList) InstanceComponent(com.cburch.logisim.instance.InstanceComponent) Component(com.cburch.logisim.comp.Component)

Example 3 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class CanvasPainter method exposeHaloedComponent.

private void exposeHaloedComponent(Graphics g) {
    Component c = haloedComponent;
    if (c == null)
        return;
    Bounds bds = c.getBounds(g).expand(7);
    int w = bds.getWidth();
    int h = bds.getHeight();
    double a = Canvas.SQRT_2 * w;
    double b = Canvas.SQRT_2 * h;
    canvas.repaint((int) Math.round(bds.getX() + w / 2.0 - a / 2.0), (int) Math.round(bds.getY() + h / 2.0 - b / 2.0), (int) Math.round(a), (int) Math.round(b));
}
Also used : Bounds(com.cburch.logisim.data.Bounds) Component(com.cburch.logisim.comp.Component)

Example 4 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class Frame method setAttrTableModel.

void setAttrTableModel(AttrTableModel value) {
    attrTable.setAttrTableModel(value);
    if (value instanceof AttrTableToolModel) {
        Tool tool = ((AttrTableToolModel) value).getTool();
        toolbox.setHaloedTool(tool);
        layoutToolbarModel.setHaloedTool(tool);
    } else {
        toolbox.setHaloedTool(null);
        layoutToolbarModel.setHaloedTool(null);
    }
    if (value instanceof AttrTableComponentModel) {
        Circuit circ = ((AttrTableComponentModel) value).getCircuit();
        Component comp = ((AttrTableComponentModel) value).getComponent();
        layoutCanvas.setHaloedComponent(circ, comp);
    } else {
        layoutCanvas.setHaloedComponent(null, null);
    }
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit) Component(com.cburch.logisim.comp.Component) Tool(com.cburch.logisim.tools.Tool)

Example 5 with Component

use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.

the class SelectionActions method drop.

// clears the selection, anchoring all floating elements in selection
public static Action drop(Selection sel, Collection<Component> comps) {
    HashSet<Component> floating = new HashSet<Component>(sel.getFloatingComponents());
    HashSet<Component> anchored = new HashSet<Component>(sel.getAnchoredComponents());
    ArrayList<Component> toDrop = new ArrayList<Component>();
    ArrayList<Component> toIgnore = new ArrayList<Component>();
    for (Component comp : comps) {
        if (floating.contains(comp)) {
            toDrop.add(comp);
        } else if (anchored.contains(comp)) {
            toDrop.add(comp);
            toIgnore.add(comp);
        }
    }
    if (toDrop.size() == toIgnore.size()) {
        for (Component comp : toIgnore) {
            sel.remove(null, comp);
        }
        return null;
    } else {
        int numDrop = toDrop.size() - toIgnore.size();
        return new Drop(sel, toDrop, numDrop);
    }
}
Also used : ArrayList(java.util.ArrayList) Component(com.cburch.logisim.comp.Component) HashSet(java.util.HashSet)

Aggregations

Component (com.cburch.logisim.comp.Component)97 Location (com.cburch.logisim.data.Location)26 ArrayList (java.util.ArrayList)20 Circuit (com.cburch.logisim.circuit.Circuit)19 AttributeSet (com.cburch.logisim.data.AttributeSet)13 Wire (com.cburch.logisim.circuit.Wire)12 Bounds (com.cburch.logisim.data.Bounds)11 HashMap (java.util.HashMap)11 HashSet (java.util.HashSet)11 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 EndData (com.cburch.logisim.comp.EndData)8 InstanceComponent (com.cburch.logisim.instance.InstanceComponent)8 Project (com.cburch.logisim.proj.Project)7 Pin (com.cburch.logisim.std.wiring.Pin)7 Graphics (java.awt.Graphics)7 CircuitState (com.cburch.logisim.circuit.CircuitState)6 Splitter (com.cburch.logisim.circuit.Splitter)6 Selection (com.cburch.logisim.gui.main.Selection)6 InstanceState (com.cburch.logisim.instance.InstanceState)5