yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
proc_rmdead.cc File Reference
#include "kernel/register.h"
#include "kernel/bitpattern.h"
#include "kernel/log.h"
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <set>
+ Include dependency graph for proc_rmdead.cc:

Go to the source code of this file.

Data Structures

struct  ProcRmdeadPass
 

Functions

USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN void 
proc_rmdead (RTLIL::SwitchRule *sw, int &counter)
 

Variables

ProcRmdeadPass ProcRmdeadPass
 

Function Documentation

USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN void proc_rmdead ( RTLIL::SwitchRule sw,
int &  counter 
)

Definition at line 31 of file proc_rmdead.cc.

32 {
33  BitPatternPool pool(sw->signal);
34 
35  for (size_t i = 0; i < sw->cases.size(); i++)
36  {
37  bool is_default = GetSize(sw->cases[i]->compare) == 0 && (!pool.empty() || GetSize(sw->signal) == 0);
38 
39  for (size_t j = 0; j < sw->cases[i]->compare.size(); j++) {
40  RTLIL::SigSpec sig = sw->cases[i]->compare[j];
41  if (!sig.is_fully_const())
42  continue;
43  if (!pool.take(sig))
44  sw->cases[i]->compare.erase(sw->cases[i]->compare.begin() + (j--));
45  }
46 
47  if (!is_default) {
48  if (sw->cases[i]->compare.size() == 0) {
49  delete sw->cases[i];
50  sw->cases.erase(sw->cases.begin() + (i--));
51  counter++;
52  continue;
53  }
54  if (pool.empty())
55  sw->cases[i]->compare.clear();
56  }
57 
58  for (auto switch_it : sw->cases[i]->switches)
59  proc_rmdead(switch_it, counter);
60 
61  if (is_default)
62  pool.take_all();
63  }
64 }
RTLIL_ATTRIBUTE_MEMBERS std::vector< RTLIL::CaseRule * > cases
Definition: rtlil.h:1134
USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN void proc_rmdead(RTLIL::SwitchRule *sw, int &counter)
Definition: proc_rmdead.cc:31
RTLIL::SigSpec signal
Definition: rtlil.h:1132
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
bool is_fully_const() const
Definition: rtlil.cc:2763

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation