aboutsummaryrefslogtreecommitdiff
path: root/qtmips_cli
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_cli')
-rw-r--r--qtmips_cli/main.cpp3
-rw-r--r--qtmips_cli/reporter.cpp9
-rw-r--r--qtmips_cli/reporter.h2
3 files changed, 14 insertions, 0 deletions
diff --git a/qtmips_cli/main.cpp b/qtmips_cli/main.cpp
index e80670b..82296ed 100644
--- a/qtmips_cli/main.cpp
+++ b/qtmips_cli/main.cpp
@@ -65,6 +65,7 @@ void create_parser(QCommandLineParser &p) {
p.addOption({{"trace-hi", "tr-hi"}, "Print HI register changes."});
p.addOption({{"dump-registers", "d-regs"}, "Dump registers state at program exit."});
p.addOption({"dump-cache-stats", "Dump cache statistics at program exit."});
+ p.addOption({"dump-cycles", "Dump number of CPU cycles till program end."});
p.addOption({"dump-range", "Dump memory range.", "START,LENGTH,FNAME"});
p.addOption({"load-range", "Load memory range.", "START,FNAME"});
p.addOption({"expect-fail", "Expect that program causes CPU trap and fail if it doesn't."});
@@ -200,6 +201,8 @@ void configure_reporter(QCommandLineParser &p, Reporter &r, const SymbolTable *s
r.regs();
if (p.isSet("dump-cache-stats"))
r.cache_stats();
+ if (p.isSet("dump-cycles"))
+ r.cycles();
QStringList fail = p.values("fail-match");
for (int i = 0; i < fail.size(); i++) {
diff --git a/qtmips_cli/reporter.cpp b/qtmips_cli/reporter.cpp
index 74cbdc1..75d889b 100644
--- a/qtmips_cli/reporter.cpp
+++ b/qtmips_cli/reporter.cpp
@@ -53,6 +53,7 @@ Reporter::Reporter(QCoreApplication *app, QtMipsMachine *machine) : QObject() {
e_regs = false;
e_cache_stats = false;
+ e_cycles = false;
e_fail = (enum FailReason)0;
}
@@ -64,6 +65,10 @@ void Reporter::cache_stats() {
e_cache_stats = true;
}
+void Reporter::cycles() {
+ e_cycles = true;
+}
+
void Reporter::expect_fail(enum FailReason reason) {
e_fail = (enum FailReason)(e_fail | reason);
}
@@ -194,6 +199,10 @@ void Reporter::report() {
cout << "d-cache:stalled-cycles:" << machine->cache_data()->stalled_cycles() << endl;
cout << "d-cache:improved-speed:" << machine->cache_data()->speed_improvement() << endl;
}
+ if (e_cycles) {
+ cout << "cycles:" << machine->core()->cycles() << endl;
+ cout << "stalls:" << machine->core()->stalls() << endl;
+ }
foreach (DumpRange range, dump_ranges) {
ofstream out;
out.open(range.fname.toLocal8Bit().data(), ios::out | ios::trunc);
diff --git a/qtmips_cli/reporter.h b/qtmips_cli/reporter.h
index 5359908..bc223cb 100644
--- a/qtmips_cli/reporter.h
+++ b/qtmips_cli/reporter.h
@@ -49,6 +49,7 @@ public:
void regs(); // Report status of registers
void cache_stats();
+ void cycles();
enum FailReason {
FR_I = (1<<0), // Unsupported Instruction
@@ -78,6 +79,7 @@ private:
bool e_regs;
bool e_cache_stats;
+ bool e_cycles;
enum FailReason e_fail;
void report();