PandA-2024.02
hls_device.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2023-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
40 #include "hls_device.hpp"
42 
43 #include "Parameter.hpp"
44 #include "fileIO.hpp"
45 #include "generic_device.hpp"
46 #include "polixml.hpp"
47 #include "technology_manager.hpp"
48 #include "xml_dom_parser.hpp"
49 #include "xml_helper.hpp"
50 
52 {
53  if(_Param->isOption(OPT_clock_period))
54  {
55  auto clock_period_value = _Param->getOption<double>(OPT_clock_period);
56  set_parameter("clock_period", clock_period_value);
57  }
58 }
59 
60 HLS_device::~HLS_device() = default;
61 
63 {
65  if(Param->isOption(OPT_xml_input_configuration))
66  {
67  try
68  {
69  auto fn = Param->getOption<std::string>(OPT_xml_input_configuration);
70  XMLDomParser parser(fn);
71  parser.Exec();
72  if(parser)
73  {
74  // Walk the tree:
75  const xml_element* node = parser.get_document()->get_root_node(); // deleted by DomParser.
76 
77  const xml_node::node_list list = node->get_children();
78  for(const auto& iter : list)
79  {
80  const auto* Enode = GetPointer<const xml_element>(iter);
81  if(!Enode)
82  {
83  continue;
84  }
85  if(Enode->get_name() == "device")
86  {
87  auto target = HLS_deviceRef(new HLS_device(Param, TM));
88  target->xload(node);
89  return target;
90  }
91  }
92  }
93  }
94  catch(const char* msg)
95  {
96  THROW_ERROR("Error during technology file parsing: " + std::string(msg));
97  }
98  catch(const std::string& msg)
99  {
100  THROW_ERROR("Error during technology file parsing: " + msg);
101  }
102  catch(const std::exception& ex)
103  {
104  THROW_ERROR("Error during technology file parsing: " + std::string(ex.what()));
105  }
106  catch(...)
107  {
108  THROW_ERROR("Error during technology file parsing");
109  }
110  }
111  return HLS_deviceRef(new HLS_device(Param, TM));
112 }
generic device description
refcount< HLS_device > HLS_deviceRef
refcount definition of class
Definition: hls_device.hpp:73
string target
Definition: lenet_tvm.py:16
Class specification of the manager of the technology library data structures.
void set_parameter(const std::string &key, G value)
Sets the value of the parameter.
This class manages the technology library structures.
const ParameterConstRef Param
class containing all the parameters
XML DOM parser.
XML DOM parser.
utility function used to read files.
std::list< xml_nodeRef > node_list
type for list of xml nodes
Definition: xml_node.hpp:90
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
const technology_managerRef TM
technology manager
~HLS_device() override
Destructor.
HLS_device(const ParameterConstRef &Param, const technology_managerRef &TM)
Constructor.
Definition: hls_device.cpp:51
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
refcount< technology_manager > technology_managerRef
this class is used to manage the command-line or XML options.
Some macro used to interface with the XML library.
node_list const & get_children()
Obtain the list of child nodes.
Definition: xml_node.hpp:310
Generic device description.
HLS specialization of generic_device.
static HLS_deviceRef factory(const ParameterRef &Param)
Factory method from XML file.
Definition: hls_device.cpp:62

Generated on Mon Feb 12 2024 13:02:53 for PandA-2024.02 by doxygen 1.8.13