PandA-2024.02
reg_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  */
46 #ifndef REG_BINDING_HPP
47 #define REG_BINDING_HPP
48 
49 #include "Variable.hpp"
50 #include "custom_set.hpp"
51 #include "refcount.hpp"
52 #include <iosfwd>
53 #include <map>
54 #include <string>
55 
62 class register_obj;
63 class reg_binsign_creator;
64 
70 class reg_binding : public variable2obj<generic_objRef>
71 {
72  friend class reg_binding_creator;
73 
74  public:
75  using type_t = enum { STG = 0, CDFG };
76 
77  protected:
79  int debug;
80 
82  unsigned int used_regs;
83 
85  std::map<unsigned int, generic_objRef> unique_table;
86 
88  std::map<unsigned int, generic_objRef> stall_reg_table;
89 
91  std::map<unsigned int, unsigned int> reverse_map;
92 
94  std::map<unsigned int, unsigned long long> bitsize_map;
95 
98 
101 
103  std::map<unsigned int, CustomOrderedSet<unsigned int>> reg2storage_values;
104 
107 
110 
112 
113  static std::string reset_type;
114 
119 
125  virtual void specialise_reg(structural_objectRef& reg, unsigned int r);
126 
127  public:
131  reg_binding(const hlsRef& HLS, const HLS_managerRef HLSMgr_);
132 
136  ~reg_binding() override;
137 
138  static reg_bindingRef create_reg_binding(const hlsRef& HLS, const HLS_managerRef HLSMgr_);
139 
143  void bind(unsigned int sv, unsigned int index);
144 
150  virtual std::string GetRegisterFUName(unsigned int i);
151 
156  unsigned int get_used_regs() const
157  {
158  return used_regs;
159  }
160 
165  void set_used_regs(unsigned int regs)
166  {
167  used_regs = regs;
168  }
169 
175  unsigned int get_register(unsigned int sv) const
176  {
177  return reverse_map.find(sv)->second;
178  }
179 
182  {
184  }
185 
189  void print_el(const_iterator& it) const override;
190 
196  generic_objRef get(const unsigned int& r) const
197  {
198  return unique_table.find(r) != unique_table.end() ? unique_table.find(r)->second : generic_objRef();
199  }
200 
204  const register_obj& operator[](unsigned int v);
205 
209  virtual void add_to_SM(structural_objectRef clock_port, structural_objectRef reset_port);
210 
214  unsigned long long get_bitsize(unsigned int r) const;
215 
216  private:
222  CustomOrderedSet<unsigned int> get_vars(const unsigned int& r) const;
223 
229  unsigned long long compute_bitsize(unsigned int r);
230 };
231 
236 
237 #endif
Data structures used to manage set of variables.
unsigned int get_register(unsigned int sv) const
return the register index where the storage value is stored
unsigned long long compute_bitsize(unsigned int r)
return and set the bitsize associated with given register
~reg_binding() override
Destructor.
std::map< unsigned int, generic_objRef > stall_reg_table
map between std register index and stall register object for pipelines
Definition: reg_binding.hpp:88
CustomOrderedSet< unsigned int > get_vars(const unsigned int &r) const
Returns the set of variable associated with the register.
bool all_regs_without_enable
when true all registers do not require write enable: pipelining comes for free
Class managing the register binding.
Definition: reg_binding.hpp:70
const FunctionBehaviorConstRef FB
void set_used_regs(unsigned int regs)
sets number of used register
std::map< unsigned int, unsigned long long > bitsize_map
relation between registers and their bitsize
Definition: reg_binding.hpp:94
void bind(unsigned int sv, unsigned int index)
class modeling a register object
std::map< unsigned int, generic_objRef > unique_table
map between register index and object
Definition: reg_binding.hpp:85
reg_binding(const hlsRef &HLS, const HLS_managerRef HLSMgr_)
Constructor.
Definition: reg_binding.cpp:69
hlsRef HLS
HLS data-structure.
Definition: reg_binding.hpp:97
const register_obj & operator[](unsigned int v)
redefinition of the [] operator
static std::string reset_type
static reg_bindingRef create_reg_binding(const hlsRef &HLS, const HLS_managerRef HLSMgr_)
Definition: reg_binding.cpp:85
bool is_all_regs_without_enable()
return true when all registers are without write enable: pipelining comes for free ...
unsigned long long get_bitsize(unsigned int r) const
return bitsize
const HLS_managerRef HLSMgr
information about all the HLS synthesis
std::map< unsigned int, CustomOrderedSet< unsigned int > > reg2storage_values
map between the register and the associated storage value
#define index(x, y)
Definition: Keccak.c:74
redefinition of set to manage ordered/unordered structures
Generic class managing all resources into datapath.
Definition: generic_obj.hpp:66
enum { STG=0, CDFG } type_t
Definition: reg_binding.hpp:75
Generic class managing the different register allocation algorithms.
virtual void specialise_reg(structural_objectRef &reg, unsigned int r)
Specialise a register according to the type of the variables crossing it.
Class managing map of the storage values on a generic object.
Definition: Variable.hpp:60
int debug
level of the verbosity during the debugging
Definition: reg_binding.hpp:79
Template definition of refcount.
virtual std::string GetRegisterFUName(unsigned int i)
return the name of register to be used
unsigned int get_used_regs() const
returns number of used register
void compute_is_without_enable()
compute the is with out enable relation
virtual void add_to_SM(structural_objectRef clock_port, structural_objectRef reset_port)
Add the resulting registers to the structural description of the datapath.
REF_FORWARD_DECL(hls)
CustomOrderedSet< unsigned int > is_without_enable
store the set of register without enable
Data structure that contains all information about high level synthesis process.
Definition: hls.hpp:83
void print_el(const_iterator &it) const override
Function that print the register binding associated with a storage value.
unsigned int used_regs
number of used register
Definition: reg_binding.hpp:82
CONSTREF_FORWARD_DECL(FunctionBehavior)
Base object for all the structural objects.
std::map< unsigned int, unsigned int > reverse_map
bind the storage value with the register instance
Definition: reg_binding.hpp:91
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