OpenASIP  2.0
TTASimulationController.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2012 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 CompiledSimController.hh
26  *
27  * Declaration of TTASimulationController class.
28  *
29  * @author Viljami Korhonen 2008 (viljami.korhonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_SIMULATION_CONTROLLER_HH
34 #define TTA_SIMULATION_CONTROLLER_HH
35 
36 #include <set>
37 #include <vector>
38 
39 #include "Exception.hh"
40 #include "BaseType.hh"
41 #include "SimulatorConstants.hh"
43 
44 class MemorySystem;
45 class MachineState;
46 class InstructionMemory;
47 class GCUState;
48 class IllegalMachine;
49 class SimValue;
50 class InstanceNotFound;
51 class StateData;
52 class MemorySystem;
53 class Memory;
54 class SimulatorFrontend;
55 
56 namespace TTAMachine {
57  class Machine;
58 }
59 
60 namespace TTAProgram {
61  class Program;
62 }
63 
64 /**
65  * An abstract interface class for controlling the simulation
66  *
67  * Owns and is the main client of the machine state model.
68  */
70 public:
71  /// The states of simulation.
73  STA_INITIALIZING,///< Simulation is being initialized.
74  STA_INITIALIZED, ///< Simulation initialized and ready to run.
75  STA_RUNNING, ///< A run command (run, stepi, until...) given.
76  STA_STOPPED, ///< Simulation stopped for some reason.
78  ///< Simulation ended after executing the last instruction.
79  };
80 
85 
86  virtual ~TTASimulationController();
87 
88  virtual void step(double count = 1) = 0;
89 
90  virtual void next(int count = 1) = 0;
91 
92  virtual void run() = 0;
93 
94  virtual void runUntil(UIntWord address) = 0;
95 
96  virtual void reset() = 0;
97 
98 
99  virtual std::string registerFileValue(
100  const std::string& rfName,
101  int registerIndex = -1) = 0;
102 
104  const std::string& iuName, int index = -1) = 0;
105 
106  virtual SimValue FUPortValue(
107  const std::string& fuName,
108  const std::string& portName) = 0;
109 
110  virtual void prepareToStop(StopReason reason);
111  virtual unsigned int stopReasonCount() const;
112  virtual StopReason stopReason(unsigned int index) const;
113  virtual SimulationStatus state() const;
114  virtual InstructionAddress programCounter() const = 0;
115  virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const;
116  virtual ClockCycleCount clockCount() const;
117  virtual MemorySystem& memorySystem(int coreId=-1);
118  virtual SimulatorFrontend& frontend();
119  virtual bool automaticFinishImpossible() const;
120 
121  virtual std::set<InstructionAddress> findProgramExitPoints(
123  const TTAMachine::Machine& machine) const;
124 
125 protected:
126  /// Copying not allowed.
128  /// Assignment not allowed.
130 
131  /// The container type for reasons why simulation stop was requested.
132  typedef std::set<StopReason> StopReasonContainer;
133 
134  /// Reference to the simulator frontend
136  /// The simulated Machine Object Model.
138  /// Program object model of the simulated program.
140 
141  /// Flag indicating that simulation should stop.
143  /// The set of reasons the simulation was stopped.
145 
146  /// The current state of the simulation.
148  /// How many clock cycles have been simulated.
150  /// The address of the last executed instruction.
151  std::vector<InstructionAddress> lastExecutedInstruction_;
152  /// The address of the first executed instruction.
154  /// If this is true, simulation cannot be finished automatically.
156  /// The index of the first illegal instruction in the instruction
157  /// sequence.
159 };
160 
161 #endif
TTASimulationController::memorySystem
virtual MemorySystem & memorySystem(int coreId=-1)
Definition: TTASimulationController.cc:171
TTAProgram
Definition: Estimator.hh:65
UIntWord
Word UIntWord
Definition: BaseType.hh:144
TTASimulationController::registerFileValue
virtual std::string registerFileValue(const std::string &rfName, int registerIndex=-1)=0
TTASimulationController::lastExecutedInstruction
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const
Definition: TTASimulationController.cc:147
TTAProgram::Program
Definition: Program.hh:63
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
BaseType.hh
TTASimulationController::STA_STOPPED
@ STA_STOPPED
Simulation stopped for some reason.
Definition: TTASimulationController.hh:76
TTASimulationController::stopReasons_
StopReasonContainer stopReasons_
The set of reasons the simulation was stopped.
Definition: TTASimulationController.hh:144
GCUState
Definition: GCUState.hh:46
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTASimulationController::StopReasonContainer
std::set< StopReason > StopReasonContainer
The container type for reasons why simulation stop was requested.
Definition: TTASimulationController.hh:132
Exception.hh
FUConflictDetectorIndex.hh
TTASimulationController::TTASimulationController
TTASimulationController(SimulatorFrontend &frontend, const TTAMachine::Machine &machine, const TTAProgram::Program &program)
Definition: TTASimulationController.cc:60
TTASimulationController::runUntil
virtual void runUntil(UIntWord address)=0
TTASimulationController::step
virtual void step(double count=1)=0
TTASimulationController::automaticFinishImpossible
virtual bool automaticFinishImpossible() const
Definition: TTASimulationController.cc:197
TTASimulationController::prepareToStop
virtual void prepareToStop(StopReason reason)
Definition: TTASimulationController.cc:90
TTASimulationController::operator=
TTASimulationController & operator=(const TTASimulationController &)
Assignment not allowed.
InstructionMemory
Definition: InstructionMemory.hh:54
TTASimulationController::stopReasonCount
virtual unsigned int stopReasonCount() const
Definition: TTASimulationController.cc:101
TTASimulationController::automaticFinishImpossible_
bool automaticFinishImpossible_
If this is true, simulation cannot be finished automatically.
Definition: TTASimulationController.hh:155
TTASimulationController::initialPC_
InstructionAddress initialPC_
The address of the first executed instruction.
Definition: TTASimulationController.hh:153
SimValue
Definition: SimValue.hh:96
SimulatorConstants.hh
TTASimulationController::STA_RUNNING
@ STA_RUNNING
A run command (run, stepi, until...) given.
Definition: TTASimulationController.hh:75
TTASimulationController::SimulationStatus
SimulationStatus
The states of simulation.
Definition: TTASimulationController.hh:72
TTASimulationController::state_
SimulationStatus state_
The current state of the simulation.
Definition: TTASimulationController.hh:147
TTASimulationController::frontend_
SimulatorFrontend & frontend_
Reference to the simulator frontend.
Definition: TTASimulationController.hh:135
TTASimulationController
Definition: TTASimulationController.hh:69
MachineState
Definition: MachineState.hh:61
TTASimulationController::STA_INITIALIZED
@ STA_INITIALIZED
Simulation initialized and ready to run.
Definition: TTASimulationController.hh:74
TTASimulationController::state
virtual SimulationStatus state() const
Definition: TTASimulationController.cc:137
TTASimulationController::findProgramExitPoints
virtual std::set< InstructionAddress > findProgramExitPoints(const TTAProgram::Program &program, const TTAMachine::Machine &machine) const
Definition: TTASimulationController.cc:209
TTASimulationController::STA_FINISHED
@ STA_FINISHED
Simulation ended after executing the last instruction.
Definition: TTASimulationController.hh:77
TTASimulationController::run
virtual void run()=0
TTASimulationController::sourceMachine_
const TTAMachine::Machine & sourceMachine_
The simulated Machine Object Model.
Definition: TTASimulationController.hh:137
TTASimulationController::lastExecutedInstruction_
std::vector< InstructionAddress > lastExecutedInstruction_
The address of the last executed instruction.
Definition: TTASimulationController.hh:151
TTASimulationController::stopRequested_
bool stopRequested_
Flag indicating that simulation should stop.
Definition: TTASimulationController.hh:142
TTASimulationController::programCounter
virtual InstructionAddress programCounter() const =0
StopReason
StopReason
The reasons to stop simulation.
Definition: SimulatorConstants.hh:60
MemorySystem
Definition: MemorySystem.hh:55
TTASimulationController::STA_INITIALIZING
@ STA_INITIALIZING
Simulation is being initialized.
Definition: TTASimulationController.hh:73
TTASimulationController::~TTASimulationController
virtual ~TTASimulationController()
Definition: TTASimulationController.cc:76
TTASimulationController::stopReason
virtual StopReason stopReason(unsigned int index) const
Definition: TTASimulationController.cc:113
TTASimulationController::frontend
virtual SimulatorFrontend & frontend()
Definition: TTASimulationController.cc:181
TTASimulationController::clockCount_
ClockCycleCount clockCount_
How many clock cycles have been simulated.
Definition: TTASimulationController.hh:149
TTASimulationController::firstIllegalInstructionIndex_
InstructionAddress firstIllegalInstructionIndex_
The index of the first illegal instruction in the instruction sequence.
Definition: TTASimulationController.hh:158
TTASimulationController::immediateUnitRegisterValue
virtual SimValue immediateUnitRegisterValue(const std::string &iuName, int index=-1)=0
IllegalMachine
Definition: Exception.hh:878
TTASimulationController::clockCount
virtual ClockCycleCount clockCount() const
Definition: TTASimulationController.cc:161
TTASimulationController::reset
virtual void reset()=0
TTASimulationController::next
virtual void next(int count=1)=0
TTASimulationController::FUPortValue
virtual SimValue FUPortValue(const std::string &fuName, const std::string &portName)=0
StateData
Definition: StateData.hh:44
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
TTAMachine
Definition: Assembler.hh:48
TTASimulationController::program_
const TTAProgram::Program & program_
Program object model of the simulated program.
Definition: TTASimulationController.hh:139
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
InstanceNotFound
Definition: Exception.hh:304
Memory
Definition: Memory.hh:74
TTAMachine::Machine
Definition: Machine.hh:73