yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RTLIL::Selection Struct Reference

#include <rtlil.h>

Public Member Functions

 Selection (bool full=true)
 
bool selected_module (RTLIL::IdString mod_name) const
 
bool selected_whole_module (RTLIL::IdString mod_name) const
 
bool selected_member (RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
 
void optimize (RTLIL::Design *design)
 
template<typename T1 >
void select (T1 *module)
 
template<typename T1 , typename T2 >
void select (T1 *module, T2 *member)
 
bool empty () const
 

Data Fields

bool full_selection
 
std::set< RTLIL::IdStringselected_modules
 
std::map< RTLIL::IdString,
std::set< RTLIL::IdString > > 
selected_members
 

Detailed Description

Definition at line 460 of file rtlil.h.

Constructor & Destructor Documentation

RTLIL::Selection::Selection ( bool  full = true)
inline

Definition at line 466 of file rtlil.h.

466 : full_selection(full) { }
bool full_selection
Definition: rtlil.h:462

Member Function Documentation

bool RTLIL::Selection::empty ( ) const
inline

Definition at line 485 of file rtlil.h.

485  {
486  return !full_selection && selected_modules.empty() && selected_members.empty();
487  }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
Definition: rtlil.h:464
bool full_selection
Definition: rtlil.h:462
void RTLIL::Selection::optimize ( RTLIL::Design design)

Definition at line 180 of file rtlil.cc.

181 {
182  if (full_selection) {
183  selected_modules.clear();
184  selected_members.clear();
185  return;
186  }
187 
188  std::vector<RTLIL::IdString> del_list, add_list;
189 
190  del_list.clear();
191  for (auto mod_name : selected_modules) {
192  if (design->modules_.count(mod_name) == 0)
193  del_list.push_back(mod_name);
194  selected_members.erase(mod_name);
195  }
196  for (auto mod_name : del_list)
197  selected_modules.erase(mod_name);
198 
199  del_list.clear();
200  for (auto &it : selected_members)
201  if (design->modules_.count(it.first) == 0)
202  del_list.push_back(it.first);
203  for (auto mod_name : del_list)
204  selected_members.erase(mod_name);
205 
206  for (auto &it : selected_members) {
207  del_list.clear();
208  for (auto memb_name : it.second)
209  if (design->modules_[it.first]->count_id(memb_name) == 0)
210  del_list.push_back(memb_name);
211  for (auto memb_name : del_list)
212  it.second.erase(memb_name);
213  }
214 
215  del_list.clear();
216  add_list.clear();
217  for (auto &it : selected_members)
218  if (it.second.size() == 0)
219  del_list.push_back(it.first);
220  else if (it.second.size() == design->modules_[it.first]->wires_.size() + design->modules_[it.first]->memories.size() +
221  design->modules_[it.first]->cells_.size() + design->modules_[it.first]->processes.size())
222  add_list.push_back(it.first);
223  for (auto mod_name : del_list)
224  selected_members.erase(mod_name);
225  for (auto mod_name : add_list) {
226  selected_members.erase(mod_name);
227  selected_modules.insert(mod_name);
228  }
229 
230  if (selected_modules.size() == design->modules_.size()) {
231  full_selection = true;
232  selected_modules.clear();
233  selected_members.clear();
234  }
235 }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
Definition: rtlil.h:464
bool full_selection
Definition: rtlil.h:462
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

+ Here is the caller graph for this function:

template<typename T1 >
void RTLIL::Selection::select ( T1 *  module)
inline

Definition at line 473 of file rtlil.h.

473  {
474  if (!full_selection && selected_modules.count(module->name) == 0) {
475  selected_modules.insert(module->name);
476  selected_members.erase(module->name);
477  }
478  }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
Definition: rtlil.h:464
RTLIL::Module * module
Definition: abc.cc:94
RTLIL::IdString name
Definition: rtlil.h:599
bool full_selection
Definition: rtlil.h:462

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
void RTLIL::Selection::select ( T1 *  module,
T2 *  member 
)
inline

Definition at line 480 of file rtlil.h.

480  {
481  if (!full_selection && selected_modules.count(module->name) == 0)
482  selected_members[module->name].insert(member->name);
483  }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
Definition: rtlil.h:464
RTLIL::Module * module
Definition: abc.cc:94
RTLIL::IdString name
Definition: rtlil.h:599
bool full_selection
Definition: rtlil.h:462
bool RTLIL::Selection::selected_member ( RTLIL::IdString  mod_name,
RTLIL::IdString  memb_name 
) const

Definition at line 168 of file rtlil.cc.

169 {
170  if (full_selection)
171  return true;
172  if (selected_modules.count(mod_name) > 0)
173  return true;
174  if (selected_members.count(mod_name) > 0)
175  if (selected_members.at(mod_name).count(memb_name) > 0)
176  return true;
177  return false;
178 }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
Definition: rtlil.h:464
bool full_selection
Definition: rtlil.h:462

+ Here is the caller graph for this function:

bool RTLIL::Selection::selected_module ( RTLIL::IdString  mod_name) const

Definition at line 148 of file rtlil.cc.

149 {
150  if (full_selection)
151  return true;
152  if (selected_modules.count(mod_name) > 0)
153  return true;
154  if (selected_members.count(mod_name) > 0)
155  return true;
156  return false;
157 }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
std::map< RTLIL::IdString, std::set< RTLIL::IdString > > selected_members
Definition: rtlil.h:464
bool full_selection
Definition: rtlil.h:462

+ Here is the caller graph for this function:

bool RTLIL::Selection::selected_whole_module ( RTLIL::IdString  mod_name) const

Definition at line 159 of file rtlil.cc.

160 {
161  if (full_selection)
162  return true;
163  if (selected_modules.count(mod_name) > 0)
164  return true;
165  return false;
166 }
std::set< RTLIL::IdString > selected_modules
Definition: rtlil.h:463
bool full_selection
Definition: rtlil.h:462

+ Here is the caller graph for this function:

Field Documentation

bool RTLIL::Selection::full_selection

Definition at line 462 of file rtlil.h.

std::map<RTLIL::IdString, std::set<RTLIL::IdString> > RTLIL::Selection::selected_members

Definition at line 464 of file rtlil.h.

std::set<RTLIL::IdString> RTLIL::Selection::selected_modules

Definition at line 463 of file rtlil.h.


The documentation for this struct was generated from the following files: