orca-sim
Public Member Functions | Private Attributes | List of all members
orcasim::modeling::ProcessorBase< T > Class Template Referenceabstract

This class implements the base operation for generic processor implementations. More...

#include <ProcessorBase.hpp>

Inheritance diagram for orcasim::modeling::ProcessorBase< T >:
orcasim::base::TimedModel orcasim::base::Model orcasim::gdbrsp::GdbProcessorBase< T >

Public Member Functions

 ProcessorBase (std::string name, MemoryAddr initial_pc, Memory *mem)
 Default constructor. More...
 
 ~ProcessorBase ()
 Destructor. More...
 
virtual SimulationTime Run ()=0
 Run method from the base TimedModel class, overloaded. More...
 
ProcessorState< T > * GetState ()
 This method returns the state model of the processor. More...
 
MemoryGetMemory ()
 This method returns a pointer to the object that models the memory core. More...
 
virtual void Reset ()=0
 Resets the instance to its starting state. More...
 
a name that identifies the model, advisably not empty.

Default ctor.

std::string GetName ()
 Getter method for the <_name> field. More...
 
void SetName (std::string s)
 Setter method for the <_name> field. More...
 

Private Attributes

struct ProcessorState< T > _state
 struct that represent the state of a processor. More...
 
Memory_memory
 We assume that every processor is attached to a memory core. More...
 

Detailed Description

template<typename T>
class orcasim::modeling::ProcessorBase< T >

This class implements the base operation for generic processor implementations.

This class uses templates to handle the size of internal registers (registers are limited to have the same size)

Definition at line 47 of file ProcessorBase.hpp.

Constructor & Destructor Documentation

§ ProcessorBase()

template<typename T >
ProcessorBase::ProcessorBase ( std::string  name,
MemoryAddr  initial_pc,
Memory mem 
)

Default constructor.

Parameters
nameA short name or description of the instance
initial_pcMemory address to which the PC register will point to at the startup.

Definition at line 41 of file ProcessorBase.cpp.

42  : TimedModel(name) {
43 
44  // set mem ptr
45  _memory = mem;
46 
47  // reset registers
48  for (int i = 0; i < NUMBER_OF_REGISTERS; i++)
49  _state.regs[i] = 0;
50 
51  // reset PC
52  _state.pc_prev = initial_pc;
53  _state.pc = initial_pc;
54  _state.pc_next = _state.pc + sizeof(T);
55 
56  // reset flags
57  #ifdef ORCA_ENABLE_GDBRSP
58  _state.bp = 0; // no breakpoint reached yet
59  _state.pause = 1; // starts paused in gdb mode
60  _state.steps = 0; // no steps to be performed, wait for gdb
61  _gdbserver = new RspServer<T>(&_state,
62  _memory, "127.0.0.1", GDBSERVER_PORT++);
63  #endif
64 
65  // reset special flags
66  _state.terminated = false;
67 }
TimedModel(std::string name)
Default Ctor.
Definition: TimedModel.cpp:31
Memory * _memory
We assume that every processor is attached to a memory core.
struct ProcessorState< T > _state
struct that represent the state of a processor.
#define NUMBER_OF_REGISTERS

§ ~ProcessorBase()

template<typename T >
ProcessorBase::~ProcessorBase ( )

Destructor.

Definition at line 70 of file ProcessorBase.cpp.

70  {
71  #ifdef ORCA_ENABLE_GDBRSP
72  delete _gdbserver;
73  #endif
74 }

Member Function Documentation

§ GetMemory()

template<typename T >
Memory * ProcessorBase::GetMemory ( )
inline

This method returns a pointer to the object that models the memory core.

It is made private to avoid being changed by the processor core implementation.

Returns
a pointers to the memory model

Definition at line 86 of file ProcessorBase.cpp.

86  {
87  return _memory;
88 }
Memory * _memory
We assume that every processor is attached to a memory core.

§ GetName()

std::string Model::GetName ( )
inherited

Getter method for the <_name> field.

Definition at line 34 of file Model.cpp.

34  {
35  return _name;
36 }
std::string _name
A name for the model.
Definition: Model.hpp:47

§ GetState()

template<typename T >
ProcessorState< T > * ProcessorBase::GetState ( )
inline

This method returns the state model of the processor.

Access the current state of the processor.

This is ideally used from the top level simulator to report processor states at the end of simulation.

Returns
a pointer to the processor state struct.
A pointer to the state of the processor.

Definition at line 81 of file ProcessorBase.cpp.

81  {
82  return &_state;
83 }
struct ProcessorState< T > _state
struct that represent the state of a processor.

§ Reset()

virtual void orcasim::base::TimedModel::Reset ( )
pure virtualinherited

Resets the instance to its starting state.

Must be implemented by subclasses

Implemented in orcasim::models::orca::NetBridge, orcasim::models::orca::DmaNetif, and orcasim::models::hermes::HermesRouter.

§ Run()

template<typename T >
SimulationTime ProcessorBase::Run ( )
pure virtual

Run method from the base TimedModel class, overloaded.

We include in the overloading external components that would apply to all processors. Examples include energy estimation (through counters) and GDBRSP.

Returns
the number of cycles to skip until next schedule.

Implements orcasim::base::TimedModel.

Implemented in orcasim::models::hfriscv::HFRiscV, and orcasim::gdbrsp::GdbProcessorBase< T >.

Definition at line 91 of file ProcessorBase.cpp.

91  {
92  return 0;
93  // nothing todo
94 }

§ SetName()

void Model::SetName ( std::string  s)
inherited

Setter method for the <_name> field.

Parameters
sValue to be set

Definition at line 38 of file Model.cpp.

38  {
39  _name = name;
40 }
std::string _name
A name for the model.
Definition: Model.hpp:47

Member Data Documentation

§ _memory

template<typename T>
Memory* orcasim::modeling::ProcessorBase< T >::_memory
private

We assume that every processor is attached to a memory core.

For now, the only core available is untimed.

Definition at line 58 of file ProcessorBase.hpp.

§ _state

template<typename T>
struct ProcessorState< T > orcasim::modeling::ProcessorBase< T >::_state
private

struct that represent the state of a processor.

All processor share the same state model, which permit us to implement features such as the GDB's remote debug server.

Definition at line 53 of file ProcessorBase.hpp.


The documentation for this class was generated from the following files: