OpenASIP  2.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
InstructionMemory Class Reference

#include <InstructionMemory.hh>

Collaboration diagram for InstructionMemory:
Collaboration graph

Public Types

typedef std::vector< ExecutableInstruction * > InstructionContainer
 Container for instructions. More...
 

Public Member Functions

 InstructionMemory (InstructionAddress startAddress)
 
virtual ~InstructionMemory ()
 
void addExecutableInstruction (InstructionAddress addr, ExecutableInstruction *instruction)
 
void addImplicitExecutableInstruction (InstructionAddress addr, ExecutableInstruction *instruction)
 
ExecutableInstructioninstructionAt (InstructionAddress address)
 
const ExecutableInstructioninstructionAtConst (InstructionAddress address) const
 
void resetExecutionCounts ()
 
bool hasInstructionAt (InstructionAddress addr) const
 
bool hasImplicitInstructionsAt (InstructionAddress addr) const
 
const InstructionContainerimplicitInstructionsAt (InstructionAddress addr) const
 

Private Member Functions

 InstructionMemory (const InstructionMemory &)
 Copying not allowed. More...
 
InstructionMemoryoperator= (const InstructionMemory &)
 Assignment not allowed. More...
 

Private Attributes

InstructionAddress startAddress_
 The starting address of the instruction memory address space. More...
 
InstructionContainer instructions_
 All the instructions of the memory. More...
 
InstructionContainer emptyInstructions_
 
std::map< InstructionAddress, ExecutableInstruction * > instructionMap_
 Stores the explicit instruction addresses. More...
 
std::map< InstructionAddress, InstructionContainer * > implicitInstructions_
 Stores implicit instructions that should be executed after the explicit one in the same address. More...
 

Detailed Description

Container for ExecutableInstructions which represent the actions performed by the simulated program's instructions to the machine's state.

Definition at line 54 of file InstructionMemory.hh.

Member Typedef Documentation

◆ InstructionContainer

Container for instructions.

Definition at line 57 of file InstructionMemory.hh.

Constructor & Destructor Documentation

◆ InstructionMemory() [1/2]

InstructionMemory::InstructionMemory ( InstructionAddress  startAddress)

Constructor.

This constructor is for constant width instructions only.

Parameters
startAddressThe starting address of the instruction memory.

Definition at line 47 of file InstructionMemory.cc.

48  :
49  startAddress_(startAddress) {
50 }

◆ ~InstructionMemory()

InstructionMemory::~InstructionMemory ( )
virtual

Destructor.

Definition at line 55 of file InstructionMemory.cc.

55  {
56 
57  for (InstructionContainer::const_iterator i = instructions_.begin();
58  i != instructions_.end(); ++i) {
59  delete (*i);
60  }
61  instructions_.clear();
62 
63  for (auto Pair : implicitInstructions_) {
64  InstructionContainer* C = Pair.second;
65  delete C;
66  }
67  implicitInstructions_.clear();
68 }

References implicitInstructions_, and instructions_.

◆ InstructionMemory() [2/2]

InstructionMemory::InstructionMemory ( const InstructionMemory )
private

Copying not allowed.

Member Function Documentation

◆ addExecutableInstruction()

void InstructionMemory::addExecutableInstruction ( InstructionAddress  addr,
ExecutableInstruction instruction 
)

Adds new ExecutableInstruction to memory.

Parameters
instructionInstruction to be added.

Definition at line 76 of file InstructionMemory.cc.

77  {
78 
79  instructions_.push_back(instruction);
80  instructionMap_[addr] = instruction;
81 }

References instructionMap_, and instructions_.

Referenced by SimProgramBuilder::build().

◆ addImplicitExecutableInstruction()

void InstructionMemory::addImplicitExecutableInstruction ( InstructionAddress  addr,
ExecutableInstruction instruction 
)

Adds an "implicit instruction" used to simulate effects triggered by operation-triggered instructions as side-effects, but which are not controlled by the programmer.

Should be added after the explicit instruction in the order of how the effects should be done.

Definition at line 92 of file InstructionMemory.cc.

93  {
94  if (implicitInstructions_.find(addr) == implicitInstructions_.end()) {
96  }
97  implicitInstructions_[addr]->push_back(instruction);
98 }

References implicitInstructions_.

Referenced by SimProgramBuilder::build().

◆ hasImplicitInstructionsAt()

bool InstructionMemory::hasImplicitInstructionsAt ( InstructionAddress  addr) const

Definition at line 123 of file InstructionMemory.cc.

123  {
124  return implicitInstructions_.find(addr) != implicitInstructions_.end();
125 }

References implicitInstructions_.

Referenced by OTASimulationController::simulateCycle().

◆ hasInstructionAt()

bool InstructionMemory::hasInstructionAt ( InstructionAddress  addr) const

Returns true in case there is an implicit or explicit instruction at the given address.

Definition at line 117 of file InstructionMemory.cc.

117  {
118  return instructionMap_.find(addr) != instructionMap_.end();
119 }

References instructionMap_.

Referenced by OTASimulationController::simulateCycle().

◆ implicitInstructionsAt()

const InstructionMemory::InstructionContainer & InstructionMemory::implicitInstructionsAt ( InstructionAddress  addr) const

Definition at line 128 of file InstructionMemory.cc.

128  {
129  if (implicitInstructions_.find(addr) == implicitInstructions_.end()) {
130  return emptyInstructions_;
131  }
132 
133  const InstructionContainer* IC = implicitInstructions_.find(addr)->second;
134  return *IC;
135 }

References emptyInstructions_, and implicitInstructions_.

Referenced by SimulationStatistics::calculate(), and OTASimulationController::simulateCycle().

◆ instructionAt()

ExecutableInstruction& InstructionMemory::instructionAt ( InstructionAddress  address)

◆ instructionAtConst()

const ExecutableInstruction& InstructionMemory::instructionAtConst ( InstructionAddress  address) const

◆ operator=()

InstructionMemory& InstructionMemory::operator= ( const InstructionMemory )
private

Assignment not allowed.

◆ resetExecutionCounts()

void InstructionMemory::resetExecutionCounts ( )

Resets execution counters of all instructions.

Definition at line 105 of file InstructionMemory.cc.

105  {
106  for (InstructionContainer::iterator i = instructions_.begin();
107  i != instructions_.end(); ++i) {
108  (*i)->resetExecutionCounts();
109  }
110 }

References instructions_.

Member Data Documentation

◆ emptyInstructions_

InstructionContainer InstructionMemory::emptyInstructions_
private

Definition at line 90 of file InstructionMemory.hh.

Referenced by implicitInstructionsAt().

◆ implicitInstructions_

std::map<InstructionAddress, InstructionContainer*> InstructionMemory::implicitInstructions_
private

Stores implicit instructions that should be executed after the explicit one in the same address.

Definition at line 98 of file InstructionMemory.hh.

Referenced by addImplicitExecutableInstruction(), hasImplicitInstructionsAt(), implicitInstructionsAt(), and ~InstructionMemory().

◆ instructionMap_

std::map<InstructionAddress, ExecutableInstruction*> InstructionMemory::instructionMap_
private

Stores the explicit instruction addresses.

Definition at line 95 of file InstructionMemory.hh.

Referenced by addExecutableInstruction(), and hasInstructionAt().

◆ instructions_

InstructionContainer InstructionMemory::instructions_
private

All the instructions of the memory.

Definition at line 88 of file InstructionMemory.hh.

Referenced by addExecutableInstruction(), resetExecutionCounts(), and ~InstructionMemory().

◆ startAddress_

InstructionAddress InstructionMemory::startAddress_
private

The starting address of the instruction memory address space.

Definition at line 85 of file InstructionMemory.hh.


The documentation for this class was generated from the following files:
InstructionMemory::emptyInstructions_
InstructionContainer emptyInstructions_
Definition: InstructionMemory.hh:90
InstructionMemory::InstructionContainer
std::vector< ExecutableInstruction * > InstructionContainer
Container for instructions.
Definition: InstructionMemory.hh:57
InstructionMemory::startAddress_
InstructionAddress startAddress_
The starting address of the instruction memory address space.
Definition: InstructionMemory.hh:85
InstructionMemory::instructionMap_
std::map< InstructionAddress, ExecutableInstruction * > instructionMap_
Stores the explicit instruction addresses.
Definition: InstructionMemory.hh:95
InstructionMemory::instructions_
InstructionContainer instructions_
All the instructions of the memory.
Definition: InstructionMemory.hh:88
InstructionMemory::implicitInstructions_
std::map< InstructionAddress, InstructionContainer * > implicitInstructions_
Stores implicit instructions that should be executed after the explicit one in the same address.
Definition: InstructionMemory.hh:98