00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00020 #ifndef __RT_PROFILE__
00021 #define __RT_PROFILE__
00022
00023 #include "robfrontend.h"
00024 #include "robmanage.h"
00025 #include "robbase.h"
00026
00027 #include <rtsystem.h>
00028 #include <rtstreams.h>
00029
00030 using namespace lrt;
00031
00032 namespace rt {
00033
00035 enum ProfileMode {
00036 profCount,
00037 profTime,
00038 profFailure
00039 };
00040
00042 class ProfilePlugin : public FrontendPlugin
00043 {
00044 public:
00045 virtual FpInterpretePos getInterpretePos();
00046 virtual String getName();
00047 virtual String getHelpText();
00048 virtual bool interpreteParams(const Array<String>& params, Array<bool>& used);
00049 virtual void fillOptions(SimOptions& options);
00050
00052 ProfileMode getMode() { return mode; }
00055 void setMode(ProfileMode m) { mode = m; }
00056
00057 ProfilePlugin(Frontend* parent);
00058 ~ProfilePlugin() {}
00059 private:
00060 ProfileMode mode;
00061 };
00062
00063 struct ProfileBankData {
00064 String name;
00065 Map<Instr*, unsigned int> data;
00066 };
00067
00068 typedef Map< Bank*, ProfileBankData > ProfileMap;
00069
00070 class ProfileSupervisor : public ExecSupervisor
00071 {
00072 public:
00073 ProfileSupervisor(Frontend* parent, ProfileMode mode);
00074 virtual void initSim(Simulation* const curSim);
00075 virtual void onExec(Instr* instr, Bank* bank, Task* task);
00076 virtual void exitSim(Simulation* const curSim);
00077 private:
00078 enum trool {
00079 trError = -1,
00080 trFalse = 0,
00081 trTrue = 1
00082 };
00083
00084 ProfileMap profData;
00085 void printProgram(Program*);
00086 void printHtml(const String& profFileName);
00087 void printInstrs(Bank*, OutputStream* out);
00088
00089 bool isReachable(Bank*, const String& name, Simulation*);
00090
00091
00092
00093
00094
00095 trool detectFailure(Instr* instr, Bank* bank, Task* task);
00096
00097 ProfileMode mode;
00098 Frontend* parent;
00099 };
00100
00101 }
00102
00103 #endif
00104