PandA-2024.02
conn_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  */
44 #ifndef CONN_BINDING_HPP
45 #define CONN_BINDING_HPP
46 
48 #include "config_HAVE_UNORDERED.hpp"
49 
50 #include <iosfwd>
51 #include <string>
52 
53 #include "refcount.hpp"
65 
66 #include "custom_map.hpp"
67 #include "generic_obj.hpp"
68 #include "graph.hpp"
69 
72 using data_transfer = std::tuple<unsigned int, unsigned int, vertex, vertex, vertex>;
73 
79 {
80  public:
82  using direction_type = enum { IN = 0, OUT };
83 
85  using type_t = enum { STG = 0 };
86 
88  using connection = std::tuple<generic_objRef, generic_objRef, unsigned int, unsigned int>;
89 
91 #if HAVE_UNORDERED
92  using conn_implementation_map = std::map<connection, connection_objRef>;
93 #else
94 
96  struct ConnectionSorter : public std::binary_function<connection, connection, bool>
97  {
104  bool operator()(const connection& x, const connection& y) const;
105  };
106 
107  using conn_implementation_map = std::map<connection, connection_objRef, ConnectionSorter>;
108 #endif
109 
111  using const_param = std::tuple<std::string, std::string>;
112 
114  struct ConnectionTarget : public std::tuple<generic_objRef, unsigned int, unsigned int>
115  {
122  ConnectionTarget(generic_objRef tgt, unsigned int tgt_port, unsigned int tgt_port_index);
123 
124 #if !HAVE_UNORDERED
125 
129  bool operator<(const ConnectionTarget& other) const;
130 #endif
131  };
132 
134 #if HAVE_UNORDERED
136 #else
137  using ConnectionSources = std::map<generic_objRef, CustomOrderedSet<data_transfer>, GenericObjSorter>;
138 #endif
139 
140  protected:
143 
146 
147  private:
150 
151  private:
154 
156  std::map<vertex, std::map<unsigned int, generic_objRef>> activation_ports;
157 
159  std::map<unsigned int, generic_objRef> input_ports;
160 
162  std::map<unsigned int, generic_objRef> output_ports;
163 
165  std::map<const_param, generic_objRef> constant_values;
166 
168  std::map<std::string, structural_objectRef> converters;
169 
171  std::map<std::pair<vertex, unsigned int>, generic_objRef> command_input_ports;
172 
174  std::map<vertex, generic_objRef> command_output_ports;
175 
177 #if HAVE_UNORDERED
178  using Selectors = std::map<std::pair<generic_objRef, unsigned int>, generic_objRef>;
179 #else
180  using Selectors = std::map<std::pair<generic_objRef, unsigned int>, generic_objRef, GenericObjUnsignedIntSorter>;
181 #endif
182  std::map<unsigned int, Selectors> selectors;
183 
185 #if HAVE_UNORDERED
187 #else
189 #endif
190 
194  std::map<ConnectionTarget, ConnectionSources> conn_variables;
195 
198 
199  static unsigned unique_id;
200 
206  void specialise_mux(const generic_objRef mux, unsigned int bits_tgt) const;
207 
211  void mux_connection(const hlsRef HLS, const structural_managerRef SM);
212 
216  void add_sparse_logic_dp(const hlsRef HLS, const structural_managerRef SM, const HLS_managerRef HLSMgr);
217 
221  void add_command_ports(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM);
222 
226  virtual void mux_allocation(const hlsRef HLS, const structural_managerRef SM, structural_objectRef src,
228 
233  const structural_objectRef src, const structural_objectRef port_tgt,
234  unsigned int conn_type);
235 
242 
243  public:
247  conn_binding(const BehavioralHelperConstRef BH, const ParameterConstRef parameters);
248 
252  virtual ~conn_binding();
253 
259  generic_objRef bind_port(unsigned int var, direction_type dir);
260 
268  generic_objRef bind_command_port(const vertex& ver, direction_type dir, unsigned int mode, const OpGraphConstRef g);
269 
270  generic_objRef bind_selector_port(direction_type dir, unsigned int mode, const vertex& cond,
271  const OpGraphConstRef data);
272 
273  generic_objRef bind_selector_port(direction_type dir, unsigned int mode, const generic_objRef elem, unsigned int op);
274 
281  generic_objRef get_port(unsigned int var, direction_type dir);
282 
286  virtual void print() const;
287 
297  void add_data_transfer(const generic_objRef op1, const generic_objRef op2, unsigned int operand,
298  unsigned int port_index, data_transfer data);
299 
309  void AddConnectionCB(const generic_objRef op1, const generic_objRef op2, unsigned int operand,
310  unsigned int port_index, connection_objRef conn);
311 
315  const std::map<ConnectionTarget, ConnectionSources>& get_data_transfers() const;
316 
320  unsigned long long determine_bit_level_mux() const;
321 
322  const std::map<unsigned int, Selectors>& GetSelectors() const
323  {
324  return selectors;
325  }
326 
327  void add_sparse_logic(const generic_objRef so)
328  {
329  sparse_logic.insert(so);
330  }
331 
335  virtual void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM);
336 
337  generic_objRef get_constant_obj(const std::string& value, const std::string& param, unsigned int precision);
338 
339  const std::map<const_param, generic_objRef>& get_constant_objs() const;
340 
349  static conn_bindingRef create_conn_binding(const HLS_managerRef _HLSMgr, const hlsRef _HLS,
350  const BehavioralHelperConstRef _BH, const ParameterConstRef _parameters);
351 
352  void cleanInternals();
353 };
356 
357 #endif
TVMValue param[3]
definition of target of a connection
bool operator<(const DiscrepancyOpInfo &a, const DiscrepancyOpInfo &b)
void AddConnectionCB(const generic_objRef op1, const generic_objRef op2, unsigned int operand, unsigned int port_index, connection_objRef conn)
Creates a connection between two objects.
generic_objRef bind_selector_port(direction_type dir, unsigned int mode, const vertex &cond, const OpGraphConstRef data)
std::map< unsigned int, generic_objRef > input_ports
map between input port variable and generic object
const std::map< unsigned int, Selectors > & GetSelectors() const
std::map< std::pair< generic_objRef, unsigned int >, generic_objRef, GenericObjUnsignedIntSorter > Selectors
selector ports
virtual void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM)
Add the interconnection to the structural representation of the datapath.
generic_objRef get_port(unsigned int var, direction_type dir)
Returns reference to generic object associated to a given variable, for a specific port direction...
const std::map< const_param, generic_objRef > & get_constant_objs() const
const ParameterConstRef parameters
The set of input parameters.
Class specification of the graph structures.
This class manages the circuit structures.
std::tuple< std::string, std::string > const_param
definition of the key to deal with constant parameters
generic_objRef bind_port(unsigned int var, direction_type dir)
Bind variable to a port object.
unsigned long long determine_bit_level_mux() const
Returns the number of bit-level multiplexers.
virtual void print() const
Function that prints the interconnection binding.
std::map< connection, connection_objRef, ConnectionSorter > conn_implementation_map
redefinition of map to manage ordered/unordered structures
generic_objRef get_constant_obj(const std::string &value, const std::string &param, unsigned int precision)
CONSTREF_FORWARD_DECL(BehavioralHelper)
bool check_pv_allconnected(structural_objectRef port_i)
check if a port vector has its port bounded to something
std::map< unsigned int, Selectors > selectors
void add_data_transfer(const generic_objRef op1, const generic_objRef op2, unsigned int operand, unsigned int port_index, data_transfer data)
Adds a data transfer between two objects.
std::map< const_param, generic_objRef > constant_values
constant values
void add_command_ports(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM)
Add signals from/to controller.
Base class for all resources into datapath.
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
Definition: custom_map.hpp:148
std::map< std::pair< vertex, unsigned int >, generic_objRef > command_input_ports
map between command input port (operation vertex and command type) and generic object ...
std::map< unsigned int, generic_objRef > output_ports
map between output port variable and generic object
This class manages the technology library structures.
std::tuple< unsigned int, unsigned int, vertex, vertex, vertex > data_transfer
definition of the data transfer (tree_node, precision, from, to, data_transferred, current_op).
Class managing the interconnection binding.
static unsigned unique_id
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
std::map< vertex, generic_objRef > command_output_ports
map between output port variable and generic object
virtual ~conn_binding()
Destructor.
Generic class managing elements used to interconnect generic objects into datapath.
void specialise_mux(const generic_objRef mux, unsigned int bits_tgt) const
Specialize a multiplexer according to the type of the variables crossing it.
conn_binding(const BehavioralHelperConstRef BH, const ParameterConstRef parameters)
Constructor.
void mux_connection(const hlsRef HLS, const structural_managerRef SM)
Add the mux-based interconnection.
static conn_bindingRef create_conn_binding(const HLS_managerRef _HLSMgr, const hlsRef _HLS, const BehavioralHelperConstRef _BH, const ParameterConstRef _parameters)
factory method to create the right conn_binding depending on the flow
std::map< ConnectionTarget, ConnectionSources > conn_variables
map between the input of the unit and the corresponding incoming connections.
std::map< generic_objRef, CustomOrderedSet< data_transfer >, GenericObjSorter > ConnectionSources
definition of sources of a connection
std::map< vertex, std::map< unsigned int, generic_objRef > > activation_ports
map between a vertex and the corresponding activation signal
Template definition of refcount.
conn_implementation_map conn_implementation
map between the connection <src, tgt, tgt_port, tgt_port_index> and the corresponding object ...
bool operator()(const connection &x, const connection &y) const
Compare position of two connections.
std::tuple< generic_objRef, generic_objRef, unsigned int, unsigned int > connection
connection between two objects (<src, tgt, tgt_port, tgt_port_index>)
const std::map< ConnectionTarget, ConnectionSources > & get_data_transfers() const
Returns the map containing all the data transfers.
void add_sparse_logic_dp(const hlsRef HLS, const structural_managerRef SM, const HLS_managerRef HLSMgr)
Add sparse logic to the datapath.
void add_datapath_connection(const technology_managerRef TM, const structural_managerRef SM, const structural_objectRef src, const structural_objectRef port_tgt, unsigned int conn_type)
Add a data converter, if needed, between two objects of the structural representation of the datapath...
const BehavioralHelperConstRef BH
reference to the behavioral helper associated with the specification
CustomOrderedSet< generic_objRef, GenericObjSorter > sparse_logic
set containing all the sparse logic contained into the datapath
REF_FORWARD_DECL(HLS_manager)
Autoheader include.
enum { IN=0, OUT } direction_type
direction port identifier
Data structure that contains all information about high level synthesis process.
Definition: hls.hpp:83
x
Return the smallest n such that 2^n >= _x.
Class used to describe a particular graph with operations as nodes.
Definition: op_graph.hpp:783
generic_objRef bind_command_port(const vertex &ver, direction_type dir, unsigned int mode, const OpGraphConstRef g)
Bind vertex to a command port object.
virtual void mux_allocation(const hlsRef HLS, const structural_managerRef SM, structural_objectRef src, structural_objectRef tgt, connection_objRef conn)
Add multiplexers to the structural representation of the datapath.
int debug_level
control the verbosity during the debugging
definition of the connection implementations
std::map< std::string, structural_objectRef > converters
data type converters
int output_level
control the output verbosity
void add_sparse_logic(const generic_objRef so)
enum { STG=0 } type_t
type of the data-structure
Base object for all the structural objects.
refcount< generic_obj > generic_objRef
RefCount definition for generic_obj class.
void cleanInternals()

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