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);
}
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);
}
}
}
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);
}
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);
}
}
}
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);
}
}
Aggregations