PandA-2024.02
commandport_obj.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 COMMANDPORT_OBJ_HPP
47 #define COMMANDPORT_OBJ_HPP
48 
49 #include "refcount.hpp"
50 #include <utility>
51 
52 #include "generic_obj.hpp"
53 
54 #include "conn_binding.hpp"
55 
62 
70 {
71  public:
73  using command_type = enum {
74  OPERATION = 0,
75  CONDITION,
76  SWITCH,
78  MULTIIF,
79  SELECTOR,
80  ALUSELECTOR,
81  UNBOUNDED,
82  MULTI_UNBOUNDED,
83  MULTI_UNBOUNDED_ENABLE,
84  WRENABLE
85  };
86 
87  using data_operation_pair = std::pair<unsigned int, vertex>;
90  using transition = std::tuple<vertex, vertex, data_operation_pair>;
91 
92  private:
97 
99 
101  unsigned int mode;
102 
104 
106 
109 
110  public:
116  commandport_obj(const vertex& signal_, unsigned int _mode, const std::string& _name)
117  : generic_obj(COMMAND_PORT, _name), signal(signal_), mode(_mode), is_a_phi_write_enable(false)
118  {
119  THROW_ASSERT(mode == OPERATION or mode == CONDITION or mode == SWITCH or mode == MULTIIF or mode == UNBOUNDED,
120  "Command mode not allowed into this constructor");
121  }
122 
123  commandport_obj(generic_objRef _elem, unsigned int _mode, const std::string& _name)
124  : generic_obj(COMMAND_PORT, _name), elem(_elem), mode(_mode), is_a_phi_write_enable(false)
125  {
126  THROW_ASSERT(mode == SELECTOR || mode == WRENABLE || mode == ALUSELECTOR or mode == MULTI_UNBOUNDED or
127  mode == MULTI_UNBOUNDED_ENABLE,
128  "Selector port is wrong");
129  }
130 
134  ~commandport_obj() override = default;
135 
140  const vertex& get_vertex() const
141  {
142  THROW_ASSERT(mode == OPERATION or mode == CONDITION or mode == SWITCH or mode == MULTIIF or mode == UNBOUNDED,
143  "Command mode not allowed");
144  return signal;
145  }
146 
151  unsigned int get_command_type() const
152  {
153  return mode;
154  }
155 
157  {
158  return activations;
159  }
160 
161  void add_activation(const transition& act)
162  {
163  activations.insert(act);
164  }
165 
171  {
172  controller_SM = _SM;
173  }
174 
180  {
181  return controller_SM.lock();
182  }
183 
184  const generic_objRef& get_elem() const
185  {
186  THROW_ASSERT(mode == SELECTOR || mode == WRENABLE || mode == ALUSELECTOR || mode == MULTI_UNBOUNDED or
187  mode == MULTI_UNBOUNDED_ENABLE,
188  "Selector port is wrong");
189  return elem;
190  }
191 
192  static const std::string get_mode_string(unsigned int _mode)
193  {
194  switch(_mode)
195  {
196  case OPERATION:
197  return "OPERATION";
198  case CONDITION:
199  return "CONDITION";
200  case SWITCH:
201  return "SWITCH";
202  case MULTIIF:
203  return "MULTIIF";
204  case UNBOUNDED:
205  return "UNBOUNDED";
206  case MULTI_UNBOUNDED:
207  return "MULTI_UNBOUNDED";
208  case MULTI_UNBOUNDED_ENABLE:
209  return "MULTI_UNBOUNDED_ENABLE";
210  case SELECTOR:
211  return "SELECTOR";
212  case WRENABLE:
213  return "WRENABLE";
214  default:
215  THROW_ERROR("Command mode not allowed for port");
216  }
217  return "";
218  }
219 
221  {
222  is_a_phi_write_enable = true;
223  }
224 
226  {
227  return is_a_phi_write_enable;
228  }
229 };
230 
231 #endif
a multi unbounded controller
Definition: generic_obj.hpp:75
std::pair< unsigned int, vertex > data_operation_pair
REF_FORWARD_DECL(commandport_obj)
vertex signal
TODO: substitute with a functor operation vertex associated with the command port signal (if type is ...
const structural_objectRef get_controller_obj() const
Gets structural_object associated to this object.
void set_controller_obj(const structural_objectRef &_SM)
Sets structural_object associated to this object.
enum { OPERATION=0, CONDITION, SWITCH, MULTIIF, SELECTOR, ALUSELECTOR, UNBOUNDED, MULTI_UNBOUNDED, MULTI_UNBOUNDED_ENABLE, WRENABLE } command_type
Available command types.
const generic_objRef & get_elem() const
This class manages command ports into datapath.
~commandport_obj() override=default
Destructor.
commandport_obj(generic_objRef _elem, unsigned int _mode, const std::string &_name)
unsigned int mode
It&#39;s command type for the port.
static const std::string get_mode_string(unsigned int _mode)
void add_activation(const transition &act)
Base class for all resources into datapath.
const CustomOrderedSet< transition > & get_activations() const
const vertex & get_vertex() const
Gets the vertex associated with port.
Data structure used to store the interconnection binding of datapath elements.
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
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
generic_objRef elem
Template definition of refcount.
refcount< T > lock() const
Definition: refcount.hpp:212
Wrefcount< structural_object > controller_SM
structural_object associated with the element inside the controller
std::tuple< vertex, vertex, data_operation_pair > transition
describe a transition from a source state to the target state plus the tree_node of the data transfer...
unsigned int get_command_type() const
Gets command type.
CustomOrderedSet< transition > activations
commandport_obj(const vertex &signal_, unsigned int _mode, const std::string &_name)
This is the constructor of the commandport_obj class.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

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