OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Private Attributes | List of all members
TPEF::LEDataSection Class Reference

#include <LEDataSection.hh>

Inheritance diagram for TPEF::LEDataSection:
Inheritance graph
Collaboration diagram for TPEF::LEDataSection:
Collaboration graph

Public Member Functions

virtual ~LEDataSection ()
 
virtual SectionType type () const
 
virtual void writeValue (Word index, Word numOfMAUs, unsigned long value)
 
virtual void writeValue (Word index, Word numOfMAUs, signed long value)
 
- Public Member Functions inherited from TPEF::DataSection
virtual ~DataSection ()
 
virtual Byte byte (const Chunk *chunk) const
 
virtual Byte byte (Word offset) const
 
virtual void addByte (Byte aByte)
 
virtual MinimumAddressableUnit MAU (Word index) const
 
virtual void addMAU (MinimumAddressableUnit aMAU)
 
virtual Word length () const
 
virtual void setDataLength (Word length)
 
virtual bool isDataSection () const override
 
- Public Member Functions inherited from TPEF::UDataSection
virtual ~UDataSection ()
 
- Public Member Functions inherited from TPEF::RawSection
virtual bool isChunkable () const
 
virtual Chunkchunk (SectionOffset offset) const
 
virtual void assureInSection (SectionOffset offset) const
 
virtual ~RawSection ()
 
bool empty () const
 
virtual void setLengthInMAUs (Word length)
 
virtual Word lengthInMAUs () const
 
virtual Word bytesToMAUs (Word byteCount) const
 
virtual Word MAUsToBytes (Word mauCount) const
 
virtual Word chunkToMAUIndex (const Chunk *chunk) const
 
Word referredChunkCount () const
 
ChunkreferredChunk (Word index) const
 
bool belongsToSection (const Chunk *chunk) const
 
- Public Member Functions inherited from TPEF::Section
virtual ~Section ()
 
bool isProgramSection () const
 
bool isAuxSection () const
 
virtual void addElement (SectionElement *element)
 
virtual void setElement (Word index, SectionElement *element)
 
SectionElementelement (Word index) const
 
Word elementCount () const
 
void setFlagNoBits ()
 
void unsetFlagNoBits ()
 
bool noBits () const
 
bool vLen () const
 
Byte flags () const
 
void setFlags (Byte flagByte)
 
void setStartingAddress (AddressImage address)
 
AddressImage startingAddress () const
 
void setLink (const ReferenceManager::SafePointer *aLink)
 
void setLink (Section *aLink)
 
Sectionlink () const
 
void setASpace (const ReferenceManager::SafePointer *addrSpace)
 
void setASpace (ASpaceElement *addrSpace)
 
ASpaceElementaSpace () const
 
void setName (const ReferenceManager::SafePointer *sectionName)
 
void setName (Chunk *sectionName)
 
Chunkname () const
 
virtual bool isCodeSection () const
 
- Public Member Functions inherited from TPEF::SafePointable
virtual ~SafePointable ()
 

Protected Member Functions

 LEDataSection (bool init)
 
virtual Sectionclone () const
 
- Protected Member Functions inherited from TPEF::DataSection
 DataSection (bool init)
 
virtual void setByte (Word offset, Byte aByte)
 
- Protected Member Functions inherited from TPEF::UDataSection
 UDataSection (bool init)
 
- Protected Member Functions inherited from TPEF::RawSection
 RawSection ()
 
- Protected Member Functions inherited from TPEF::Section
 Section ()
 
void setFlagVLen ()
 
void unsetFlagVLen ()
 
- Protected Member Functions inherited from TPEF::SafePointable
 SafePointable ()
 

Static Private Attributes

static LEDataSection proto_
 Prototype instance of section.
 

Additional Inherited Members

- Public Types inherited from TPEF::Section
enum  SectionType {
  ST_NULL = 0x00 , ST_STRTAB = 0x01 , ST_SYMTAB = 0x02 , ST_DEBUG = 0x03 ,
  ST_RELOC = 0x04 , ST_LINENO = 0x05 , ST_NOTE = 0x06 , ST_ADDRSP = 0x07 ,
  ST_MR = 0x0A , ST_CODE = 0x81 , ST_DATA = 0x82 , ST_UDATA = 0x83 ,
  ST_LEDATA = 0x84 , ST_DUMMY = 0xff
}
 
enum  SectionFlag { SF_VLEN = 0x40 , SF_NOBITS = 0x80 }
 
- Static Public Member Functions inherited from TPEF::Section
static SectioncreateSection (SectionType type)
 
static bool isProgramSection (SectionType type)
 
- Static Protected Member Functions inherited from TPEF::Section
static void registerSection (const Section *section)
 

Detailed Description

Data section for initialized data in Little-Endian ADFs

Derives from big-endian data section so, this is extension of DataSection.

Definition at line 52 of file LEDataSection.hh.

Constructor & Destructor Documentation

◆ ~LEDataSection()

TPEF::LEDataSection::~LEDataSection ( )
virtual

Destructor.

Definition at line 64 of file LEDataSection.cc.

64 {
65}

◆ LEDataSection()

TPEF::LEDataSection::LEDataSection ( bool  init)
protected

Constructor.

Parameters
inittrue if registeration is wanted

Definition at line 51 of file LEDataSection.cc.

51 : DataSection(false) {
52
53 if (init) {
55 }
56
59}
DataSection(bool init)
static void registerSection(const Section *section)
Definition Section.cc:114
void unsetFlagNoBits()
void unsetFlagVLen()

References TPEF::Section::registerSection(), TPEF::Section::unsetFlagNoBits(), and TPEF::Section::unsetFlagVLen().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

Section * TPEF::LEDataSection::clone ( ) const
protectedvirtual

Creates an instance of DataSection.

Returns
Newly created section.

Reimplemented from TPEF::DataSection.

Definition at line 83 of file LEDataSection.cc.

83 {
84
85 return new LEDataSection(false);
86}

◆ type()

Section::SectionType TPEF::LEDataSection::type ( ) const
virtual

Returns section's type.

Returns
Type of section.

Reimplemented from TPEF::DataSection.

Definition at line 73 of file LEDataSection.cc.

73 {
74 return ST_LEDATA;
75}
@ ST_LEDATA
Initialized little endian data section.
Definition Section.hh:82

References TPEF::Section::ST_LEDATA.

◆ writeValue() [1/2]

void TPEF::LEDataSection::writeValue ( Word  index,
Word  numOfMAUs,
signed long  value 
)
virtual

Writes signed value to data section.

For example, when we call writeValue(0, 4, -3) and MAU is 2bit start of data section will be 11 11 11 01.

MAUs are stored in data section like this: 00000011 000000011 00000011 00000001 (one MAU per byte)

If we call writeValue(0, 4, -3) and MAU is 10bit start of data section will be 1111111111 1111111111 1111111111 1111111101.

However the MAUs are stored in data section like this:

00000011 11111111|00000011 11111111|00000011 11111111|00000011 11111101| MAU1 | MAU2 | MAU3 | MAU4 |

Parameters
indexMAU offset to section where to we write value.
numOfMAUsNumber of MAUs that we use for storing value.
valueValue to write.

Reimplemented from TPEF::DataSection.

Definition at line 161 of file LEDataSection.cc.

161 {
162
163 int mauInBytes = MAUsToBytes(1);
164
165 MinimumAddressableUnit mauMask =
166 static_cast<unsigned int>(-1) >>
167 (sizeof(mauMask)*BYTE_BITWIDTH - aSpace()->MAU());
168
169 int shiftCount = 0;
170 // start writing from beginning of area..
171 for (unsigned int i = 0; i < numOfMAUs; i++) {
172 int byteOffset = MAUsToBytes(index + i);
173
174 MinimumAddressableUnit currentMAU =
175 static_cast<MinimumAddressableUnit>(~0);
176
177 if (shiftCount < static_cast<int>(sizeof(value)*BYTE_BITWIDTH)) {
178 // I tried math tools... system tests went broken :(
179 // ssooo... if it's not broken....
180 currentMAU = (value >> shiftCount) & mauMask;
181 shiftCount += aSpace()->MAU();
182 }
183
184 // write current MAU :)
185 for (int j = mauInBytes-1; j >= 0; j--) {
186 Byte currentByte = static_cast<Byte>(currentMAU);
187 setByte(byteOffset + j,currentByte);
188 currentMAU = currentMAU >> BYTE_BITWIDTH;
189 }
190 }
191}
Word MinimumAddressableUnit
Type for storing a MAU (must be unsigned type!). This limits the maximum size of the simulated minimu...
Definition BaseType.hh:184
const Byte BYTE_BITWIDTH
Definition BaseType.hh:136
unsigned char Byte
Definition BaseType.hh:116
Byte MAU() const
virtual void setByte(Word offset, Byte aByte)
virtual Word MAUsToBytes(Word mauCount) const
Definition Section.cc:320
ASpaceElement * aSpace() const

References TPEF::Section::aSpace(), BYTE_BITWIDTH, TPEF::ASpaceElement::MAU(), TPEF::RawSection::MAUsToBytes(), and TPEF::DataSection::setByte().

Here is the call graph for this function:

◆ writeValue() [2/2]

void TPEF::LEDataSection::writeValue ( Word  index,
Word  numOfMAUs,
unsigned long  value 
)
virtual

Writes unsigned value to data section.

Value is aligned to field as normal big endian value least significant bit is stored to last bit of last MAU.

If we call writeValue(0, 4, 3) and MAU is 2bit start of data section will be 00 00 00 11.

However the MAUs are stored in data section like this: 00000000|000000000|00000000|00000011 (one MAU per byte) MAU1 | MAU2 | MAU3 | MAU4

Parameters
indexMAU offset to section where to we write value.
numOfMAUsNumber of MAUs that we use for storing value.
valueValue to write.

Reimplemented from TPEF::DataSection.

Definition at line 107 of file LEDataSection.cc.

107 {
108
109 int mauInBytes = MAUsToBytes(1);
110
111 MinimumAddressableUnit mauMask =
112 static_cast<unsigned int>(-1) >>
113 (sizeof(mauMask)*BYTE_BITWIDTH - aSpace()->MAU());
114
115 int shiftCount = 0;
116 // start writing from beginning of area..
117 for (unsigned int i = 0; i < numOfMAUs; i++) {
118 int byteOffset = MAUsToBytes(index + i);
119
120 MinimumAddressableUnit currentMAU = 0;
121
122 if (shiftCount < static_cast<int>(sizeof(value)*BYTE_BITWIDTH)) {
123 // I tried math tools... system tests went broken :(
124 // ssooo... if it's not broken....
125 currentMAU = (value >> shiftCount) & mauMask;
126 }
127
128 shiftCount += aSpace()->MAU();
129
130 // write current MAU :)
131 for (int j = mauInBytes-1; j >= 0; j--) {
132 Byte currentByte = static_cast<Byte>(currentMAU);
133 setByte(byteOffset + j, currentByte);
134 currentMAU = currentMAU >> BYTE_BITWIDTH;
135 }
136 }
137}

References TPEF::Section::aSpace(), BYTE_BITWIDTH, TPEF::ASpaceElement::MAU(), TPEF::RawSection::MAUsToBytes(), and TPEF::DataSection::setByte().

Here is the call graph for this function:

Member Data Documentation

◆ proto_

LEDataSection TPEF::LEDataSection::proto_
staticprivate

Prototype instance of section.

Definition at line 66 of file LEDataSection.hh.


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