OpenASIP 2.2
Loading...
Searching...
No Matches
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
38using namespace std;
39
40/**
41 * Load and parse the Blocks 'architecture.xml'.
42 */
43void
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 */
73bool
75 return mdfState_->hasChild("configuration") &&
76 mdfState_->hasChild("Core");
77}
void LoadModelFromXml()
bool VerifyXmlStructure()
ObjectState * mdfState_
std::list< FunctionalUnit > mFunctionalUnitList
const std::map< std::string, BlocksTranslator::FU_TYPE > stringToEnum
ObjectState * childByName(const std::string &name) const
bool hasChild(const std::string &name) const
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
int childCount() const
BlocksTranslator::FU_TYPE type
std::list< std::string > src