Search in sources :

Example 11 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class CircuitHDLGeneratorFactory method GetComponentDeclarationSection.

@Override
public ArrayList<String> GetComponentDeclarationSection(Netlist TheNetlist, AttributeSet attrs) {
    ArrayList<String> Components = new ArrayList<String>();
    Set<String> InstantiatedComponents = new HashSet<String>();
    for (NetlistComponent Gate : TheNetlist.GetNormalComponents()) {
        String CompName = Gate.GetComponent().getFactory().getHDLName(Gate.GetComponent().getAttributeSet());
        if (!InstantiatedComponents.contains(CompName)) {
            InstantiatedComponents.add(CompName);
            HDLGeneratorFactory Worker = Gate.GetComponent().getFactory().getHDLGenerator(VHDL, Gate.GetComponent().getAttributeSet());
            if (Worker != null) {
                if (!Worker.IsOnlyInlined(VHDL)) {
                    Components.addAll(Worker.GetComponentInstantiation(TheNetlist, Gate.GetComponent().getAttributeSet(), CompName, VHDL));
                }
            }
        }
    }
    InstantiatedComponents.clear();
    for (NetlistComponent Gate : TheNetlist.GetSubCircuits()) {
        String CompName = Gate.GetComponent().getFactory().getHDLName(Gate.GetComponent().getAttributeSet());
        if (!InstantiatedComponents.contains(CompName)) {
            InstantiatedComponents.add(CompName);
            HDLGeneratorFactory Worker = Gate.GetComponent().getFactory().getHDLGenerator(VHDL, Gate.GetComponent().getAttributeSet());
            SubcircuitFactory sub = (SubcircuitFactory) Gate.GetComponent().getFactory();
            if (Worker != null) {
                Components.addAll(Worker.GetComponentInstantiation(sub.getSubcircuit().getNetList(), Gate.GetComponent().getAttributeSet(), CompName, VHDL));
            }
        }
    }
    return Components;
}
Also used : ArrayList(java.util.ArrayList) NetlistComponent(com.bfh.logisim.designrulecheck.NetlistComponent) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) ClockHDLGeneratorFactory(com.cburch.logisim.std.wiring.ClockHDLGeneratorFactory) HashSet(java.util.HashSet)

Example 12 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method doubleClicked.

public void doubleClicked(ProjectExplorerEvent event) {
    Object clicked = event.getTarget();
    if (clicked instanceof ProjectExplorerToolNode) {
        Tool baseTool = ((ProjectExplorerToolNode) clicked).getValue();
        if (baseTool instanceof AddTool) {
            AddTool tool = (AddTool) baseTool;
            ComponentFactory source = tool.getFactory();
            if (source instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) source;
                proj.setCurrentCircuit(circFact.getSubcircuit());
                proj.getFrame().setEditorView(Frame.EDIT_LAYOUT);
                if (lastSelected != null) {
                    proj.setTool(lastSelected);
                } else {
                    Library base = proj.getLogisimFile().getLibrary("Base");
                    if (base != null)
                        proj.setTool(base.getTool("Edit Tool"));
                }
            }
        }
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) AddTool(com.cburch.logisim.tools.AddTool) Library(com.cburch.logisim.tools.Library) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Example 13 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class SimulationTreeCircuitNode method computeChildren.

// returns true if changed
private boolean computeChildren() {
    ArrayList<TreeNode> newChildren = new ArrayList<TreeNode>();
    ArrayList<Component> subcircs = new ArrayList<Component>();
    for (Component comp : circuitState.getCircuit().getNonWires()) {
        if (comp.getFactory() instanceof SubcircuitFactory) {
            subcircs.add(comp);
        } else {
            TreeNode toAdd = model.mapComponentToNode(comp);
            if (toAdd != null) {
                newChildren.add(toAdd);
            }
        }
    }
    Collections.sort(newChildren, new CompareByName());
    Collections.sort(subcircs, this);
    for (Component comp : subcircs) {
        SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
        CircuitState state = factory.getSubstate(circuitState, comp);
        SimulationTreeCircuitNode toAdd = null;
        for (TreeNode o : children) {
            if (o instanceof SimulationTreeCircuitNode) {
                SimulationTreeCircuitNode n = (SimulationTreeCircuitNode) o;
                if (n.circuitState == state) {
                    toAdd = n;
                    break;
                }
            }
        }
        if (toAdd == null) {
            toAdd = new SimulationTreeCircuitNode(model, this, state, comp);
        }
        newChildren.add(toAdd);
    }
    if (!children.equals(newChildren)) {
        children = newChildren;
        return true;
    } else {
        return false;
    }
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) TreeNode(javax.swing.tree.TreeNode) ArrayList(java.util.ArrayList) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Component(com.cburch.logisim.comp.Component)

Example 14 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class Dependencies method processCircuit.

private void processCircuit(Circuit circ) {
    circ.addCircuitListener(myListener);
    for (Component comp : circ.getNonWires()) {
        if (comp.getFactory() instanceof SubcircuitFactory) {
            SubcircuitFactory factory = (SubcircuitFactory) comp.getFactory();
            depends.addEdge(circ, factory.getSubcircuit());
        }
    }
}
Also used : SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Component(com.cburch.logisim.comp.Component)

Example 15 with SubcircuitFactory

use of com.cburch.logisim.circuit.SubcircuitFactory in project logisim-evolution by reds-heig.

the class ToolboxManip method selectionChanged.

public void selectionChanged(ProjectExplorerEvent event) {
    Object selected = event.getTarget();
    if (selected instanceof ProjectExplorerToolNode) {
        Tool tool = ((ProjectExplorerToolNode) selected).getValue();
        if (selected instanceof AddTool) {
            AddTool addTool = (AddTool) tool;
            ComponentFactory source = addTool.getFactory();
            if (source instanceof SubcircuitFactory) {
                SubcircuitFactory circFact = (SubcircuitFactory) source;
                Circuit circ = circFact.getSubcircuit();
                if (proj.getCurrentCircuit() == circ) {
                    AttrTableModel m = new AttrTableCircuitModel(proj, circ);
                    proj.getFrame().setAttrTableModel(m);
                    return;
                }
            }
        }
        // This was causing the selection to lag behind double-clicks,
        // commented-out
        // lastSelected = proj.getTool();
        proj.setTool(tool);
        proj.getFrame().viewAttributes(tool);
    }
}
Also used : ProjectExplorerToolNode(com.cburch.logisim.gui.generic.ProjectExplorerToolNode) ComponentFactory(com.cburch.logisim.comp.ComponentFactory) AttrTableModel(com.cburch.logisim.gui.generic.AttrTableModel) SubcircuitFactory(com.cburch.logisim.circuit.SubcircuitFactory) Circuit(com.cburch.logisim.circuit.Circuit) AddTool(com.cburch.logisim.tools.AddTool) Tool(com.cburch.logisim.tools.Tool) AddTool(com.cburch.logisim.tools.AddTool)

Aggregations

SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)32 ArrayList (java.util.ArrayList)13 Circuit (com.cburch.logisim.circuit.Circuit)12 Component (com.cburch.logisim.comp.Component)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 AddTool (com.cburch.logisim.tools.AddTool)8 Tool (com.cburch.logisim.tools.Tool)6 InstanceComponent (com.cburch.logisim.instance.InstanceComponent)5 ProjectExplorerToolNode (com.cburch.logisim.gui.generic.ProjectExplorerToolNode)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Wire (com.cburch.logisim.circuit.Wire)3 Pin (com.cburch.logisim.std.wiring.Pin)3 Library (com.cburch.logisim.tools.Library)3 NetlistComponent (com.bfh.logisim.designrulecheck.NetlistComponent)2 CircuitException (com.cburch.logisim.circuit.CircuitException)2 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)2 CircuitState (com.cburch.logisim.circuit.CircuitState)2 EndData (com.cburch.logisim.comp.EndData)2 ProjectExplorerLibraryNode (com.cburch.logisim.gui.generic.ProjectExplorerLibraryNode)2