OpenASIP  2.0
BEMSerializer.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file BEMSerializer.cc
26  *
27  * Implementation of BEMSerializer class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include <vector>
35 
36 #include "BEMSerializer.hh"
37 #include "BinaryEncoding.hh"
38 #include "SocketCodeTable.hh"
39 #include "FUPortCode.hh"
40 #include "RFPortCode.hh"
41 #include "IUPortCode.hh"
42 #include "ImmediateControlField.hh"
43 #include "MoveSlot.hh"
44 #include "LImmDstRegisterField.hh"
45 #include "ImmediateSlotField.hh"
46 #include "GuardField.hh"
47 #include "SourceField.hh"
48 #include "DestinationField.hh"
49 #include "GPRGuardEncoding.hh"
50 #include "FUGuardEncoding.hh"
52 #include "SocketEncoding.hh"
53 #include "BridgeEncoding.hh"
54 #include "ImmediateEncoding.hh"
55 #include "NOPEncoding.hh"
56 #include "Application.hh"
57 #include "Environment.hh"
58 #include "ObjectState.hh"
59 #include "InstructionFormat.hh"
60 
61 using std::string;
62 using std::vector;
63 
64 const string TRUE = "true";
65 const string FALSE = "false";
66 
67 const string ADF_ENCODING = "adf-encoding";
68 const string BEM_VERSION_STR = "version";
69 const string REQUIRED_VERSION = "required-version";
70 
71 const string SOCKET_CODE_TABLE = "map-ports";
72 const string SC_TABLE_NAME = "name";
73 const string SC_TABLE_EXTRA_BITS = "extra-bits";
74 const string FU_PORT_CODE = "fu-port-code";
75 const string FU_PORT_CODE_PORT = "name";
76 const string FU_PORT_CODE_FU = "fu";
77 const string FU_PORT_CODE_OPERATION = "operation";
78 const string FU_PORT_CODE_ENCODING = "encoding";
79 const string FU_PORT_CODE_EXTRA_BITS = "extra-bits";
80 const string RF_PORT_CODE = "rf-port-code";
81 const string RF_PORT_CODE_RF = "rf";
82 const string RF_PORT_CODE_INDEX_WIDTH = "index-width";
83 const string RF_PORT_CODE_MAX_INDEX = "max-index";
84 const string RF_PORT_CODE_ENCODING = "encoding";
85 const string RF_PORT_CODE_EXTRA_BITS = "extra-bits";
86 const string IU_PORT_CODE = "iu-port-code";
87 const string IU_PORT_CODE_IU = "iu";
88 
89 const string LONG_IMMEDIATE_TAG = "long-immediate-tag";
90 const string LIMM_TAG_POSITION = "pos";
91 const string LIMM_TAG_EXTRA_BITS = "extra-bits";
92 const string LIMM_TAG_MAP = "map";
93 const string LIMM_TAG_MAP_NAME = "name";
94 
95 const string IMM_REG_FIELD = "immediate-register-field";
96 const string IMM_REG_FIELD_POS = "pos";
97 const string IMM_REG_FIELD_WIDTH = "width";
98 const string IMM_REG_FIELD_ITEMP = "instruction-template";
99 const string IMM_REG_FIELD_ITEMP_NAME = "name";
100 const string IMM_REG_FIELD_ITEMP_REG_INDEX = "reg-index-of";
101 
102 const string SLOT = "slot";
103 const string SLOT_NAME = "name";
104 const string SLOT_POSITION = "pos";
105 const string SLOT_EXTRA_BITS = "extra-bits";
106 const string SLOT_GUARD = "guard";
107 const string SLOT_GUARD_POSITION = "pos";
108 const string SLOT_GUARD_EXTRA_BITS = "extra-bits";
109 const string REG_GUARD_CODE = "reg-guard-code";
110 const string REG_GUARD_CODE_RF = "rf";
111 const string REG_GUARD_CODE_INDEX = "index";
112 const string REG_GUARD_CODE_INVERTED = "inv";
113 const string PORT_GUARD_CODE = "port-guard-code";
114 const string PORT_GUARD_CODE_FU = "fu";
115 const string PORT_GUARD_CODE_PORT = "port";
116 const string PORT_GUARD_CODE_INVERTED = "inv";
117 const string ALWAYS_TRUE_GUARD_CODE = "always-true-guard-code";
118 const string ALWAYS_FALSE_GUARD_CODE = "always-false-guard-code";
119 
120 const string SLOT_SOURCE = "source";
121 const string SLOT_DESTINATION = "destination";
122 
123 const string SRC_DST_POSITION = "pos";
124 const string SRC_DST_EXTRA_BITS = "extra-bits";
125 const string SRC_DST_ID_POS = "id-pos";
126 const string ID_POS_LEFT = "left";
127 const string ID_POS_RIGHT = "right";
128 
129 const string SOCKET = "socket";
130 const string SOCKET_NAME = "name";
131 const string SOCKET_MAP = "map";
132 const string SOCKET_MAP_EXTRA_BITS = "extra-bits";
133 const string SOCKET_MAP_CODES = "codes";
134 
135 const string SOURCE_IMMEDIATE = "immediate";
136 const string SOURCE_IMMEDIATE_WIDTH = "width";
137 const string SOURCE_IMMEDIATE_MAP = "map";
138 const string SOURCE_IMMEDIATE_MAP_EXTRA_BITS = "extra-bits";
139 const string SOURCE_BRIDGE = "bridge";
140 const string SOURCE_BRIDGE_NAME = "name";
141 const string SOURCE_BRIDGE_MAP = "map";
142 const string SOURCE_BRIDGE_MAP_EXTRA_BITS = "extra-bits";
143 
144 const string SRC_DST_NO_OPERATION = "no-operation";
145 const string SRC_DST_NO_OPERATION_MAP = "map";
146 const string SRC_DST_NO_OPERATION_MAP_EXTRA_BITS = "extra-bits";
147 
148 const string INSTRUCTION_FORMAT = "ota-format";
149 const string INSTRUCTION_FORMAT_NAME = "name";
150 
151 const string IMMEDIATE_SLOT = "immediate-slot";
152 const string IMMEDIATE_SLOT_NAME = "name";
153 const string IMMEDIATE_SLOT_WIDTH = "width";
154 const string IMMEDIATE_SLOT_POS = "pos";
155 
156 const string EXTRA_BITS = "extra-bits";
157 const string MAP = "map";
158 
159 const string BEM_SCHEMA_FILE = "bem/BEM_Schema.xsd";
160 
161 /**
162  * The constructor.
163  */
166  setUseSchema(true);
167 }
168 
169 
170 /**
171  * The destructor.
172  */
174 }
175 
176 
177 /**
178  * Reads the BEM file and returns an ObjectState tree that can be loaded by
179  * BinaryEncoding.
180  *
181  * @return An ObjectState tree that can be loaded by BinaryEncoding.
182  * @exception SerializerException If an error occurs while reading the BEM
183  * file.
184  */
187  ObjectState* fileState = XMLSerializer::readState();
188 
189  double version = fileState->doubleAttribute(BEM_VERSION_STR);
190  if (fileState->hasAttribute(REQUIRED_VERSION)) {
191  double requiredVersion = fileState->doubleAttribute(REQUIRED_VERSION);
192  if (requiredVersion > 1.5) {
195  "Cannot parse the file. "
196  "The file requests parser version of " +
197  fileState->stringAttribute(REQUIRED_VERSION) +
198  ". "
199  "The version of the parser is 1.5.");
200  }
201  }
202  if (version < 1.2) {
203  convertZeroEncExtraBits(fileState);
204  }
205  ObjectState* omState = convertToOMFormat(fileState);
206  delete fileState;
207  return omState;
208 }
209 
210 /**
211  * Recursively convert all encodings with zero encodings to have
212  * one more extra bit.
213  */
215  if (os->name() == MAP) {
216  if (os->intValue() == 0 && os->hasAttribute(EXTRA_BITS)) {
217  int extraBits = os->intAttribute(EXTRA_BITS);
218  os->setAttribute(EXTRA_BITS, extraBits + 1);
219  }
220  }
221  if (os->name() == FU_PORT_CODE &&
222  os->hasChild(EXTRA_BITS) &&
224  if (os->childByName(FU_PORT_CODE_ENCODING)->intValue() == 0) {
226  eb ->setValue(eb->intValue()+1);
227  }
228  }
229  // call recursively for children
230  for (int i = 0; i < os->childCount(); i++) {
231  ObjectState* child = os->child(i);
233  }
234 }
235 
236 
237 /**
238  * Writes the given ObjectState tree that represents a BEM object model to a
239  * BEM file.
240  *
241  * @param state ObjectState tree obtained by calling
242  * BinaryEncoding::saveState().
243  * @exception SerializerException If the destination file cannot be written.
244  */
245 void
247  ObjectState* fileState = convertToFileFormat(state);
248  XMLSerializer::writeState(fileState);
249  delete fileState;
250 }
251 
252 /**
253  * Reads the BEM file and creates a BinaryEncoding instance from it.
254  *
255  * @return The newly created BinaryEncoding instance.
256  */
259  ObjectState* omState = readState();
260  BinaryEncoding* bem = new BinaryEncoding(omState);
261  delete omState;
262  return bem;
263 }
264 
265 /**
266  * Writes the given binary encoding to a BEM file.
267  *
268  * @param bem The binary encoding.
269  * @exception SerializerException If the destination file cannot be written.
270  */
271 void
273  ObjectState* omState = bem.saveState();
274  writeState(omState);
275  delete omState;
276 }
277 
278 /**
279  * Converts the given ObjectState tree that represents a BEM file to an
280  * ObjectState tree that can be loaded by BinaryEncoding.
281  *
282  * @param fileState ObjectState tree that represents a BEM file.
283  * @return A newly created ObjectState tree that can be loaded by
284  * BinaryEncoding.
285  */
288 
290 
291  for (int i = 0; i < fileState->childCount(); i++) {
292  ObjectState* child = fileState->child(i);
293  if (child->name() == SOCKET_CODE_TABLE) {
294  bem->addChild(socketCodeTableToOM(child));
295  } else if (child->name() == SLOT) {
296  bem->addChild(moveSlotToOM(child));
297  } else if (child->name() == IMMEDIATE_SLOT) {
298  bem->addChild(immediateSlotToOM(child));
299  } else if (child->name() == LONG_IMMEDIATE_TAG) {
300  bem->addChild(longImmTagToOM(child));
301  } else if (child->name() == IMM_REG_FIELD) {
302  bem->addChild(longImmDstRegFieldToOM(child));
303  } else if (child->name() == INSTRUCTION_FORMAT) {
304  ObjectState* newChild = new ObjectState(*child);
305  bem->addChild(newChild);
306  } else if (
308  bem->addChild(new ObjectState(*child));
309  } else {
310  assert(false);
311  }
312  }
313 
314  return bem;
315 }
316 
317 
318 /**
319  * Converts the ObjectState tree that represent the BEM object model to an
320  * ObjectState tree that represents the BEM file format.
321  *
322  * @param omState ObjectState tree that represents BEM object model (returned
323  * by BinaryEncoding::saveState()).
324  * @return ObjectState tree representing BEM file.
325  */
328 
329  ObjectState* fileState = new ObjectState(ADF_ENCODING);
330  const string version = "1.5";
331  const string requiredVersion = "1.5";
332  fileState->setAttribute(BEM_VERSION_STR, version);
333  fileState->setAttribute(REQUIRED_VERSION, requiredVersion);
334 
335  // create socket code tables
336  for (int i = 0; i < state->childCount(); i++) {
337  ObjectState* child = state->child(i);
339  fileState->addChild(socketCodeTableToFile(child));
340  }
341  }
342 
343  // create long immediate tag
344  for (int i = 0; i < state->childCount(); i++) {
345  ObjectState* child = state->child(i);
346  if (child->name() ==
348  fileState->addChild(longImmTagToFile(child));
349  }
350  }
351 
352  // create long immediate destination register fields
353  for (int i = 0; i < state->childCount(); i++) {
354  ObjectState* child = state->child(i);
355  if (child->name() ==
357  fileState->addChild(longImmDstRegisterFieldToFile(child));
358  }
359  }
360 
361  // create move slots
362  for (int i = 0; i < state->childCount(); i++) {
363  ObjectState* child = state->child(i);
364  if (child->name() == MoveSlot::OSNAME_MOVE_SLOT) {
365  fileState->addChild(moveSlotToFile(child));
366  }
367  }
368 
369  // create immediate slots
370  for (int i = 0; i < state->childCount(); i++) {
371  ObjectState* child = state->child(i);
372  if (child->name() ==
374  fileState->addChild(immediateSlotToFile(child));
375  }
376  }
377 
378  for (int i = 0; i < state->childCount(); i++) {
379  ObjectState* child = state->child(i);
381  ObjectState* newChild = new ObjectState(*child);
382  fileState->addChild(newChild);
383  }
384  }
385 
386  // template extra bits: copy OS tree
387  for (int i = 0; i < state->childCount(); i++) {
388  ObjectState* child = state->child(i);
390  fileState->addChild(new ObjectState(*child));
391  }
392  }
393  return fileState;
394 }
395 
396 
397 /**
398  * Converts the given ObjectState tree that represents a socket code table in
399  * the object model format to BEM file format.
400  *
401  * @return The newly created ObjectState tree.
402  */
405 
406  ObjectState* scTable = new ObjectState(SOCKET_CODE_TABLE);
407  scTable->setAttribute(
408  SC_TABLE_NAME, omTable->stringAttribute(
410 
411  // create extra-bits element
412  ObjectState* extraBits = new ObjectState(SC_TABLE_EXTRA_BITS);
413  scTable->addChild(extraBits);
414  extraBits->setValue(
416 
417  // create fu-port-code elements
418  for (int i = 0; i < omTable->childCount(); i++) {
419  ObjectState* portCode = omTable->child(i);
420  if (portCode->name() == FUPortCode::OSNAME_FU_PORT_CODE) {
421  ObjectState* fuPortCode = new ObjectState(FU_PORT_CODE);
422  scTable->addChild(fuPortCode);
423  fuPortCode->setAttribute(
426  fuPortCode->setAttribute(
430  fuPortCode->setAttribute(
432  portCode->stringAttribute(
434  }
436  fuPortCode->addChild(encoding);
437  encoding->setValue(
440  fuPortCode->addChild(extraBits);
441  extraBits->setValue(
443  }
444  }
445 
446  // create rf-port-code elements
447  for (int i = 0; i < omTable->childCount(); i++) {
448  ObjectState* portCode = omTable->child(i);
449  if (portCode->name() == RFPortCode::OSNAME_RF_PORT_CODE) {
450  ObjectState* rfPortCode = new ObjectState(RF_PORT_CODE);
451  scTable->addChild(rfPortCode);
452  rfPortCode->setAttribute(
455  rfPortCode->setAttribute(
458 
460  rfPortCode->setAttribute(
463 
464  if (portCode->hasAttribute(RFPortCode::OSKEY_ENCODING)) {
465  ObjectState* encoding = new ObjectState(
467  rfPortCode->addChild(encoding);
468  encoding->setValue(
470  ObjectState* extraBits = new ObjectState(
472  rfPortCode->addChild(extraBits);
473  extraBits->setValue(
475  }
476  }
477  }
478 
479  // create iu-port-code elements
480  for (int i = 0; i < omTable->childCount(); i++) {
481  ObjectState* portCode = omTable->child(i);
482  if (portCode->name() == IUPortCode::OSNAME_IU_PORT_CODE) {
483  ObjectState* iuPortCode = new ObjectState(IU_PORT_CODE);
484  scTable->addChild(iuPortCode);
485  iuPortCode->setAttribute(
488  iuPortCode->setAttribute(
491 
493  iuPortCode->setAttribute(
496 
497  if (portCode->hasAttribute(IUPortCode::OSKEY_ENCODING)) {
498  ObjectState* encoding = new ObjectState(
500  iuPortCode->addChild(encoding);
501  encoding->setValue(
503  ObjectState* extraBits = new ObjectState(
505  iuPortCode->addChild(extraBits);
506  extraBits->setValue(
508  }
509  }
510  }
511 
512  return scTable;
513 }
514 
515 
516 /**
517  * Converts the given ObjectState tree that represents immediate control field
518  * in object model format to BEM file file format.
519  *
520  * @param immTag The ObjectState tree.
521  * @return The newly created ObjectState tree.
522  */
525 
527  ObjectState* position = new ObjectState(LIMM_TAG_POSITION);
528  fileTag->addChild(position);
529  position->setValue(
531  ObjectState* extraBits = new ObjectState(LIMM_TAG_EXTRA_BITS);
532  fileTag->addChild(extraBits);
533  extraBits->setValue(
535 
536  // create map elements
537  for (int i = 0; i < immTag->childCount(); i++) {
538  ObjectState* child = immTag->child(i);
541  fileTag->addChild(map);
542  map->setAttribute(
544  child->stringAttribute(
546  map->setValue(
548  }
549 
550  return fileTag;
551 }
552 
553 
554 /**
555  * Converts the given ObjectState tree that represents a move slot in object
556  * model format to BEM file format.
557  *
558  * @param slotState The ObjectState tree.
559  * @return The newly created ObjectState tree.
560  */
563 
564  ObjectState* slot = new ObjectState(SLOT);
565  slot->setAttribute(
567 
568  ObjectState* position = new ObjectState(SLOT_POSITION);
569  slot->addChild(position);
570  position->setValue(slotState->stringAttribute(MoveSlot::OSKEY_POSITION));
571  ObjectState* extraBits = new ObjectState(SLOT_EXTRA_BITS);
572  slot->addChild(extraBits);
573  extraBits->setValue(
575 
576  // add guard field
577  if (slotState->hasChild(GuardField::OSNAME_GUARD_FIELD)) {
578  ObjectState* guardField = slotState->childByName(
580  slot->addChild(guardFieldToFile(guardField));
581  }
582 
583  // add source field
584  if (slotState->hasChild(SourceField::OSNAME_SOURCE_FIELD)) {
585  ObjectState* sourceField = slotState->childByName(
587  slot->addChild(sourceFieldToFile(sourceField));
588  }
589 
590  // add destination field
592  ObjectState* destinationField = slotState->childByName(
594  slot->addChild(destinationFieldToFile(destinationField));
595  }
596  return slot;
597 }
598 
599 
600 /**
601  * Converts the given ObjectState tree that represents a guard field
602  * in object model to BEM file format.
603  *
604  * @param gFieldState The ObjectState tree.
605  * @return The newly created ObjectState tree.
606  */
609 
610  ObjectState* guard = new ObjectState(SLOT_GUARD);
612  guard->addChild(position);
613  position->setValue(
616  guard->addChild(extraBits);
617  extraBits->setValue(
619 
620  // add register guard encodings
621  for (int i = 0; i < gFieldState->childCount(); i++) {
622  ObjectState* child = gFieldState->child(i);
624  ObjectState* regGuard = new ObjectState(REG_GUARD_CODE);
625  guard->addChild(regGuard);
626  regGuard->setAttribute(
629  regGuard->setAttribute(
631  child->stringAttribute(
633  string inverted = child->boolAttribute(
635  regGuard->setAttribute(REG_GUARD_CODE_INVERTED, inverted);
636  regGuard->setValue(
638  }
639  }
640 
641  // add port guard encodings
642  for (int i = 0; i < gFieldState->childCount(); i++) {
643  ObjectState* child = gFieldState->child(i);
645  ObjectState* fuGuard = new ObjectState(PORT_GUARD_CODE);
646  guard->addChild(fuGuard);
647  fuGuard->setAttribute(
650  fuGuard->setAttribute(
653  string inverted = child->boolAttribute(
655  fuGuard->setAttribute(PORT_GUARD_CODE_INVERTED, inverted);
656  fuGuard->setValue(
658  }
659  }
660 
661  // add unconditional always-true-guard encoding
662  for (int i = 0; i < gFieldState->childCount(); i++) {
663  ObjectState* child = gFieldState->child(i);
664  if (child->name() ==
666  OSNAME_UNCONDITIONAL_GUARD_ENCODING &&
667  !child->boolAttribute(
670  guard->addChild(ucGuard);
671  ucGuard->setValue(
672  child->stringAttribute(
674  }
675  }
676 
677  // add always-false-guard encoding
678  for (int i = 0; i < gFieldState->childCount(); i++) {
679  ObjectState* child = gFieldState->child(i);
680  if (child->name() ==
682  && child->boolAttribute(
685  guard->addChild(ucGuard);
686  ucGuard->setValue(
687  child->stringAttribute(
689  }
690  }
691 
692  return guard;
693 }
694 
695 
696 /**
697  * Converts the given ObjectState tree that represents a source field in
698  * object model to BEM file format.
699  *
700  * @param sFieldState The ObjectState tree.
701  * @return The newly created ObjectState tree.
702  */
705 
706  ObjectState* source = slotFieldToFile(sFieldState);
707  source->setName(SLOT_SOURCE);
708 
709  // add immediate element in front of socket elements, it has to be done
710  // by removing the socket elements
712  std::vector<ObjectState*> socketElems;
713  for (int i = 0; i < source->childCount();) {
714  ObjectState* child = source->child(i);
715  if (child->name() == SOCKET) {
716  socketElems.push_back(child);
717  source->removeChild(child);
718  } else {
719  i++;
720  }
721  }
722  ObjectState* immediate = new ObjectState(SOURCE_IMMEDIATE);
723  source->addChild(immediate);
724  ObjectState* encodingState = sFieldState->childByName(
726  immediate->setAttribute(
728  encodingState->stringAttribute(
731  immediate->addChild(map);
733  encodingState->stringAttribute(
735  map->setValue(
736  encodingState->stringAttribute(
738 
739  // add the socket elements
740  for (vector<ObjectState*>::const_iterator iter = socketElems.begin();
741  iter != socketElems.end(); iter++) {
742  source->addChild(*iter);
743  }
744  }
745 
746  // add bridge elements
747  for (int i = 0; i < sFieldState->childCount(); i++) {
748  ObjectState* child = sFieldState->child(i);
750  ObjectState* bridge = new ObjectState(SOURCE_BRIDGE);
751  source->addChild(bridge);
752  bridge->setAttribute(
756  bridge->addChild(map);
757  map->setAttribute(
760  map->setValue(
762  }
763  }
764 
765  // move the no-operation element to the end
766  if (source->hasChild(SRC_DST_NO_OPERATION)) {
768  source->removeChild(nop);
769  source->addChild(nop);
770  }
771 
772  return source;
773 }
774 
775 
776 /**
777  * Converts the given ObjectState tree that represents a destination field in
778  * object model to BEM file format.
779  *
780  * @param dFieldState The ObjectState tree.
781  * @return The newly created ObjectState tree.
782  */
785  ObjectState* destination = slotFieldToFile(dFieldState);
786  destination->setName(SLOT_DESTINATION);
787  return destination;
788 }
789 
790 /**
791  * Converts the given ObjectState tree that represents either source or
792  * destination in BEM object model to BEM file format.
793  *
794  * @param sFieldState The ObjectState tree.
795  * @return The newly created ObjectState tree.
796  */
799 
800  ObjectState* srcOrDst = new ObjectState(SLOT_SOURCE);
801  ObjectState* position = new ObjectState(SRC_DST_POSITION);
802  srcOrDst->addChild(position);
803  position->setValue(
805  ObjectState* extraBits = new ObjectState(SRC_DST_EXTRA_BITS);
806  srcOrDst->addChild(extraBits);
807  extraBits->setValue(
809  ObjectState* encodingPos = new ObjectState(SRC_DST_ID_POS);
810  srcOrDst->addChild(encodingPos);
813  encodingPos->setValue(ID_POS_LEFT);
814  } else {
815  encodingPos->setValue(ID_POS_RIGHT);
816  }
817 
818  // add socket elements
819  for (int i = 0; i < sFieldState->childCount(); i++) {
820  ObjectState* child = sFieldState->child(i);
822  ObjectState* socket = new ObjectState(SOCKET);
823  srcOrDst->addChild(socket);
824  socket->setAttribute(
825  SOCKET_NAME,
827  ObjectState* map = new ObjectState(SOCKET_MAP);
828  socket->addChild(map);
829  map->setAttribute(
833  map->setAttribute(
836  }
837  map->setValue(
839  }
840  }
841 
842  // add move no-operation element
843  if (sFieldState->hasChild(NOPEncoding::OSNAME_NOP_ENCODING)) {
844  ObjectState* nopEncoding = sFieldState->childByName(
846  ObjectState* noOperation = new ObjectState(SRC_DST_NO_OPERATION);
847  srcOrDst->addChild(noOperation);
849  noOperation->addChild(map);
850  map->setAttribute(
853  map->setValue(
855  }
856 
857  return srcOrDst;
858 }
859 
860 
861 /**
862  * Converts the given ObjectState instance that represents an
863  * ImmediateSlotField instance to BEM file format.
864  *
865  * @param slotState The ObjectState instance that represents an
866  * ImmediateSlotField instance.
867  * @return The newly created ObjectState tree.
868  */
871  ObjectState* immSlot = new ObjectState(IMMEDIATE_SLOT);
872  immSlot->setAttribute(
876  immSlot->addChild(pos);
877  pos->setValue(
880  immSlot->addChild(width);
881  width->setValue(
883  return immSlot;
884 }
885 
886 
887 /**
888  * Converts the given ObjectState tree that represent a long immediate
889  * destination register field in BEM object model to BEM file format.
890  *
891  * @param omState The ObjectState tree.
892  * @return The newly create ObjectState tree.
893  */
896 
897  ObjectState* fileState = new ObjectState(IMM_REG_FIELD);
898  ObjectState* posElem = new ObjectState(IMM_REG_FIELD_POS);
899  fileState->addChild(posElem);
900  posElem->setValue(
902  ObjectState* widthElem = new ObjectState(IMM_REG_FIELD_WIDTH);
903  fileState->addChild(widthElem);
904  widthElem->setValue(
906 
907  for (int i = 0; i < omState->childCount(); i++) {
908  ObjectState* child = omState->child(i);
910  ObjectState* iTempElem = new ObjectState(IMM_REG_FIELD_ITEMP);
911  fileState->addChild(iTempElem);
912  iTempElem->setAttribute(
915  ObjectState* regIndexElem = new ObjectState(
917  iTempElem->addChild(regIndexElem);
918  regIndexElem->setValue(
920  }
921 
922  return fileState;
923 }
924 
925 /**
926  * Converts the given ObjectState tree that represents a socket code table
927  * in BEM file to an ObjectState tree that can be loaded by SocketCodeTable.
928  *
929  * @param scTable The ObjectState tree.
930  * @return The newly created ObjectState tree that can be loaded by
931  * SocketCodeTable.
932  */
935 
936  ObjectState* omTable = new ObjectState(
938  string name = scTable->stringAttribute(SC_TABLE_NAME);
940  int extraBits = scTable->childByName(SC_TABLE_EXTRA_BITS)->intValue();
941  omTable->setAttribute(
943 
944  // add port codes
945  for (int i = 0; i < scTable->childCount(); i++) {
946  ObjectState* child = scTable->child(i);
947  if (child->name() == FU_PORT_CODE) {
948  ObjectState* fuPortCode = new ObjectState(
950  omTable->addChild(fuPortCode);
951  string portName = child->stringAttribute(FU_PORT_CODE_PORT);
952  string fuName = child->stringAttribute(FU_PORT_CODE_FU);
953  fuPortCode->setAttribute(FUPortCode::OSKEY_UNIT_NAME, fuName);
954  fuPortCode->setAttribute(FUPortCode::OSKEY_PORT_NAME, portName);
955  if (child->hasAttribute(FU_PORT_CODE_OPERATION)) {
956  string opName = child->stringAttribute(
958  fuPortCode->setAttribute(
960  }
961 
962  fuPortCode->setAttribute(
965  fuPortCode->setAttribute(
968  } else if (child->name() == RF_PORT_CODE) {
969  ObjectState* rfPortCode = new ObjectState(
971  omTable->addChild(rfPortCode);
972  readRegisterFilePortCode(child, rfPortCode);
973  } else if (child->name() == IU_PORT_CODE) {
974  ObjectState* iuPortCode = new ObjectState(
976  omTable->addChild(iuPortCode);
977  readRegisterFilePortCode(child, iuPortCode);
978  }
979  }
980 
981  return omTable;
982 }
983 
984 
985 /**
986  * Converts the given ObjectState tree that represents a long-immediate-tag
987  * element of BEM file to ObjectState tree that can be loaded by
988  * ImmediateControlField.
989  *
990  * @param fileTag An ObjectState tree that represents a long-immediate-tag
991  * element.
992  * @return The newly created ObjectState tree.
993  */
996  ObjectState* immControlField =
998  ObjectState* pos = immTag->childByName(LIMM_TAG_POSITION);
999  immControlField->setAttribute(
1001  ObjectState* extraBits = immTag->childByName(LIMM_TAG_EXTRA_BITS);
1002  immControlField->setAttribute(
1004 
1005  // add template mappings
1006  for (int i = 0; i < immTag->childCount(); i++) {
1007  ObjectState* child = immTag->child(i);
1008  if (child->name() == LIMM_TAG_MAP) {
1009  ObjectState* mapping = new ObjectState(
1011  immControlField->addChild(mapping);
1012  mapping->setAttribute(
1015  mapping->setAttribute(
1017  }
1018  }
1019 
1020  return immControlField;
1021 }
1022 
1023 
1024 /**
1025  * Converts the given ObjectState tree that represents a slot element of
1026  * BEM file to ObjectState tree that can be loaded by MoveSlot.
1027  *
1028  * @param fileSlot The ObjectState tree that represents a slot element.
1029  * @return The newly created ObjectState tree.
1030  */
1031 ObjectState*
1033 
1035  string busName = fileSlot->stringAttribute(SLOT_NAME);
1036  moveSlot->setAttribute(MoveSlot::OSKEY_BUS_NAME, busName);
1037 
1038  ObjectState* pos = fileSlot->childByName(SLOT_POSITION);
1040 
1041  ObjectState* extraBits = fileSlot->childByName(SLOT_EXTRA_BITS);
1042  moveSlot->setAttribute(
1043  MoveSlot::OSKEY_EXTRA_BITS, extraBits->stringValue());
1044 
1045  // add guard field
1046  if (fileSlot->hasChild(SLOT_GUARD)) {
1047  ObjectState* guard = fileSlot->childByName(SLOT_GUARD);
1048  moveSlot->addChild(guardFieldToOM(guard));
1049  }
1050 
1051  // add source field
1052  if (fileSlot->hasChild(SLOT_SOURCE)) {
1053  ObjectState* source = fileSlot->childByName(SLOT_SOURCE);
1054  moveSlot->addChild(sourceFieldToOM(source));
1055  }
1056 
1057  // add destination field
1058  if (fileSlot->hasChild(SLOT_DESTINATION)) {
1059  ObjectState* destination = fileSlot->childByName(SLOT_DESTINATION);
1060  moveSlot->addChild(destinationFieldToOM(destination));
1061  }
1062 
1063  return moveSlot;
1064 }
1065 
1066 
1067 /**
1068  * Converts the given ObjectState tree that represents a guard element of
1069  * BEM file to a new ObjectState tree that can be loaded by GuardField.
1070  *
1071  * @param fileGuard An ObjectState tree that represents a guard element of
1072  * BEM file.
1073  * @return The newly created ObjectState tree.
1074  */
1075 ObjectState*
1077 
1078  ObjectState* guardField = new ObjectState(
1080  ObjectState* pos = fileGuard->childByName(SLOT_GUARD_POSITION);
1082  ObjectState* extraBits = fileGuard->childByName(SLOT_GUARD_EXTRA_BITS);
1083  guardField->setAttribute(
1085 
1086  // add guard encodings
1087  for (int i = 0; i < fileGuard->childCount(); i++) {
1088  ObjectState* child = fileGuard->child(i);
1089  if (child->name() == REG_GUARD_CODE) {
1090  ObjectState* guardCode = new ObjectState(
1092  guardField->addChild(guardCode);
1093  string regFile = child->stringAttribute(REG_GUARD_CODE_RF);
1094  guardCode->setAttribute(
1096  int regIndex = child->intAttribute(REG_GUARD_CODE_INDEX);
1097  guardCode->setAttribute(
1099  string inverted = child->stringAttribute(
1101  if (inverted == TRUE) {
1102  guardCode->setAttribute(
1104  } else if (inverted == FALSE) {
1105  guardCode->setAttribute(
1107  } else {
1108  assert(false);
1109  }
1110  guardCode->setAttribute(
1112 
1113  } else if (child->name() == PORT_GUARD_CODE) {
1114  ObjectState* guardCode = new ObjectState(
1116  guardField->addChild(guardCode);
1117  string fu = child->stringAttribute(PORT_GUARD_CODE_FU);
1119  string port = child->stringAttribute(PORT_GUARD_CODE_PORT);
1121  string inverted = child->stringAttribute(
1123  if (inverted == TRUE) {
1124  guardCode->setAttribute(
1126  } else if (inverted == FALSE) {
1127  guardCode->setAttribute(
1129  } else {
1130  assert(false);
1131  }
1132  guardCode->setAttribute(
1134 
1135  } else if (child->name() == ALWAYS_TRUE_GUARD_CODE ||
1136  child->name() == ALWAYS_FALSE_GUARD_CODE) {
1137  ObjectState* guardCode = new ObjectState(
1139  OSNAME_UNCONDITIONAL_GUARD_ENCODING);
1140  guardField->addChild(guardCode);
1141  guardCode->setAttribute(
1143  child->stringValue());
1144  if (child->name() == ALWAYS_TRUE_GUARD_CODE) {
1145  guardCode->setAttribute(
1147  } else {
1148  guardCode->setAttribute(
1150  }
1151  }
1152  }
1153 
1154  return guardField;
1155 }
1156 
1157 
1158 /**
1159  * Converts the given ObjectState tree that represents a source element in
1160  * BEM file to an ObjectState tree that can be loaded by SourceField.
1161  *
1162  * @param fileSource An ObjectState tree that represents a source element
1163  * in a BEM file.
1164  * @return The newly created ObjectState tree.
1165  */
1166 ObjectState*
1168 
1169  ObjectState* sourceField = slotFieldToOM(fileSource);
1171 
1172  // add immediate encoding
1173  if (fileSource->hasChild(SOURCE_IMMEDIATE)) {
1174  ObjectState* immEncoding = new ObjectState(
1176  sourceField->addChild(immEncoding);
1177  immEncoding->setAttribute(
1181  ObjectState* map = fileSource->childByName(SOURCE_IMMEDIATE)->
1182  child(0);
1183  immEncoding->setAttribute(
1185  immEncoding->setAttribute(
1188  }
1189 
1190  // add bridge encodings
1191  for (int i = 0; i < fileSource->childCount(); i++) {
1192  ObjectState* child = fileSource->child(i);
1193  if (child->name() == SOURCE_BRIDGE) {
1194  ObjectState* bridgeEncoding = new ObjectState(
1196  sourceField->addChild(bridgeEncoding);
1197  bridgeEncoding->setAttribute(
1200  ObjectState* map = child->childByName(SOURCE_BRIDGE_MAP);
1201  bridgeEncoding->setAttribute(
1204  bridgeEncoding->setAttribute(
1206  }
1207  }
1208 
1209  return sourceField;
1210 }
1211 
1212 
1213 /**
1214  * Converts the given ObjectState tree that represents a destination element
1215  * in BEM file to an ObjectState tree that can be loaded by DestinationField.
1216  *
1217  * @param fileDestination An ObjectState tree that represents a destination
1218  * element in a BEM file.
1219  * @return The newly created ObjectState tree.
1220  */
1221 ObjectState*
1223  ObjectState* destinationField = slotFieldToOM(fileDestination);
1225  return destinationField;
1226 }
1227 
1228 
1229 /**
1230  * Converts the given ObjectState tree that represents either source or
1231  * destination element of BEM file to an ObjectState tree that can be loaded
1232  * by SlotField.
1233  *
1234  * @param fileSlot An ObjectState tree representing source or destination
1235  * field.
1236  * @return The newly created ObjectState tree.
1237  */
1238 ObjectState*
1240 
1242  ObjectState* pos = fileSlot->childByName(SRC_DST_POSITION);
1243  slotField->setAttribute(
1245  ObjectState* extraBits = fileSlot->childByName(SRC_DST_EXTRA_BITS);
1246  slotField->setAttribute(
1248  if (fileSlot->childByName(SRC_DST_ID_POS)->stringValue() ==
1249  ID_POS_RIGHT) {
1250  slotField->setAttribute(
1252  } else {
1253  assert(
1254  fileSlot->childByName(SRC_DST_ID_POS)->stringValue() ==
1255  ID_POS_LEFT);
1256  slotField->setAttribute(
1258  }
1259 
1260  // read socket elements
1261  for (int i = 0; i < fileSlot->childCount(); i++) {
1262  ObjectState* child = fileSlot->child(i);
1263  if (child->name() == SOCKET) {
1264  ObjectState* socketEncoding = new ObjectState(
1266  slotField->addChild(socketEncoding);
1267  socketEncoding->setAttribute(
1269  child->stringAttribute(SOCKET_NAME));
1270  ObjectState* map = child->childByName(SOCKET_MAP);
1271  socketEncoding->setAttribute(
1273  socketEncoding->setAttribute(
1276  if (map->hasAttribute(SOCKET_MAP_CODES)) {
1277  socketEncoding->setAttribute(
1280  }
1281  }
1282  }
1283 
1284  // read NOP encoding
1285  if (fileSlot->hasChild(SRC_DST_NO_OPERATION)) {
1286  ObjectState* nopEncoding = new ObjectState(
1288  slotField->addChild(nopEncoding);
1289  ObjectState* map = fileSlot->childByName(SRC_DST_NO_OPERATION)->
1290  child(0);
1291  nopEncoding->setAttribute(
1293  nopEncoding->setAttribute(
1296  }
1297 
1298  return slotField;
1299 }
1300 
1301 
1302 /**
1303  * Converts the given ObjectState tree that represents immediate-slot element
1304  * of BEM file to an ObjectState instance that can be loaded by
1305  * ImmediateSlotField instance.
1306  *
1307  * @param fileSlot ObjectState tree that represents immediate-slot element
1308  * of BEM file.
1309  * @return The newly created ObjectState instance.
1310  */
1311 ObjectState*
1313  ObjectState* immSlotField = new ObjectState(
1315  string name = fileSlot->stringAttribute(IMMEDIATE_SLOT_NAME);
1316  immSlotField->setAttribute(ImmediateSlotField::OSKEY_NAME, name);
1317  string width = fileSlot->childByName(IMMEDIATE_SLOT_WIDTH)->
1318  stringValue();
1319  immSlotField->setAttribute(ImmediateSlotField::OSKEY_WIDTH, width);
1320  string pos = fileSlot->childByName(IMMEDIATE_SLOT_POS)->stringValue();
1323  return immSlotField;
1324 }
1325 
1326 
1327 /**
1328  * Converts the given ObjectState tree that represents a long immediate
1329  * destination register field in BEM file to an ObjectState tree that can
1330  * be loaded by LImmDstRegisterField instance.
1331  *
1332  * @param fileField The ObjectState tree that represents long immediate
1333  * destination register field in BEM file.
1334  * @return The newly created ObjectState tree.
1335  */
1336 ObjectState*
1338 
1339  ObjectState* omState = new ObjectState(
1342  omState->setAttribute(
1344  fileField->childByName(IMM_REG_FIELD_POS)->stringValue());
1345  omState->setAttribute(
1348 
1349  for (int i = 0; i < fileField->childCount(); i++) {
1350  ObjectState* child = fileField->child(i);
1351  if (child->name() == IMM_REG_FIELD_ITEMP) {
1352  ObjectState* iuDst = new ObjectState(
1354  omState->addChild(iuDst);
1355  iuDst->setAttribute(
1358  iuDst->setAttribute(
1360  child->child(0)->stringValue());
1361  }
1362  }
1363 
1364  return omState;
1365 }
1366 
1367 /**
1368  * Reads rf-port-code or iu-port-code element from an ObjectState tree that
1369  * represents BEM file and adds the data to the given ObjectState instance
1370  * to make it loadable by RFPortCode or IUPortCode.
1371  *
1372  * @param filePortCode ObjectState tree representing rf-port-code or
1373  * iu-port-code element of BEM file.
1374  * @param omPortCode The ObjectState instance to which the data is added.
1375  */
1376 void
1378  const ObjectState* filePortCode,
1379  ObjectState* omPortCode) {
1380 
1381  string unit;
1382  if (filePortCode->name() == RF_PORT_CODE) {
1383  unit = filePortCode->stringAttribute(RF_PORT_CODE_RF);
1384  } else if (filePortCode->name() == IU_PORT_CODE) {
1385  unit = filePortCode->stringAttribute(IU_PORT_CODE_IU);
1386  } else {
1387  assert(false);
1388  }
1389 
1390  omPortCode->setAttribute(PortCode::OSKEY_UNIT_NAME, unit);
1391  omPortCode->setAttribute(
1393  filePortCode->stringAttribute(RF_PORT_CODE_INDEX_WIDTH));
1394 
1395  if (filePortCode->hasChild(RF_PORT_CODE_ENCODING)) {
1396  ObjectState* encoding = filePortCode->childByName(
1398  omPortCode->setAttribute(
1399  PortCode::OSKEY_ENCODING, encoding->stringValue());
1400  ObjectState* extraBits = filePortCode->childByName(
1402  omPortCode->setAttribute(
1403  PortCode::OSKEY_EXTRA_BITS, extraBits->stringValue());
1404  }
1405 
1406 }
IMMEDIATE_SLOT_NAME
const string IMMEDIATE_SLOT_NAME
Definition: BEMSerializer.cc:152
SOCKET_NAME
const string SOCKET_NAME
Definition: BEMSerializer.cc:130
MAP
const string MAP
Definition: BEMSerializer.cc:157
FU_PORT_CODE_OPERATION
const string FU_PORT_CODE_OPERATION
Definition: BEMSerializer.cc:77
RF_PORT_CODE_EXTRA_BITS
const string RF_PORT_CODE_EXTRA_BITS
Definition: BEMSerializer.cc:85
ImmediateControlField::OSKEY_TEMPLATE_NAME
static const std::string OSKEY_TEMPLATE_NAME
ObjectState attribute key for the name of the instruction template.
Definition: ImmediateControlField.hh:88
FUGuardEncoding::OSKEY_PORT_NAME
static const std::string OSKEY_PORT_NAME
ObjectState attribute key for the name of the port.
Definition: FUGuardEncoding.hh:65
MoveSlot::OSNAME_MOVE_SLOT
static const std::string OSNAME_MOVE_SLOT
ObjectState name for move slot.
Definition: MoveSlot.hh:96
SLOT_GUARD_EXTRA_BITS
const string SLOT_GUARD_EXTRA_BITS
Definition: BEMSerializer.cc:108
UnconditionalGuardEncoding.hh
ObjectState::hasAttribute
bool hasAttribute(const std::string &name) const
Definition: ObjectState.cc:205
ADF_ENCODING
const string ADF_ENCODING
Definition: BEMSerializer.cc:67
SLOT_NAME
const string SLOT_NAME
Definition: BEMSerializer.cc:103
SRC_DST_ID_POS
const string SRC_DST_ID_POS
Definition: BEMSerializer.cc:125
BinaryEncoding
Definition: BinaryEncoding.hh:61
IMM_REG_FIELD_ITEMP_REG_INDEX
const string IMM_REG_FIELD_ITEMP_REG_INDEX
Definition: BEMSerializer.cc:100
BEMSerializer::BEMSerializer
BEMSerializer()
Definition: BEMSerializer.cc:164
IUPortCode.hh
BEMSerializer::immediateSlotToFile
static ObjectState * immediateSlotToFile(const ObjectState *slotState)
Definition: BEMSerializer.cc:870
InstructionField::OSKEY_POSITION
static const std::string OSKEY_POSITION
ObjectState attribute key for the relative position of the field.
Definition: InstructionField.hh:77
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
INSTRUCTION_FORMAT_NAME
const string INSTRUCTION_FORMAT_NAME
Definition: BEMSerializer.cc:149
SLOT_GUARD
const string SLOT_GUARD
Definition: BEMSerializer.cc:106
BEMSerializer::longImmDstRegisterFieldToFile
static ObjectState * longImmDstRegisterFieldToFile(const ObjectState *omState)
Definition: BEMSerializer.cc:895
FU_PORT_CODE_FU
const string FU_PORT_CODE_FU
Definition: BEMSerializer.cc:76
SC_TABLE_EXTRA_BITS
const string SC_TABLE_EXTRA_BITS
Definition: BEMSerializer.cc:73
ImmediateEncoding::OSNAME_IMM_ENCODING
static const std::string OSNAME_IMM_ENCODING
ObjectState name for immediate encoding.
Definition: ImmediateEncoding.hh:63
SRC_DST_NO_OPERATION_MAP
const string SRC_DST_NO_OPERATION_MAP
Definition: BEMSerializer.cc:145
RF_PORT_CODE_RF
const string RF_PORT_CODE_RF
Definition: BEMSerializer.cc:81
SOURCE_BRIDGE_NAME
const string SOURCE_BRIDGE_NAME
Definition: BEMSerializer.cc:140
ObjectState::intValue
int intValue() const
PortCode::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: PortCode.hh:73
GuardField.hh
BEMSerializer::slotFieldToOM
static ObjectState * slotFieldToOM(const ObjectState *fileSlot)
Definition: BEMSerializer.cc:1239
GPRGuardEncoding::OSKEY_REGISTER_INDEX
static const std::string OSKEY_REGISTER_INDEX
ObjectState attribute key for register index.
Definition: GPRGuardEncoding.hh:65
ImmediateControlField::OSNAME_IMM_CONTROL_FIELD
static const std::string OSNAME_IMM_CONTROL_FIELD
ObjectState name for immediate control field.
Definition: ImmediateControlField.hh:84
ImmediateSlotField::OSNAME_IMMEDIATE_SLOT_FIELD
static const std::string OSNAME_IMMEDIATE_SLOT_FIELD
ObjectState name for immediate slot field.
Definition: ImmediateSlotField.hh:63
BinaryEncoding::OSNAME_TEMPLATE_EXTRA_BITS
static const std::string OSNAME_TEMPLATE_EXTRA_BITS
Definition: BinaryEncoding.hh:128
SOURCE_BRIDGE_MAP
const string SOURCE_BRIDGE_MAP
Definition: BEMSerializer.cc:141
IMMEDIATE_SLOT_POS
const string IMMEDIATE_SLOT_POS
Definition: BEMSerializer.cc:154
FU_PORT_CODE
const string FU_PORT_CODE
Definition: BEMSerializer.cc:74
SocketCodeTable.hh
ImmediateSlotField.hh
ObjectState
Definition: ObjectState.hh:59
PortCode::OSKEY_UNIT_NAME
static const std::string OSKEY_UNIT_NAME
ObjectState attribute key for the name of the unit.
Definition: PortCode.hh:69
RFPortCode.hh
SOURCE_IMMEDIATE_MAP_EXTRA_BITS
const string SOURCE_IMMEDIATE_MAP_EXTRA_BITS
Definition: BEMSerializer.cc:138
PORT_GUARD_CODE_PORT
const string PORT_GUARD_CODE_PORT
Definition: BEMSerializer.cc:115
ImmediateEncoding.hh
INSTRUCTION_FORMAT
const string INSTRUCTION_FORMAT
Definition: BEMSerializer.cc:148
LONG_IMMEDIATE_TAG
const string LONG_IMMEDIATE_TAG
Definition: BEMSerializer.cc:89
GuardEncoding::OSKEY_INVERTED
static const std::string OSKEY_INVERTED
ObjectState attribute key for invert flag.
Definition: GuardEncoding.hh:58
RF_PORT_CODE_INDEX_WIDTH
const string RF_PORT_CODE_INDEX_WIDTH
Definition: BEMSerializer.cc:82
RFPortCode::OSNAME_RF_PORT_CODE
static const std::string OSNAME_RF_PORT_CODE
ObjectState name for RF port code.
Definition: RFPortCode.hh:57
SRC_DST_POSITION
const string SRC_DST_POSITION
Definition: BEMSerializer.cc:123
SourceField.hh
PortCode::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding.
Definition: PortCode.hh:71
FUPortCode::OSNAME_FU_PORT_CODE
static const std::string OSNAME_FU_PORT_CODE
ObjectState name for FU port code.
Definition: FUPortCode.hh:66
ObjectState::setName
void setName(const std::string &name)
SLOT_SOURCE
const string SLOT_SOURCE
Definition: BEMSerializer.cc:120
BEMSerializer::destinationFieldToFile
static ObjectState * destinationFieldToFile(const ObjectState *dFieldState)
Definition: BEMSerializer.cc:784
BEM_SCHEMA_FILE
const string BEM_SCHEMA_FILE
Definition: BEMSerializer.cc:159
BridgeEncoding::OSNAME_BRIDGE_ENCODING
static const std::string OSNAME_BRIDGE_ENCODING
ObjectState name for bridge encoding.
Definition: BridgeEncoding.hh:62
InstructionField::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: InstructionField.hh:75
MoveSlot.hh
SOURCE_IMMEDIATE_MAP
const string SOURCE_IMMEDIATE_MAP
Definition: BEMSerializer.cc:137
BridgeEncoding.hh
ALWAYS_FALSE_GUARD_CODE
const string ALWAYS_FALSE_GUARD_CODE
Definition: BEMSerializer.cc:118
PORT_GUARD_CODE
const string PORT_GUARD_CODE
Definition: BEMSerializer.cc:113
ObjectState::childByName
ObjectState * childByName(const std::string &name) const
Definition: ObjectState.cc:443
SOURCE_IMMEDIATE
const string SOURCE_IMMEDIATE
Definition: BEMSerializer.cc:135
SOCKET_MAP_EXTRA_BITS
const string SOCKET_MAP_EXTRA_BITS
Definition: BEMSerializer.cc:132
BEMSerializer::sourceFieldToOM
static ObjectState * sourceFieldToOM(const ObjectState *fileSource)
Definition: BEMSerializer.cc:1167
FUPortCode::OSKEY_OPERATION_NAME
static const std::string OSKEY_OPERATION_NAME
ObjectState attribute key for the name of the operation.
Definition: FUPortCode.hh:70
assert
#define assert(condition)
Definition: Application.hh:86
SLOT
const string SLOT
Definition: BEMSerializer.cc:102
LImmDstRegisterField::OSKEY_DST_IU
static const std::string OSKEY_DST_IU
ObjectState attribute key for the name of the immediate unit.
Definition: LImmDstRegisterField.hh:78
SocketEncoding::OSKEY_SC_TABLE
static const std::string OSKEY_SC_TABLE
ObjectState attribute key for the name of the socket code table.
Definition: SocketEncoding.hh:83
PORT_GUARD_CODE_FU
const string PORT_GUARD_CODE_FU
Definition: BEMSerializer.cc:114
PORT_GUARD_CODE_INVERTED
const string PORT_GUARD_CODE_INVERTED
Definition: BEMSerializer.cc:116
LIMM_TAG_EXTRA_BITS
const string LIMM_TAG_EXTRA_BITS
Definition: BEMSerializer.cc:91
ImmediateControlField::OSNAME_TEMPLATE_MAP
static const std::string OSNAME_TEMPLATE_MAP
ObjectState name for a template mapping.
Definition: ImmediateControlField.hh:86
BEMSerializer::convertToFileFormat
static ObjectState * convertToFileFormat(const ObjectState *omState)
Definition: BEMSerializer.cc:327
SOURCE_BRIDGE
const string SOURCE_BRIDGE
Definition: BEMSerializer.cc:139
BEMSerializer::~BEMSerializer
virtual ~BEMSerializer()
Definition: BEMSerializer.cc:173
SOCKET_CODE_TABLE
const string SOCKET_CODE_TABLE
Definition: BEMSerializer.cc:71
BEMSerializer::sourceFieldToFile
static ObjectState * sourceFieldToFile(const ObjectState *sFieldState)
Definition: BEMSerializer.cc:704
SocketEncoding::OSNAME_SOCKET_ENCODING
static const std::string OSNAME_SOCKET_ENCODING
ObjectState name for socket encoding.
Definition: SocketEncoding.hh:79
FUGuardEncoding.hh
LIMM_TAG_MAP_NAME
const string LIMM_TAG_MAP_NAME
Definition: BEMSerializer.cc:93
RF_PORT_CODE
const string RF_PORT_CODE
Definition: BEMSerializer.cc:80
SLOT_POSITION
const string SLOT_POSITION
Definition: BEMSerializer.cc:104
PortCode::OSKEY_MAX_INDEX
static const std::string OSKEY_MAX_INDEX
ObjectState attribute key for the max-index attribute.
Definition: PortCode.hh:77
XMLSerializer::setSchemaFile
void setSchemaFile(const std::string &fileName)
Definition: XMLSerializer.cc:168
BinaryEncoding::saveState
virtual ObjectState * saveState() const
Definition: BinaryEncoding.cc:858
ImmediateEncoding::OSKEY_IMM_WIDTH
static const std::string OSKEY_IMM_WIDTH
ObjectState attribute key for the immediate width.
Definition: ImmediateEncoding.hh:65
FUGuardEncoding::OSNAME_FU_GUARD_ENCODING
static const std::string OSNAME_FU_GUARD_ENCODING
ObjectState name for FU guard encoding.
Definition: FUGuardEncoding.hh:61
FU_PORT_CODE_PORT
const string FU_PORT_CODE_PORT
Definition: BEMSerializer.cc:75
ID_POS_LEFT
const string ID_POS_LEFT
Definition: BEMSerializer.cc:126
BEMSerializer::moveSlotToOM
static ObjectState * moveSlotToOM(const ObjectState *fileSlot)
Definition: BEMSerializer.cc:1032
BEMSerializer::guardFieldToOM
static ObjectState * guardFieldToOM(const ObjectState *fileGuard)
Definition: BEMSerializer.cc:1076
THROW_EXCEPTION
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition: Exception.hh:39
BEMSerializer::longImmTagToFile
static ObjectState * longImmTagToFile(const ObjectState *immTag)
Definition: BEMSerializer.cc:524
BinaryEncoding.hh
XMLSerializer::readState
virtual ObjectState * readState()
Definition: XMLSerializer.cc:200
SC_TABLE_NAME
const string SC_TABLE_NAME
Definition: BEMSerializer.cc:72
SOCKET_MAP
const string SOCKET_MAP
Definition: BEMSerializer.cc:131
REQUIRED_VERSION
const string REQUIRED_VERSION
Definition: BEMSerializer.cc:69
BEMSerializer::guardFieldToFile
static ObjectState * guardFieldToFile(const ObjectState *gFieldState)
Definition: BEMSerializer.cc:608
Application.hh
BEMSerializer::readState
virtual ObjectState * readState()
Definition: BEMSerializer.cc:186
BEMSerializer::writeState
virtual void writeState(const ObjectState *state)
Definition: BEMSerializer.cc:246
BinaryEncoding::LEFT
@ LEFT
Definition: BinaryEncoding.hh:64
ObjectState.hh
BEMSerializer::moveSlotToFile
static ObjectState * moveSlotToFile(const ObjectState *slotState)
Definition: BEMSerializer.cc:562
DestinationField::OSNAME_DESTINATION_FIELD
static const std::string OSNAME_DESTINATION_FIELD
ObjectState name for destination field.
Definition: DestinationField.hh:54
IMMEDIATE_SLOT
const string IMMEDIATE_SLOT
Definition: BEMSerializer.cc:151
IU_PORT_CODE_IU
const string IU_PORT_CODE_IU
Definition: BEMSerializer.cc:87
Environment::schemaDirPath
static std::string schemaDirPath(const std::string &prog)
Definition: Environment.cc:151
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
LIMM_TAG_MAP
const string LIMM_TAG_MAP
Definition: BEMSerializer.cc:92
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
NOPEncoding.hh
IMM_REG_FIELD_ITEMP_NAME
const string IMM_REG_FIELD_ITEMP_NAME
Definition: BEMSerializer.cc:99
Environment.hh
ObjectState::childCount
int childCount() const
SOCKET_MAP_CODES
const string SOCKET_MAP_CODES
Definition: BEMSerializer.cc:133
EXTRA_BITS
const string EXTRA_BITS
Definition: BEMSerializer.cc:156
Encoding::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding.
Definition: Encoding.hh:66
SRC_DST_EXTRA_BITS
const string SRC_DST_EXTRA_BITS
Definition: BEMSerializer.cc:124
LImmDstRegisterField::OSKEY_WIDTH
static const std::string OSKEY_WIDTH
ObjectState attribute key for the width of the field.
Definition: LImmDstRegisterField.hh:72
ImmediateSlotField::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the immediate slot.
Definition: ImmediateSlotField.hh:65
SOURCE_IMMEDIATE_WIDTH
const string SOURCE_IMMEDIATE_WIDTH
Definition: BEMSerializer.cc:136
SerializerException
Definition: Exception.hh:675
ObjectState::hasChild
bool hasChild(const std::string &name) const
Definition: ObjectState.cc:358
RF_PORT_CODE_ENCODING
const string RF_PORT_CODE_ENCODING
Definition: BEMSerializer.cc:84
IU_PORT_CODE
const string IU_PORT_CODE
Definition: BEMSerializer.cc:86
RF_PORT_CODE_MAX_INDEX
const string RF_PORT_CODE_MAX_INDEX
Definition: BEMSerializer.cc:83
SOCKET
const string SOCKET
Definition: BEMSerializer.cc:129
REG_GUARD_CODE_INVERTED
const string REG_GUARD_CODE_INVERTED
Definition: BEMSerializer.cc:112
ImmediateSlotField::OSKEY_WIDTH
static const std::string OSKEY_WIDTH
ObjectState attribute key for the width of the field.
Definition: ImmediateSlotField.hh:67
ObjectState::name
std::string name() const
XMLSerializer::setUseSchema
void setUseSchema(bool useSchema)
Definition: XMLSerializer.cc:179
LImmDstRegisterField::OSNAME_IU_DESTINATION
static const std::string OSNAME_IU_DESTINATION
ObjectState name for a immediate unit destination.
Definition: LImmDstRegisterField.hh:74
SocketEncoding.hh
IMM_REG_FIELD_POS
const string IMM_REG_FIELD_POS
Definition: BEMSerializer.cc:96
BridgeEncoding::OSKEY_BRIDGE_NAME
static const std::string OSKEY_BRIDGE_NAME
ObjectState attribute key for the name of the bridge.
Definition: BridgeEncoding.hh:64
SocketCodeTable::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for name of the table.
Definition: SocketCodeTable.hh:123
LIMM_TAG_POSITION
const string LIMM_TAG_POSITION
Definition: BEMSerializer.cc:90
GuardField::OSNAME_GUARD_FIELD
static const std::string OSNAME_GUARD_FIELD
ObjectState name for guard field.
Definition: GuardField.hh:99
BEMSerializer::socketCodeTableToOM
static ObjectState * socketCodeTableToOM(const ObjectState *scTable)
Definition: BEMSerializer.cc:934
GPRGuardEncoding.hh
UnconditionalGuardEncoding::OSNAME_UNCONDITIONAL_GUARD_ENCODING
static const std::string OSNAME_UNCONDITIONAL_GUARD_ENCODING
ObjectState name for unconditional guard encoding.
Definition: UnconditionalGuardEncoding.hh:57
Encoding::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: Encoding.hh:68
ImmediateControlField.hh
GPRGuardEncoding::OSKEY_RF_NAME
static const std::string OSKEY_RF_NAME
ObjectState attribute key for the name of the register file.
Definition: GPRGuardEncoding.hh:63
FU_PORT_CODE_EXTRA_BITS
const string FU_PORT_CODE_EXTRA_BITS
Definition: BEMSerializer.cc:79
LImmDstRegisterField::OSNAME_LIMM_DST_REGISTER_FIELD
static const std::string OSNAME_LIMM_DST_REGISTER_FIELD
ObjectState name for long immediate destination register field.
Definition: LImmDstRegisterField.hh:70
ObjectState::doubleAttribute
double doubleAttribute(const std::string &name) const
Definition: ObjectState.cc:323
BEMSerializer::immediateSlotToOM
static ObjectState * immediateSlotToOM(const ObjectState *fileSlot)
Definition: BEMSerializer.cc:1312
GPRGuardEncoding::OSNAME_GPR_GUARD_ENCODING
static const std::string OSNAME_GPR_GUARD_ENCODING
ObjectState name for GPR guard encoding.
Definition: GPRGuardEncoding.hh:61
SlotField::OSNAME_SLOT_FIELD
static const std::string OSNAME_SLOT_FIELD
ObjectState name for slot field.
Definition: SlotField.hh:89
SLOT_EXTRA_BITS
const string SLOT_EXTRA_BITS
Definition: BEMSerializer.cc:105
ObjectState::removeChild
void removeChild(ObjectState *child)
Definition: ObjectState.cc:389
SRC_DST_NO_OPERATION_MAP_EXTRA_BITS
const string SRC_DST_NO_OPERATION_MAP_EXTRA_BITS
Definition: BEMSerializer.cc:146
BEMSerializer::convertToOMFormat
static ObjectState * convertToOMFormat(const ObjectState *fileState)
Definition: BEMSerializer.cc:287
FU_PORT_CODE_ENCODING
const string FU_PORT_CODE_ENCODING
Definition: BEMSerializer.cc:78
REG_GUARD_CODE_INDEX
const string REG_GUARD_CODE_INDEX
Definition: BEMSerializer.cc:111
IUPortCode::OSNAME_IU_PORT_CODE
static const std::string OSNAME_IU_PORT_CODE
ObjectState name for RF port code.
Definition: IUPortCode.hh:55
BinaryEncoding::RIGHT
@ RIGHT
Definition: BinaryEncoding.hh:65
IMM_REG_FIELD
const string IMM_REG_FIELD
Definition: BEMSerializer.cc:95
BinaryEncoding::OSNAME_BEM
static const std::string OSNAME_BEM
ObjectState name for binary encoding.
Definition: BinaryEncoding.hh:126
TRUE
const string TRUE
Definition: BEMSerializer.cc:64
ObjectState::boolAttribute
bool boolAttribute(const std::string &name) const
Definition: ObjectState.cc:338
LImmDstRegisterField::OSKEY_ITEMP
static const std::string OSKEY_ITEMP
ObjectState attribute key for the name of the instruction template.
Definition: LImmDstRegisterField.hh:76
PortCode::OSKEY_INDEX_WIDTH
static const std::string OSKEY_INDEX_WIDTH
ObjectState attribute key for the widht of register index.
Definition: PortCode.hh:75
BEMSerializer::convertZeroEncExtraBits
static void convertZeroEncExtraBits(ObjectState *os)
Definition: BEMSerializer.cc:214
MoveSlot::OSKEY_BUS_NAME
static const std::string OSKEY_BUS_NAME
ObjectState attribute key for the name of the bus.
Definition: MoveSlot.hh:98
SocketCodeTable::OSNAME_SOCKET_CODE_TABLE
static const std::string OSNAME_SOCKET_CODE_TABLE
ObjectState name for socket code table.
Definition: SocketCodeTable.hh:121
IMMEDIATE_SLOT_WIDTH
const string IMMEDIATE_SLOT_WIDTH
Definition: BEMSerializer.cc:153
BEMSerializer::readRegisterFilePortCode
static void readRegisterFilePortCode(const ObjectState *filePortCode, ObjectState *omPortCode)
Definition: BEMSerializer.cc:1377
BEMSerializer::writeBinaryEncoding
void writeBinaryEncoding(const BinaryEncoding &bem)
Definition: BEMSerializer.cc:272
FALSE
const string FALSE
Definition: BEMSerializer.cc:65
ALWAYS_TRUE_GUARD_CODE
const string ALWAYS_TRUE_GUARD_CODE
Definition: BEMSerializer.cc:117
ImmediateControlField::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for the encoding of the instruction template.
Definition: ImmediateControlField.hh:91
ObjectState::stringValue
std::string stringValue() const
BEMSerializer::socketCodeTableToFile
static ObjectState * socketCodeTableToFile(const ObjectState *scTable)
Definition: BEMSerializer.cc:404
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
InstructionFormat.hh
GuardEncoding::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for encoding.
Definition: GuardEncoding.hh:60
BEMSerializer::longImmTagToOM
static ObjectState * longImmTagToOM(const ObjectState *fileTag)
Definition: BEMSerializer.cc:995
NOPEncoding::OSNAME_NOP_ENCODING
static const std::string OSNAME_NOP_ENCODING
ObjectState name for NOP encoding.
Definition: NOPEncoding.hh:57
SLOT_DESTINATION
const string SLOT_DESTINATION
Definition: BEMSerializer.cc:121
SOURCE_BRIDGE_MAP_EXTRA_BITS
const string SOURCE_BRIDGE_MAP_EXTRA_BITS
Definition: BEMSerializer.cc:142
BEMSerializer::slotFieldToFile
static ObjectState * slotFieldToFile(const ObjectState *sFieldState)
Definition: BEMSerializer.cc:798
IMM_REG_FIELD_ITEMP
const string IMM_REG_FIELD_ITEMP
Definition: BEMSerializer.cc:98
DestinationField.hh
SlotField::OSKEY_COMPONENT_ID_POSITION
static const std::string OSKEY_COMPONENT_ID_POSITION
ObjectState attribute key for component ID position.
Definition: SlotField.hh:91
BEMSerializer::longImmDstRegFieldToOM
static ObjectState * longImmDstRegFieldToOM(const ObjectState *fileField)
Definition: BEMSerializer.cc:1337
ID_POS_RIGHT
const string ID_POS_RIGHT
Definition: BEMSerializer.cc:127
BEMSerializer.hh
SRC_DST_NO_OPERATION
const string SRC_DST_NO_OPERATION
Definition: BEMSerializer.cc:144
REG_GUARD_CODE
const string REG_GUARD_CODE
Definition: BEMSerializer.cc:109
FUPortCode.hh
XMLSerializer
Definition: XMLSerializer.hh:62
BEM_VERSION_STR
const string BEM_VERSION_STR
Definition: BEMSerializer.cc:68
UnconditionalGuardEncoding
Definition: UnconditionalGuardEncoding.hh:47
IMM_REG_FIELD_WIDTH
const string IMM_REG_FIELD_WIDTH
Definition: BEMSerializer.cc:97
SourceField::OSNAME_SOURCE_FIELD
static const std::string OSNAME_SOURCE_FIELD
ObjectState name for source field.
Definition: SourceField.hh:74
FUPortCode::OSKEY_PORT_NAME
static const std::string OSKEY_PORT_NAME
ObjectState attribute key for the name of the port.
Definition: FUPortCode.hh:68
ObjectState::setValue
void setValue(const std::string &value)
REG_GUARD_CODE_RF
const string REG_GUARD_CODE_RF
Definition: BEMSerializer.cc:110
SLOT_GUARD_POSITION
const string SLOT_GUARD_POSITION
Definition: BEMSerializer.cc:107
FUGuardEncoding::OSKEY_FU_NAME
static const std::string OSKEY_FU_NAME
ObjectState attribute key for the name of the function unit.
Definition: FUGuardEncoding.hh:63
LImmDstRegisterField.hh
InstructionFormat::OSNAME_INSTRUCTION_FORMAT
static const std::string OSNAME_INSTRUCTION_FORMAT
Definition: InstructionFormat.hh:77
SocketCodeTable::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: SocketCodeTable.hh:125
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
BEMSerializer::destinationFieldToOM
static ObjectState * destinationFieldToOM(const ObjectState *fileDestination)
Definition: BEMSerializer.cc:1222
SocketEncoding::OSKEY_SOCKET_NAME
static const std::string OSKEY_SOCKET_NAME
ObjectState attribute key for the name of the socket.
Definition: SocketEncoding.hh:81
XMLSerializer::writeState
virtual void writeState(const ObjectState *rootState)
Definition: XMLSerializer.cc:219
BEMSerializer::readBinaryEncoding
BinaryEncoding * readBinaryEncoding()
Definition: BEMSerializer.cc:258