Add batch (no input thread) mode to emulator.
This commit is contained in:
@@ -207,7 +207,7 @@ int disasm_main(int argc, char **argv) {
|
|||||||
|
|
||||||
int emu_main(int argc, char **argv) {
|
int emu_main(int argc, char **argv) {
|
||||||
string archString("8w32/32/8/8"), imgFileName("a.out.bin");
|
string archString("8w32/32/8/8"), imgFileName("a.out.bin");
|
||||||
bool showHelp, showStats, basicMachine;
|
bool showHelp, showStats, basicMachine, batch;
|
||||||
|
|
||||||
/* Read the command line arguments. */
|
/* Read the command line arguments. */
|
||||||
CommandLineArgFlag fh("-h", "--help", "", showHelp);
|
CommandLineArgFlag fh("-h", "--help", "", showHelp);
|
||||||
@@ -215,6 +215,7 @@ int emu_main(int argc, char **argv) {
|
|||||||
CommandLineArgSetter<string>fa("-a", "--arch", "", archString);
|
CommandLineArgSetter<string>fa("-a", "--arch", "", archString);
|
||||||
CommandLineArgFlag fs("-s", "--stats", "", showStats);
|
CommandLineArgFlag fs("-s", "--stats", "", showStats);
|
||||||
CommandLineArgFlag fb("-b", "--basic", "", basicMachine);
|
CommandLineArgFlag fb("-b", "--basic", "", basicMachine);
|
||||||
|
CommandLineArgFlag fi("-i", "--batch", "", batch);
|
||||||
|
|
||||||
CommandLineArg::readArgs(argc, argv);
|
CommandLineArg::readArgs(argc, argv);
|
||||||
|
|
||||||
@@ -240,7 +241,7 @@ int emu_main(int argc, char **argv) {
|
|||||||
Core core(arch, *dec, mu/*, ID in multicore implementations*/);
|
Core core(arch, *dec, mu/*, ID in multicore implementations*/);
|
||||||
|
|
||||||
RamMemDevice mem(imgFileName.c_str(), arch.getWordSize());
|
RamMemDevice mem(imgFileName.c_str(), arch.getWordSize());
|
||||||
ConsoleMemDevice console(arch.getWordSize(), cout, core);
|
ConsoleMemDevice console(arch.getWordSize(), cout, core, batch);
|
||||||
mu.attach(mem, 0);
|
mu.attach(mem, 0);
|
||||||
mu.attach(console, 1ll<<(arch.getWordSize()*8 - 1));
|
mu.attach(console, 1ll<<(arch.getWordSize()*8 - 1));
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ namespace HarpTools {
|
|||||||
" -c, --core <filename> RAM image\n"
|
" -c, --core <filename> RAM image\n"
|
||||||
" -a, --arch <arch string> Architecture string\n"
|
" -a, --arch <arch string> Architecture string\n"
|
||||||
" -s, --stats Print stats on exit.\n"
|
" -s, --stats Print stats on exit.\n"
|
||||||
" -b, --basic Disable virtual memory.\n",
|
" -b, --basic Disable virtual memory.\n"
|
||||||
|
" -i, --batch Disable console input.\n",
|
||||||
*asmHelp = "HARP Assembler command line arguments:\n"
|
*asmHelp = "HARP Assembler command line arguments:\n"
|
||||||
" -a, --arch <arch string>\n"
|
" -a, --arch <arch string>\n"
|
||||||
" -o, --output <filename>\n",
|
" -o, --output <filename>\n",
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Harp {
|
|||||||
class Core;
|
class Core;
|
||||||
class ConsoleMemDevice : public MemDevice {
|
class ConsoleMemDevice : public MemDevice {
|
||||||
public:
|
public:
|
||||||
ConsoleMemDevice(Size wS, std::ostream &o, Core &core);
|
ConsoleMemDevice(Size wS, std::ostream &o, Core &core, bool batch = false);
|
||||||
~ConsoleMemDevice() {}
|
~ConsoleMemDevice() {}
|
||||||
|
|
||||||
//virtual Size wordSize() const { return wordSize; }
|
//virtual Size wordSize() const { return wordSize; }
|
||||||
|
|||||||
10
src/mem.cpp
10
src/mem.cpp
@@ -187,11 +187,15 @@ void *Harp::consoleInputThread(void* arg_vp) {
|
|||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleMemDevice::ConsoleMemDevice(Size wS, std::ostream &o, Core &core) :
|
ConsoleMemDevice::ConsoleMemDevice(Size wS, std::ostream &o, Core &core,
|
||||||
|
bool batch) :
|
||||||
wordSize(wS), output(o), core(core), cBuf()
|
wordSize(wS), output(o), core(core), cBuf()
|
||||||
{
|
{
|
||||||
pthread_t *thread = new pthread_t;
|
// Create a console input thread if we are running in interactive mode.
|
||||||
pthread_create(thread, NULL, consoleInputThread, (void*)this);
|
if (!batch) {
|
||||||
|
pthread_t *thread = new pthread_t;
|
||||||
|
pthread_create(thread, NULL, consoleInputThread, (void*)this);
|
||||||
|
}
|
||||||
pthread_mutex_init(&cBufLock, NULL);
|
pthread_mutex_init(&cBufLock, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
HARPLD = ../harptool -L
|
HARPLD = ../harptool -L
|
||||||
HARPAS = ../harptool -A
|
HARPAS = ../harptool -A
|
||||||
HARPEM = ../harptool -E
|
HARPEM = ../harptool -E -i
|
||||||
HARPDIS = ../harptool -D
|
HARPDIS = ../harptool -D
|
||||||
4BARCH = 4b16/16/2/1
|
4BARCH = 4b16/16/2/1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user