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

#include <bitpattern.h>

Public Types

typedef std::vector< RTLIL::Statebits_t
 

Public Member Functions

 BitPatternPool (RTLIL::SigSpec sig)
 
 BitPatternPool (int width)
 
bits_t sig2bits (RTLIL::SigSpec sig)
 
bool match (bits_t a, bits_t b)
 
bool has_any (RTLIL::SigSpec sig)
 
bool has_all (RTLIL::SigSpec sig)
 
bool take (RTLIL::SigSpec sig)
 
bool take_all ()
 
bool empty ()
 

Data Fields

int width
 
std::set< bits_tpool
 

Detailed Description

Definition at line 28 of file bitpattern.h.

Member Typedef Documentation

typedef std::vector<RTLIL::State> BitPatternPool::bits_t

Definition at line 31 of file bitpattern.h.

Constructor & Destructor Documentation

BitPatternPool::BitPatternPool ( RTLIL::SigSpec  sig)
inline

Definition at line 34 of file bitpattern.h.

35  {
36  width = sig.size();
37  if (width > 0) {
38  std::vector<RTLIL::State> pattern(width);
39  for (int i = 0; i < width; i++) {
40  if (sig[i].wire == NULL && sig[i].data <= RTLIL::State::S1)
41  pattern[i] = sig[i].data;
42  else
43  pattern[i] = RTLIL::State::Sa;
44  }
45  pool.insert(pattern);
46  }
47  }
std::set< bits_t > pool
Definition: bitpattern.h:32
int size() const
Definition: rtlil.h:1019
#define NULL

+ Here is the call graph for this function:

BitPatternPool::BitPatternPool ( int  width)
inline

Definition at line 49 of file bitpattern.h.

50  {
51  this->width = width;
52  if (width > 0) {
53  std::vector<RTLIL::State> pattern(width);
54  for (int i = 0; i < width; i++)
55  pattern[i] = RTLIL::State::Sa;
56  pool.insert(pattern);
57  }
58  }
std::set< bits_t > pool
Definition: bitpattern.h:32

Member Function Documentation

bool BitPatternPool::empty ( )
inline

Definition at line 132 of file bitpattern.h.

133  {
134  return pool.empty();
135  }
std::set< bits_t > pool
Definition: bitpattern.h:32

+ Here is the caller graph for this function:

bool BitPatternPool::has_all ( RTLIL::SigSpec  sig)
inline

Definition at line 88 of file bitpattern.h.

89  {
90  bits_t bits = sig2bits(sig);
91  for (auto &it : pool)
92  if (match(it, bits)) {
93  for (int i = 0; i < width; i++)
94  if (bits[i] > RTLIL::State::S1 && it[i] <= RTLIL::State::S1)
95  goto next_pool_entry;
96  return true;
97  next_pool_entry:;
98  }
99  return false;
100  }
std::set< bits_t > pool
Definition: bitpattern.h:32
std::vector< RTLIL::State > bits_t
Definition: bitpattern.h:31
bool match(bits_t a, bits_t b)
Definition: bitpattern.h:69
bits_t sig2bits(RTLIL::SigSpec sig)
Definition: bitpattern.h:60

+ Here is the call graph for this function:

bool BitPatternPool::has_any ( RTLIL::SigSpec  sig)
inline

Definition at line 79 of file bitpattern.h.

80  {
81  bits_t bits = sig2bits(sig);
82  for (auto &it : pool)
83  if (match(it, bits))
84  return true;
85  return false;
86  }
std::set< bits_t > pool
Definition: bitpattern.h:32
std::vector< RTLIL::State > bits_t
Definition: bitpattern.h:31
bool match(bits_t a, bits_t b)
Definition: bitpattern.h:69
bits_t sig2bits(RTLIL::SigSpec sig)
Definition: bitpattern.h:60

+ Here is the call graph for this function:

bool BitPatternPool::match ( bits_t  a,
bits_t  b 
)
inline

Definition at line 69 of file bitpattern.h.

70  {
71  log_assert(int(a.size()) == width);
72  log_assert(int(b.size()) == width);
73  for (int i = 0; i < width; i++)
74  if (a[i] <= RTLIL::State::S1 && b[i] <= RTLIL::State::S1 && a[i] != b[i])
75  return false;
76  return true;
77  }
#define log_assert(_assert_expr_)
Definition: log.h:85

+ Here is the caller graph for this function:

bits_t BitPatternPool::sig2bits ( RTLIL::SigSpec  sig)
inline

Definition at line 60 of file bitpattern.h.

61  {
62  bits_t bits = sig.as_const().bits;
63  for (auto &b : bits)
64  if (b > RTLIL::State::S1)
65  b = RTLIL::State::Sa;
66  return bits;
67  }
RTLIL::Const as_const() const
Definition: rtlil.cc:2857
std::vector< RTLIL::State > bits_t
Definition: bitpattern.h:31
std::vector< RTLIL::State > bits
Definition: rtlil.h:438

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool BitPatternPool::take ( RTLIL::SigSpec  sig)
inline

Definition at line 102 of file bitpattern.h.

103  {
104  bool status = false;
105  bits_t bits = sig2bits(sig);
106  std::vector<bits_t> pattern_list;
107  for (auto &it : pool)
108  if (match(it, bits))
109  pattern_list.push_back(it);
110  for (auto pattern : pattern_list) {
111  pool.erase(pattern);
112  for (int i = 0; i < width; i++) {
113  if (pattern[i] != RTLIL::State::Sa || bits[i] == RTLIL::State::Sa)
114  continue;
115  bits_t new_pattern = pattern;
116  new_pattern[i] = bits[i] == RTLIL::State::S1 ? RTLIL::State::S0 : RTLIL::State::S1;
117  pool.insert(new_pattern);
118  }
119  status = true;
120  }
121  return status;
122  }
std::set< bits_t > pool
Definition: bitpattern.h:32
std::vector< RTLIL::State > bits_t
Definition: bitpattern.h:31
bool match(bits_t a, bits_t b)
Definition: bitpattern.h:69
bits_t sig2bits(RTLIL::SigSpec sig)
Definition: bitpattern.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool BitPatternPool::take_all ( )
inline

Definition at line 124 of file bitpattern.h.

125  {
126  if (pool.empty())
127  return false;
128  pool.clear();
129  return true;
130  }
std::set< bits_t > pool
Definition: bitpattern.h:32

+ Here is the caller graph for this function:

Field Documentation

std::set<bits_t> BitPatternPool::pool

Definition at line 32 of file bitpattern.h.

int BitPatternPool::width

Definition at line 30 of file bitpattern.h.


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