OpenASIP 2.2
Loading...
Searching...
No Matches
Functions
TestOsal.cc File Reference
#include <iostream>
#include "TestOsal.hh"
#include "Operation.hh"
#include "Conversion.hh"
#include "SimValue.hh"
#include "Application.hh"
#include "LineReader.hh"
#include "LineReaderFactory.hh"
#include "CmdHelp.hh"
#include "StringTools.hh"
#include "InterpreterContext.hh"
#include "OperationSimulator.hh"
#include "IdealSRAM.hh"
#include "BaseType.hh"
#include "TCEString.hh"
#include "tce_config.h"
#include "OperationBehavior.hh"
#include "OperationPool.hh"
Include dependency graph for TestOsal.cc:

Go to the source code of this file.

Functions

void executeCommand (OsalInterpreter &interpreter, string command)
 
int main (int argc, char *argv[])
 

Detailed Description

Implementation of test_osal.

Author
Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
Note
rating: red

Definition in file TestOsal.cc.

Function Documentation

◆ executeCommand()

void executeCommand ( OsalInterpreter interpreter,
string  command 
)

Executes given command with interpreter.

Parameters
interpreterInterpreter which executes the command.
commandThe command to be executed.
printTrue, if result is printed.

Definition at line 1039 of file TestOsal.cc.

1039 {
1040 bool succeeded = interpreter.interpret(command);
1041 if (interpreter.result() != "") {
1042 if (!succeeded) {
1043 cout << "Error: ";
1044 }
1045 cout << interpreter.result() << endl;
1046 }
1047}
virtual std::string result()
virtual bool interpret(const std::string &commandLine)

References SimpleScriptInterpreter::interpret(), and ScriptInterpreter::result().

Referenced by main().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main program.

Definition at line 942 of file TestOsal.cc.

942 {
943
945 try {
946 options.parse(argv, argc);
947 } catch (ParserStopRequest const&) {
948 return EXIT_SUCCESS;
949 } catch (const IllegalCommandLine& i) {
950 cerr << i.errorMessage() << endl;
951 return EXIT_FAILURE;
952 }
953
954 OsalInterpreter interpreter;
956 TesterContext context;
957 CmdTrigger* trigger = new CmdTrigger();
958 CmdHelp* help = new CmdHelp();
959 CmdReset* reset = new CmdReset();
960 CmdOutput* output = new CmdOutput();
961 CmdQuit* quit = new CmdQuit();
962 CmdRegister* reg = new CmdRegister();
963 CmdMem* mem = new CmdMem();
964 CmdAdvanceClock* clock = new CmdAdvanceClock();
965
966 interpreter.initialize(argc, argv, &context, reader);
967 interpreter.addCustomCommand(trigger);
968 interpreter.addCustomCommand(help);
969 interpreter.addCustomCommand(reset);
970 interpreter.addCustomCommand(output);
971 interpreter.addCustomCommand(quit);
972 interpreter.addCustomCommand(reg);
973 interpreter.addCustomCommand(mem);
974 interpreter.addCustomCommand(clock);
975 reader->initialize(">> ");
976
977 // memory is 64k bytes
978 // TODO: what endianess
979 IdealSRAM* memory = new IdealSRAM(0, 65535, 8, false);
980 context.operationContext().setMemory(memory);
981
982 if (options.numberOfArguments() > 0) {
983 // batch mode
984
985 string command = "trigger ";
986 for (int i = 1; i <= options.numberOfArguments(); i++) {
987 string token = options.argument(i);
988 if (token.substr(token.size() - 1) == ";") {
989 // an end of the command
990 command += token.substr(0, token.size() - 1);
991 executeCommand(interpreter, command);
992 command = "trigger ";
993 } else {
994 command += token + " ";
995 }
996 }
997 if (command != "") {
998 executeCommand(interpreter, command);
999 }
1000
1001 } else {
1002 // interactive mode
1003 string command = "";
1004 InterpreterContext& interpCont = interpreter.context();
1005 TesterContext& testCont = *dynamic_cast<TesterContext*>(&interpCont);
1006 while (testCont.cont()) {
1007 try {
1008 command = reader->readLine();
1009 } catch (const EndOfFile&) {
1010 interpreter.interpret("quit\n");
1011 break;
1012 }
1013 command = StringTools::trim(command);
1014 if (command == "") {
1015 continue;
1016 }
1017 if (command.find("!") == string::npos) {
1018 command = "trigger " + command;
1019 } else {
1020 command = command.substr(1, command.length());
1021 }
1022 executeCommand(interpreter, command);
1023 }
1024 }
1025 delete reader;
1026 delete memory;
1027 interpreter.finalize();
1028 return EXIT_SUCCESS;
1029}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
void executeCommand(OsalInterpreter &interpreter, string command)
Definition TestOsal.cc:1039
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::string errorMessage() const
Definition Exception.cc:123
static LineReader * lineReader()
virtual void initialize(std::string defPrompt="", FILE *in=stdin, FILE *out=stdout, FILE *err=stderr)=0
virtual std::string readLine(std::string prompt="")=0
void setMemory(Memory *memory)
virtual void finalize()
virtual void addCustomCommand(CustomCommand *command)
virtual void initialize(int argc, char *argv[], InterpreterContext *context, LineReader *reader)
virtual InterpreterContext & context() const
static std::string trim(const std::string &source)
OperationContext & operationContext()
Definition TestOsal.cc:453
bool cont() const
Definition TestOsal.cc:441

References ScriptInterpreter::addCustomCommand(), CmdLineParser::argument(), TesterContext::cont(), SimpleScriptInterpreter::context(), Exception::errorMessage(), executeCommand(), ScriptInterpreter::finalize(), SimpleScriptInterpreter::initialize(), LineReader::initialize(), SimpleScriptInterpreter::interpret(), LineReaderFactory::lineReader(), CmdLineParser::numberOfArguments(), TesterContext::operationContext(), options, CmdLineOptions::parse(), LineReader::readLine(), OperationContext::setMemory(), and StringTools::trim().

Here is the call graph for this function: