--- /dev/null
+#ifndef COLOR_H
+#define COLOR_H
+
+//
+//taken from
+//http://www.velocityreviews.com/forums/t279115-design-question-a-little-c-header-for-colorizing-text-in-linux-comments-ideas.html
+
+#include <iostream>
+using namespace std;
+
+enum ColorName
+{
+ black,
+ red,
+ green,
+ brown,
+ blue,
+ magenta,
+ cyan,
+ gray,
+
+ darkgray,
+ lightred,
+ lightgreen,
+ yellow,
+ lightblue,
+ lightmagenta,
+ lightcyan,
+ white
+};
+
+
+struct color
+{
+ color(ColorName f = white, ColorName b = black) : fore(f), back(b) {}
+
+ ColorName fore;
+ ColorName back;
+};
+
+
+inline ostream& operator<<(ostream& o, const color& c)
+{
+ o << "\033[";
+
+ if(c.back != black) {
+ o << "4" << c.back << ";";
+ }
+ else {
+ o << "0;";
+ }
+
+ if(c.fore > gray) {
+ // bold color
+ o << "1;3" << c.fore - gray - 1;
+ }
+ else {
+ o << "0;3" << c.fore ;
+ }
+
+ return o << "m";
+
+}
+
+#endif
throw string("Out of Instructions!");
}
if(this->conditionMet(instr->getCondition())) {
- cout << "Executing: " << instr->toString() << endl;
+ cout << color(green,black) << "Executing: " << color(white,black) << instr->toString() << endl;
instr->execInstr();
this->incPerfBy(instr->getClockCount());
}
else {
- cout << "Didn't Execute " << instr->toString() << "; condition wasn't met" << endl;
+ cout << color(red,black) << "Didn't Execute " << color(white,black) << instr->toString() << "; condition wasn't met" << endl;
this->incPerf();
}
#include "cmem.hpp"
#include "cpmem.hpp"
+#include "ccolor.h"
+
class Iinstr;
#include "Iinstr.hpp"
}
else {
ignoreBreak = true;
- cout << "Breakpoint 0x" << std::hex << setw(8) << setfill('0') << *breakp << std::hex << " hit" << endl;
+ cout << color(white,red) << "Breakpoint" << color(white,black) << " 0x" << std::hex << setw(8) << setfill('0') << *breakp << std::hex << " hit" << endl;
break;
}
}
}
else {
ignoreBreak = true;
- cout << "Breakpoint 0x" << std::hex << setw(8) << setfill('0') << *breakp << std::hex << " hit" << endl;
+ cout << color(white,red) << "Breakpoint" << color(white,black) << " 0x" << std::hex << setw(8) << setfill('0') << *breakp << std::hex << " hit" << endl;
return;
}
}
--- /dev/null
+../3b_sim/ccolor.h
\ No newline at end of file