42 #include <boost/regex.hpp>
44 #include "boost/tuple/tuple.hpp"
120 virtual bool execute(
const std::vector<DataObject>& arguments) {
122 if (!
parent().checkProgramLoaded()) {
126 const int argumentCount = arguments.size() - 2;
127 if (!
parent().checkArgumentCount(argumentCount, 1, 2)) {
131 std::string registerFile =
"";
132 std::string registerName =
"";
133 std::string registerString =
"";
134 int registerIndex = -1;
136 if (argumentCount == 1) {
147 registerFile = arguments[2].stringValue();
151 parent().simulatorFrontend().registerFileValue(registerFile));
160 }
else if (argumentCount == 2) {
162 if (!
parent().checkPositiveIntegerArgument(arguments[3])) {
165 registerFile = arguments[2].stringValue();
166 registerIndex = arguments[3].integerValue();
176 parent().simulatorFrontend().registerFileValue(
177 registerFile, registerIndex));
196 const std::string& regName,
198 return regName +
" " + value.
hexValue() +
" " +
234 virtual bool execute(
const std::vector<DataObject>& arguments) {
236 if (!
parent().checkProgramLoaded()) {
240 const int argumentCount = arguments.size() - 2;
242 if (!
parent().checkArgumentCount(argumentCount, 1, 2)) {
246 const std::string unitName = arguments[2].stringValue();
249 if (!navigator.
hasItem(unitName)) {
256 if (argumentCount == 1) {
257 std::string output =
"";
258 bool firstReg =
true;
260 for (
int i = 0; i < navigator.
count(); ++i) {
266 immediateUnitRegisterValue(unitName, i);
268 const std::string registerName =
272 registerName, value);
278 }
else if (argumentCount == 2) {
280 if (!
parent().checkPositiveIntegerArgument(arguments[3])) {
283 int registerIndex = arguments[3].integerValue();
286 immediateUnitRegisterValue(unitName, registerIndex);
329 virtual bool execute(
const std::vector<DataObject>& arguments) {
331 const int argumentCount = arguments.size() - 2;
333 if (!
parent().checkArgumentCount(argumentCount, 0, 0)) {
336 if (!
parent().checkMachineLoaded()) {
343 std::string result =
"";
345 for (
int i = 0; i < nav.
count(); ++i) {
348 result += nav.
item(i)->name();
383 virtual bool execute(
const std::vector<DataObject>& arguments) {
385 const int argumentCount = arguments.size() - 2;
387 if (!
parent().checkArgumentCount(argumentCount, 0, 0)) {
390 if (!
parent().checkMachineLoaded()) {
397 std::string result =
"";
399 for (
int i = 0; i < nav.
count(); ++i) {
402 result += nav.
item(i)->name();
436 virtual bool execute(
const std::vector<DataObject>& arguments) {
438 const int argumentCount = arguments.size() - 2;
440 if (!
parent().checkArgumentCount(argumentCount, 0, 1)) {
446 if (argumentCount == 0) {
449 std::string result =
"";
451 for (
int i = 0; i < nav.
count(); ++i) {
456 result += bus->
name() +
": ";
457 bool isFirstSegment =
true;
462 isFirstSegment =
false;
468 }
else if (argumentCount == 1) {
471 const std::string busName = arguments.at(2).stringValue();
482 std::string result =
"";
483 result += bus->
name() +
": ";
484 bool isFirstSegment =
true;
489 isFirstSegment =
false;
524 virtual bool execute(
const std::vector<DataObject>& arguments) {
526 const int argumentCount = arguments.size() - 2;
528 if (!
parent().checkMachineLoaded()) {
532 if (!
parent().checkArgumentCount(argumentCount, 1, 2)) {
538 const std::string functionUnit = arguments.at(2).stringValue();
544 if (nav.
hasItem(functionUnit)) {
545 fu = nav.
item(functionUnit);
557 if (argumentCount == 1) {
558 std::string result =
"";
560 for (
int i = 0; i < fu->
portCount(); ++i) {
563 std::string portName = fu->
port(i)->
name();
566 functionUnit, portName);
573 }
else if (argumentCount == 2) {
574 const std::string portName = arguments.at(3).stringValue();
578 functionUnit, portName);
618 virtual bool execute(
const std::vector<DataObject>& arguments) {
620 const int argumentCount = arguments.size() - 2;
622 if (!
parent().checkArgumentCount(argumentCount, 1, 2)) {
625 if (!
parent().checkMachineLoaded()) {
631 const std::string busName = arguments.at(2).stringValue();
647 if (argumentCount == 1) {
648 std::string result =
"";
652 }
else if (argumentCount == 2) {
654 "Segmented busses not yet supported.");
689 virtual bool execute(
const std::vector<DataObject>& arguments) {
691 const int argumentCount = arguments.size() - 2;
693 if (!
parent().checkArgumentCount(argumentCount, 0, 0)) {
696 if (!
parent().checkMachineLoaded()) {
703 std::string result =
"";
705 for (
int i = 0; i < nav.
count(); ++i) {
708 result += nav.
item(i)->name();
742 virtual bool execute(
const std::vector<DataObject>& arguments) {
744 if (!
parent().checkSimulationEnded() &&
745 !
parent().checkSimulationInitialized() &&
746 !
parent().checkSimulationStopped() &&
747 !
parent().simulatorFrontend().isSimulationRunning()) {
752 const int argumentCount = arguments.size() - 2;
754 if (!
parent().checkArgumentCount(argumentCount, 1, 1)) {
758 const std::string command =
761 if (command ==
"cycles") {
763 (boost::format(
"%.0f") %
764 parent().simulatorFrontend().cycleCount()).str());
766 }
else if (command ==
"stats") {
767 std::stringstream result;
777 <<
"utilizations" << std::endl
778 <<
"------------" << std::endl;
780 const int COLUMN_WIDTH = 15;
783 std::set<std::string> operationsOfMachine;
786 << std::endl <<
"buses:" << std::endl << std::endl;
791 for (
int i = 0; i < busNav.
count(); ++i) {
798 << std::left << std::setw(COLUMN_WIDTH)
799 << bus->
name() <<
" "
800 << std::left << std::setw(COLUMN_WIDTH)
808 <<
"sockets:" << std::endl << std::endl;
812 for (
int i = 0; i < socketNav.
count(); ++i) {
819 << std::left << std::setw(COLUMN_WIDTH)
820 << socket->
name() <<
" "
821 << std::left << std::setw(COLUMN_WIDTH)
829 <<
"operations executed in function units:"
830 << std::endl << std::endl;
834 for (
int i = 0; i <= fuNav.
count(); ++i) {
836 if (i < fuNav.
count())
845 << fu->
name() <<
":" << std::endl;
850 const std::string operationUpper =
852 operationsOfMachine.insert(operationUpper);
855 fu->
name(), operationUpper);
858 << std::left << std::setw(COLUMN_WIDTH)
859 << operationUpper <<
" "
860 << std::left << std::setw(COLUMN_WIDTH)
862 executions * 100.0 / totalTriggersOfFU) +
869 << std::left << std::setw(COLUMN_WIDTH)
871 << std::left << std::setw(COLUMN_WIDTH)
873 totalTriggersOfFU * 100.0 / totalCycles) +
"% (" +
875 " triggers)" << std::endl << std::endl;
882 const std::string operationUpper =
884 operationsOfMachine.insert(operationUpper);
888 << std::endl <<
"operations:" << std::endl << std::endl;
890 for (std::set<std::string>::iterator i =
891 operationsOfMachine.begin(); i !=
892 operationsOfMachine.end(); ++i) {
897 << std::left << std::setw(COLUMN_WIDTH)
898 << *i <<
" " << std::left << std::setw(COLUMN_WIDTH)
906 <<
"FU port guard accesses:" << std::endl;
912 for (UtilizationStats::FUOperationUtilizationIndex::iterator i =
913 fuGuardAccesses.begin(); i != fuGuardAccesses.end(); ++i) {
915 std::string fuName = i->first;
923 for (UtilizationStats::ComponentUtilizationIndex::iterator j =
924 i->second.begin(); j != i->second.end(); ++j) {
925 std::string fuPort = j->first;
930 << std::left << std::setw(COLUMN_WIDTH)
939 <<
"register accesses:" << std::endl
944 for (
int i = 0; i < rfNav.
count(); ++i) {
949 << rf->
name() <<
":" << std::endl;
951 int regsUsedInFile = 0;
958 for (
int reg = 0; reg <= lastReg; ++reg) {
964 totalGuards += guardReads;
967 totalWrites += writes;
970 << std::left << std::setw(COLUMN_WIDTH)
972 << std::left << std::setw(COLUMN_WIDTH)
974 << std::left << std::setw(COLUMN_WIDTH + 5)
976 << std::left << std::setw(COLUMN_WIDTH)
982 << std::left << std::setw(COLUMN_WIDTH)
984 << std::left << std::setw(COLUMN_WIDTH)
986 << std::left << std::setw(COLUMN_WIDTH + 5)
988 << std::left << std::setw(COLUMN_WIDTH)
993 <<
"TOTAL " << regsUsedInFile <<
" registers used"
994 << std::endl << std::endl;
999 <<
"immediate unit accesses:" << std::endl
1004 for (
int i = 0; i < iuNav.
count(); ++i) {
1009 << iu->
name() <<
":" << std::endl;
1011 int usedRegCount = 0;
1015 for (
int reg = 0; reg <= lastReg; ++reg) {
1022 << std::left << std::setw(COLUMN_WIDTH)
1024 << std::left << std::setw(COLUMN_WIDTH)
1026 << std::left << std::setw(COLUMN_WIDTH)
1031 <<
"TOTAL " << usedRegCount <<
" registers used"
1032 << std::endl << std::endl;
1036 if (
parent().simulatorFrontend().rfAccessTracing()) {
1044 <<
"register file accesses" << std::endl
1045 <<
"----------------------" << std::endl;
1047 const int COL_WIDTH = 20;
1050 << std::left << std::setw(COL_WIDTH)
1052 << std::left << std::setw(COL_WIDTH)
1054 << std::left << std::setw(COL_WIDTH)
1056 << std::left << std::setw(COL_WIDTH)
1057 <<
"count" << std::endl;
1059 RFAccessTracker::ConcurrentRFAccessIndex::
1065 << std::left << std::setw(COL_WIDTH)
1066 << (*i).first.get<0>()
1067 << std::left << std::setw(COL_WIDTH)
1068 << (*i).first.get<1>()
1069 << std::left << std::setw(COL_WIDTH)
1070 << (*i).first.get<2>()
1071 << std::left << std::setw(COL_WIDTH)
1072 << (*i).second << std::endl;
1081 }
else if (command ==
"mapping") {
1086 for (
int i = 0; i < nav.
count(); ++i) {
1088 unsigned int sizeOfSpace = space.
end() - space.
start();
1090 << std::left << std::setw(15)
1096 <<
" (" << sizeOfSpace <<
" ";
1097 if (space.
width() == 8) {
1101 <<
"words of size " << space.
width() <<
" bits";
1141 virtual bool execute(
const std::vector<DataObject>& arguments) {
1142 if (!
parent().checkSimulationEnded() &&
1143 !
parent().checkSimulationInitialized() &&
1144 !
parent().checkSimulationStopped() &&
1145 !
parent().simulatorFrontend().isSimulationRunning()) {
1149 const int argumentCount = arguments.size() - 2;
1151 if (!
parent().checkArgumentCount(argumentCount, 1, 1)) {
1155 const std::string command =
1174 if (command ==
"executed_operations") {
1175 for (
int i = 0; i <= fuNav.
count(); ++i) {
1177 if (i < fuNav.
count())
1191 static_cast<double>(totalOperationExecutions));
1193 }
else if (command ==
"register_reads") {
1194 for (
int i = 0; i < rfNav.
count(); ++i) {
1200 for (
int reg = 0; reg <= lastReg; ++reg) {
1205 static_cast<double>(totalRegisterReads));
1208 }
else if (command ==
"register_writes") {
1209 for (
int i = 0; i < rfNav.
count(); ++i) {
1215 for (
int reg = 0; reg <= lastReg; ++reg) {
1220 static_cast<double>(totalRegisterWrites));
1260 virtual bool execute(
const std::vector<DataObject>& arguments) {
1261 const int argumentCount = arguments.size() - 2;
1263 if (argumentCount == 0) {
1265 if (
parent().simulatorFrontend().isSimulationStopped()) {
1272 }
else if (
parent().simulatorFrontend().hasSimulationEnded()) {
1276 }
else if (
parent().simulatorFrontend().isSimulationRunning()) {
1278 "It should not be possible to do this while "
1279 "simulation is running!");
1280 }
else if (
parent().simulatorFrontend().isSimulationInitialized()) {
1289 }
else if (argumentCount == 3) {
1291 if (!
parent().simulatorFrontend().isProgramLoaded()) {
1298 const std::string command =
1301 if (command ==
"is_instruction_reference") {
1303 const int addr = arguments[3].integerValue();
1304 const int move = arguments[4].integerValue();
1305 if (
parent().simulatorFrontend().
program().instructionAt(addr).
1306 move(move).source().isInstructionAddress()) {
1314 string msg =
"Instruction address and move index parameters "
1315 "must be integers.";
1319 string msg =
"Instruction address not found.";
1323 string msg =
"Move slot not found.";
1328 "Unexpected exception in 'info program "
1329 "is_instruction_reference' command!");
1338 if (!(
parent().checkArgumentCount(argumentCount, 0, 0) ||
1339 parent().checkArgumentCount(argumentCount, 3, 3))) {
1376 virtual bool execute(
const std::vector<DataObject>& arguments) {
1377 const int argumentCount = arguments.size() - 2;
1378 if (!
parent().checkArgumentCount(argumentCount, 0, 1)) {
1382 if (argumentCount == 1 &&
1383 !
parent().checkPositiveIntegerArgument(arguments[2])) {
1387 if (!
parent().checkSimulationEnded() &&
1388 !
parent().checkSimulationStopped() &&
1389 !
parent().checkSimulationInitialized()) {
1393 if (argumentCount == 1) {
1394 unsigned int breakpointHandle =
1395 static_cast<unsigned int>(arguments[2].integerValue());
1417 isCompiledSimulation_(isCompiledSimulation) {
1461 SubCommandMap::iterator subCommandPosition =
1471 assert((*subCommandPosition).second != NULL);
1474 return subCommand.
execute(arguments);