67 tpef_(tpef), adf_(adf), aSpaceSection_(NULL), strings_(NULL),
68 undefASpace_(NULL), codeASpace_(NULL), nullSection_(NULL),
69 resourceSection_(NULL), lastFunctionUnitID_(0), lastRegisterFileID_(0),
70 lastOpOrSpecRegisterID_(0), parent_(parent) {
95 "ADF doesn't contain address space: " + name);
102 assert(adfAddressSpace != NULL);
115 "Method can't be used for getting code address space.");
222 if (adfAddressSpace == NULL) {
225 "Control unit has no address space.");
298 std::cerr <<
"\ttype: " << term.
type << std::endl;
338 currentLine, term, slotNumber, type, resKey.
keyString);
353 std::cerr <<
"resKey: " << resKey.
keyString
354 <<
"\ttype: " << resKey.
type
397 for (
int i = 0; i < busNavi.
count(); i++) {
402 newRes->
setId(i + 1);
425 std::cerr <<
"Added resource element: "
427 <<
"\t" << (int)resource->
type()
428 <<
"\t" << (int)resource->
id()
529 if (opOrPortString.find(
'.') == std::string::npos) {
542 newRes->
setId(generatedID);
563 default:
return "invalid request type";
596 "Can't find function unit from machine: " +
606 "Can't find port: " +
612 std::string regString;
620 " is not found from fu: " +
639 " is not bound to port: " +
672 RequestType type, std::string& resourceKeyString) {
696 std::string warning =
"Unit name '";
698 warning +=
"' is ambiguous. Because of disambiguity rules, '";
700 warning +=
"' is selected to refer the register file insread of";
701 warning +=
" the immediate unit.";
720 if (rf != NULL && fu != NULL) {
721 std::string warning =
"Unit name '";
723 warning +=
"' is ambiguous.";
728 fu, rf, currentLine, term, slotNumber, type, resourceKeyString);
733 rf, term, slotNumber, type, resourceKeyString);
758 std::string& resourceKeyString) {
771 std::stringstream newErrorMsg;
773 <<
"Too few busses for all moves in instruction."
782 bool isPossible =
false;
787 for (
int i = 0; i < rf->
portCount(); i++) {
805 "Selected different port for move"
806 "that was given by user.");
861 if (rf == NULL && fu != NULL) {
875 "Can't find operand: " +
884 std::stringstream newErrorMsg;
886 <<
"Too few busses for all moves in instruction."
895 bool isPossible =
false;
922 if (guard->
port() == port &&
937 std::string operationRegisterStr =
959 if (rf == NULL && fu == NULL) {
963 "fu term: " + resourceKeyString);
985 RequestType type, std::string& resourceKeyString) {
994 " rf.index term: " + resourceKeyString);
1002 "Not enough registers in registerfile.");
1008 bool isPossible =
false;
1017 if (immUnit != NULL) {
1023 for (
int i = 0; i < rf->
portCount(); i++) {
1043 for (
int i = 0; i < bus->
guardCount(); i++) {
1047 if (guard != NULL) {
1075 " term: " + resourceKeyString);
#define abortWithError(message)
#define assert(condition)
void addWarning(UValue lineNumber, const std::string &message)
bool prev
Previous or next bus register.
static std::string toString(const T &source)
std::string errorMessage() const
void setCause(const Exception &cause)
std::string part3
Operation name.
std::string part2
Port name.
std::string part1
Unit name.
bool part3Used
Is operation part of the term used.
std::string part1
Unit name.
std::string part2
Port or operation name.
bool part2Used
Is port name used.
UValue index
Register or operand index.
TPEF::StringSection * strings_
The string section of TPEF.
void initResourceSection()
std::map< std::string, UValue > opOrPortIDs_
Bookkeeping of already added ports, operations and special registers.
ResourceID & resourceID(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type)
AssemblyParserDiagnostic * parent_
Assembler root class for adding warnings.
void addResourceElement(TPEF::ResourceElement *resource)
const TTAMachine::Machine & adf_
Machine where manager tries to find used resources.
UValue lastRegisterFileID_
For generating register file resource ids.
UValue functionUnitID(TTAMachine::FunctionUnit *unit)
std::map< TTAMachine::BaseRegisterFile *, UValue > registerFileIDs_
Bookkeeping of already added register files.
std::string requestTypeString(RequestType type) const
ResourceID rFPortOrFUIndexReference(TTAMachine::FunctionUnit *fu, TTAMachine::BaseRegisterFile *rf, UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
ResourceID functionUnitPortResource(const RegisterTerm &term)
TPEF::ResourceSection * resourceSection_
The resource section of TPEF.
UValue lastOpOrSpecRegisterID_
For generating shared ids for ports, operations or special registers.
ResourceID registerFileIndexReference(TTAMachine::BaseRegisterFile *rf, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
std::map< std::string, TPEF::ASpaceElement * > addressSpaces_
Bookkeeping for already requested address spaces.
UValue findBusWidth(UValue slotNumber)
MachineResourceManager(TPEF::Binary &tpef, const TTAMachine::Machine &adf, AssemblyParserDiagnostic *parent_)
@ RQST_INVGUARD
Inverted register or port guard.
@ RQST_READ
Register of port for reading.
@ RQST_WRITE
Register or port for writing.
@ RQST_GUARD
Register or port guard.
TPEF::Section * nullSection()
UValue opOrPortID(std::string opOrPortString, const TTAMachine::Port *port)
TPEF::Binary & tpef_
Binary where all used resources are added.
TPEF::ASpaceSection * aSpaceSection_
The address space section of TPEF.
TPEF::StringSection * stringSection()
TPEF::ASpaceElement * findDataAddressSpace(std::string name)
ResourceID indexResource(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
TPEF::ASpaceElement * codeASpace_
The instruction address space element of TPEF.
TPEF::ASpaceElement * undefinedAddressSpace()
TPEF::Chunk * stringToChunk(const std::string aStr)
std::map< TTAMachine::FunctionUnit *, UValue > functionUnitIDs_
Bookkeeping of already added function units.
TPEF::ASpaceElement * codeAddressSpace()
UValue lastFunctionUnitID_
For generating function unit resource ids.
UValue registerFileID(TTAMachine::BaseRegisterFile *rf)
TPEF::ASpaceElement * undefASpace_
The undefined address space element of TPEF.
TPEF::NullSection * nullSection_
The null section of TPEF.
std::map< ResourceKey, ResourceID > resourceMap_
Bookkeeping for already requested resources.
TPEF::ResourceSection * resourceSection()
FUTerm fuTerm
The fu term, if type field is FUNCTION_UNIT. Otherwise not used.
IndexTerm indexTerm
The index term, if type field is INDEX. Otherwise not used.
TermType type
Type of terminal that is represented by this object.
BusTerm busTerm
The bus term, if type field is BUS. Otherwise not used.
void setName(const ReferenceManager::SafePointer *aName)
void setUndefinedASpace(ASpaceElement *aSpace)
void addSection(Section *section)
void setStrings(StringSection *strTable)
virtual void addByte(Byte aByte)
ResourceType type() const
void setName(ReferenceManager::SafePointer *aName)
@ MRT_SR
Special register.
@ MRT_PORT
Function unit port.
@ MRT_OP
Operation operand or function unit register.
void setType(ResourceType aType)
static Section * createSection(SectionType type)
virtual void addElement(SectionElement *element)
@ ST_ADDRSP
Address space section.
@ ST_MR
Machine resources section.
void setLink(const ReferenceManager::SafePointer *aLink)
void setASpace(const ReferenceManager::SafePointer *addrSpace)
void setName(const ReferenceManager::SafePointer *sectionName)
std::string chunk2String(const Chunk *chunk) const
Chunk * string2Chunk(const std::string &str)
virtual int width() const
virtual int numberOfRegisters() const
virtual int width() const
virtual RFPort * port(const std::string &name) const
Guard * guard(int index) const
virtual TCEString name() const
virtual AddressSpace * addressSpace() const
virtual HWOperation * operation(const std::string &name) const
virtual bool hasOperation(const std::string &name) const
virtual BaseFUPort * port(const std::string &name) const
virtual bool isInverted() const
virtual FUPort * port(int operand) const
int io(const FUPort &port) const
ComponentType * item(int index) const
bool hasItem(const std::string &name) const
virtual RegisterFileNavigator registerFileNavigator() const
virtual FunctionUnitNavigator functionUnitNavigator() const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
virtual BusNavigator busNavigator() const
virtual AddressSpaceNavigator addressSpaceNavigator() const
virtual ControlUnit * controlUnit() const
virtual Socket * outputSocket() const
virtual int width() const =0
virtual Socket * inputSocket() const
virtual std::string name() const
int registerIndex() const
const RegisterFile * registerFile() const
bool isConnectedTo(const Bus &bus) const
virtual bool hasPort(const std::string &name) const
virtual int portCount() const
UValue width
Width of accessed port or other resource.
TPEF::MoveElement::FieldType type
Resource type.
UValue index
TPEF Resource operand id or register file index.
UValue unit
TPEF Resource unit id.
UValue slotNumber
Bus that was used.
std::string keyString
Key string for resource.
RequestType type
Was resource read or written or was it guard.