mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 23:18:02 -04:00
rom address is send back to assembler via TCP/IP interface
This commit is contained in:
parent
0166fba015
commit
ea86dd1b93
@ -1,5 +1,6 @@
|
||||
package de.neemann.digital.core;
|
||||
|
||||
import de.neemann.digital.core.memory.ROM;
|
||||
import de.neemann.digital.core.wiring.Break;
|
||||
import de.neemann.digital.core.wiring.Clock;
|
||||
import de.neemann.digital.core.wiring.Reset;
|
||||
@ -43,6 +44,7 @@ public class Model implements Iterable<Node> {
|
||||
private final ArrayList<Clock> clocks;
|
||||
private final ArrayList<Break> breaks;
|
||||
private final ArrayList<Reset> resets;
|
||||
private final ArrayList<ROM> progRoms;
|
||||
|
||||
private final ArrayList<Signal> signals;
|
||||
private final ArrayList<Signal> inputs;
|
||||
@ -62,6 +64,7 @@ public class Model implements Iterable<Node> {
|
||||
this.clocks = new ArrayList<>();
|
||||
this.breaks = new ArrayList<>();
|
||||
this.resets = new ArrayList<>();
|
||||
this.progRoms = new ArrayList<>();
|
||||
this.signals = new ArrayList<>();
|
||||
this.outputs = new ArrayList<>();
|
||||
this.inputs = new ArrayList<>();
|
||||
@ -429,6 +432,15 @@ public class Model implements Iterable<Node> {
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
public void addProgRom(ROM rom) {
|
||||
progRoms.add(rom);
|
||||
}
|
||||
|
||||
public ArrayList<ROM> getProgRoms() {
|
||||
return progRoms;
|
||||
}
|
||||
|
||||
/**
|
||||
* fires a model changed event to all listeners
|
||||
*/
|
||||
|
@ -115,6 +115,9 @@ public class ROM extends Node implements Element {
|
||||
|
||||
@Override
|
||||
public void init(Model model) throws NodeException {
|
||||
if (isProgramMemory) {
|
||||
model.addProgRom(this);
|
||||
}
|
||||
if (autoLoad) {
|
||||
try {
|
||||
data = new DataField(hexFile);
|
||||
|
@ -21,30 +21,37 @@ public interface DigitalRemoteInterface {
|
||||
|
||||
/**
|
||||
* Starts the model
|
||||
*
|
||||
* @throws RemoteException RemoteException
|
||||
*/
|
||||
void start() throws RemoteException;
|
||||
|
||||
/**
|
||||
* Starts the model in debug mode
|
||||
*
|
||||
* @throws RemoteException RemoteException
|
||||
*/
|
||||
void debug() throws RemoteException;
|
||||
|
||||
/**
|
||||
* performs a single step
|
||||
*
|
||||
* @return actual position
|
||||
* @throws RemoteException RemoteException
|
||||
*/
|
||||
void doSingleStep() throws RemoteException;
|
||||
String doSingleStep() throws RemoteException;
|
||||
|
||||
/**
|
||||
* runs model to the next BRK instruction
|
||||
*
|
||||
* @return actual position
|
||||
* @throws RemoteException RemoteException
|
||||
*/
|
||||
void runToBreak() throws RemoteException;
|
||||
String runToBreak() throws RemoteException;
|
||||
|
||||
/**
|
||||
* stops the model
|
||||
*
|
||||
* @throws RemoteException RemoteException
|
||||
*/
|
||||
void stop() throws RemoteException;
|
||||
|
@ -52,6 +52,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -1019,39 +1020,57 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSingleStep() {
|
||||
public String doSingleStep() throws RemoteException {
|
||||
if (model != null && !realtimeClockRunning) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
ArrayList<Clock> cl = model.getClocks();
|
||||
if (cl.size() == 1) {
|
||||
ObservableValue clkVal = cl.get(0).getClockOutput();
|
||||
clkVal.setBool(!clkVal.getBool());
|
||||
try {
|
||||
model.doStep();
|
||||
if (clkVal.getBool()) {
|
||||
clkVal.setBool(!clkVal.getBool());
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
ArrayList<Clock> cl = model.getClocks();
|
||||
if (cl.size() == 1) {
|
||||
ObservableValue clkVal = cl.get(0).getClockOutput();
|
||||
clkVal.setBool(!clkVal.getBool());
|
||||
try {
|
||||
model.doStep();
|
||||
if (clkVal.getBool()) {
|
||||
clkVal.setBool(!clkVal.getBool());
|
||||
model.doStep();
|
||||
}
|
||||
circuitComponent.hasChanged();
|
||||
} catch (NodeException e) {
|
||||
showErrorAndStopModel(Lang.get("err_remoteExecution"), e);
|
||||
}
|
||||
circuitComponent.hasChanged();
|
||||
} catch (NodeException e) {
|
||||
showErrorAndStopModel(Lang.get("err_remoteExecution"), e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return getProgRomAddr();
|
||||
} catch (InterruptedException | InvocationTargetException e) {
|
||||
throw new RemoteException("error performing a single step "+e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getProgRomAddr() {
|
||||
ArrayList<ROM> roms = model.getProgRoms();
|
||||
if (roms.size()==1)
|
||||
return Long.toHexString(roms.get(0).getRomAddress());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runToBreak() {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (model != null && model.isFastRunModel() && !realtimeClockRunning)
|
||||
runToBreakAction.actionPerformed(null);
|
||||
});
|
||||
public String runToBreak() throws RemoteException {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (model != null && model.isFastRunModel() && !realtimeClockRunning)
|
||||
runToBreakAction.actionPerformed(null);
|
||||
});
|
||||
return getProgRomAddr();
|
||||
} catch (InterruptedException | InvocationTargetException e) {
|
||||
throw new RemoteException("error performing a run to break "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setDebug(boolean debug) throws RemoteException {
|
||||
VisualElement rom = getProgramRomFromCircuit();
|
||||
rom.getElementAttributes().set(Keys.SHOW_LISTING, debug);
|
||||
//rom.getElementAttributes().set(Keys.SHOW_LISTING, debug);
|
||||
settings.set(Keys.SHOW_DATA_TABLE, debug);
|
||||
}
|
||||
|
||||
|
@ -31,34 +31,35 @@ public class DigitalHandler implements HandlerInterface {
|
||||
}
|
||||
|
||||
try {
|
||||
handle(command.toLowerCase(), args);
|
||||
return "ok";
|
||||
String ret = handle(command.toLowerCase(), args);
|
||||
if (ret != null)
|
||||
return "ok:"+ret;
|
||||
else
|
||||
return "ok";
|
||||
} catch (RemoteException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(String command, String args) throws RemoteException {
|
||||
private String handle(String command, String args) throws RemoteException {
|
||||
switch (command) {
|
||||
case "step":
|
||||
digitalRemoteInterface.doSingleStep();
|
||||
break;
|
||||
return digitalRemoteInterface.doSingleStep();
|
||||
case "start":
|
||||
digitalRemoteInterface.start();
|
||||
break;
|
||||
return null;
|
||||
case "debug":
|
||||
digitalRemoteInterface.debug();
|
||||
break;
|
||||
return null;
|
||||
case "run":
|
||||
digitalRemoteInterface.runToBreak();
|
||||
break;
|
||||
return digitalRemoteInterface.runToBreak();
|
||||
case "stop":
|
||||
digitalRemoteInterface.stop();
|
||||
break;
|
||||
return null;
|
||||
case "load":
|
||||
File file = new File(args);
|
||||
digitalRemoteInterface.loadRom(file);
|
||||
break;
|
||||
return null;
|
||||
default:
|
||||
throw new RemoteException(Lang.get("msg_remoteUnknownCommand", command));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user