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

#include <rtlil.h>

Public Member Functions

 Design ()
 
 ~Design ()
 
RTLIL::ObjRange< RTLIL::Module * > modules ()
 
RTLIL::Modulemodule (RTLIL::IdString name)
 
bool has (RTLIL::IdString id) const
 
void add (RTLIL::Module *module)
 
RTLIL::ModuleaddModule (RTLIL::IdString name)
 
void remove (RTLIL::Module *module)
 
void scratchpad_unset (std::string varname)
 
void scratchpad_set_int (std::string varname, int value)
 
void scratchpad_set_bool (std::string varname, bool value)
 
void scratchpad_set_string (std::string varname, std::string value)
 
int scratchpad_get_int (std::string varname, int default_value=0) const
 
bool scratchpad_get_bool (std::string varname, bool default_value=false) const
 
std::string scratchpad_get_string (std::string varname, std::string default_value=std::string()) const
 
void check ()
 
void optimize ()
 
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
 
bool selected_module (RTLIL::Module *mod) const
 
bool selected_whole_module (RTLIL::Module *mod) const
 
bool full_selection () const
 
template<typename T1 >
bool selected (T1 *module) const
 
template<typename T1 , typename T2 >
bool selected (T1 *module, T2 *member) const
 
template<typename T1 , typename T2 >
void select (T1 *module, T2 *member)
 
std::vector< RTLIL::Module * > selected_modules () const
 
std::vector< RTLIL::Module * > selected_whole_modules () const
 
std::vector< RTLIL::Module * > selected_whole_modules_warn () const
 

Data Fields

std::set< RTLIL::Monitor * > monitors
 
std::map< std::string,
std::string > 
scratchpad
 
int refcount_modules_
 
std::map< RTLIL::IdString,
RTLIL::Module * > 
modules_
 
std::vector< RTLIL::Selectionselection_stack
 
std::map< RTLIL::IdString,
RTLIL::Selection
selection_vars
 
std::string selected_active_module
 

Detailed Description

Definition at line 501 of file rtlil.h.

Constructor & Destructor Documentation

RTLIL::Design::Design ( )

Definition at line 237 of file rtlil.cc.

238 {
239  refcount_modules_ = 0;
240  selection_stack.push_back(RTLIL::Selection());
241 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
int refcount_modules_
Definition: rtlil.h:506
RTLIL::Design::~Design ( )

Definition at line 243 of file rtlil.cc.

244 {
245  for (auto it = modules_.begin(); it != modules_.end(); it++)
246  delete it->second;
247 }
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

Member Function Documentation

void RTLIL::Design::add ( RTLIL::Module module)

Definition at line 259 of file rtlil.cc.

260 {
261  log_assert(modules_.count(module->name) == 0);
263  modules_[module->name] = module;
264  module->design = this;
265 
266  for (auto mon : monitors)
267  mon->notify_module_add(module);
268 }
int refcount_modules_
Definition: rtlil.h:506
#define log_assert(_assert_expr_)
Definition: log.h:85
RTLIL::IdString name
Definition: rtlil.h:599
RTLIL::Module * module(RTLIL::IdString name)
Definition: rtlil.cc:254
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
RTLIL::Design * design
Definition: rtlil.h:589
std::set< RTLIL::Monitor * > monitors
Definition: rtlil.h:503

+ Here is the caller graph for this function:

RTLIL::Module * RTLIL::Design::addModule ( RTLIL::IdString  name)

Definition at line 270 of file rtlil.cc.

271 {
272  log_assert(modules_.count(name) == 0);
274 
276  modules_[name] = module;
277  module->design = this;
278  module->name = name;
279 
280  for (auto mon : monitors)
281  mon->notify_module_add(module);
282 
283  return module;
284 }
int refcount_modules_
Definition: rtlil.h:506
#define log_assert(_assert_expr_)
Definition: log.h:85
RTLIL::IdString name
Definition: rtlil.h:599
RTLIL::Module * module(RTLIL::IdString name)
Definition: rtlil.cc:254
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
RTLIL::Design * design
Definition: rtlil.h:589
std::set< RTLIL::Monitor * > monitors
Definition: rtlil.h:503

+ Here is the caller graph for this function:

void RTLIL::Design::check ( )

Definition at line 357 of file rtlil.cc.

358 {
359 #ifndef NDEBUG
360  for (auto &it : modules_) {
361  log_assert(this == it.second->design);
362  log_assert(it.first == it.second->name);
363  log_assert(!it.first.empty());
364  it.second->check();
365  }
366 #endif
367 }
#define log_assert(_assert_expr_)
Definition: log.h:85
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

+ Here is the caller graph for this function:

bool RTLIL::Design::full_selection ( ) const
inline

Definition at line 547 of file rtlil.h.

547  {
548  return selection_stack.back().full_selection;
549  }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509

+ Here is the caller graph for this function:

bool RTLIL::Design::has ( RTLIL::IdString  id) const
inline

Definition at line 519 of file rtlil.h.

519  {
520  return modules_.count(id) != 0;
521  }
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

+ Here is the caller graph for this function:

RTLIL::Module * RTLIL::Design::module ( RTLIL::IdString  name)

Definition at line 254 of file rtlil.cc.

255 {
256  return modules_.count(name) ? modules_.at(name) : NULL;
257 }
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
#define NULL

+ Here is the caller graph for this function:

RTLIL::ObjRange< RTLIL::Module * > RTLIL::Design::modules ( )

Definition at line 249 of file rtlil.cc.

250 {
252 }
int refcount_modules_
Definition: rtlil.h:506
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

+ Here is the caller graph for this function:

void RTLIL::Design::optimize ( )

Definition at line 369 of file rtlil.cc.

370 {
371  for (auto &it : modules_)
372  it.second->optimize();
373  for (auto &it : selection_stack)
374  it.optimize(this);
375  for (auto &it : selection_vars)
376  it.second.optimize(this);
377 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::map< RTLIL::IdString, RTLIL::Selection > selection_vars
Definition: rtlil.h:510
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

+ Here is the caller graph for this function:

void RTLIL::Design::remove ( RTLIL::Module module)

Definition at line 347 of file rtlil.cc.

348 {
349  for (auto mon : monitors)
350  mon->notify_module_del(module);
351 
352  log_assert(modules_.at(module->name) == module);
353  modules_.erase(module->name);
354  delete module;
355 }
#define log_assert(_assert_expr_)
Definition: log.h:85
RTLIL::IdString name
Definition: rtlil.h:599
RTLIL::Module * module(RTLIL::IdString name)
Definition: rtlil.cc:254
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
std::set< RTLIL::Monitor * > monitors
Definition: rtlil.h:503

+ Here is the caller graph for this function:

bool RTLIL::Design::scratchpad_get_bool ( std::string  varname,
bool  default_value = false 
) const

Definition at line 324 of file rtlil.cc.

325 {
326  if (scratchpad.count(varname) == 0)
327  return default_value;
328 
329  std::string str = scratchpad.at(varname);
330 
331  if (str == "0" || str == "false")
332  return false;
333 
334  if (str == "1" || str == "true")
335  return true;
336 
337  return default_value;
338 }
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504

+ Here is the caller graph for this function:

int RTLIL::Design::scratchpad_get_int ( std::string  varname,
int  default_value = 0 
) const

Definition at line 306 of file rtlil.cc.

307 {
308  if (scratchpad.count(varname) == 0)
309  return default_value;
310 
311  std::string str = scratchpad.at(varname);
312 
313  if (str == "0" || str == "false")
314  return 0;
315 
316  if (str == "1" || str == "true")
317  return 1;
318 
319  char *endptr = nullptr;
320  long int parsed_value = strtol(str.c_str(), &endptr, 10);
321  return *endptr ? default_value : parsed_value;
322 }
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504
std::string RTLIL::Design::scratchpad_get_string ( std::string  varname,
std::string  default_value = std::string() 
) const

Definition at line 340 of file rtlil.cc.

341 {
342  if (scratchpad.count(varname) == 0)
343  return default_value;
344  return scratchpad.at(varname);
345 }
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504
void RTLIL::Design::scratchpad_set_bool ( std::string  varname,
bool  value 
)

Definition at line 296 of file rtlil.cc.

297 {
298  scratchpad[varname] = value ? "true" : "false";
299 }
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504

+ Here is the caller graph for this function:

void RTLIL::Design::scratchpad_set_int ( std::string  varname,
int  value 
)

Definition at line 291 of file rtlil.cc.

292 {
293  scratchpad[varname] = stringf("%d", value);
294 }
std::string stringf(const char *fmt,...)
Definition: yosys.cc:58
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504

+ Here is the call graph for this function:

void RTLIL::Design::scratchpad_set_string ( std::string  varname,
std::string  value 
)

Definition at line 301 of file rtlil.cc.

302 {
303  scratchpad[varname] = value;
304 }
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504
void RTLIL::Design::scratchpad_unset ( std::string  varname)

Definition at line 286 of file rtlil.cc.

287 {
288  scratchpad.erase(varname);
289 }
std::map< std::string, std::string > scratchpad
Definition: rtlil.h:504

+ Here is the caller graph for this function:

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

Definition at line 559 of file rtlil.h.

559  {
560  if (selection_stack.size() > 0) {
561  RTLIL::Selection &sel = selection_stack.back();
562  sel.select(module, member);
563  }
564  }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
void select(T1 *module)
Definition: rtlil.h:473
RTLIL::Module * module(RTLIL::IdString name)
Definition: rtlil.cc:254

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 >
bool RTLIL::Design::selected ( T1 *  module) const
inline

Definition at line 551 of file rtlil.h.

551  {
552  return selected_module(module->name);
553  }
bool selected_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:379
RTLIL::IdString name
Definition: rtlil.h:599
RTLIL::Module * module(RTLIL::IdString name)
Definition: rtlil.cc:254

+ Here is the call graph for this function:

template<typename T1 , typename T2 >
bool RTLIL::Design::selected ( T1 *  module,
T2 *  member 
) const
inline

Definition at line 555 of file rtlil.h.

555  {
556  return selected_member(module->name, member->name);
557  }
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
Definition: rtlil.cc:397
RTLIL::IdString name
Definition: rtlil.h:599
RTLIL::Module * module(RTLIL::IdString name)
Definition: rtlil.cc:254

+ Here is the call graph for this function:

bool RTLIL::Design::selected_member ( RTLIL::IdString  mod_name,
RTLIL::IdString  memb_name 
) const

Definition at line 397 of file rtlil.cc.

398 {
399  if (!selected_active_module.empty() && mod_name != selected_active_module)
400  return false;
401  if (selection_stack.size() == 0)
402  return true;
403  return selection_stack.back().selected_member(mod_name, memb_name);
404 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511

+ Here is the caller graph for this function:

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

Definition at line 379 of file rtlil.cc.

380 {
381  if (!selected_active_module.empty() && mod_name != selected_active_module)
382  return false;
383  if (selection_stack.size() == 0)
384  return true;
385  return selection_stack.back().selected_module(mod_name);
386 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511

+ Here is the caller graph for this function:

bool RTLIL::Design::selected_module ( RTLIL::Module mod) const

Definition at line 406 of file rtlil.cc.

407 {
408  return selected_module(mod->name);
409 }
bool selected_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:379
RTLIL::IdString name
Definition: rtlil.h:599
std::vector< RTLIL::Module * > RTLIL::Design::selected_modules ( ) const

Definition at line 416 of file rtlil.cc.

417 {
418  std::vector<RTLIL::Module*> result;
419  result.reserve(modules_.size());
420  for (auto &it : modules_)
421  if (selected_module(it.first))
422  result.push_back(it.second);
423  return result;
424 }
bool selected_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:379
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507

+ Here is the caller graph for this function:

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

Definition at line 388 of file rtlil.cc.

389 {
390  if (!selected_active_module.empty() && mod_name != selected_active_module)
391  return false;
392  if (selection_stack.size() == 0)
393  return true;
394  return selection_stack.back().selected_whole_module(mod_name);
395 }
std::vector< RTLIL::Selection > selection_stack
Definition: rtlil.h:509
std::string selected_active_module
Definition: rtlil.h:511

+ Here is the caller graph for this function:

bool RTLIL::Design::selected_whole_module ( RTLIL::Module mod) const

Definition at line 411 of file rtlil.cc.

412 {
413  return selected_whole_module(mod->name);
414 }
RTLIL::IdString name
Definition: rtlil.h:599
bool selected_whole_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:388
std::vector< RTLIL::Module * > RTLIL::Design::selected_whole_modules ( ) const

Definition at line 426 of file rtlil.cc.

427 {
428  std::vector<RTLIL::Module*> result;
429  result.reserve(modules_.size());
430  for (auto &it : modules_)
431  if (selected_whole_module(it.first))
432  result.push_back(it.second);
433  return result;
434 }
bool selected_whole_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:388
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
std::vector< RTLIL::Module * > RTLIL::Design::selected_whole_modules_warn ( ) const

Definition at line 436 of file rtlil.cc.

437 {
438  std::vector<RTLIL::Module*> result;
439  result.reserve(modules_.size());
440  for (auto &it : modules_)
441  if (selected_whole_module(it.first))
442  result.push_back(it.second);
443  else if (selected_module(it.first))
444  log_warning("Ignoring partially selected module %s.\n", log_id(it.first));
445  return result;
446 }
void log_warning(const char *format,...)
Definition: log.cc:196
bool selected_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:379
bool selected_whole_module(RTLIL::IdString mod_name) const
Definition: rtlil.cc:388
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
const char * log_id(RTLIL::IdString str)
Definition: log.cc:283

+ Here is the call graph for this function:

Field Documentation

std::map<RTLIL::IdString, RTLIL::Module*> RTLIL::Design::modules_

Definition at line 507 of file rtlil.h.

std::set<RTLIL::Monitor*> RTLIL::Design::monitors

Definition at line 503 of file rtlil.h.

int RTLIL::Design::refcount_modules_

Definition at line 506 of file rtlil.h.

std::map<std::string, std::string> RTLIL::Design::scratchpad

Definition at line 504 of file rtlil.h.

std::string RTLIL::Design::selected_active_module

Definition at line 511 of file rtlil.h.

std::vector<RTLIL::Selection> RTLIL::Design::selection_stack

Definition at line 509 of file rtlil.h.

std::map<RTLIL::IdString, RTLIL::Selection> RTLIL::Design::selection_vars

Definition at line 510 of file rtlil.h.


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