rom address is send back to assembler via TCP/IP interface

This commit is contained in:
hneemann 2016-12-16 20:02:27 +01:00
parent 0166fba015
commit ea86dd1b93
5 changed files with 76 additions and 34 deletions

View File

@ -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
*/

View File

@ -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);

View File

@ -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;

View File

@ -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,9 +1020,10 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
}
@Override
public void doSingleStep() {
public String doSingleStep() throws RemoteException {
if (model != null && !realtimeClockRunning) {
SwingUtilities.invokeLater(() -> {
try {
SwingUtilities.invokeAndWait(() -> {
ArrayList<Clock> cl = model.getClocks();
if (cl.size() == 1) {
ObservableValue clkVal = cl.get(0).getClockOutput();
@ -1038,20 +1040,37 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, 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(() -> {
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);
}

View File

@ -31,34 +31,35 @@ public class DigitalHandler implements HandlerInterface {
}
try {
handle(command.toLowerCase(), args);
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));
}