PandA-2024.02
fu_binding.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  */
45 #ifndef FU_BINDING_HPP
46 #define FU_BINDING_HPP
47 
48 #include "custom_set.hpp"
49 #include "op_graph.hpp"
50 #include "refcount.hpp"
51 
52 #include <iosfwd>
53 #include <limits>
54 #include <list>
55 #include <map>
56 #include <utility>
57 
62 class funit_obj;
63 class module;
79 
80 struct jms_sorter
81 {
82  bool operator()(const structural_objectRef& a, const structural_objectRef& b) const;
83 };
84 
91 {
92  protected:
94  std::map<unsigned int, unsigned int> allocation_map;
95 
97  std::map<std::pair<unsigned int, unsigned int>, generic_objRef> unique_table;
98 
100  std::map<std::pair<unsigned int, unsigned int>, OpVertexSet> operations;
101 
103  std::map<unsigned int, generic_objRef> op_binding;
104 
107 
110 
113 
116 
119 
122 
125 
131  void update_allocation(unsigned int unit, unsigned int number);
132 
136  structural_objectRef add_gate(const HLS_managerRef HLSMgr, const hlsRef HLS, const technology_nodeRef fu,
137  const std::string& name, const OpVertexSet& ops, structural_objectRef clock_port,
138  structural_objectRef reset_port) const;
139 
143  void check_parametrization(structural_objectRef curr_gate);
144 
151  void kill_proxy_memory_units(std::map<unsigned int, unsigned int>& memory_units, structural_objectRef curr_gate,
152  std::map<unsigned int, std::list<structural_objectRef>>& var_call_sites_rel,
153  std::map<unsigned int, unsigned int>& reverse_memory_units);
154 
155  void kill_proxy_function_units(std::map<unsigned int, std::string>& wrapped_units, structural_objectRef curr_gate,
156  std::map<std::string, std::list<structural_objectRef>>& fun_call_sites_rel,
157  std::map<std::string, unsigned int>& reverse_wrapped_units);
158 
166  void manage_killing_memory_proxies(std::map<unsigned int, structural_objectRef>& mem_obj,
167  std::map<unsigned int, unsigned int>& reverse_memory_units,
168  std::map<unsigned int, std::list<structural_objectRef>>& var_call_sites_rel,
169  const structural_managerRef SM, const hlsRef HLS, unsigned int& _unique_id);
170 
171  void manage_killing_function_proxies(std::map<unsigned int, structural_objectRef>& fun_obj,
172  std::map<std::string, unsigned int>& reverse_function_units,
173  std::map<std::string, std::list<structural_objectRef>>& fun_call_sites_rel,
174  const structural_managerRef SM, const hlsRef HLS, unsigned int& _unique_id);
175 
176  public:
178  static const unsigned int UNKNOWN;
179 
186  fu_binding(const HLS_managerConstRef _HLSMgr, const unsigned int function_id, const ParameterConstRef parameters);
187 
189 
190  fu_binding& operator=(const fu_binding&) = delete;
191 
195  virtual ~fu_binding();
196 
204  static fu_bindingRef create_fu_binding(const HLS_managerConstRef _HLSMgr, const unsigned int _function_id,
205  const ParameterConstRef _parameters);
206 
214  void bind(const vertex& v, unsigned int unit, unsigned int index = std::numeric_limits<unsigned int>::max());
215 
221  unsigned int get_assign(const vertex& v) const;
222 
228  unsigned int get_assign(const unsigned int statement_index) const;
229 
235  unsigned int get_index(const vertex& v) const;
236 
242  std::string get_fu_name(vertex const& v) const;
243 
249  unsigned int get_number(unsigned int unit) const
250  {
251  auto it = allocation_map.find(unit);
252  if(it != allocation_map.end())
253  {
254  return it->second;
255  }
256  else
257  {
258  return 0;
259  }
260  }
261 
270  const funit_obj& operator[](const vertex& v);
271 
277  generic_objRef get(const vertex v) const;
278 
279  generic_objRef get(unsigned int name, unsigned int index)
280  {
281  return (unique_table.count(std::make_pair(name, index))) ? unique_table[std::make_pair(name, index)] :
282  generic_objRef();
283  }
284 
289  std::list<unsigned int> get_allocation_list() const;
290 
296  bool is_assigned(const vertex& v) const;
297 
303  bool is_assigned(const unsigned int statement_index) const;
304 
308  virtual void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef clock_port,
309  structural_objectRef reset_port);
310 
311  virtual void manage_extern_global_port(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM,
312  structural_objectRef port_in, unsigned int dir, structural_objectRef circuit,
313  unsigned int num);
314 
318  static void manage_memory_ports_chained(const structural_managerRef SM,
319  const std::list<structural_objectRef>& memory_modules,
320  const structural_objectRef circuit);
321  virtual void manage_memory_ports_parallel_chained(const HLS_managerRef HLSMgr, const structural_managerRef SM,
322  const std::list<structural_objectRef>& memory_modules,
323  const structural_objectRef circuit, const hlsRef HLS,
324  unsigned int& unique_id);
325 
329  OpVertexSet get_operations(unsigned int unit, unsigned int index) const;
330 
334  void specialise_fu(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef fu_obj, unsigned int fu,
335  const OpVertexSet& operations, unsigned int ar);
336 
340  void specialize_memory_unit(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef fu_obj,
341  unsigned int ar, const std::string& base_address, unsigned long long rangesize,
342  bool is_memory_splitted, bool is_sparse_memory, bool is_sds);
343 
344  virtual bool manage_module_ports(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM,
345  const structural_objectRef curr_gate, unsigned int num);
346 
352  void set_ports_are_swapped(vertex v, bool condition);
353 
360  {
361  return ports_are_swapped.find(v) != ports_are_swapped.end();
362  }
363 
365  bool has_resource_sharing() const
366  {
367  return has_resource_sharing_p;
368  }
369 
370  static void
371  join_merge_split(const structural_managerRef SM, const hlsRef HLS,
372  std::map<structural_objectRef, std::list<structural_objectRef>, jms_sorter>& primary_outs,
373  const structural_objectRef circuit, unsigned int& unique_id);
374 
390  static void fill_array_ref_memory(std::ostream& init_file_a, std::ostream& init_file_b, unsigned int ar,
391  unsigned long long& vec_size, unsigned long long& elts_size, const memoryRef mem,
392  tree_managerConstRef TM, bool is_sds, unsigned long long bitsize_align);
393 
394  static void write_init(const tree_managerConstRef TreeM, tree_nodeRef var_node, tree_nodeRef init_node,
395  std::vector<std::string>& init_file, const memoryRef mem,
396  unsigned long long element_precision);
397 };
398 
404 
405 #endif
int debug_level
The debug level.
Definition: fu_binding.hpp:121
std::map< unsigned int, unsigned int > allocation_map
map between functional unit id and number of units allocated
Definition: fu_binding.hpp:94
REF_FORWARD_DECL(AllocationInformation)
bool get_ports_are_swapped(vertex v) const
Check if vertex v has its ports swapped or not.
Definition: fu_binding.hpp:359
This class manages the tree structures extracted from the raw file.
bool has_resource_sharing() const
return true in case at least one resource is shared
Definition: fu_binding.hpp:365
This class manages the circuit structures.
const tree_managerConstRef TreeM
information about the tree data-structure
Definition: fu_binding.hpp:109
bool operator()(const structural_objectRef &a, const structural_objectRef &b) const
std::map< std::pair< unsigned int, unsigned int >, generic_objRef > unique_table
map between unit and allocated objects
Definition: fu_binding.hpp:97
A set of operation vertices.
Definition: op_graph.hpp:654
Abstract pure class for the tree structure.
Definition: tree_node.hpp:139
#define max
Definition: backprop.h:17
const OpGraphConstRef op_graph
The operation graph.
Definition: fu_binding.hpp:112
std::map< std::pair< unsigned int, unsigned int >, OpVertexSet > operations
reverse map that associated each functional unit with the set of operations that are executed ...
Definition: fu_binding.hpp:100
unsigned map[NUM_VERTICES]
Definition: bfs.c:12
unsigned int get_number(unsigned int unit) const
Returns number of functional unit allocated.
Definition: fu_binding.hpp:249
#define index(x, y)
Definition: Keccak.c:74
redefinition of set to manage ordered/unordered structures
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
Generic class managing all resources into datapath.
Definition: generic_obj.hpp:66
static const unsigned int UNKNOWN
The value used to identified unknown functional unit.
Definition: fu_binding.hpp:178
Class representing functional units in the datapath.
Definition: funit_obj.hpp:56
CONSTREF_FORWARD_DECL(AllocationInformation)
Template definition of refcount.
AllocationInformationRef allocation_information
allocation manager. Used to retrieve the string name of the functional units.
Definition: fu_binding.hpp:106
bool has_resource_sharing_p
useful to know for automatic pipelining
Definition: fu_binding.hpp:124
std::map< unsigned int, generic_objRef > op_binding
operation binding
Definition: fu_binding.hpp:103
int original[DIMENSION_Y][DIMENSION_X]
Definition: boxfilter.h:1
Data structures used in operations graph.
Data structure that contains all information about high level synthesis process.
Definition: hls.hpp:83
Class managing the functional-unit binding.
Definition: fu_binding.hpp:90
const ParameterConstRef parameters
The set of input parameters.
Definition: fu_binding.hpp:118
Class used to describe a particular graph with operations as nodes.
Definition: op_graph.hpp:783
CustomOrderedSet< vertex > ports_are_swapped
port assignment: ports are swapped predicate
Definition: fu_binding.hpp:115
This class describes a generic module.
Abstract pure class for the technology structure.
Base object for all the structural objects.
refcount< generic_obj > generic_objRef
RefCount definition for generic_obj class.

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