OpenASIP 2.2
Loading...
Searching...
No Matches
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
47class Operation;
48class OperationPool;
49
50//////////////////////////////////////////////////////////////////////////////
51// CmdTrigger
52//////////////////////////////////////////////////////////////////////////////
53
54/**
55 * Custom command that executes the trigger command of last loaded
56 * operation.
57 */
58class CmdTrigger : public CustomCommand {
59public:
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 */
77class CmdReset : public CustomCommand {
78public:
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 */
94class CmdQuit : public CustomCommand {
95public:
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 */
114class CmdOutput : public CustomCommand {
115public:
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 */
146public:
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 */
168class CmdMem : public CustomCommand {
169public:
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 */
196public:
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 */
213public:
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
228private:
229 /// Flag indicating whether program can continue or not.
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 */
250public:
252 virtual ~OsalInterpreter();
253
254 Operation& operation(const std::string& name);
255
256private:
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 */
271public:
273 virtual ~OsalCmdLineOptions();
274
275 virtual void printVersion() const;
276 virtual void printHelp() const;
277
278private:
279 /// Copying not allowed.
281 /// Assignment not allowed.
283};
284
285#endif
UInt32 InstructionAddress
Definition BaseType.hh:175
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:866
virtual ~CmdAdvanceClock()
Definition TestOsal.cc:855
virtual std::string helpText() const
Definition TestOsal.cc:896
static const std::string MEM_DOUBLE_WORD
Name for double word memory access.
Definition TestOsal.hh:178
virtual std::string helpText() const
Definition TestOsal.cc:824
static const std::string MEM_WORD
Name for word memory access.
Definition TestOsal.hh:176
virtual ~CmdMem()
Definition TestOsal.cc:724
static const std::string MEM_HALF_WORD
Name for half word memory access.
Definition TestOsal.hh:174
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:735
static const std::string MEM_BYTE
Name for byte memory access.
Definition TestOsal.hh:172
static const std::string OUTPUT_FORMAT_BIN
Definition TestOsal.hh:124
static const std::string OUTPUT_FORMAT_LONG_SIGNED
Definition TestOsal.hh:119
static const std::string OUTPUT_FORMAT_DOUBLE
Definition TestOsal.hh:121
virtual ~CmdOutput()
Definition TestOsal.cc:284
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:294
static const std::string OUTPUT_FORMAT_HALF
Definition TestOsal.hh:123
static const std::string OUTPUT_FORMAT_FLOAT
Definition TestOsal.hh:122
virtual std::string helpText() const
Definition TestOsal.cc:339
static const std::string OUTPUT_FORMAT_INT_SIGNED
Definition TestOsal.hh:117
static const std::string OUTPUT_FORMAT_LONG_UNSIGNED
Definition TestOsal.hh:120
static const std::string OUTPUT_FORMAT_HEX
Definition TestOsal.hh:125
static const std::string OUTPUT_FORMAT_INT_UNSIGNED
Definition TestOsal.hh:118
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:576
virtual std::string helpText() const
Definition TestOsal.cc:602
virtual ~CmdQuit()
Definition TestOsal.cc:563
static const std::string REGISTER_PROGRAM_COUNTER
Definition TestOsal.hh:148
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:643
virtual ~CmdRegister()
Definition TestOsal.cc:630
static const std::string REGISTER_RETURN_ADDRESS
Definition TestOsal.hh:149
virtual std::string helpText() const
Definition TestOsal.cc:690
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:210
virtual std::string helpText() const
Definition TestOsal.cc:248
virtual ~CmdReset()
Definition TestOsal.cc:200
virtual ~CmdTrigger()
Definition TestOsal.cc:79
virtual std::string helpText() const
Definition TestOsal.cc:175
virtual bool execute(const std::vector< DataObject > &arguments)
Definition TestOsal.cc:90
OsalCmdLineOptions(const OsalCmdLineOptions &)
Copying not allowed.
virtual void printVersion() const
Definition TestOsal.cc:920
OsalCmdLineOptions & operator=(const OsalCmdLineOptions &)
Assignment not allowed.
virtual void printHelp() const
Definition TestOsal.cc:929
virtual ~OsalCmdLineOptions()
Definition TestOsal.cc:913
virtual ~OsalInterpreter()
Definition TestOsal.cc:377
Operation * operation_
Last loaded operation.
Definition TestOsal.hh:260
Operation & operation(const std::string &name)
Definition TestOsal.cc:388
OperationPool * pool_
Used to load operations.
Definition TestOsal.hh:258
std::string toOutputFormat(SimValue *value)
Definition TestOsal.cc:484
OperationContext & operationContext()
Definition TestOsal.cc:453
InstructionAddress programCounterStorage_
Definition TestOsal.hh:232
bool continue_
Flag indicating whether program can continue or not.
Definition TestOsal.hh:230
virtual ~TesterContext()
Definition TestOsal.cc:424
InstructionAddress irfStartStorage_
Definition TestOsal.hh:233
SimValue & returnAddress()
Definition TestOsal.cc:537
SimValue & syscallHandler()
bool cont() const
Definition TestOsal.cc:441
int branchDelayCycles_
Definition TestOsal.hh:234
SimValue returnAddressStorage_
Definition TestOsal.hh:231
SimValue & syscallNumber()
void setOutputFormat(std::string outputFormat)
Definition TestOsal.cc:473
std::string outputFormat_
Indicates which output format is used currently.
Definition TestOsal.hh:236
InstructionAddress & programCounter()
Definition TestOsal.cc:527
OperationContext opContext_
The operation context shared with all operations invoked in the application.
Definition TestOsal.hh:239
std::string outputFormat() const
Definition TestOsal.cc:463