PandA-2024.02
hls_constraints.hpp
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) 2004-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  */
46 #ifndef HLS_CONSTRAINTS_HPP
47 #define HLS_CONSTRAINTS_HPP
48 
50 #include <iosfwd>
51 #include <limits>
52 #include <string>
53 #include <utility>
54 
56 #include "custom_map.hpp"
57 #include "refcount.hpp"
58 
62 class xml_element;
63 
65 #define ENCODE_FU_LIB(fu_name, library) ((fu_name) + ":" + (library))
66 
73 {
76 
80 
83 
85  double clock_period;
86 
89 
91  unsigned int registers;
92 
95  std::string fun_name;
96 
99 
100  public:
102  friend class allocation;
103 
107  HLS_constraints(const ParameterConstRef& Param, std::string _fun_name);
108 
112  std::string get_function_name() const;
113 
118 
123  void read_HLS_constraints_File(const std::string& f);
124 
129  void write_HLS_constraints_File(const std::string& f);
130 
137  void set_number_fu(const std::string& name, const std::string& library,
138  unsigned int n_resources = std::numeric_limits<unsigned int>::max());
139 
146  unsigned int get_number_fu(const std::string& name, const std::string& library) const;
147 
153  unsigned int get_number_fu(const std::string& combined) const;
154 
162  void bind_vertex_to_fu(const std::string& vertex_name, const std::string& fu_name, const std::string& fu_library,
163  const unsigned int fu_index);
164 
169  bool has_binding_to_fu(const std::string& vertex_name) const;
170 
176  void set_scheduling_priority(const std::string& vertex_name, int Priority);
177 
183 
188  void set_clock_period(double period);
189 
194  double get_clock_period() const
195  {
196  return clock_period;
197  }
198 
204  {
206  }
207 
212  void set_max_registers(unsigned int n_resources);
213 
218  unsigned int get_max_registers() const
219  {
220  return registers;
221  }
222 
227  void xload(const xml_element* Enode);
228 
233  void xwrite(xml_element* rootnode);
234 
239  void xwriteHLSConstraints(xml_element* Enode, bool forDump = false);
240 
249  void xwriteFUConstraints(xml_element* Enode, const std::string& fu_name, const std::string& fu_library,
250  unsigned int number_fu, bool forDump = false);
251 
259  void xwriteBindingConstraints(xml_element* Enode, const std::string& vertex_name, const std::string& fu_name,
260  const std::string& fu_library, unsigned int fu_index);
261 
268  void xwriteSchedulingConstraints(xml_element* Enode, const std::string& vertex_name, int priority);
269 
274  void print(std::ostream& os) const;
275 
279  friend std::ostream& operator<<(std::ostream& os, const HLS_constraints& s)
280  {
281  s.print(os);
282  return os;
283  }
284 
286  std::string get_kind_text() const
287  {
288  return std::string("HLS_constraints");
289  }
290 };
293 
294 #endif
generic device description
unsigned int registers
Variable storing the number of registers.
std::string get_kind_text() const
definition of the get_kind_text method
bool has_binding_to_fu(const std::string &vertex_name) const
Binds a vertex to a functional unit.
void read_HLS_constraints_File(const std::string &f)
Reads an XML file describing the structural data structures.
CONSTREF_FORWARD_DECL(Parameter)
std::string get_function_name() const
Gets the name of the function which the constraints are associated with.
void set_max_registers(unsigned int n_resources)
Sets the number of registers present in the function.
void set_clock_period(double period)
Sets the clock period.
CustomOrderedMap< T, U > CustomMap
Definition: custom_map.hpp:167
double get_clock_period_resource_fraction() const
Gets the resource fraction of the clock period.
void set_scheduling_priority(const std::string &vertex_name, int Priority)
Stores the priority value for an operation vertex.
void xload(const xml_element *Enode)
Loads a set of HLS constraints starting from an XML node.
void xwriteBindingConstraints(xml_element *Enode, const std::string &vertex_name, const std::string &fu_name, const std::string &fu_library, unsigned int fu_index)
Writes the binding constraints (i.e., functional unit, instance and library) associated with an opera...
redefinition of map to manage ordered/unordered structures
unsigned int get_number_fu(const std::string &name, const std::string &library) const
This method returns the maximum number of functional units available for the design.
#define max
Definition: backprop.h:17
void xwriteFUConstraints(xml_element *Enode, const std::string &fu_name, const std::string &fu_library, unsigned int number_fu, bool forDump=false)
Writes the constraints on the functional units.
void set_number_fu(const std::string &name, const std::string &library, unsigned int n_resources=std::numeric_limits< unsigned int >::max())
Sets the maximum number of resources available in the design.
CustomMap< std::string, std::pair< std::string, std::pair< std::string, unsigned int > > > binding_constraints
put into relation the vertex name with the functional unit, its library and the functional unit index...
double get_clock_period() const
Gets the clock period.
REF_FORWARD_DECL(HLS_constraints)
STD include.
void print(std::ostream &os) const
Function that prints the class HLS_constraints.
Data structure used to store all the HLS constraints.
void xwrite(xml_element *rootnode)
Writes the HLS constraints into an XML tree.
This wrapper collects all the methods used by the High-level synthesis classes to retrieve informatio...
Definition: allocation.hpp:102
friend std::ostream & operator<<(std::ostream &os, const HLS_constraints &s)
Friend definition of the << operator.
Template definition of refcount.
CustomMap< std::string, int > get_scheduling_priority() const
Returns the data structure containing scheduling priority constraints.
void write_HLS_constraints_File(const std::string &f)
Writes an XML file describing the high level synthesis constraints data structure.
unsigned int get_max_registers() const
Returns the number of registers available.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
void xwriteSchedulingConstraints(xml_element *Enode, const std::string &vertex_name, int priority)
Writes the scheduling constraints (i.e., priority value) associated with an operation.
void bind_vertex_to_fu(const std::string &vertex_name, const std::string &fu_name, const std::string &fu_library, const unsigned int fu_index)
Binds a vertex to a functional unit.
CustomMap< std::string, unsigned int > tech_constraints
For each functional unit tech_constraints stores the number of resources.
const ParameterConstRef parameters
The set of input parameters.
CustomMap< std::string, int > scheduling_constraints
map between an operation vertex and its given scheduling priority value
double clock_period_resource_fraction
current value of the resource fraction
std::string fun_name
name of the function which the constraints are associated with; emtpy string means that they are glob...
HLS_constraints(const ParameterConstRef &Param, std::string _fun_name)
Constructor.
void add_builtin_constraints()
Adds the builtin constraints.
double clock_period
Clock period in ns.
void xwriteHLSConstraints(xml_element *Enode, bool forDump=false)
Writes the generic synthesis constraints.

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