Go to the documentation of this file.
50 #include "tce_config.h"
96 if (arguments.size() < 2) {
102 string opName = arguments[1].stringValue();
115 obj->
setString(
"unknown operation \"" + opName +
"\"");
121 vector<DataObject> inputs;
122 for (
size_t i = 2; i < arguments.size(); i++) {
123 inputs.push_back(arguments[i]);
126 vector<SimValue*> args;
135 if (!simulator.
simulateTrigger(*op, inputs, args, opContext, result)) {
136 for (
unsigned int i = 0; i < args.size(); i++) {
147 string output =
context.toOutputFormat(current);
151 if (i < op->numberOfOutputs() - 1) {
157 for (
unsigned int i = 0; i < args.size(); i++) {
176 return "trigger <operation> <operand>...";
216 if (arguments.size() != 2) {
217 result->
setString(
"wrong number of arguments");
222 string opName = arguments[1].stringValue();
227 result->
setString(
"unknown operation \"" + opName +
"\"");
249 return "Resets the state of the operation.\n\n"
250 "!reset <command name>";
300 if (arguments.size() != 2) {
301 result->
setString(
"wrong number of arguments");
306 string outputFormat = arguments[1].stringValue();
320 context.setOutputFormat(outputFormat);
324 result->
setString(
"illegal output format \"" +
347 "Changes the format of the output between "
348 "int, double, float, bin and hex.\n"
414 irfStartStorage_(0), branchDelayCycles_(3),
415 outputFormat_(
CmdOutput::OUTPUT_FORMAT_INT_SIGNED),
416 opContext_(NULL, programCounterStorage_, returnAddressStorage_,
417 branchDelayCycles_) {
492 value->
width() > 64) {
582 if (arguments.size() != 1) {
583 result->
setString(
"wrong number of arguments");
603 return "exits the program";
649 if (arguments.size() != 2) {
650 result->
setString(
"wrong number of arguments");
655 string registerValue = arguments[1].stringValue();
666 output =
context.toOutputFormat(&value);
671 output =
context.toOutputFormat(&value);
673 result->
setString(
"illegal register name \"" +
674 registerValue +
"\"");
692 "Prints the contents of the register. Register is one of the "
742 if (arguments.size() != 3) {
743 result->
setString(
"wrong number of arguments");
748 string size = arguments[1].stringValue();
755 result->
setString(
"invalid memory size: " + size);
766 string addressString = arguments[2].stringValue();
771 result->
setString(
"illegal address: " + addressString);
786 memory.
read(address, 1, resultInt);
787 resultValue = resultInt;
791 memory.
read(address, 2, resultInt);
792 resultValue = resultInt;
796 memory.
read(address, 4, resultInt);
797 resultValue = resultInt;
803 memory.
readBE(address, result);
804 resultValue = result;
808 result->
setString(
"address " + addressString +
" out of memory bounds");
812 string output =
context.toOutputFormat(&resultValue);
826 "Prints the contents of the memory.\n"
827 "!mem <size> <address>\n"
828 "size is one of the following:\n{" +
873 if (arguments.size() != 1) {
874 result->
setString(
"wrong number of arguments");
884 context.operationContext().advanceClock();
897 return "Advances clock per one cycle";
921 cout <<
"test_osal - OSAL Tester "
930 string helpText =
"test_osal\n\tcommands:\n";
931 helpText +=
"\t<operation> param...: Executes operation with parameters.\n";
932 helpText +=
"\t!quit: Quits the execution of the program.\n";
933 cout << helpText << endl;
942 int main(
int argc,
char* argv[]) {
966 interpreter.
initialize(argc, argv, &context, reader);
985 string command =
"trigger ";
988 if (token.substr(token.size() - 1) ==
";") {
990 command += token.substr(0, token.size() - 1);
992 command =
"trigger ";
994 command += token +
" ";
1003 string command =
"";
1006 while (testCont.
cont()) {
1014 if (command ==
"") {
1017 if (command.find(
"!") == string::npos) {
1018 command =
"trigger " + command;
1020 command = command.substr(1, command.length());
1028 return EXIT_SUCCESS;
1040 bool succeeded = interpreter.
interpret(command);
1041 if (interpreter.
result() !=
"") {
1045 cout << interpreter.
result() << endl;
virtual bool execute(const std::vector< DataObject > &arguments)
virtual bool execute(const std::vector< DataObject > &arguments)
void setMemory(Memory *memory)
static LineReader * lineReader()
void setBitWidth(int width)
Operation & operation(const char *name)
virtual std::string helpText() const
UInt32 InstructionAddress
int main(int argc, char *argv[])
std::string toOutputFormat(SimValue *value)
SimValue & returnAddress()
DoubleWord doubleWordValue() const
SLongWord sLongWordValue() const
virtual ~OsalInterpreter()
virtual bool execute(const std::vector< DataObject > &arguments)
virtual std::string result()
virtual int numberOfArguments() const
Operation * operation_
Last loaded operation.
virtual InterpreterContext & context() const
static const std::string OUTPUT_FORMAT_DOUBLE
void setOutputFormat(std::string outputFormat)
static const std::string OUTPUT_FORMAT_BIN
virtual int numberOfInputs() const
virtual void initialize(int argc, char *argv[], InterpreterContext *context, LineReader *reader)
std::string outputFormat_
Indicates which output format is used currently.
InterpreterContext * context() const
virtual ~CmdAdvanceClock()
static const std::string MEM_DOUBLE_WORD
Name for double word memory access.
virtual void readBE(ULongWord address, int size, ULongWord &data)
static const std::string OUTPUT_FORMAT_HALF
static NullOperation & instance()
virtual TCEString name() const
static std::string toString(const T &source)
virtual void createState(OperationContext &context) const
virtual std::string readLine(std::string prompt="")=0
bool continue_
Flag indicating whether program can continue or not.
#define assert(condition)
virtual std::string helpText() const
OperationContext opContext_
The operation context shared with all operations invoked in the application.
virtual std::string helpText() const
virtual ~OsalCmdLineOptions()
virtual bool execute(const std::vector< DataObject > &arguments)
static const std::string MEM_BYTE
Name for byte memory access.
Operation & operation(const std::string &name)
FloatWord floatWordValue() const
OperationContext & operationContext()
OperationPool * pool_
Used to load operations.
bool simulateTrigger(Operation &op, std::vector< DataObject > inputs, std::vector< SimValue * > &outputs, OperationContext &context, std::string &result)
ULongWord uLongWordValue() const
virtual bool execute(const std::vector< DataObject > &arguments)
virtual Memory::MAU read(ULongWord address)=0
static const std::string OUTPUT_FORMAT_FLOAT
static const std::string OUTPUT_FORMAT_HEX
void executeCommand(OsalInterpreter &interpreter, string command)
std::string errorMessage() const
void parse(char *argv[], int argc)
TCEString hexValue(bool noHexIdentifier=false) const
ScriptInterpreter * interpreter() const
virtual void setResult(DataObject *result)
static MachInfoCmdLineOptions options
virtual bool execute(const std::vector< DataObject > &arguments)
virtual void advanceClock()
InstructionAddress & programCounter()
static const std::string MEM_HALF_WORD
Name for half word memory access.
TCEString binaryValue() const
virtual void deleteState(OperationContext &context) const
virtual void printVersion() const
InstructionAddress & programCounter()
virtual bool execute(const std::vector< DataObject > &arguments)
virtual void initialize(std::string defPrompt="", FILE *in=stdin, FILE *out=stdout, FILE *err=stderr)=0
static const std::string OUTPUT_FORMAT_LONG_SIGNED
virtual std::string helpText() const
static const std::string OUTPUT_FORMAT_LONG_UNSIGNED
virtual std::string helpText() const
virtual OperationBehavior & behavior() const
static const std::string MEM_WORD
Name for word memory access.
virtual std::string helpText() const
virtual bool interpret(const std::string &commandLine)
static int toInt(const T &source)
static const std::string REGISTER_PROGRAM_COUNTER
virtual void printHelp() const
static const std::string REGISTER_RETURN_ADDRESS
virtual void setString(std::string value)
virtual std::string helpText() const
virtual std::string argument(int index) const
static std::string TCEVersionString()
std::string outputFormat() const
static const std::string OUTPUT_FORMAT_INT_SIGNED
virtual int numberOfOutputs() const
SimValue & returnAddress()
virtual void addCustomCommand(CustomCommand *command)
static const std::string OUTPUT_FORMAT_INT_UNSIGNED
static OperationSimulator & instance()
HalfFloatWord halfFloatWordValue() const