OpenASIP 2.2
Loading...
Searching...
No Matches
IPXactModel.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2010 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 IPXactModel.cc
26 *
27 * Implementation of IPXactModel class.
28 *
29 * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30 * @note rating: red
31 */
32#include <vector>
33#include <cassert>
34#include "IPXactModel.hh"
35#include "IPXactInterface.hh"
36#include "IPXactClkInterface.hh"
39#include "IPXactAddressSpace.hh"
40#include "ObjectState.hh"
41#include "HDLPort.hh"
42#include "Conversion.hh"
45using IPXact::Vlnv;
46using std::vector;
47
48const TCEString IPXactModel::OSNAME_IPXACT_MODEL = "spirit:component";
49const TCEString IPXactModel::OSNAME_VENDOR = "spirit:vendor";
50const TCEString IPXactModel::OSNAME_LIBRARY = "spirit:library";
51const TCEString IPXactModel::OSNAME_NAME = "spirit:name";
52const TCEString IPXactModel::OSNAME_VERSION = "spirit:version";
53const TCEString IPXactModel::OSNAME_BUS_INTERFACES = "spirit:busInterfaces";
54const TCEString IPXactModel::OSNAME_BUS_INTERFACE = "spirit:busInterface";
55const TCEString IPXactModel::OSNAME_BUS_TYPE = "spirit:busType";
56const TCEString IPXactModel::OSNAME_BUS_ABS_TYPE = "spirit:abstractionType";
57const TCEString IPXactModel::OSNAME_BUS_MASTER = "spirit:master";
59 "spirit:mirroredMaster";
60const TCEString IPXactModel::OSNAME_BUS_SLAVE = "spirit:slave";
62 "spirit:mirroredSlave";
63const TCEString IPXactModel::OSNAME_BUS_SYSTEM = "spirit:system";
65 "spirit:mirroredSystem";
66const TCEString IPXactModel::OSNAME_BUS_MONITOR = "spirit:monitor";
67const TCEString IPXactModel::OSNAME_BUS_PORT_MAPS = "spirit:portMaps";
68const TCEString IPXactModel::OSNAME_BUS_PORT_MAP = "spirit:portMap";
71 "spirit:physicalPort";
73 "spirit:logicalPort";
74const TCEString IPXactModel::OSNAME_MODEL = "spirit:model";
75const TCEString IPXactModel::OSNAME_PORTS = "spirit:ports";
76const TCEString IPXactModel::OSNAME_WIRE = "spirit:wire";
77const TCEString IPXactModel::OSNAME_VECTOR = "spirit:vector";
78const TCEString IPXactModel::OSNAME_PORT = "spirit:port";
79const TCEString IPXactModel::OSNAME_PORT_DIRECTION = "spirit:direction";
80const TCEString IPXactModel::OSNAME_PORT_LEFT = "spirit:left";
81const TCEString IPXactModel::OSNAME_PORT_RIGHT = "spirit:right";
82const TCEString IPXactModel::OSNAME_FILESETS = "spirit:fileSets";
83const TCEString IPXactModel::OSNAME_FILESET = "spirit:fileSet";
84const TCEString IPXactModel::OSNAME_FILE = "spirit:file";
85const TCEString IPXactModel::OSNAME_FILE_NAME = "spirit:name";
86const TCEString IPXactModel::OSNAME_FILE_TYPE = "spirit:fileType";
87const std::string IPXactModel::OSNAME_ADDRESS_SPACES = "spirit:addressSpaces";
88const std::string IPXactModel::OSNAME_ADDRESS_SPACE = "spirit:addressSpace";
89const std::string IPXactModel::OSNAME_AS_RANGE = "spirit:range";
90const std::string IPXactModel::OSNAME_AS_WIDTH = "spirit:width";
91const std::string IPXactModel::OSNAME_AS_MAU = "spirit:addressUnitBits";
92const TCEString IPXactModel::OSNAME_MODEL_PARAMS = "spirit:modelParameters";
93const TCEString IPXactModel::OSNAME_MODEL_PARAM = "spirit:modelParameter";
94const TCEString IPXactModel::OSNAME_DISPLAY_NAME = "spirit:displayName";
95const TCEString IPXactModel::OSNAME_VALUE = "spirit:value";
96const TCEString IPXactModel::OSNAME_ATTR_DATA_TYPE = "spirit:dataType";
97const TCEString IPXactModel::OSNAME_ATTR_FORMAT = "spirit:format";
98const TCEString IPXactModel::OSNAME_ATTR_ID = "spirit:id";
99const TCEString IPXactModel::OSNAME_ATTR_RESOLVE = "spirit:resolve";
100
101const TCEString IPXactModel::HDL_SET_ID = "hdlSources";
102const TCEString IPXactModel::VHDL_FILE = "vhdlSource";
103const TCEString IPXactModel::OTHER_FILE = "unknown";
105const TCEString IPXactModel::STRING_PARAM = "string";
106const TCEString IPXactModel::INTEGER_PARAM = "integer";
108const TCEString IPXactModel::DEV_FAMILY_GENERIC = "dev_family_g";
109
111 vlnv_("","","",""), signals_(), parameters_(), busInterfaces_(),
112 addressSpaces_(), hdlFiles_(), otherFiles_() {
113}
114
116 : vlnv_("", "", "", ""),
117 signals_(),
118 parameters_(),
119 busInterfaces_(),
120 addressSpaces_(),
121 hdlFiles_(),
122 otherFiles_() {
123 loadState(state);
124}
125
127
128 for (unsigned int i = 0; i < signals_.size(); i++) {
129 delete signals_.at(i);
130 }
131 for (unsigned int i = 0; i < busInterfaces_.size(); i++) {
132 if (busInterfaces_.at(i) != NULL) {
133 delete busInterfaces_.at(i);
134 }
135 }
136 for (unsigned int i = 0; i < addressSpaces_.size(); i++) {
137 if (addressSpaces_.at(i) != NULL) {
138 delete addressSpaces_.at(i);
139 }
140 }
141}
142
143
144void
146
147 extractVLNV(state);
148
149 if (state->hasChild(OSNAME_BUS_INTERFACES)) {
151 }
152
153 if (state->hasChild(OSNAME_ADDRESS_SPACES)) {
155 }
156
157 if (state->hasChild(OSNAME_MODEL)) {
158 const ObjectState* model = state->childByName(OSNAME_MODEL);
159 if (model->hasChild(OSNAME_PORTS)) {
161 }
162 if (model->hasChild(OSNAME_MODEL_PARAMS)) {
163 const ObjectState* modelParams =
165 if (modelParams->hasChild(OSNAME_MODEL_PARAM)) {
166 extractModelParams(modelParams);
167 }
168 }
169 }
170
171 if (state->hasChild(OSNAME_FILESETS)) {
173 }
174}
175
176
179
181
182 // add VLNV
184 vendor->setValue(vlnv_.vendor);
185 root->addChild(vendor);
186 ObjectState* library = new ObjectState(OSNAME_LIBRARY);
187 library->setValue(vlnv_.library);
188 root->addChild(library);
189 ObjectState* compName = new ObjectState(OSNAME_NAME);
190 compName->setValue(vlnv_.name);
191 root->addChild(compName);
192 ObjectState* compVersion = new ObjectState(OSNAME_VERSION);
193 compVersion->setValue(vlnv_.version);
194 root->addChild(compVersion);
195
196 // add bus interfaces
197 ObjectState* busInterfaces = new ObjectState(OSNAME_BUS_INTERFACES);
198 root->addChild(busInterfaces);
199 for (unsigned int i = 0; i < busInterfaces_.size(); i++) {
200 ObjectState* busInterface = new ObjectState(OSNAME_BUS_INTERFACE);
201 addBusInterfaceObject(busInterfaces_.at(i), busInterface);
202 busInterfaces->addChild(busInterface);
203 }
204
205 // add address spaces
206 ObjectState* addressSpaces = new ObjectState(OSNAME_ADDRESS_SPACES);
207 root->addChild(addressSpaces);
208 for (unsigned int i = 0; i < addressSpaces_.size(); i++) {
209 ObjectState* addressSpace = new ObjectState(OSNAME_ADDRESS_SPACE);
210 addAddressSpaceObject(addressSpaces_.at(i), addressSpace);
211 addressSpaces->addChild(addressSpace);
212 }
213
214 // create model and add signals
216 root->addChild(model);
217 ObjectState* signals = new ObjectState(OSNAME_PORTS);
218 model->addChild(signals);
219 for (unsigned int i = 0; i < signals_.size(); i++) {
220 ObjectState* signal = new ObjectState(OSNAME_PORT);
221 addSignalObject(signals_.at(i), signal);
222 signals->addChild(signal);
223 }
224
225 // add model parameters if any
226 if (parameters_.size() > 0) {
228 }
229
230 // add hdl files
231 ObjectState* fileSets = new ObjectState(OSNAME_FILESETS);
232 root->addChild(fileSets);
233 ObjectState* fileSet = new ObjectState(OSNAME_FILESET);
234 ObjectState* fileSetName = new ObjectState(OSNAME_FILE_NAME);
235 fileSetName->setValue(HDL_SET_ID);
236 fileSet->addChild(fileSetName);
237 fileSets->addChild(fileSet);
238 for (unsigned int i = 0; i < hdlFiles_.size(); i++) {
240 addFileObject(hdlFiles_.at(i), VHDL_FILE, file);
241 fileSet->addChild(file);
242 }
243 // add other files (memory init files etc)
244 for (unsigned int i = 0; i < otherFiles_.size(); i++) {
247 fileSet->addChild(file);
248 }
249 return root;
250}
251
252
253void
255 TCEString vendor,
256 TCEString library,
257 TCEString name,
258 TCEString version) {
259
260 vlnv_.vendor = vendor;
261 vlnv_.library = library;
262 vlnv_.name = name;
263 vlnv_.version = version;
264}
265
266
267void
269
270 hdlFiles_.push_back(file);
271}
272
273void
275
276 otherFiles_.push_back(file);
277}
278
279
280void
281IPXactModel::setHdlFiles(const std::vector<TCEString>& files) {
282
283 for (unsigned int i = 0; i < files.size(); i++) {
284 setHdlFile(files.at(i));
285 }
286}
287
288
289void
291
292 signals_.push_back(new HDLPort(signal));
293}
294
295void
297 parameters_.push_back(parameter);
298}
299
300void
302
303 busInterfaces_.push_back(interface);
304}
305
306void
308
309 addressSpaces_.push_back(addrSpace);
310}
311
312
313void
315 const IPXactInterface* bus,
316 ObjectState* parent) const {
317
318 ObjectState* busName = new ObjectState(OSNAME_NAME);
319 busName->setValue(bus->instanceName());
320 parent->addChild(busName);
321
322 Vlnv busIfType = bus->busType();
324 busType->setAttribute(OSNAME_VENDOR, busIfType.vendor);
325 busType->setAttribute(OSNAME_LIBRARY, busIfType.library);
326 busType->setAttribute(OSNAME_NAME, busIfType.name);
327 busType->setAttribute(OSNAME_VERSION, busIfType.version);
328 parent->addChild(busType);
329
330 Vlnv absType = bus->busAbstractionType();
332 busAbsType->setAttribute(OSNAME_VENDOR, absType.vendor);
333 busAbsType->setAttribute(OSNAME_LIBRARY, absType.library);
334 busAbsType->setAttribute(OSNAME_NAME, absType.name);
335 busAbsType->setAttribute(OSNAME_VERSION, absType.version);
336 parent->addChild(busAbsType);
337
338 ObjectState* mode = NULL;
339 BusMode busMode = bus->busMode();
340 if (busMode == MASTER) {
342 } else if (busMode == MIRRORED_MASTER) {
344 } else if (busMode == SLAVE) {
346 } else if (busMode == MIRRORED_SLAVE) {
348 } else {
349 TCEString msg = "Unknown bus mode!";
350 InvalidData exc(__FILE__, __LINE__, "IPXactModel", msg);
351 throw exc;
352 }
353 parent->addChild(mode);
354
356 parent->addChild(portMaps);
357
358 const SignalMappingList& signalMap = bus->interfaceMapping();
359 for (unsigned int i = 0; i < signalMap.size(); i++) {
360 ObjectState* portMapping = new ObjectState(OSNAME_BUS_PORT_MAP);
361 portMaps->addChild(portMapping);
362
365 compPortName->setValue(signalMap.at(i)->first);
366 compPort->addChild(compPortName);
367
370 busPortName->setValue(signalMap.at(i)->second);
371 busPort->addChild(busPortName);
372
373 // in IP-XACT 1.5 bus logical port comes before physical port
374 portMapping->addChild(busPort);
375 portMapping->addChild(compPort);
376 }
377}
378
379
380void
382 const IPXactAddressSpace* as,
383 ObjectState* parent) const {
384
386 name->setValue(as->name());
387 parent->addChild(name);
388
390 range->setValue(as->memRange());
391 parent->addChild(range);
392
394 width->setValue(as->memLocationWidth());
395 parent->addChild(width);
396
397 if (as->mauWidth() > 0) {
399 mau->setValue(as->mauWidth());
400 parent->addChild(mau);
401 }
402}
403
404
405void
407 const HDLPort* port, ObjectState* parent) const {
408
410 name->setValue(port->name());
411 parent->addChild(name);
412
414 parent->addChild(wire);
415
417 TCEString dir = "";
418 if (port->direction() == ProGe::IN) {
419 dir = "in";
420 } else if (port->direction() == ProGe::OUT) {
421 dir = "out";
422 } else if (port->direction() == ProGe::BIDIR) {
423 dir = "inout";
424 } else {
425 assert(false && "unknown direction");
426 }
427 direction->setValue(dir);
428 wire->addChild(direction);
429
430 ObjectState* vector = NULL;
431 if (port->type() == ProGe::BIT_VECTOR) {
432 int leftBorder = 0;
433 int rightBorder = 0;
434 vector = new ObjectState(OSNAME_VECTOR);
435 if (port->hasRealWidth()) {
436 int width = port->realWidth();
437 if (width > 1) {
438 leftBorder = width-1;
439 }
440 } else {
441 // width is unknown, guessing 1
442 leftBorder = 0;
443 }
445 left->setValue(leftBorder);
446 vector->addChild(left);
448 right->setValue(rightBorder);
449 vector->addChild(right);
450 } else if (port->type() != ProGe::BIT) {
451 assert(false && "unknown port type");
452 }
453
454 if (vector != NULL) {
455 wire->addChild(vector);
456 }
457}
458
459
460void
462
464 parent->addChild(params);
465 for (unsigned int i = 0; i < parameters_.size(); i++) {
467 if (parameters_.at(i).type().lower() == STRING_PARAM) {
469 } else if (parameters_.at(i).type().lower() == INTEGER_PARAM) {
471 } else {
472 // unsuppored type, ignore
473 delete param;
474 continue;
475 }
476 params->addChild(param);
477
479 name->setValue(parameters_.at(i).name());
480 param->addChild(name);
481
482 ObjectState* displayName = new ObjectState(OSNAME_DISPLAY_NAME);
483 displayName->setValue(parameters_.at(i).name());
484 param->addChild(displayName);
485
487 if (parameters_.at(i).type().lower() == STRING_PARAM) {
489 } else if (parameters_.at(i).type().lower() == INTEGER_PARAM) {
491 }
492 TCEString id;
493 id << parameters_.at(i).name().upper() << "_ID";
494 value->setAttribute(OSNAME_ATTR_ID, id);
496 value->setValue(parameters_.at(i).value());
497 param->addChild(value);
498 }
499}
500
501
502void
504 const TCEString& name,
505 const TCEString& type,
506 ObjectState* parent) const {
507
509 fileName->setValue(name);
510 parent->addChild(fileName);
512 fileType->setValue(type);
513 parent->addChild(fileType);
514}
515
516
517void
519
520 assert(root->name() == OSNAME_IPXACT_MODEL);
521 TCEString vendor = "";
522 TCEString library = "";
523 TCEString name = "";
524 TCEString version = "";
525 if (root->hasChild(OSNAME_VENDOR)) {
526 vendor = root->childByName(OSNAME_VENDOR)->stringValue();
527 }
528 if (root->hasChild(OSNAME_LIBRARY)) {
529 library = root->childByName(OSNAME_LIBRARY)->stringValue();
530 }
531 if (root->hasChild(OSNAME_NAME)) {
532 name = root->childByName(OSNAME_NAME)->stringValue();
533 }
534 if (root->hasChild(OSNAME_VERSION)) {
535 version = root->childByName(OSNAME_VERSION)->stringValue();
536 }
537 setVLNV(vendor, library, name, version);
538}
539
542
543 assert(busType->name() == OSNAME_BUS_TYPE ||
544 busType->name() == OSNAME_BUS_ABS_TYPE);
545 IPXact::Vlnv vlnv;
546 if (busType->hasAttribute(OSNAME_VENDOR)) {
547 vlnv.vendor = busType->stringAttribute(OSNAME_VENDOR);
548 }
549 if (busType->hasAttribute(OSNAME_LIBRARY)) {
550 vlnv.library = busType->stringAttribute(OSNAME_LIBRARY);
551 }
552 if (busType->hasAttribute(OSNAME_NAME)) {
553 vlnv.name = busType->stringAttribute(OSNAME_NAME);
554 }
555 if (busType->hasAttribute(OSNAME_VERSION)) {
556 vlnv.version = busType->stringAttribute(OSNAME_VERSION);
557 }
558 return vlnv;
559}
560
561void
563
564 assert(busInterfaces->name() == OSNAME_BUS_INTERFACES);
565 if (!busInterfaces->hasChild(OSNAME_BUS_INTERFACE)) {
566 return;
567 }
568 for (int i = 0; i < busInterfaces->childCount(); i++) {
569 const ObjectState* bus = busInterfaces->child(i);
570 if (bus->name() == OSNAME_BUS_INTERFACE) {
572 }
573 }
574}
575
576
577void
579
580 assert(busInterface->name() == OSNAME_BUS_INTERFACE);
581 if (!busInterface->hasChild(OSNAME_NAME)) {
582 TCEString msg = "Bus has no name";
584 new ObjectStateLoadingException(__FILE__, __LINE__,
585 "IPXactModel", msg);
586 throw exc;
587 }
588 if (!busInterface->hasChild(OSNAME_BUS_TYPE)) {
589 TCEString msg = "Bus has no type";
591 new ObjectStateLoadingException(__FILE__, __LINE__,
592 "IPXactModel", msg);
593 throw exc;
594 }
595 if (!busInterface->hasChild(OSNAME_BUS_ABS_TYPE)) {
596 TCEString msg = "Bus has no abstraction type";
598 new ObjectStateLoadingException(__FILE__, __LINE__,
599 "IPXactModel", msg);
600 throw exc;
601 }
602
603 TCEString instanceName =
604 busInterface->childByName(OSNAME_NAME)->stringValue();
605 const ObjectState* busType =
606 busInterface->childByName(OSNAME_BUS_TYPE);
607 const ObjectState* busAbsType = busInterface->childByName(
609 IPXact::Vlnv type = extractVlnvFromAttr(busType);
610 IPXact::Vlnv absType = extractVlnvFromAttr(busAbsType);
611 BusMode mode = extractBusMode(busInterface);
612
613 IPXactInterface* interface =
614 interfaceByType(type, absType, instanceName, mode);
615 if (!interface) {
616 TCEString msg = "Unknown bus type";
618 new ObjectStateLoadingException(__FILE__, __LINE__,
619 "IPXactModel", msg);
620 throw exc;
621 }
622
623 if (busInterface->hasChild(OSNAME_BUS_PORT_MAPS)) {
624 const ObjectState* portMaps =
625 busInterface->childByName(OSNAME_BUS_PORT_MAPS);
626 extractPortMappings(portMaps, *interface);
627 }
628 busInterfaces_.push_back(interface);
629}
630
631
632void
634
635 assert(addressSpaces->name() == OSNAME_ADDRESS_SPACES);
636 if (!addressSpaces->hasChild(OSNAME_ADDRESS_SPACE)) {
637 return;
638 }
639 for (int i = 0; i < addressSpaces->childCount(); i++) {
640 const ObjectState* as = addressSpaces->child(i);
641 if (as->name() == OSNAME_ADDRESS_SPACE) {
643 }
644 }
645}
646
647
648void
650
652 TCEString errorMsg = "Address space has no ";
653 if (!as->hasChild(OSNAME_NAME)) {
654 errorMsg << "name.";
657 __FILE__, __LINE__, "IPXactModel", errorMsg);
658 throw exc;
659 } else if (!as->hasChild(OSNAME_AS_RANGE)) {
660 errorMsg << "range.";
663 __FILE__, __LINE__, "IPXactModel", errorMsg);
664 throw exc;
665 } else if (!as->hasChild(OSNAME_AS_WIDTH)) {
666 errorMsg << "width.";
669 __FILE__, __LINE__, "IPXactModel", errorMsg);
670 throw exc;
671 }
673 int range = as->childByName(OSNAME_AS_RANGE)->intValue();
674 int width = as->childByName(OSNAME_AS_WIDTH)->intValue();
675 int mau = 0;
676 if (as->hasChild(OSNAME_AS_MAU)) {
678 }
679 IPXactAddressSpace* ipXactAs =
680 new IPXactAddressSpace(name, range, width, mau);
681 addressSpaces_.push_back(ipXactAs);
682}
683
684
686IPXactModel::extractBusMode(const ObjectState* busInterface) const {
687
688 assert(busInterface->name() == OSNAME_BUS_INTERFACE);
690 if (busInterface->hasChild(OSNAME_BUS_MASTER)) {
691 mode = MASTER;
692 } else if (busInterface->hasChild(OSNAME_BUS_MIRRORED_MASTER)) {
694 } else if (busInterface->hasChild(OSNAME_BUS_SLAVE)) {
695 mode = SLAVE;
696 } else if (busInterface->hasChild(OSNAME_BUS_MIRRORED_SLAVE)) {
698 } else if (busInterface->hasChild(OSNAME_BUS_SYSTEM)) {
699 mode = SYSTEM;
700 } else if (busInterface->hasChild(OSNAME_BUS_MIRRORED_SYSTEM)) {
702 } else if (busInterface->hasChild(OSNAME_BUS_MONITOR)) {
703 mode = MONITOR;
704 } else {
705 assert(false && "Unknown bus mode!");
706 }
707 assert(mode != INVALID && "Bus mode is invalid");
708 return mode;
709}
710
711void
713 const ObjectState* portMaps,
714 IPXactInterface& interface) const {
715
716 assert(portMaps->name() == OSNAME_BUS_PORT_MAPS);
717 if (!portMaps->hasChild(OSNAME_BUS_PORT_MAP)) {
718 return;
719 }
720 for (int i = 0; i < portMaps->childCount(); i++) {
721 const ObjectState* map = portMaps->child(i);
722 if (map->name() == OSNAME_BUS_PORT_MAP) {
723 extractPortMap(map, interface);
724 }
725 }
726}
727
728void
730 const ObjectState* portMap,
731 IPXactInterface& interface) const {
732
733 assert(portMap->name() == OSNAME_BUS_PORT_MAP);
734 if (!(portMap->hasChild(OSNAME_BUS_PORT_MAP_BUS) &&
736
737 TCEString msg = "Bus interface port map is invalid";
739 new ObjectStateLoadingException(__FILE__, __LINE__,
740 "IPXactModel", msg);
741 throw exc;
742 }
743
744 const ObjectState* busPort =
746 const ObjectState* compPort =
748 if (!busPort->hasChild(OSNAME_BUS_PORT_MAP_NAME) ||
750
751 TCEString msg = "Port name missing from port map";
753 new ObjectStateLoadingException(__FILE__, __LINE__,
754 "IPXactModel", msg);
755 throw exc;
756 }
757 TCEString compPortName =
759 TCEString busPortName =
761
762 if (busPortName.empty() || compPortName.empty()) {
763 TCEString msg = "Port name is empty in port map";
765 new ObjectStateLoadingException(__FILE__, __LINE__,
766 "IPXactModel", msg);
767 throw exc;
768 }
769 interface.addSignalMapping(compPortName, busPortName);
770}
771
772void
774
775 assert(signals->name() == OSNAME_PORTS);
776
777 for (int i = 0; i < signals->childCount(); i++) {
778 const ObjectState* signal = signals->child(i);
779 if (signal->name() != OSNAME_PORT) {
780 continue;
781 }
782
783 TCEString name = "";
784 ProGe::Direction direction = ProGe::IN;
786 int width = 0;
787
788 if (signal->hasChild(OSNAME_NAME)) {
789 name = signal->childByName(OSNAME_NAME)->stringValue();
790 }
791 if (!signal->hasChild(OSNAME_WIRE)) {
792 TCEString msg = "Wire node not found from Port!";
793 InvalidData exc(__FILE__, __LINE__, "IPXactModel", msg);
794 throw exc;
795 }
796 const ObjectState* wire = signal->childByName(OSNAME_WIRE);
797 if (wire->hasChild(OSNAME_PORT_DIRECTION)) {
798 TCEString dir =
800 if (dir == "in") {
801 direction = ProGe::IN;
802 } else if (dir == "out") {
803 direction = ProGe::OUT;
804 } else if (dir == "inout") {
805 direction = ProGe::BIDIR;
806 } else {
807 assert(false && "Unknown direction");
808 }
809 } else {
810 TCEString msg = "Port does not have direction!";
811 InvalidData exc(__FILE__, __LINE__, "IPXactModel", msg);
812 throw exc;
813 }
814
815 if (wire->hasChild(OSNAME_VECTOR)) {
816 type = ProGe::BIT_VECTOR;
817 int leftBorder = 0;
818 int rightBorder = 0;
819 const ObjectState* vector = wire->childByName(OSNAME_VECTOR);
820 if (vector->hasChild(OSNAME_PORT_LEFT)) {
821 leftBorder =
823 assert(leftBorder >= 0);
824 }
825 if (vector->hasChild(OSNAME_PORT_RIGHT)) {
826 rightBorder =
828 assert(rightBorder >= 0);
829 }
830 if (leftBorder < rightBorder) {
831 TCEString msg = "Reversed bit order is not supported";
832 UnexpectedValue* exc =
833 new UnexpectedValue(__FILE__, __LINE__, "IPXactModel",
834 msg);
835 throw exc;
836 }
837 width = leftBorder - rightBorder + 1;
838 } else {
839 type = ProGe::BIT;
840 width = 0;
841 }
842
843 TCEString widthFormula = Conversion::toString(width);
844 HDLPort* port = new HDLPort(name, widthFormula, type, direction,
845 false, width);
846 signals_.push_back(port);
847 }
848}
849
850void
852
853 assert(fileSets->name() == OSNAME_FILESETS);
854 for (int i = 0; i < fileSets->childCount(); i++) {
855 const ObjectState* fs = fileSets->child(i);
856 if (fs->name() != OSNAME_FILESET) {
857 continue;
858 }
859 if (!fs->hasChild(OSNAME_FILE_NAME)) {
860 TCEString msg = "Fileset has no name!";
861 InvalidData exc(__FILE__, __LINE__, "IPXactModel", msg);
862 throw exc;
863 }
865 if (fsName != HDL_SET_ID) {
866 // unknown stuff, ignore
867 continue;
868 }
869
870 for (int j = 0; j < fs->childCount(); j++) {
871 const ObjectState* file = fs->child(j);
872 if (file->name() != OSNAME_FILE) {
873 continue;
874 }
875 TCEString fileName = "";
876 TCEString fileType = "";
877 if (file->hasChild(OSNAME_NAME)) {
878 fileName = file->childByName(OSNAME_NAME)->stringValue();
879 }
880 if (file->hasChild(OSNAME_FILE_TYPE)) {
881 fileType = file->childByName(OSNAME_FILE_TYPE)->stringValue();
882 }
883
884 if (fileType == VHDL_FILE) {
885 hdlFiles_.push_back(fileName);
886 } else if (fileType == OTHER_FILE) {
887 otherFiles_.push_back(fileName);
888 } else {
889 // unknown file type, ignore
890 continue;
891 }
892 }
893 }
894}
895
896
899 const IPXact::Vlnv& type,
900 const IPXact::Vlnv& absType,
901 const TCEString instanceName,
902 BusMode mode) const {
903
904 IPXactInterface* interface = NULL;
905
906 vector<IPXactInterface*> available;
907 available.push_back(new IPXactClkInterface());
908 available.push_back(new IPXactResetInterface());
909 available.push_back(new IPXactHibiInterface());
910
911 bool found = false;
912 for (unsigned int i = 0; i < available.size(); i++) {
913 if (!found) {
914 if (available.at(i)->busType() == type &&
915 available.at(i)->busAbstractionType() == absType &&
916 available.at(i)->busMode() == mode) {
917 interface = available.at(i);
918 interface->setInstanceName(instanceName);
919 found = true;
920 continue;
921 }
922 }
923 delete available.at(i);
924 }
925 return interface;
926}
927
928
929void
931
932 assert(modelParameters->name() == OSNAME_MODEL_PARAMS);
933 for (int i = 0; i < modelParameters->childCount(); i++) {
934 TCEString childName = modelParameters->child(i)->name();
935 if (childName == OSNAME_MODEL_PARAM) {
936 extractModelParam(modelParameters->child(i));
937 }
938 }
939}
940
941void
943
944 assert(modelParameter->name() == OSNAME_MODEL_PARAM);
945 if (!modelParameter->hasChild(OSNAME_NAME)) {
946 TCEString msg = "Model parameter has no name";
948 new ObjectStateLoadingException(__FILE__, __LINE__,
949 "IPXactModel", msg);
950 throw exc;
951 }
952 if (!modelParameter->hasChild(OSNAME_VALUE)) {
953 TCEString msg = "Model parameter has no value";
955 new ObjectStateLoadingException(__FILE__, __LINE__,
956 "IPXactModel", msg);
957 throw exc;
958 }
959 ProGe::Parameter parameter;
960 const ObjectState* nameObj = modelParameter->childByName(OSNAME_NAME);
961 parameter.setName(nameObj->stringValue());
962
963 parameter.setType(STRING_PARAM);
964 if (nameObj->hasAttribute(OSNAME_ATTR_DATA_TYPE)) {
965 TCEString typeAttr =
967 if (typeAttr.lower() == STRING_PARAM) {
968 parameter.setType(STRING_PARAM);
969 } else if (typeAttr.lower() == LONG_PARAM) {
970 parameter.setType(INTEGER_PARAM);
971 }
972 }
973
974 const ObjectState* valueObj = modelParameter->childByName(OSNAME_VALUE);
975 parameter.setValue(valueObj->stringValue());
976 parameters_.push_back(parameter);
977}
#define assert(condition)
static std::string toString(const T &source)
int realWidth() const
Definition HDLPort.cc:107
ProGe::Direction direction() const
Definition HDLPort.cc:112
TCEString name() const
Definition HDLPort.cc:87
bool hasRealWidth() const
Definition HDLPort.cc:102
ProGe::DataType type() const
Definition HDLPort.cc:117
TCEString name() const
virtual const PlatInt::SignalMappingList & interfaceMapping() const
virtual void addSignalMapping(const TCEString &actualSignal, const TCEString &busSignal)
virtual IPXactModel::BusMode busMode() const
virtual IPXact::Vlnv busAbstractionType() const
void setInstanceName(const TCEString &name)
virtual TCEString instanceName() const
virtual IPXact::Vlnv busType() const
static const TCEString OSNAME_VALUE
static const TCEString OSNAME_BUS_ABS_TYPE
void extractModelParams(const ObjectState *modelParameters)
virtual ~IPXactModel()
static const TCEString RESOLVE_USER
static const TCEString OSNAME_FILE
std::vector< IPXactAddressSpace * > addressSpaces_
static const TCEString OSNAME_VENDOR
static const TCEString OSNAME_PORT_DIRECTION
static const TCEString OSNAME_VERSION
static const TCEString OSNAME_PORT_RIGHT
void extractAddressSpace(const ObjectState *as)
void setVLNV(TCEString vendor, TCEString library, TCEString name, TCEString version)
IPXactInterface * interfaceByType(const IPXact::Vlnv &type, const IPXact::Vlnv &absType, const TCEString instanceName, BusMode mode) const
void addFileObject(const TCEString &name, const TCEString &type, ObjectState *parent) const
static const TCEString OSNAME_MODEL
std::vector< ProGe::Parameter > parameters_
static const TCEString OSNAME_FILE_TYPE
static const TCEString OSNAME_BUS_PORT_MAP_BUS
void addAddressSpace(IPXactAddressSpace *addrSpace)
static const TCEString OSNAME_BUS_PORT_MAP_COMP
static const TCEString OSNAME_BUS_INTERFACES
IPXact::Vlnv vlnv_
std::vector< TCEString > otherFiles_
static const TCEString OSNAME_BUS_PORT_MAP
static const TCEString OSNAME_FILESET
static const TCEString OSNAME_NAME
void extractAddressSpaces(const ObjectState *addressSpaces)
void extractBusInterfaces(const ObjectState *busInterfaces)
BusMode extractBusMode(const ObjectState *busInterface) const
void addSignalObject(const HDLPort *port, ObjectState *parent) const
void extractPortMappings(const ObjectState *portMaps, IPXactInterface &interface) const
void extractVLNV(const ObjectState *root)
static const TCEString OTHER_FILE
static const TCEString OSNAME_PORT
void addParameter(const ProGe::Parameter &parameter)
static const TCEString OSNAME_BUS_SLAVE
static const TCEString OSNAME_FILESETS
static const std::string OSNAME_AS_MAU
static const TCEString OSNAME_ATTR_FORMAT
static const TCEString OSNAME_PORTS
static const TCEString VHDL_FILE
static const TCEString LONG_PARAM
static const TCEString STRING_PARAM
static const TCEString OSNAME_ATTR_ID
static const TCEString OSNAME_BUS_MONITOR
void addAddressSpaceObject(const IPXactAddressSpace *as, ObjectState *parent) const
void extractPortMap(const ObjectState *portMap, IPXactInterface &interface) const
void setHdlFiles(const std::vector< TCEString > &files)
void extractModelParam(const ObjectState *modelParameter)
static const TCEString OSNAME_BUS_PORT_MAPS
virtual ObjectState * saveState() const
void extractFiles(const ObjectState *fileSets)
void extractSignals(const ObjectState *signals)
void addModelParamsObject(ObjectState *parent) const
static const TCEString OSNAME_IPXACT_MODEL
void addBusInterfaceObject(const IPXactInterface *bus, ObjectState *parent) const
static const TCEString OSNAME_LIBRARY
static const TCEString OSNAME_DISPLAY_NAME
static const TCEString OSNAME_BUS_INTERFACE
static const std::string OSNAME_ADDRESS_SPACES
static const TCEString HDL_SET_ID
static const TCEString OSNAME_MODEL_PARAM
static const TCEString OSNAME_PORT_LEFT
static const TCEString OSNAME_BUS_TYPE
virtual void loadState(const ObjectState *state)
static const TCEString OSNAME_BUS_PORT_MAP_NAME
void extractBusInterface(const ObjectState *busInterface)
static const TCEString OSNAME_FILE_NAME
void setFile(const TCEString &file)
static const std::string OSNAME_ADDRESS_SPACE
static const TCEString OSNAME_BUS_MIRRORED_MASTER
static const TCEString OSNAME_VECTOR
static const TCEString OSNAME_MODEL_PARAMS
static const TCEString OSNAME_WIRE
static const TCEString OSNAME_BUS_SYSTEM
static const TCEString OSNAME_ATTR_DATA_TYPE
static const std::string OSNAME_AS_RANGE
std::vector< HDLPort * > signals_
static const TCEString INTEGER_PARAM
void setHdlFile(const TCEString &file)
static const TCEString OSNAME_ATTR_RESOLVE
std::vector< IPXactInterface * > busInterfaces_
static const TCEString OSNAME_BUS_MASTER
static const TCEString OSNAME_BUS_MIRRORED_SLAVE
void addSignal(const HDLPort &signal)
void addBusInterface(IPXactInterface *interface)
static const TCEString OSNAME_BUS_MIRRORED_SYSTEM
std::vector< TCEString > hdlFiles_
static const TCEString DEV_FAMILY_GENERIC
IPXact::Vlnv extractVlnvFromAttr(const ObjectState *busType) const
static const std::string OSNAME_AS_WIDTH
bool hasAttribute(const std::string &name) const
ObjectState * childByName(const std::string &name) const
void setAttribute(const std::string &name, const std::string &value)
void setValue(const std::string &value)
bool hasChild(const std::string &name) const
ObjectState * child(int index) const
void addChild(ObjectState *child)
int intValue() const
std::string stringAttribute(const std::string &name) const
std::string stringValue() const
std::string name() const
int childCount() const
void setName(const TCEString &name)
Definition Parameter.cc:118
void setValue(const TCEString &value)
Definition Parameter.cc:128
void setType(const TCEString &type)
Definition Parameter.cc:123
TCEString lower() const
Definition TCEString.cc:78
TCEString upper() const
Definition TCEString.cc:86
std::vector< SignalMapping * > SignalMappingList
DataType
Data types of hardware ports.
Definition ProGeTypes.hh:46
@ BIT
One bit.
Definition ProGeTypes.hh:47
@ BIT_VECTOR
Several bits.
Definition ProGeTypes.hh:48
Direction
Direction of the port.
Definition ProGeTypes.hh:52
@ OUT
Output port.
Definition ProGeTypes.hh:54
@ IN
Input port.
Definition ProGeTypes.hh:53
@ BIDIR
Bidirectional port.
Definition ProGeTypes.hh:55
TCEString name
Entity name.
Definition Vlnv.hh:60
TCEString version
Entity version.
Definition Vlnv.hh:62
TCEString vendor
Vendor name.
Definition Vlnv.hh:56
TCEString library
Library name.
Definition Vlnv.hh:58
mode
Definition tceopgen.cc:45