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

#include <sigtools.h>

Data Structures

struct  bitDef_t
 
struct  shared_bit_data_t
 

Public Member Functions

 SigMap (RTLIL::Module *module=NULL)
 
 SigMap (const SigMap &other)
 
const SigMapoperator= (const SigMap &other)
 
void copy (const SigMap &other)
 
void swap (SigMap &other)
 
 ~SigMap ()
 
void clear ()
 
void set (RTLIL::Module *module)
 
void register_bit (const RTLIL::SigBit &bit)
 
void unregister_bit (const RTLIL::SigBit &bit)
 
void merge_bit (const RTLIL::SigBit &bit1, const RTLIL::SigBit &bit2)
 
void set_bit (const RTLIL::SigBit &bit1, const RTLIL::SigBit &bit2)
 
void map_bit (RTLIL::SigBit &bit) const
 
void add (RTLIL::SigSpec from, RTLIL::SigSpec to)
 
void add (RTLIL::SigSpec sig)
 
void del (RTLIL::SigSpec sig)
 
void apply (RTLIL::SigBit &bit) const
 
void apply (RTLIL::SigSpec &sig) const
 
RTLIL::SigBit operator() (RTLIL::SigBit bit) const
 
RTLIL::SigSpec operator() (RTLIL::SigSpec sig) const
 
RTLIL::SigSpec operator() (RTLIL::Wire *wire) const
 

Data Fields

std::map< bitDef_t,
shared_bit_data_t * > 
bits
 

Detailed Description

Definition at line 212 of file sigtools.h.

Constructor & Destructor Documentation

SigMap::SigMap ( RTLIL::Module module = NULL)
inline

Definition at line 226 of file sigtools.h.

227  {
228  if (module != NULL)
229  set(module);
230  }
void set(RTLIL::Module *module)
Definition: sigtools.h:273
#define NULL

+ Here is the call graph for this function:

SigMap::SigMap ( const SigMap other)
inline

Definition at line 232 of file sigtools.h.

233  {
234  copy(other);
235  }
void copy(const SigMap &other)
Definition: sigtools.h:243

+ Here is the call graph for this function:

SigMap::~SigMap ( )
inline

Definition at line 258 of file sigtools.h.

259  {
260  clear();
261  }
void clear()
Definition: sigtools.h:263

+ Here is the call graph for this function:

Member Function Documentation

void SigMap::add ( RTLIL::SigSpec  from,
RTLIL::SigSpec  to 
)
inline

Definition at line 347 of file sigtools.h.

348  {
349  log_assert(GetSize(from) == GetSize(to));
350 
351  for (int i = 0; i < GetSize(from); i++)
352  {
353  RTLIL::SigBit &bf = from[i];
354  RTLIL::SigBit &bt = to[i];
355 
356  if (bf.wire == NULL)
357  continue;
358 
359  register_bit(bf);
360  register_bit(bt);
361 
362  if (bt.wire != NULL)
363  merge_bit(bf, bt);
364  else
365  set_bit(bf, bt);
366  }
367  }
RTLIL::Wire * wire
Definition: rtlil.h:907
void merge_bit(const RTLIL::SigBit &bit1, const RTLIL::SigBit &bit2)
Definition: sigtools.h:304
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
void set_bit(const RTLIL::SigBit &bit1, const RTLIL::SigBit &bit2)
Definition: sigtools.h:333
#define NULL
void register_bit(const RTLIL::SigBit &bit)
Definition: sigtools.h:281

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SigMap::add ( RTLIL::SigSpec  sig)
inline

Definition at line 369 of file sigtools.h.

370  {
371  for (auto &bit : sig) {
372  register_bit(bit);
373  set_bit(bit, bit);
374  }
375  }
void set_bit(const RTLIL::SigBit &bit1, const RTLIL::SigBit &bit2)
Definition: sigtools.h:333
void register_bit(const RTLIL::SigBit &bit)
Definition: sigtools.h:281

+ Here is the call graph for this function:

void SigMap::apply ( RTLIL::SigBit bit) const
inline

Definition at line 383 of file sigtools.h.

384  {
385  map_bit(bit);
386  }
void map_bit(RTLIL::SigBit &bit) const
Definition: sigtools.h:341

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SigMap::apply ( RTLIL::SigSpec sig) const
inline

Definition at line 388 of file sigtools.h.

389  {
390  for (auto &bit : sig)
391  map_bit(bit);
392  }
void map_bit(RTLIL::SigBit &bit) const
Definition: sigtools.h:341

+ Here is the call graph for this function:

void SigMap::clear ( )
inline

Definition at line 263 of file sigtools.h.

264  {
265  std::set<shared_bit_data_t*> all_bd_ptr;
266  for (auto &it : bits)
267  all_bd_ptr.insert(it.second);
268  for (auto bd_ptr : all_bd_ptr)
269  delete bd_ptr;
270  bits.clear();
271  }
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224

+ Here is the caller graph for this function:

void SigMap::copy ( const SigMap other)
inline

Definition at line 243 of file sigtools.h.

244  {
245  clear();
246  for (auto &bit : other.bits) {
247  bits[bit.first] = new shared_bit_data_t;
248  bits[bit.first]->map_to = bit.second->map_to;
249  bits[bit.first]->bits = bit.second->bits;
250  }
251  }
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224
void clear()
Definition: sigtools.h:263

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SigMap::del ( RTLIL::SigSpec  sig)
inline

Definition at line 377 of file sigtools.h.

378  {
379  for (auto &bit : sig)
380  unregister_bit(bit);
381  }
void unregister_bit(const RTLIL::SigBit &bit)
Definition: sigtools.h:292

+ Here is the call graph for this function:

void SigMap::map_bit ( RTLIL::SigBit bit) const
inline

Definition at line 341 of file sigtools.h.

342  {
343  if (bit.wire && bits.count(bit) > 0)
344  bit = bits.at(bit)->map_to;
345  }
RTLIL::Wire * wire
Definition: rtlil.h:907
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224

+ Here is the caller graph for this function:

void SigMap::merge_bit ( const RTLIL::SigBit bit1,
const RTLIL::SigBit bit2 
)
inline

Definition at line 304 of file sigtools.h.

305  {
306  log_assert(bit1.wire != NULL && bit2.wire != NULL);
307 
308  shared_bit_data_t *bd1 = bits[bit1];
309  shared_bit_data_t *bd2 = bits[bit2];
310  log_assert(bd1 != NULL && bd2 != NULL);
311 
312  if (bd1 == bd2)
313  return;
314 
315  if (bd1->bits.size() < bd2->bits.size())
316  {
317  for (auto &bit : bd1->bits)
318  bits[bit] = bd2;
319  bd2->bits.insert(bd1->bits.begin(), bd1->bits.end());
320  delete bd1;
321  }
322  else
323  {
324  bd1->map_to = bd2->map_to;
325  for (auto &bit : bd2->bits)
326  bits[bit] = bd1;
327  bd1->bits.insert(bd2->bits.begin(), bd2->bits.end());
328  delete bd2;
329  }
330  }
RTLIL::Wire * wire
Definition: rtlil.h:907
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL

+ Here is the caller graph for this function:

RTLIL::SigBit SigMap::operator() ( RTLIL::SigBit  bit) const
inline

Definition at line 394 of file sigtools.h.

395  {
396  apply(bit);
397  return bit;
398  }
void apply(RTLIL::SigBit &bit) const
Definition: sigtools.h:383

+ Here is the call graph for this function:

RTLIL::SigSpec SigMap::operator() ( RTLIL::SigSpec  sig) const
inline

Definition at line 400 of file sigtools.h.

401  {
402  apply(sig);
403  return sig;
404  }
void apply(RTLIL::SigBit &bit) const
Definition: sigtools.h:383

+ Here is the call graph for this function:

RTLIL::SigSpec SigMap::operator() ( RTLIL::Wire wire) const
inline

Definition at line 406 of file sigtools.h.

407  {
408  RTLIL::SigSpec sig(wire);
409  apply(sig);
410  return sig;
411  }
void apply(RTLIL::SigBit &bit) const
Definition: sigtools.h:383

+ Here is the call graph for this function:

const SigMap& SigMap::operator= ( const SigMap other)
inline

Definition at line 237 of file sigtools.h.

238  {
239  copy(other);
240  return *this;
241  }
void copy(const SigMap &other)
Definition: sigtools.h:243

+ Here is the call graph for this function:

void SigMap::register_bit ( const RTLIL::SigBit bit)
inline

Definition at line 281 of file sigtools.h.

282  {
283  if (bit.wire && bits.count(bit) == 0) {
284  shared_bit_data_t *bd = new shared_bit_data_t;
285  bd->map_to = bit;
286  bd->bits.insert(bit);
287  bits[bit] = bd;
288  }
289  }
RTLIL::Wire * wire
Definition: rtlil.h:907
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224

+ Here is the caller graph for this function:

void SigMap::set ( RTLIL::Module module)
inline

Definition at line 273 of file sigtools.h.

274  {
275  clear();
276  for (auto &it : module->connections())
277  add(it.first, it.second);
278  }
const std::vector< RTLIL::SigSig > & connections() const
Definition: rtlil.cc:1307
void clear()
Definition: sigtools.h:263
void add(RTLIL::SigSpec from, RTLIL::SigSpec to)
Definition: sigtools.h:347

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SigMap::set_bit ( const RTLIL::SigBit bit1,
const RTLIL::SigBit bit2 
)
inline

Definition at line 333 of file sigtools.h.

334  {
335  log_assert(bit1.wire != NULL);
336  log_assert(bits.count(bit1) > 0);
337  bits[bit1]->map_to = bit2;
338  }
RTLIL::Wire * wire
Definition: rtlil.h:907
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL

+ Here is the caller graph for this function:

void SigMap::swap ( SigMap other)
inline

Definition at line 253 of file sigtools.h.

254  {
255  bits.swap(other.bits);
256  }
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224

+ Here is the caller graph for this function:

void SigMap::unregister_bit ( const RTLIL::SigBit bit)
inline

Definition at line 292 of file sigtools.h.

293  {
294  if (bit.wire && bits.count(bit) > 0) {
295  shared_bit_data_t *bd = bits[bit];
296  bd->bits.erase(bit);
297  if (bd->bits.size() == 0)
298  delete bd;
299  bits.erase(bit);
300  }
301  }
RTLIL::Wire * wire
Definition: rtlil.h:907
std::map< bitDef_t, shared_bit_data_t * > bits
Definition: sigtools.h:224

+ Here is the caller graph for this function:

Field Documentation

std::map<bitDef_t, shared_bit_data_t*> SigMap::bits

Definition at line 224 of file sigtools.h.


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