OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
Encoding Class Referenceabstract

#include <Encoding.hh>

Inheritance diagram for Encoding:
Inheritance graph
Collaboration diagram for Encoding:
Collaboration graph

Public Member Functions

virtual ~Encoding ()
 
InstructionFieldparent () const
 
unsigned int encoding () const
 
unsigned int extraBits () const
 
virtual int width () const
 
virtual int bitPosition () const =0
 
virtual ObjectStatesaveState () const
 

Static Public Attributes

static const std::string OSNAME_ENCODING = "encoding"
 ObjectState name for Encoding class.
 
static const std::string OSKEY_ENCODING = "encoding"
 ObjectState attribute key for the encoding.
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits.
 

Protected Member Functions

 Encoding (unsigned int encoding, unsigned int extraBits, InstructionField *parent)
 
 Encoding (const ObjectState *state, InstructionField *parent)
 
void setParent (InstructionField *parent)
 
void setEncoding (unsigned int encoding, unsigned int extraBits)
 

Private Attributes

unsigned int encoding_
 The encoding.
 
unsigned int extraBits_
 The number of extra bits.
 
InstructionFieldparent_
 The parent instruction field.
 

Detailed Description

Represents an encoding of a source of destination within a move slot. This is a base class for different encodings.

Definition at line 46 of file Encoding.hh.

Constructor & Destructor Documentation

◆ ~Encoding()

Encoding::~Encoding ( )
virtual

The destructor.

Definition at line 87 of file Encoding.cc.

87 {
88}

◆ Encoding() [1/2]

Encoding::Encoding ( unsigned int  encoding,
unsigned int  extraBits,
InstructionField parent 
)
protected

The constructor.

Parameters
encodingThe encoding.
extraBitsThe number of extra bits.
parentThe parent pointer.

Definition at line 53 of file Encoding.cc.

56 :
58}
unsigned int encoding_
The encoding.
Definition Encoding.hh:81
unsigned int extraBits() const
Definition Encoding.cc:119
InstructionField * parent() const
Definition Encoding.cc:97
InstructionField * parent_
The parent instruction field.
Definition Encoding.hh:85
unsigned int extraBits_
The number of extra bits.
Definition Encoding.hh:83
unsigned int encoding() const
Definition Encoding.cc:108

◆ Encoding() [2/2]

Encoding::Encoding ( const ObjectState state,
InstructionField parent 
)
protected

The constructor.

Loads the state of the object from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
parentThe parent pointer.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Definition at line 71 of file Encoding.cc.

73 const string procName = "Encoding::Encoding";
74
75 try {
78 } catch (const Exception& exception) {
80 __FILE__, __LINE__, procName, exception.errorMessage());
81 }
82}
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition Encoding.hh:68
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding.
Definition Encoding.hh:66
std::string errorMessage() const
Definition Exception.cc:123
int intAttribute(const std::string &name) const

References encoding_, Exception::errorMessage(), extraBits_, ObjectState::intAttribute(), OSKEY_ENCODING, and OSKEY_EXTRA_BITS.

Here is the call graph for this function:

Member Function Documentation

◆ bitPosition()

virtual int Encoding::bitPosition ( ) const
pure virtual

Returns the position of the encoding within the parent field.

Implemented in BridgeEncoding, ImmediateEncoding, NOPEncoding, and SocketEncoding.

◆ encoding()

unsigned int Encoding::encoding ( ) const

◆ extraBits()

unsigned int Encoding::extraBits ( ) const

◆ parent()

InstructionField * Encoding::parent ( ) const

Returns the parent instruction field.

Returns
The parent instruction field.

Definition at line 97 of file Encoding.cc.

97 {
98 return parent_;
99}

References parent_.

Referenced by BridgeEncoding::parent(), ImmediateEncoding::parent(), NOPEncoding::parent(), SocketEncoding::parent(), and setParent().

◆ saveState()

ObjectState * Encoding::saveState ( ) const
virtual

Saves the state of the object to an ObjectState instance.

Returns
The newly created ObjectState instance.

Reimplemented in BridgeEncoding, ImmediateEncoding, NOPEncoding, and SocketEncoding.

Definition at line 141 of file Encoding.cc.

141 {
145 return state;
146}
static const std::string OSNAME_ENCODING
ObjectState name for Encoding class.
Definition Encoding.hh:64
void setAttribute(const std::string &name, const std::string &value)

References encoding(), extraBits(), OSKEY_ENCODING, OSKEY_EXTRA_BITS, OSNAME_ENCODING, and ObjectState::setAttribute().

Referenced by BridgeEncoding::saveState(), ImmediateEncoding::saveState(), NOPEncoding::saveState(), and SocketEncoding::saveState().

Here is the call graph for this function:

◆ setEncoding()

void Encoding::setEncoding ( unsigned int  encoding,
unsigned int  extraBits 
)
protected

Sets the encoding

Definition at line 163 of file Encoding.cc.

163 {
166}

References encoding(), encoding_, extraBits(), and extraBits_.

Referenced by SocketEncoding::setEncoding().

Here is the call graph for this function:

◆ setParent()

void Encoding::setParent ( InstructionField parent)
protected

◆ width()

int Encoding::width ( ) const
virtual

Returns the bit width required by the encoding.

Returns
The bit width.

Reimplemented in ImmediateEncoding, and SocketEncoding.

Definition at line 130 of file Encoding.cc.

130 {
132}
static unsigned int bitLength(long unsigned int number)

References MathTools::bitLength(), encoding(), and extraBits().

Referenced by BridgeEncoding::bitPosition(), NOPEncoding::bitPosition(), BEMTester::canAddComponentEncoding(), CodeCompressorPlugin::encodeNOP(), ImmediateEncoding::encodingWidth(), printSlotFieldEncodings(), printSourceFieldEncodings(), SlotField::width(), and SourceField::width().

Here is the call graph for this function:

Member Data Documentation

◆ encoding_

unsigned int Encoding::encoding_
private

The encoding.

Definition at line 81 of file Encoding.hh.

Referenced by encoding(), Encoding(), and setEncoding().

◆ extraBits_

unsigned int Encoding::extraBits_
private

The number of extra bits.

Definition at line 83 of file Encoding.hh.

Referenced by Encoding(), extraBits(), and setEncoding().

◆ OSKEY_ENCODING

const std::string Encoding::OSKEY_ENCODING = "encoding"
static

◆ OSKEY_EXTRA_BITS

const std::string Encoding::OSKEY_EXTRA_BITS = "extra_bits"
static

◆ OSNAME_ENCODING

const std::string Encoding::OSNAME_ENCODING = "encoding"
static

ObjectState name for Encoding class.

Definition at line 64 of file Encoding.hh.

Referenced by saveState().

◆ parent_

InstructionField* Encoding::parent_
private

The parent instruction field.

Definition at line 85 of file Encoding.hh.

Referenced by parent(), and setParent().


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