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

#include <modtools.h>

+ Collaboration diagram for ModWalker:

Data Structures

struct  PortBit
 

Public Member Functions

void add_wire (RTLIL::Wire *wire)
 
void add_cell_port (RTLIL::Cell *cell, RTLIL::IdString port, std::vector< RTLIL::SigBit > bits, bool is_output, bool is_input)
 
void add_cell (RTLIL::Cell *cell)
 
 ModWalker ()
 
 ModWalker (RTLIL::Design *design, RTLIL::Module *module, CellTypes *filter_ct=NULL)
 
void setup (RTLIL::Design *design, RTLIL::Module *module, CellTypes *filter_ct=NULL)
 
template<typename T >
bool get_drivers (std::set< PortBit > &result, RTLIL::SigBit bit) const
 
template<typename T >
bool get_consumers (std::set< PortBit > &result, RTLIL::SigBit bit) const
 
template<typename T >
bool get_inputs (std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
 
template<typename T >
bool get_outputs (std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
 
template<typename T >
bool get_drivers (std::set< PortBit > &result, const T &bits) const
 
template<typename T >
bool get_consumers (std::set< PortBit > &result, const T &bits) const
 
template<typename T >
bool get_inputs (std::set< RTLIL::SigBit > &result, const T &bits) const
 
template<typename T >
bool get_outputs (std::set< RTLIL::SigBit > &result, const T &bits) const
 
bool get_drivers (std::set< PortBit > &result, RTLIL::SigSpec signal) const
 
bool get_consumers (std::set< PortBit > &result, RTLIL::SigSpec signal) const
 
bool get_inputs (std::set< RTLIL::SigBit > &result, RTLIL::SigSpec signal) const
 
bool get_outputs (std::set< RTLIL::SigBit > &result, RTLIL::SigSpec signal) const
 
template<typename T >
bool has_drivers (const T &sig) const
 
template<typename T >
bool has_consumers (const T &sig) const
 
template<typename T >
bool has_inputs (const T &sig) const
 
template<typename T >
bool has_outputs (const T &sig) const
 
bool has_drivers (RTLIL::SigSpec sig) const
 
bool has_consumers (RTLIL::SigSpec sig) const
 
bool has_inputs (RTLIL::SigSpec sig) const
 
bool has_outputs (RTLIL::SigSpec sig) const
 

Data Fields

RTLIL::Designdesign
 
RTLIL::Modulemodule
 
CellTypes ct
 
SigMap sigmap
 
std::map< RTLIL::SigBit,
std::set< PortBit > > 
signal_drivers
 
std::map< RTLIL::SigBit,
std::set< PortBit > > 
signal_consumers
 
std::set< RTLIL::SigBitsignal_inputs
 
std::set< RTLIL::SigBitsignal_outputs
 
std::map< RTLIL::Cell
*, std::set< RTLIL::SigBit > > 
cell_outputs
 
std::map< RTLIL::Cell
*, std::set< RTLIL::SigBit > > 
cell_inputs
 

Detailed Description

Definition at line 181 of file modtools.h.

Constructor & Destructor Documentation

ModWalker::ModWalker ( )
inline

Definition at line 256 of file modtools.h.

256  : design(NULL), module(NULL)
257  {
258  }
RTLIL::Design * design
Definition: modtools.h:198
#define NULL
RTLIL::Module * module
Definition: modtools.h:199
ModWalker::ModWalker ( RTLIL::Design design,
RTLIL::Module module,
CellTypes filter_ct = NULL 
)
inline

Definition at line 260 of file modtools.h.

261  {
262  setup(design, module, filter_ct);
263  }
void setup(RTLIL::Design *design, RTLIL::Module *module, CellTypes *filter_ct=NULL)
Definition: modtools.h:265

+ Here is the call graph for this function:

Member Function Documentation

void ModWalker::add_cell ( RTLIL::Cell cell)
inline

Definition at line 243 of file modtools.h.

244  {
245  if (ct.cell_known(cell->type)) {
246  for (auto &conn : cell->connections())
247  add_cell_port(cell, conn.first, sigmap(conn.second),
248  ct.cell_output(cell->type, conn.first),
249  ct.cell_input(cell->type, conn.first));
250  } else {
251  for (auto &conn : cell->connections())
252  add_cell_port(cell, conn.first, sigmap(conn.second), true, true);
253  }
254  }
void add_cell_port(RTLIL::Cell *cell, RTLIL::IdString port, std::vector< RTLIL::SigBit > bits, bool is_output, bool is_input)
Definition: modtools.h:227
SigMap sigmap
Definition: modtools.h:202
RTLIL::IdString type
Definition: rtlil.h:854
bool cell_known(RTLIL::IdString type)
Definition: celltypes.h:188
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
Definition: celltypes.h:193
CellTypes ct
Definition: modtools.h:201
bool cell_input(RTLIL::IdString type, RTLIL::IdString port)
Definition: celltypes.h:199
const std::map< RTLIL::IdString, RTLIL::SigSpec > & connections() const
Definition: rtlil.cc:1814

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ModWalker::add_cell_port ( RTLIL::Cell cell,
RTLIL::IdString  port,
std::vector< RTLIL::SigBit bits,
bool  is_output,
bool  is_input 
)
inline

Definition at line 227 of file modtools.h.

228  {
229  for (int i = 0; i < int(bits.size()); i++)
230  if (bits[i].wire != NULL) {
231  PortBit pbit = { cell, port, i };
232  if (is_output) {
233  signal_drivers[bits[i]].insert(pbit);
234  cell_outputs[cell].insert(bits[i]);
235  }
236  if (is_input) {
237  signal_consumers[bits[i]].insert(pbit);
238  cell_inputs[cell].insert(bits[i]);
239  }
240  }
241  }
std::map< RTLIL::SigBit, std::set< PortBit > > signal_consumers
Definition: modtools.h:205
std::map< RTLIL::Cell *, std::set< RTLIL::SigBit > > cell_outputs
Definition: modtools.h:208
std::map< RTLIL::Cell *, std::set< RTLIL::SigBit > > cell_inputs
Definition: modtools.h:208
#define NULL
std::map< RTLIL::SigBit, std::set< PortBit > > signal_drivers
Definition: modtools.h:204

+ Here is the caller graph for this function:

void ModWalker::add_wire ( RTLIL::Wire wire)
inline

Definition at line 210 of file modtools.h.

211  {
212  if (wire->port_input) {
213  std::vector<RTLIL::SigBit> bits = sigmap(wire);
214  for (auto bit : bits)
215  if (bit.wire != NULL)
216  signal_inputs.insert(bit);
217  }
218 
219  if (wire->port_output) {
220  std::vector<RTLIL::SigBit> bits = sigmap(wire);
221  for (auto bit : bits)
222  if (bit.wire != NULL)
223  signal_outputs.insert(bit);
224  }
225  }
std::set< RTLIL::SigBit > signal_outputs
Definition: modtools.h:206
SigMap sigmap
Definition: modtools.h:202
bool port_input
Definition: rtlil.h:827
std::set< RTLIL::SigBit > signal_inputs
Definition: modtools.h:206
bool port_output
Definition: rtlil.h:827
#define NULL

+ Here is the caller graph for this function:

template<typename T >
bool ModWalker::get_consumers ( std::set< PortBit > &  result,
RTLIL::SigBit  bit 
) const
inline

Definition at line 301 of file modtools.h.

302  {
303  bool found = false;
304  if (signal_consumers.count(bit)) {
305  const std::set<PortBit> &r = signal_consumers.at(bit);
306  result.insert(r.begin(), r.end());
307  found = true;
308  }
309  return found;
310  }
std::map< RTLIL::SigBit, std::set< PortBit > > signal_consumers
Definition: modtools.h:205

+ Here is the caller graph for this function:

template<typename T >
bool ModWalker::get_consumers ( std::set< PortBit > &  result,
const T &  bits 
) const
inline

Definition at line 346 of file modtools.h.

347  {
348  bool found = false;
349  for (RTLIL::SigBit bit : bits)
350  if (signal_consumers.count(bit)) {
351  const std::set<PortBit> &r = signal_consumers.at(bit);
352  result.insert(r.begin(), r.end());
353  found = true;
354  }
355  return found;
356  }
std::map< RTLIL::SigBit, std::set< PortBit > > signal_consumers
Definition: modtools.h:205
bool ModWalker::get_consumers ( std::set< PortBit > &  result,
RTLIL::SigSpec  signal 
) const
inline

Definition at line 386 of file modtools.h.

387  {
388  std::vector<RTLIL::SigBit> bits = sigmap(signal);
389  return get_consumers(result, bits);
390  }
SigMap sigmap
Definition: modtools.h:202
bool get_consumers(std::set< PortBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:301

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::get_drivers ( std::set< PortBit > &  result,
RTLIL::SigBit  bit 
) const
inline

Definition at line 289 of file modtools.h.

290  {
291  bool found = false;
292  if (signal_drivers.count(bit)) {
293  const std::set<PortBit> &r = signal_drivers.at(bit);
294  result.insert(r.begin(), r.end());
295  found = true;
296  }
297  return found;
298  }
std::map< RTLIL::SigBit, std::set< PortBit > > signal_drivers
Definition: modtools.h:204

+ Here is the caller graph for this function:

template<typename T >
bool ModWalker::get_drivers ( std::set< PortBit > &  result,
const T &  bits 
) const
inline

Definition at line 333 of file modtools.h.

334  {
335  bool found = false;
336  for (RTLIL::SigBit bit : bits)
337  if (signal_drivers.count(bit)) {
338  const std::set<PortBit> &r = signal_drivers.at(bit);
339  result.insert(r.begin(), r.end());
340  found = true;
341  }
342  return found;
343  }
std::map< RTLIL::SigBit, std::set< PortBit > > signal_drivers
Definition: modtools.h:204
bool ModWalker::get_drivers ( std::set< PortBit > &  result,
RTLIL::SigSpec  signal 
) const
inline

Definition at line 380 of file modtools.h.

381  {
382  std::vector<RTLIL::SigBit> bits = sigmap(signal);
383  return get_drivers(result, bits);
384  }
SigMap sigmap
Definition: modtools.h:202
bool get_drivers(std::set< PortBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:289

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::get_inputs ( std::set< RTLIL::SigBit > &  result,
RTLIL::SigBit  bit 
) const
inline

Definition at line 313 of file modtools.h.

314  {
315  bool found = false;
316  if (signal_inputs.count(bit))
317  result.insert(bit), found = true;
318  return found;
319  }
std::set< RTLIL::SigBit > signal_inputs
Definition: modtools.h:206

+ Here is the caller graph for this function:

template<typename T >
bool ModWalker::get_inputs ( std::set< RTLIL::SigBit > &  result,
const T &  bits 
) const
inline

Definition at line 359 of file modtools.h.

360  {
361  bool found = false;
362  for (RTLIL::SigBit bit : bits)
363  if (signal_inputs.count(bit))
364  result.insert(bit), found = true;
365  return found;
366  }
std::set< RTLIL::SigBit > signal_inputs
Definition: modtools.h:206
bool ModWalker::get_inputs ( std::set< RTLIL::SigBit > &  result,
RTLIL::SigSpec  signal 
) const
inline

Definition at line 392 of file modtools.h.

393  {
394  std::vector<RTLIL::SigBit> bits = sigmap(signal);
395  return get_inputs(result, bits);
396  }
SigMap sigmap
Definition: modtools.h:202
bool get_inputs(std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:313

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::get_outputs ( std::set< RTLIL::SigBit > &  result,
RTLIL::SigBit  bit 
) const
inline

Definition at line 322 of file modtools.h.

323  {
324  bool found = false;
325  if (signal_outputs.count(bit))
326  result.insert(bit), found = true;
327  return found;
328  }
std::set< RTLIL::SigBit > signal_outputs
Definition: modtools.h:206

+ Here is the caller graph for this function:

template<typename T >
bool ModWalker::get_outputs ( std::set< RTLIL::SigBit > &  result,
const T &  bits 
) const
inline

Definition at line 369 of file modtools.h.

370  {
371  bool found = false;
372  for (RTLIL::SigBit bit : bits)
373  if (signal_outputs.count(bit))
374  result.insert(bit), found = true;
375  return found;
376  }
std::set< RTLIL::SigBit > signal_outputs
Definition: modtools.h:206
bool ModWalker::get_outputs ( std::set< RTLIL::SigBit > &  result,
RTLIL::SigSpec  signal 
) const
inline

Definition at line 398 of file modtools.h.

399  {
400  std::vector<RTLIL::SigBit> bits = sigmap(signal);
401  return get_outputs(result, bits);
402  }
SigMap sigmap
Definition: modtools.h:202
bool get_outputs(std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:322

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::has_consumers ( const T &  sig) const
inline

Definition at line 413 of file modtools.h.

413  {
414  std::set<PortBit> result;
415  return get_consumers(result, sig);
416  }
bool get_consumers(std::set< PortBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:301

+ Here is the call graph for this function:

bool ModWalker::has_consumers ( RTLIL::SigSpec  sig) const
inline

Definition at line 437 of file modtools.h.

437  {
438  std::set<PortBit> result;
439  return get_consumers(result, sig);
440  }
bool get_consumers(std::set< PortBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:301

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::has_drivers ( const T &  sig) const
inline

Definition at line 407 of file modtools.h.

407  {
408  std::set<PortBit> result;
409  return get_drivers(result, sig);
410  }
bool get_drivers(std::set< PortBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:289

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ModWalker::has_drivers ( RTLIL::SigSpec  sig) const
inline

Definition at line 432 of file modtools.h.

432  {
433  std::set<PortBit> result;
434  return get_drivers(result, sig);
435  }
bool get_drivers(std::set< PortBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:289

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::has_inputs ( const T &  sig) const
inline

Definition at line 419 of file modtools.h.

419  {
420  std::set<RTLIL::SigBit> result;
421  return get_inputs(result, sig);
422  }
bool get_inputs(std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:313

+ Here is the call graph for this function:

bool ModWalker::has_inputs ( RTLIL::SigSpec  sig) const
inline

Definition at line 442 of file modtools.h.

442  {
443  std::set<RTLIL::SigBit> result;
444  return get_inputs(result, sig);
445  }
bool get_inputs(std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:313

+ Here is the call graph for this function:

template<typename T >
bool ModWalker::has_outputs ( const T &  sig) const
inline

Definition at line 425 of file modtools.h.

425  {
426  std::set<RTLIL::SigBit> result;
427  return get_outputs(result, sig);
428  }
bool get_outputs(std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:322

+ Here is the call graph for this function:

bool ModWalker::has_outputs ( RTLIL::SigSpec  sig) const
inline

Definition at line 447 of file modtools.h.

447  {
448  std::set<RTLIL::SigBit> result;
449  return get_outputs(result, sig);
450  }
bool get_outputs(std::set< RTLIL::SigBit > &result, RTLIL::SigBit bit) const
Definition: modtools.h:322

+ Here is the call graph for this function:

void ModWalker::setup ( RTLIL::Design design,
RTLIL::Module module,
CellTypes filter_ct = NULL 
)
inline

Definition at line 265 of file modtools.h.

266  {
267  this->design = design;
268  this->module = module;
269 
270  ct.clear();
271  ct.setup(design);
272  sigmap.set(module);
273 
274  signal_drivers.clear();
275  signal_consumers.clear();
276  signal_inputs.clear();
277  signal_outputs.clear();
278 
279  for (auto &it : module->wires_)
280  add_wire(it.second);
281  for (auto &it : module->cells_)
282  if (filter_ct == NULL || filter_ct->cell_known(it.second->type))
283  add_cell(it.second);
284  }
std::map< RTLIL::SigBit, std::set< PortBit > > signal_consumers
Definition: modtools.h:205
std::set< RTLIL::SigBit > signal_outputs
Definition: modtools.h:206
void clear()
Definition: celltypes.h:183
void setup(RTLIL::Design *design=NULL)
Definition: celltypes.h:47
SigMap sigmap
Definition: modtools.h:202
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
Definition: rtlil.h:595
std::set< RTLIL::SigBit > signal_inputs
Definition: modtools.h:206
void set(RTLIL::Module *module)
Definition: sigtools.h:273
bool cell_known(RTLIL::IdString type)
Definition: celltypes.h:188
RTLIL::Design * design
Definition: modtools.h:198
void add_wire(RTLIL::Wire *wire)
Definition: modtools.h:210
#define NULL
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
Definition: rtlil.h:596
RTLIL::Module * module
Definition: modtools.h:199
CellTypes ct
Definition: modtools.h:201
std::map< RTLIL::SigBit, std::set< PortBit > > signal_drivers
Definition: modtools.h:204
void add_cell(RTLIL::Cell *cell)
Definition: modtools.h:243

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

std::map<RTLIL::Cell*, std::set<RTLIL::SigBit> > ModWalker::cell_inputs

Definition at line 208 of file modtools.h.

std::map<RTLIL::Cell*, std::set<RTLIL::SigBit> > ModWalker::cell_outputs

Definition at line 208 of file modtools.h.

CellTypes ModWalker::ct

Definition at line 201 of file modtools.h.

RTLIL::Design* ModWalker::design

Definition at line 198 of file modtools.h.

RTLIL::Module* ModWalker::module

Definition at line 199 of file modtools.h.

SigMap ModWalker::sigmap

Definition at line 202 of file modtools.h.

std::map<RTLIL::SigBit, std::set<PortBit> > ModWalker::signal_consumers

Definition at line 205 of file modtools.h.

std::map<RTLIL::SigBit, std::set<PortBit> > ModWalker::signal_drivers

Definition at line 204 of file modtools.h.

std::set<RTLIL::SigBit> ModWalker::signal_inputs

Definition at line 206 of file modtools.h.

std::set<RTLIL::SigBit> ModWalker::signal_outputs

Definition at line 206 of file modtools.h.


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