X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=3b_sim%2Fsim.cpp;h=d9cc8c2a0c2d2065b815edab5c8da4ddc92a3fbd;hb=1968f329b10681b760faec9369aa893cd2af8d44;hp=0e1a0aef071cfb6bc7b2304dcb938c2b5d29eb56;hpb=d664b832f84b5130620e78dd87c80d79ef81a139;p=calu.git diff --git a/3b_sim/sim.cpp b/3b_sim/sim.cpp index 0e1a0ae..d9cc8c2 100644 --- a/3b_sim/sim.cpp +++ b/3b_sim/sim.cpp @@ -1,3 +1,24 @@ +/* `Deep Thought', a softcore CPU implemented on a FPGA + + Copyright (C) 2010 Markus Hofstaetter + Copyright (C) 2010 Martin Perner + Copyright (C) 2010 Stefan Rebernig + Copyright (C) 2010 Manfred Schwarz + Copyright (C) 2010 Bernhard Urban + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + #include #include #include @@ -19,6 +40,9 @@ #include "iext.hpp" #include "extensions/cprog.hpp" +#include "extensions/cuart.hpp" + +#include #include "SReadline/SReadline.h" using namespace swift; @@ -89,6 +113,11 @@ bool ignoreBreak = false; bool exitProg = false; +void signalCpuBreak(int) +{ + global_cpu->breakNext(); +} + void doExit(const vector&) { exitProg = true; @@ -141,7 +170,7 @@ void execRun(const vector&) while(1) { try { auto breakp = find(breakpoints.begin(), breakpoints.end(), global_cpu->getNextPC()); - if(breakp == breakpoints.end() || ignoreBreak) { + if((breakp == breakpoints.end() || ignoreBreak) && !global_cpu->shouldBreak() ) { global_cpu->tick(); ignoreBreak = false; } @@ -455,6 +484,12 @@ void resetPerf(const vector&) global_cpu->setPerf(0); } +void applyToExtensions(const vector& in) +{ + global_cpu->applyToExtensions(in); +} + + void printStatus(const vector&) { CDat stackp = global_cpu->getStack(); @@ -540,6 +575,7 @@ int main(int argc, char* argv[]) global_cpu = &cpu; + signal(SIGINT, signalCpuBreak); Iinstr::setCPU(&cpu); Iext::setCPU(&cpu); @@ -549,6 +585,7 @@ int main(int argc, char* argv[]) Iext::setDisasm(&disasm); global_cpu->registerExtension(new Cprog()); + global_cpu->registerExtension(new Cuart()); vector commentDefer; vector labelDefer; @@ -720,7 +757,7 @@ int main(int argc, char* argv[]) Completers.push_back(CompleterElement("status",&printStatus, "Prints status of CPU.")); Completers.push_back(CompleterElement("getperf",&getPerf, "Prints performance counter.")); Completers.push_back(CompleterElement("resetperf",&resetPerf, "Resets performance counter to 0.")); - + Completers.push_back(CompleterElement("extension",&applyToExtensions, "Write to extensions.")); Reader.RegisterCompletions(Completers); string UserInput;