OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
GuardState Class Reference

#include <GuardState.hh>

Inheritance diagram for GuardState:
Inheritance graph
Collaboration diagram for GuardState:
Collaboration graph

Public Member Functions

 GuardState (const ReadableState &targetRegister, int latency)
 
virtual ~GuardState ()
 
virtual const SimValuevalue () 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...
 
- Public Member Functions inherited from ReadableState
 ReadableState ()
 
virtual ~ReadableState ()
 

Protected Member Functions

 GuardState ()
 Only subclasses allowed to create empty GuardStates. More...
 

Private Member Functions

 GuardState (const GuardState &)
 Copying not allowed. More...
 
GuardStateoperator= (const GuardState &)
 Assignment not allowed. More...
 

Private Attributes

const ReadableStatetarget_
 The target register watched by this guard. More...
 
std::vector< SimValuehistory_
 Value history ring buffer. More...
 
int position_
 History ring buffer position. Point to the index of the current value of the guard. More...
 

Detailed Description

Models the programmer visible delay of guards with latency more than 1.

GuardState with latency of 1 is the default latency which can be modeled with a direct reference to the guarded register, thus this class should not be used to model such cases. Guard latency of 1 means that the guard value can be used in the same instruction in which the value itself can be used. Thus, in case of a register guard, the instruction following the write to the register. For example, guard with latency of 2 means that there is one instruction cycle after updating the value of the guard in which the new value is not yet visible, and so on. This latency is modeled with a ring buffer which represents the history of guard's target values.

Definition at line 60 of file GuardState.hh.

Constructor & Destructor Documentation

◆ GuardState() [1/3]

GuardState::GuardState ( const ReadableState targetRegister,
int  latency 
)

Constructor.

Parameters
targetRegisterThe target register this guard watches.
latencyThe total guard latency modeled.

Definition at line 50 of file GuardState.cc.

52  :
53  target_(&targetRegister) {
54  assert(latency && "Use DirectGuardState for 0-cycle latency");
55  for (int i = 0; i < latency; ++i) {
56  history_.push_back(targetRegister.value());
57  }
58  position_ = 0;
59 }

References assert, history_, position_, and ReadableState::value().

Here is the call graph for this function:

◆ ~GuardState()

GuardState::~GuardState ( )
virtual

Destructor.

Definition at line 73 of file GuardState.cc.

73  {
74 }

◆ GuardState() [2/3]

GuardState::GuardState ( )
protected

Only subclasses allowed to create empty GuardStates.

Constructor.

Creates an empty GuardState, only to be used by subclasses, i.e., NullGuardState.

Definition at line 67 of file GuardState.cc.

67  : target_(NULL), position_(-1) {
68 }

◆ GuardState() [3/3]

GuardState::GuardState ( const GuardState )
private

Copying not allowed.

Member Function Documentation

◆ advanceClock()

void GuardState::advanceClock ( )
virtual

Updates the guard value history.

Implements ClockedState.

Reimplemented in DirectGuardState.

Definition at line 89 of file GuardState.cc.

89  {
91  position_ = (position_ + 1);
92  if ((size_t)position_ >= history_.size())
93  position_ = 0;
94 }

References history_, position_, target_, and ReadableState::value().

Here is the call graph for this function:

◆ endClock()

void GuardState::endClock ( )
virtual

Does nothing.

The guard history is updated in advanceClock().

Implements ClockedState.

Reimplemented in DirectGuardState.

Definition at line 82 of file GuardState.cc.

82  {
83 }

◆ operator=()

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

Assignment not allowed.

◆ value()

const SimValue & GuardState::value ( ) const
virtual

Returns the current value of the guard, taking the latency in account.

Returns
The current value of the guard.

Implements ReadableState.

Reimplemented in DirectGuardState.

Definition at line 102 of file GuardState.cc.

102  {
103  return history_[position_];
104 }

References history_, and position_.

Member Data Documentation

◆ history_

std::vector<SimValue> GuardState::history_
private

Value history ring buffer.

Definition at line 86 of file GuardState.hh.

Referenced by advanceClock(), GuardState(), and value().

◆ position_

int GuardState::position_
private

History ring buffer position. Point to the index of the current value of the guard.

Definition at line 89 of file GuardState.hh.

Referenced by advanceClock(), GuardState(), and value().

◆ target_

const ReadableState* GuardState::target_
private

The target register watched by this guard.

Definition at line 84 of file GuardState.hh.

Referenced by advanceClock().


The documentation for this class was generated from the following files:
GuardState::history_
std::vector< SimValue > history_
Value history ring buffer.
Definition: GuardState.hh:86
GuardState::position_
int position_
History ring buffer position. Point to the index of the current value of the guard.
Definition: GuardState.hh:89
assert
#define assert(condition)
Definition: Application.hh:86
ReadableState::value
virtual const SimValue & value() const =0
GuardState::target_
const ReadableState * target_
The target register watched by this guard.
Definition: GuardState.hh:84