OpenASIP  2.0
TestOsal.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file TestOsal.hh
26  *
27  * Declaration of classes test_osal needs.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_TEST_OSAL_HH
34 #define TTA_TEST_OSAL_HH
35 
36 #include <string>
37 #include <vector>
38 
39 #include "CustomCommand.hh"
40 #include "Exception.hh"
41 #include "DataObject.hh"
43 #include "CmdLineOptions.hh"
44 #include "OperationContext.hh"
45 #include "SimValue.hh"
46 
47 class Operation;
48 class OperationPool;
49 
50 //////////////////////////////////////////////////////////////////////////////
51 // CmdTrigger
52 //////////////////////////////////////////////////////////////////////////////
53 
54 /**
55  * Custom command that executes the trigger command of last loaded
56  * operation.
57  */
58 class CmdTrigger : public CustomCommand {
59 public:
60  CmdTrigger();
61  explicit CmdTrigger(const CmdTrigger& cmd);
62  virtual ~CmdTrigger();
63 
64  virtual bool execute(const std::vector<DataObject>& arguments);
65  virtual std::string helpText() const;
66 };
67 
68 //////////////////////////////////////////////////////////////////////////////
69 // CmdReset
70 //////////////////////////////////////////////////////////////////////////////
71 
72 /**
73  * Custom command that executes the reset command.
74  *
75  * Reset command resets the state of the operation.
76  */
77 class CmdReset : public CustomCommand {
78 public:
79  CmdReset();
80  explicit CmdReset(const CmdReset& cmd);
81  virtual ~CmdReset();
82 
83  virtual bool execute(const std::vector<DataObject>& arguments);
84  virtual std::string helpText() const;
85 };
86 
87 //////////////////////////////////////////////////////////////////////////////
88 // CmdQuit
89 //////////////////////////////////////////////////////////////////////////////
90 
91 /**
92  * Command that quits the execution of the program.
93  */
94 class CmdQuit : public CustomCommand {
95 public:
96  CmdQuit();
97  explicit CmdQuit(const CmdQuit& cmd);
98  virtual ~CmdQuit();
99 
100  virtual bool execute(const std::vector<DataObject>& arguments);
101  virtual std::string helpText() const;
102 };
103 
104 //////////////////////////////////////////////////////////////////////////////
105 // CmdOutput
106 //////////////////////////////////////////////////////////////////////////////
107 
108 /**
109  * Custom command that executes the output command.
110  *
111  * Output command changes the format of the output. Possible output
112  * formats are decimal, binary and hexadecimal.
113  */
114 class CmdOutput : public CustomCommand {
115 public:
116 
117  static const std::string OUTPUT_FORMAT_INT_SIGNED;
118  static const std::string OUTPUT_FORMAT_INT_UNSIGNED;
119  static const std::string OUTPUT_FORMAT_LONG_SIGNED;
120  static const std::string OUTPUT_FORMAT_LONG_UNSIGNED;
121  static const std::string OUTPUT_FORMAT_DOUBLE;
122  static const std::string OUTPUT_FORMAT_FLOAT;
123  static const std::string OUTPUT_FORMAT_HALF;
124  static const std::string OUTPUT_FORMAT_BIN;
125  static const std::string OUTPUT_FORMAT_HEX;
126 
127  CmdOutput();
128  explicit CmdOutput(const CmdOutput& cmd);
129  virtual ~CmdOutput();
130 
131  virtual bool execute(const std::vector<DataObject>& arguments);
132  virtual std::string helpText() const;
133 };
134 
135 //////////////////////////////////////////////////////////////////////////////
136 // CmdRegister
137 //////////////////////////////////////////////////////////////////////////////
138 
139 /**
140  * Custom command for showing register values.
141  *
142  * There are currently two register values which can asked:
143  * program counter and return address.
144  */
145 class CmdRegister : public CustomCommand {
146 public:
147 
148  static const std::string REGISTER_PROGRAM_COUNTER;
149  static const std::string REGISTER_RETURN_ADDRESS;
150 
151  CmdRegister();
152  explicit CmdRegister(const CmdRegister& cmd);
153  virtual ~CmdRegister();
154 
155  virtual bool execute(const std::vector<DataObject>& arguments);
156  virtual std::string helpText() const;
157 };
158 
159 //////////////////////////////////////////////////////////////////////////////
160 // CmdMem
161 //////////////////////////////////////////////////////////////////////////////
162 
163 /**
164  * Command for viewing memory contents.
165  *
166  * This implementation expects that MAU is 1 byte.
167  */
168 class CmdMem : public CustomCommand {
169 public:
170 
171  /// Name for byte memory access.
172  static const std::string MEM_BYTE;
173  /// Name for half word memory access.
174  static const std::string MEM_HALF_WORD;
175  /// Name for word memory access.
176  static const std::string MEM_WORD;
177  /// Name for double word memory access.
178  static const std::string MEM_DOUBLE_WORD;
179 
180  CmdMem();
181  explicit CmdMem(const CmdMem& cmd);
182  virtual ~CmdMem();
183 
184  virtual bool execute(const std::vector<DataObject>& arguments);
185  virtual std::string helpText() const;
186 };
187 
188 //////////////////////////////////////////////////////////////////////////////
189 // CmdAdvanceClock
190 //////////////////////////////////////////////////////////////////////////////
191 
192 /**
193  * Advances clock by one cycle.
194  */
196 public:
197  CmdAdvanceClock();
198  explicit CmdAdvanceClock(const CmdAdvanceClock& cmd);
199  virtual ~CmdAdvanceClock();
200 
201  virtual bool execute(const std::vector<DataObject>& arguments);
202  virtual std::string helpText() const;
203 };
204 
205 //////////////////////////////////////////////////////////////////////////////
206 // TesterContext.
207 //////////////////////////////////////////////////////////////////////////////
208 
209 /**
210  * Operation context for the program.
211  */
213 public:
214  TesterContext();
215  virtual ~TesterContext();
216  void stop();
217  bool cont() const;
219  std::string outputFormat() const;
220  void setOutputFormat(std::string outputFormat);
221  std::string toOutputFormat(SimValue* value);
222 
227 
228 private:
229  /// Flag indicating whether program can continue or not.
230  bool continue_;
235  /// Indicates which output format is used currently.
236  std::string outputFormat_;
237  /// The operation context shared with all operations invoked in
238  /// the application.
240 };
241 
242 //////////////////////////////////////////////////////////////////////////////
243 // OsalInterpreter
244 //////////////////////////////////////////////////////////////////////////////
245 
246 /**
247  * Interpreter for test_osal.
248  */
250 public:
251  OsalInterpreter();
252  virtual ~OsalInterpreter();
253 
254  Operation& operation(const std::string& name);
255 
256 private:
257  /// Used to load operations.
259  /// Last loaded operation.
261 };
262 
263 //////////////////////////////////////////////////////////////////////////////
264 // OsalCmdLineOptions
265 //////////////////////////////////////////////////////////////////////////////
266 
267 /**
268  * Command line option class for test_osal
269  */
271 public:
273  virtual ~OsalCmdLineOptions();
274 
275  virtual void printVersion() const;
276  virtual void printHelp() const;
277 
278 private:
279  /// Copying not allowed.
281  /// Assignment not allowed.
283 };
284 
285 #endif
CmdReset::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:210
CmdOutput::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:294
CmdTrigger::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:175
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
TesterContext::toOutputFormat
std::string toOutputFormat(SimValue *value)
Definition: TestOsal.cc:484
TesterContext::returnAddress
SimValue & returnAddress()
Definition: TestOsal.cc:537
OsalInterpreter::~OsalInterpreter
virtual ~OsalInterpreter()
Definition: TestOsal.cc:377
CmdAdvanceClock::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:866
Exception.hh
TesterContext::syscallNumber
SimValue & syscallNumber()
OperationContext
Definition: OperationContext.hh:56
OsalInterpreter::operation_
Operation * operation_
Last loaded operation.
Definition: TestOsal.hh:260
CmdOutput::OUTPUT_FORMAT_DOUBLE
static const std::string OUTPUT_FORMAT_DOUBLE
Definition: TestOsal.hh:121
TesterContext::setOutputFormat
void setOutputFormat(std::string outputFormat)
Definition: TestOsal.cc:473
CmdOutput::OUTPUT_FORMAT_BIN
static const std::string OUTPUT_FORMAT_BIN
Definition: TestOsal.hh:124
TesterContext::outputFormat_
std::string outputFormat_
Indicates which output format is used currently.
Definition: TestOsal.hh:236
CmdLineOptions.hh
CmdAdvanceClock::~CmdAdvanceClock
virtual ~CmdAdvanceClock()
Definition: TestOsal.cc:855
CmdMem
Definition: TestOsal.hh:168
CmdTrigger
Definition: TestOsal.hh:58
CmdMem::MEM_DOUBLE_WORD
static const std::string MEM_DOUBLE_WORD
Name for double word memory access.
Definition: TestOsal.hh:178
CmdOutput::OUTPUT_FORMAT_HALF
static const std::string OUTPUT_FORMAT_HALF
Definition: TestOsal.hh:123
CmdQuit::CmdQuit
CmdQuit()
Definition: TestOsal.cc:549
CmdReset::CmdReset
CmdReset()
Definition: TestOsal.cc:186
SimValue
Definition: SimValue.hh:96
TesterContext::syscallHandler
SimValue & syscallHandler()
TesterContext::continue_
bool continue_
Flag indicating whether program can continue or not.
Definition: TestOsal.hh:230
CmdAdvanceClock::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:896
TesterContext::opContext_
OperationContext opContext_
The operation context shared with all operations invoked in the application.
Definition: TestOsal.hh:239
CustomCommand.hh
CmdOutput::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:339
TesterContext::cont
bool cont() const
Definition: TestOsal.cc:441
OsalCmdLineOptions::~OsalCmdLineOptions
virtual ~OsalCmdLineOptions()
Definition: TestOsal.cc:913
CmdQuit::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:576
CmdOutput::CmdOutput
CmdOutput()
Definition: TestOsal.cc:270
CmdMem::MEM_BYTE
static const std::string MEM_BYTE
Name for byte memory access.
Definition: TestOsal.hh:172
OsalInterpreter::operation
Operation & operation(const std::string &name)
Definition: TestOsal.cc:388
CmdLineOptions
Definition: CmdLineOptions.hh:54
TesterContext
Definition: TestOsal.hh:212
TesterContext::operationContext
OperationContext & operationContext()
Definition: TestOsal.cc:453
OsalCmdLineOptions::OsalCmdLineOptions
OsalCmdLineOptions()
Definition: TestOsal.cc:907
OsalInterpreter::pool_
OperationPool * pool_
Used to load operations.
Definition: TestOsal.hh:258
CustomCommand
Definition: CustomCommand.hh:54
CmdRegister::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:643
CmdQuit
Definition: TestOsal.hh:94
InterpreterContext
Definition: InterpreterContext.hh:40
CmdOutput::OUTPUT_FORMAT_FLOAT
static const std::string OUTPUT_FORMAT_FLOAT
Definition: TestOsal.hh:122
CmdOutput::OUTPUT_FORMAT_HEX
static const std::string OUTPUT_FORMAT_HEX
Definition: TestOsal.hh:125
TesterContext::branchDelayCycles_
int branchDelayCycles_
Definition: TestOsal.hh:234
DataObject.hh
CmdReset
Definition: TestOsal.hh:77
TesterContext::irfStartStorage_
InstructionAddress irfStartStorage_
Definition: TestOsal.hh:233
Operation
Definition: Operation.hh:59
CmdRegister::CmdRegister
CmdRegister()
Definition: TestOsal.cc:616
SimpleScriptInterpreter
Definition: SimpleScriptInterpreter.hh:49
OsalInterpreter
Definition: TestOsal.hh:249
CmdMem::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:735
TesterContext::~TesterContext
virtual ~TesterContext()
Definition: TestOsal.cc:424
CmdTrigger::~CmdTrigger
virtual ~CmdTrigger()
Definition: TestOsal.cc:79
CmdMem::MEM_HALF_WORD
static const std::string MEM_HALF_WORD
Name for half word memory access.
Definition: TestOsal.hh:174
CmdRegister
Definition: TestOsal.hh:145
SimpleScriptInterpreter.hh
OsalCmdLineOptions::printVersion
virtual void printVersion() const
Definition: TestOsal.cc:920
SimValue.hh
TesterContext::programCounter
InstructionAddress & programCounter()
Definition: TestOsal.cc:527
CmdMem::~CmdMem
virtual ~CmdMem()
Definition: TestOsal.cc:724
CmdTrigger::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: TestOsal.cc:90
CmdOutput::OUTPUT_FORMAT_LONG_SIGNED
static const std::string OUTPUT_FORMAT_LONG_SIGNED
Definition: TestOsal.hh:119
CmdRegister::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:690
TesterContext::TesterContext
TesterContext()
Definition: TestOsal.cc:412
CmdOutput::OUTPUT_FORMAT_LONG_UNSIGNED
static const std::string OUTPUT_FORMAT_LONG_UNSIGNED
Definition: TestOsal.hh:120
TesterContext::stop
void stop()
Definition: TestOsal.cc:431
CmdMem::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:824
CmdQuit::~CmdQuit
virtual ~CmdQuit()
Definition: TestOsal.cc:563
OsalInterpreter::OsalInterpreter
OsalInterpreter()
Definition: TestOsal.cc:369
CmdMem::MEM_WORD
static const std::string MEM_WORD
Name for word memory access.
Definition: TestOsal.hh:176
CmdReset::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:248
CmdTrigger::CmdTrigger
CmdTrigger()
Definition: TestOsal.cc:67
CmdRegister::REGISTER_PROGRAM_COUNTER
static const std::string REGISTER_PROGRAM_COUNTER
Definition: TestOsal.hh:148
CmdOutput
Definition: TestOsal.hh:114
OperationPool
Definition: OperationPool.hh:52
OsalCmdLineOptions::printHelp
virtual void printHelp() const
Definition: TestOsal.cc:929
CmdRegister::REGISTER_RETURN_ADDRESS
static const std::string REGISTER_RETURN_ADDRESS
Definition: TestOsal.hh:149
CmdAdvanceClock
Definition: TestOsal.hh:195
CmdMem::CmdMem
CmdMem()
Definition: TestOsal.cc:710
CmdAdvanceClock::CmdAdvanceClock
CmdAdvanceClock()
Definition: TestOsal.cc:840
CmdReset::~CmdReset
virtual ~CmdReset()
Definition: TestOsal.cc:200
CmdQuit::helpText
virtual std::string helpText() const
Definition: TestOsal.cc:602
OsalCmdLineOptions::operator=
OsalCmdLineOptions & operator=(const OsalCmdLineOptions &)
Assignment not allowed.
TesterContext::outputFormat
std::string outputFormat() const
Definition: TestOsal.cc:463
CmdOutput::OUTPUT_FORMAT_INT_SIGNED
static const std::string OUTPUT_FORMAT_INT_SIGNED
Definition: TestOsal.hh:117
CmdOutput::~CmdOutput
virtual ~CmdOutput()
Definition: TestOsal.cc:284
OperationContext.hh
TesterContext::returnAddressStorage_
SimValue returnAddressStorage_
Definition: TestOsal.hh:231
CmdRegister::~CmdRegister
virtual ~CmdRegister()
Definition: TestOsal.cc:630
OsalCmdLineOptions
Definition: TestOsal.hh:270
CmdOutput::OUTPUT_FORMAT_INT_UNSIGNED
static const std::string OUTPUT_FORMAT_INT_UNSIGNED
Definition: TestOsal.hh:118
TesterContext::programCounterStorage_
InstructionAddress programCounterStorage_
Definition: TestOsal.hh:232