OpenASIP  2.0
BlocksModel.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2021 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 BlocksModel.cc
26  *
27  * Implementation of the Blocks utility class which contains a Blocks model.
28  *
29  * @author Maarten Molendijk 2020 (m.j.molendijk@tue.nl)
30  * @author Kanishkan Vadivel 2021 (k.vadivel@tue.nl)
31  */
32 
33 #include "BlocksModel.hh"
34 
35 #include <exception>
36 #include <iostream>
37 
38 using namespace std;
39 
40 /**
41  * Load and parse the Blocks 'architecture.xml'.
42  */
43 void
45  // TODO(mm): add check for configuration bits
46  if (!VerifyXmlStructure()) return;
47 
48  ObjectState* configs = mdfState_->childByName("configuration");
49  ObjectState* fuState = configs->childByName("functionalunits");
50 
51  for (int i = 0; i < fuState->childCount(); i++) {
52  ObjectState* fu = fuState->child(i);
53  FunctionalUnit unit = {};
54  unit.usesOut0 = false;
55  unit.usesOut1 = false;
56  string unitTypeString = fu->stringAttribute("type");
57  unit.type = stringToEnum.at(unitTypeString);
58  unit.name = fu->stringAttribute("name");
59 
60  // FU ports
61  for (int srcnum = 0; srcnum < fu->childCount(); srcnum++) {
62  ObjectState* srcPort = fu->child(srcnum);
63  unit.src.push_back(srcPort->stringAttribute("source"));
64  }
65 
66  mFunctionalUnitList.push_back(unit); // Add functional unit to list
67  }
68 }
69 
70 /**
71  * Verify the structure of the 'architecture.xml' file.
72  */
73 bool
75  return mdfState_->hasChild("configuration") &&
76  mdfState_->hasChild("Core");
77 }
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
BlocksModel::VerifyXmlStructure
bool VerifyXmlStructure()
Definition: BlocksModel.cc:74
ObjectState
Definition: ObjectState.hh:59
ObjectState::childByName
ObjectState * childByName(const std::string &name) const
Definition: ObjectState.cc:443
BlocksModel::FunctionalUnit::name
std::string name
Definition: BlocksModel.hh:71
BlocksModel::FunctionalUnit::type
BlocksTranslator::FU_TYPE type
Definition: BlocksModel.hh:70
BlocksModel::FunctionalUnit::usesOut1
bool usesOut1
Definition: BlocksModel.hh:74
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
ObjectState::childCount
int childCount() const
BlocksModel::FunctionalUnit
Definition: BlocksModel.hh:69
BlocksModel.hh
BlocksModel::FunctionalUnit::src
std::list< std::string > src
Definition: BlocksModel.hh:72
BlocksModel::FunctionalUnit::usesOut0
bool usesOut0
Definition: BlocksModel.hh:73
BlocksModel::LoadModelFromXml
void LoadModelFromXml()
Definition: BlocksModel.cc:44