Search in sources :

Example 26 with Circuit

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

the class Project method setCircuitState.

public void setCircuitState(CircuitState value) {
    if (value == null || circuitState == value)
        return;
    CircuitState old = circuitState;
    Circuit oldCircuit = old == null ? null : old.getCircuit();
    Circuit newCircuit = value.getCircuit();
    boolean circuitChanged = old == null || oldCircuit != newCircuit;
    if (circuitChanged) {
        Canvas canvas = frame == null ? null : frame.getCanvas();
        if (canvas != null) {
            if (tool != null)
                tool.deselect(canvas);
            Selection selection = canvas.getSelection();
            if (selection != null) {
                Action act = SelectionActions.dropAll(selection);
                if (act != null) {
                    doAction(act);
                }
            }
            if (tool != null)
                tool.select(canvas);
        }
        if (oldCircuit != null) {
            for (CircuitListener l : circuitListeners) {
                oldCircuit.removeCircuitListener(l);
            }
        }
    }
    circuitState = value;
    stateMap.put(circuitState.getCircuit(), circuitState);
    simulator.setCircuitState(circuitState);
    if (circuitChanged) {
        fireEvent(ProjectEvent.ACTION_SET_CURRENT, oldCircuit, newCircuit);
        if (newCircuit != null) {
            for (CircuitListener l : circuitListeners) {
                newCircuit.addCircuitListener(l);
            }
        }
    }
    fireEvent(ProjectEvent.ACTION_SET_STATE, old, circuitState);
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) CircuitListener(com.cburch.logisim.circuit.CircuitListener) Selection(com.cburch.logisim.gui.main.Selection) Canvas(com.cburch.logisim.gui.main.Canvas) Circuit(com.cburch.logisim.circuit.Circuit)

Example 27 with Circuit

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

the class FPGACommanderGui method DownLoadDesign.

private void DownLoadDesign(boolean generateOnly, boolean downloadOnly) {
    if (generateOnly && downloadOnly) {
        MyReporter.AddError("Can not have skip VHDL generation and generate HDL only in the same time...");
        return;
    }
    if (!MapPannel.isDoneAssignment()) {
        MyReporter.AddError("Download to board canceled");
        return;
    }
    String CircuitName = circuitsList.getSelectedItem().toString();
    String ProjectDir = AppPreferences.FPGA_Workspace.get() + File.separator + MyProject.getLogisimFile().getName();
    if (!ProjectDir.endsWith(File.separator)) {
        ProjectDir += File.separator;
    }
    LogisimFile myfile = MyProject.getLogisimFile();
    Circuit RootSheet = myfile.getCircuit(CircuitName);
    ProjectDir += CorrectLabel.getCorrectLabel(RootSheet.getName()) + File.separator;
    String SourcePath = ProjectDir + AppPreferences.HDL_Type.get().toLowerCase() + File.separator;
    ArrayList<String> Entities = new ArrayList<String>();
    ArrayList<String> Behaviors = new ArrayList<String>();
    GetVHDLFiles(ProjectDir, SourcePath, Entities, Behaviors, AppPreferences.HDL_Type.get());
    if (MyBoardInformation.fpga.getVendor() == VendorSoftware.VendorAltera) {
        if (AlteraDownload.GenerateQuartusScript(MyReporter, ProjectDir + HDLPaths[ScriptPath] + File.separator, RootSheet.getNetList(), MyMappableResources, MyBoardInformation, Entities, Behaviors, AppPreferences.HDL_Type.get())) {
            AlteraDownload.Download(ProjectDir + HDLPaths[ScriptPath] + File.separator, SourcePath, ProjectDir + HDLPaths[SandboxPath] + File.separator, MyReporter);
        }
    } else if (MyBoardInformation.fpga.getVendor() == VendorSoftware.VendorXilinx) {
        if (XilinxDownload.GenerateISEScripts(MyReporter, ProjectDir, ProjectDir + HDLPaths[ScriptPath] + File.separator, ProjectDir + HDLPaths[UCFPath] + File.separator, RootSheet.getNetList(), MyMappableResources, MyBoardInformation, Entities, Behaviors, AppPreferences.HDL_Type.get(), writeToFlash.isSelected()) && !generateOnly) {
            XilinxDownload.Download(MyBoardInformation, ProjectDir + HDLPaths[ScriptPath] + File.separator, ProjectDir + HDLPaths[UCFPath] + File.separator, ProjectDir, ProjectDir + HDLPaths[SandboxPath] + File.separator, MyReporter);
        }
    } else if (MyBoardInformation.fpga.getVendor() == VendorSoftware.VendorVivado) {
        if (VivadoDownload.GenerateScripts(MyReporter, ProjectDir, ProjectDir + HDLPaths[ScriptPath] + File.separator, ProjectDir + HDLPaths[XDCPath] + File.separator, ProjectDir + HDLPaths[SandboxPath] + File.separator, RootSheet.getNetList(), MyMappableResources, MyBoardInformation, Entities, Behaviors, AppPreferences.HDL_Type.get(), writeToFlash.isSelected()) && !generateOnly) {
            VivadoDownload.Download(ProjectDir + HDLPaths[ScriptPath] + File.separator, ProjectDir + HDLPaths[SandboxPath] + File.separator, MyReporter, downloadOnly);
        }
    }
}
Also used : LogisimFile(com.cburch.logisim.file.LogisimFile) ArrayList(java.util.ArrayList) Circuit(com.cburch.logisim.circuit.Circuit)

Example 28 with Circuit

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

the class InstancePainter method isPortConnected.

public boolean isPortConnected(int index) {
    Circuit circ = context.getCircuit();
    Location loc = comp.getEnd(index).getLocation();
    return circ.isConnected(loc, comp);
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit) Location(com.cburch.logisim.data.Location)

Example 29 with Circuit

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

the class ProjectCircuitActions method doAddCircuit.

public static void doAddCircuit(Project proj) {
    String name = promptForCircuitName(proj.getFrame(), proj.getLogisimFile(), "");
    if (name != null) {
        JLabel error = null;
        /* Checking for valid names */
        if (name.isEmpty()) {
            error = new JLabel(Strings.get("circuitNameMissingError"));
        } else if (!SyntaxChecker.isVariableNameAcceptable(name, false)) {
            error = new JLabel("\"" + name + "\": " + Strings.get("circuitNameInvalidName"));
        } else if (CorrectLabel.IsKeyword(name, false)) {
            error = new JLabel("\"" + name + "\": " + Strings.get("circuitNameKeyword"));
        } else if (NameIsInUse(proj, name)) {
            error = new JLabel("\"" + name + "\": " + Strings.get("circuitNameExists"));
        }
        if (error != null) {
            JOptionPane.showMessageDialog(proj.getFrame(), error, Strings.get("circuitCreateTitle"), JOptionPane.ERROR_MESSAGE);
        } else {
            Circuit circuit = new Circuit(name, proj.getLogisimFile(), proj);
            proj.doAction(LogisimFileActions.addCircuit(circuit));
            proj.setCurrentCircuit(circuit);
        }
    }
}
Also used : JLabel(javax.swing.JLabel) Circuit(com.cburch.logisim.circuit.Circuit)

Example 30 with Circuit

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

the class BuildCircuitButton method performAction.

private void performAction(Project dest, String name, boolean replace, final boolean twoInputs, final boolean useNands) {
    if (replace) {
        final Circuit circuit = dest.getLogisimFile().getCircuit(name);
        if (circuit == null) {
            JOptionPane.showMessageDialog(parent, "Internal error prevents replacing circuit.", "Internal Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs, useNands);
        dest.doAction(xn.toAction(Strings.getter("replaceCircuitAction")));
    } else {
        // add the circuit
        Circuit circuit = new Circuit(name, dest.getLogisimFile(), dest);
        CircuitMutation xn = CircuitBuilder.build(circuit, model, twoInputs, useNands);
        xn.execute();
        dest.doAction(LogisimFileActions.addCircuit(circuit));
        dest.setCurrentCircuit(circuit);
    }
}
Also used : CircuitMutation(com.cburch.logisim.circuit.CircuitMutation) Circuit(com.cburch.logisim.circuit.Circuit)

Aggregations

Circuit (com.cburch.logisim.circuit.Circuit)62 Component (com.cburch.logisim.comp.Component)19 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)12 Project (com.cburch.logisim.proj.Project)11 ArrayList (java.util.ArrayList)9 Wire (com.cburch.logisim.circuit.Wire)8 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)8 Location (com.cburch.logisim.data.Location)8 Bounds (com.cburch.logisim.data.Bounds)6 LogisimFile (com.cburch.logisim.file.LogisimFile)6 AddTool (com.cburch.logisim.tools.AddTool)6 Tool (com.cburch.logisim.tools.Tool)6 CircuitState (com.cburch.logisim.circuit.CircuitState)5 AttributeSet (com.cburch.logisim.data.AttributeSet)5 Selection (com.cburch.logisim.gui.main.Selection)5 Action (com.cburch.logisim.proj.Action)4 CircuitMutation (com.cburch.logisim.circuit.CircuitMutation)3 ComponentDrawContext (com.cburch.logisim.comp.ComponentDrawContext)3 Graphics (java.awt.Graphics)3 CanvasObject (com.cburch.draw.model.CanvasObject)2