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

#include <LongImmediateUnitState.hh>

Inheritance diagram for LongImmediateUnitState:
Inheritance graph
Collaboration diagram for LongImmediateUnitState:
Collaboration graph

Classes

struct  Item
 

Public Member Functions

 LongImmediateUnitState (int size, int latency, const std::string &name, int width, bool signExtend)
 
virtual ~LongImmediateUnitState ()
 
virtual SimValueregisterValue (int index)
 
virtual void setRegisterValue (int index, const SimValue &value)
 
virtual LongImmediateRegisterStateimmediateRegister (int i)
 
virtual int immediateRegisterCount () const
 
virtual void endClock ()
 
virtual void advanceClock ()
 
- Public Member Functions inherited from ClockedState
 ClockedState ()
 
virtual ~ClockedState ()
 
virtual void reset ()
 this is called at (re)initialization of the simulation More...
 

Private Types

typedef std::queue< ItemItemQueue
 
typedef std::vector< LongImmediateRegisterState * > RegisterContainer
 
typedef std::vector< SimValueValueContainer
 

Private Member Functions

 LongImmediateUnitState (const LongImmediateUnitState &)
 Copying not allowed. More...
 
LongImmediateUnitStateoperator= (const LongImmediateUnitState &)
 Assignment not allowed. More...
 
void clear ()
 

Private Attributes

int latency_
 Latency of LongImmediateUnit. More...
 
std::string name_
 Name of the unit. More...
 
ItemQueue queue_
 Queue of register value update requests. More...
 
RegisterContainer registers_
 Contains all long immediate registers of the unit. More...
 
ValueContainer values_
 Contains all values of the registers. More...
 
unsigned timer_ = 0
 Counter to time arrival of immediate values. Note: value is expected to wrap. More...
 

Detailed Description

Class that represents the states of long immediate units.

Definition at line 55 of file LongImmediateUnitState.hh.

Member Typedef Documentation

◆ ItemQueue

typedef std::queue<Item> LongImmediateUnitState::ItemQueue
private

Definition at line 101 of file LongImmediateUnitState.hh.

◆ RegisterContainer

Definition at line 102 of file LongImmediateUnitState.hh.

◆ ValueContainer

typedef std::vector<SimValue> LongImmediateUnitState::ValueContainer
private

Definition at line 103 of file LongImmediateUnitState.hh.

Constructor & Destructor Documentation

◆ LongImmediateUnitState() [1/2]

LongImmediateUnitState::LongImmediateUnitState ( int  size,
int  latency,
const std::string &  name,
int  width,
bool  signExtend 
)

Constructor.

Parameters
sizeSize of the unit.
latencyLatency of the unit.
nameName of the unit.
widthThe bit width of the registers in the unit.
signExtendWhether the values written to the registers should be sign extended.

Definition at line 58 of file LongImmediateUnitState.cc.

63  :
64  ClockedState(), latency_(latency), name_(name) {
65 
66  for (int i = 0; i < size; i++) {
67  registers_.push_back(
68  new LongImmediateRegisterState(this, i, width, signExtend));
69  }
70  SimValue val(width);
71  values_.resize(size, val);
72 }

References registers_, and values_.

◆ ~LongImmediateUnitState()

LongImmediateUnitState::~LongImmediateUnitState ( )
virtual

Destructor.

Definition at line 77 of file LongImmediateUnitState.cc.

77  {
78  clear();
79 }

References clear().

Here is the call graph for this function:

◆ LongImmediateUnitState() [2/2]

LongImmediateUnitState::LongImmediateUnitState ( const LongImmediateUnitState )
private

Copying not allowed.

Member Function Documentation

◆ advanceClock()

void LongImmediateUnitState::advanceClock ( )
virtual

Advances clock by one cycle.

Register values are updated. This method is used to simulate the latency of the immediate unit state: register values are not updated immediately in case the latency is greater than zero.

Implements ClockedState.

Reimplemented in NullLongImmediateUnitState.

Definition at line 144 of file LongImmediateUnitState.cc.

144  {
145  timer_++;
146  while (!queue_.empty() && queue_.front().arrival_ == timer_) {
147  values_[queue_.front().index_] = queue_.front().value_;
148  queue_.pop();
149  }
150 }

References queue_, timer_, and values_.

◆ clear()

void LongImmediateUnitState::clear ( )
private

Clears the containers.

Definition at line 85 of file LongImmediateUnitState.cc.

85  {
87  values_.clear();
88 }

References SequenceTools::deleteAllItems(), registers_, and values_.

Referenced by ~LongImmediateUnitState().

Here is the call graph for this function:

◆ endClock()

void LongImmediateUnitState::endClock ( )
virtual

End of clock cycle.

Nothing is done.

Implements ClockedState.

Reimplemented in NullLongImmediateUnitState.

Definition at line 133 of file LongImmediateUnitState.cc.

133  {
134 }

◆ immediateRegister()

LongImmediateRegisterState & LongImmediateUnitState::immediateRegister ( int  i)
virtual

Returns the register of the given index.

Parameters
indexIndex of the register.
Returns
Register of the given index.
Exceptions
OutOfRangeIf index is out of range.

Reimplemented in NullLongImmediateUnitState.

Definition at line 160 of file LongImmediateUnitState.cc.

160  {
161  if (i < 0 || i > static_cast<int>(registers_.size()) - 1) {
162  string msg = "Index out of range.";
163  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
164  }
165  return *registers_[i];
166 }

References __func__, and registers_.

Referenced by ProximRegisterWindow::loadImmediateUnit(), SimProgramBuilder::processInstruction(), and SimProgramBuilder::processSourceTerminal().

◆ immediateRegisterCount()

int LongImmediateUnitState::immediateRegisterCount ( ) const
virtual

Returns the count of the registers in the unit.

Returns
The count of the immediate registers.

Reimplemented in NullLongImmediateUnitState.

Definition at line 174 of file LongImmediateUnitState.cc.

174  {
175  return registers_.size();
176 }

References registers_.

Referenced by ProximIUDetailsCmd::Do(), and ProximRegisterWindow::loadImmediateUnit().

◆ operator=()

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

Assignment not allowed.

◆ registerValue()

SimValue & LongImmediateUnitState::registerValue ( int  index)
virtual

Returns the register value of the given index.

Parameters
indexIndex of the register.
Returns
Register value of the given index.
Exceptions
OutOfRangeIf index is out of range.

Reimplemented in NullLongImmediateUnitState.

Definition at line 98 of file LongImmediateUnitState.cc.

98  {
99  if (index < 0 || index > static_cast<int>(values_.size()) - 1) {
100  string msg = "Index out of range.";
101  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
102  }
103  return values_[index];
104 }

References __func__, and values_.

Referenced by ProximIUDetailsCmd::Do(), and LongImmediateRegisterState::value().

◆ setRegisterValue()

void LongImmediateUnitState::setRegisterValue ( int  index,
const SimValue value 
)
virtual

Sets the register value.

Parameters
indexIndex of the register.
valueValue to be set.
Exceptions
OutOfRangeIf index is out of range.

Reimplemented in NullLongImmediateUnitState.

Definition at line 114 of file LongImmediateUnitState.cc.

114  {
115  if (index < 0 || index > static_cast<int>(values_.size()) - 1) {
116  string msg = "Index out of range.";
117  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
118  }
119 
120  if (latency_ == 0) {
121  values_[index] = value;
122  } else {
123  queue_.emplace(value, index, timer_ + latency_);
124  }
125 }

References __func__, latency_, queue_, timer_, and values_.

Referenced by LongImmediateRegisterState::setValue().

Member Data Documentation

◆ latency_

int LongImmediateUnitState::latency_
private

Latency of LongImmediateUnit.

Definition at line 106 of file LongImmediateUnitState.hh.

Referenced by setRegisterValue().

◆ name_

std::string LongImmediateUnitState::name_
private

Name of the unit.

Definition at line 108 of file LongImmediateUnitState.hh.

◆ queue_

ItemQueue LongImmediateUnitState::queue_
private

Queue of register value update requests.

Definition at line 110 of file LongImmediateUnitState.hh.

Referenced by advanceClock(), and setRegisterValue().

◆ registers_

RegisterContainer LongImmediateUnitState::registers_
private

Contains all long immediate registers of the unit.

Definition at line 112 of file LongImmediateUnitState.hh.

Referenced by clear(), immediateRegister(), immediateRegisterCount(), and LongImmediateUnitState().

◆ timer_

unsigned LongImmediateUnitState::timer_ = 0
private

Counter to time arrival of immediate values. Note: value is expected to wrap.

Definition at line 117 of file LongImmediateUnitState.hh.

Referenced by advanceClock(), and setRegisterValue().

◆ values_

ValueContainer LongImmediateUnitState::values_
private

Contains all values of the registers.

Definition at line 114 of file LongImmediateUnitState.hh.

Referenced by advanceClock(), clear(), LongImmediateUnitState(), registerValue(), and setRegisterValue().


The documentation for this class was generated from the following files:
LongImmediateUnitState::values_
ValueContainer values_
Contains all values of the registers.
Definition: LongImmediateUnitState.hh:114
OutOfRange
Definition: Exception.hh:320
LongImmediateUnitState::queue_
ItemQueue queue_
Queue of register value update requests.
Definition: LongImmediateUnitState.hh:110
SimValue
Definition: SimValue.hh:96
LongImmediateRegisterState
Definition: LongImmediateRegisterState.hh:47
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
LongImmediateUnitState::clear
void clear()
Definition: LongImmediateUnitState.cc:85
__func__
#define __func__
Definition: Application.hh:67
ClockedState::ClockedState
ClockedState()
Definition: ClockedState.cc:38
LongImmediateUnitState::registers_
RegisterContainer registers_
Contains all long immediate registers of the unit.
Definition: LongImmediateUnitState.hh:112
LongImmediateUnitState::name_
std::string name_
Name of the unit.
Definition: LongImmediateUnitState.hh:108
LongImmediateUnitState::timer_
unsigned timer_
Counter to time arrival of immediate values. Note: value is expected to wrap.
Definition: LongImmediateUnitState.hh:117
LongImmediateUnitState::latency_
int latency_
Latency of LongImmediateUnit.
Definition: LongImmediateUnitState.hh:106