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

#include <rtlil.h>

Public Member Functions

 SigSpec ()
 
 SigSpec (const RTLIL::SigSpec &other)
 
 SigSpec (std::initializer_list< RTLIL::SigSpec > parts)
 
const RTLIL::SigSpecoperator= (const RTLIL::SigSpec &other)
 
 SigSpec (const RTLIL::Const &value)
 
 SigSpec (const RTLIL::SigChunk &chunk)
 
 SigSpec (RTLIL::Wire *wire)
 
 SigSpec (RTLIL::Wire *wire, int offset, int width=1)
 
 SigSpec (const std::string &str)
 
 SigSpec (int val, int width=32)
 
 SigSpec (RTLIL::State bit, int width=1)
 
 SigSpec (RTLIL::SigBit bit, int width=1)
 
 SigSpec (std::vector< RTLIL::SigChunk > chunks)
 
 SigSpec (std::vector< RTLIL::SigBit > bits)
 
 SigSpec (std::set< RTLIL::SigBit > bits)
 
 SigSpec (bool bit)
 
 SigSpec (RTLIL::SigSpec &&other)
 
const RTLIL::SigSpecoperator= (RTLIL::SigSpec &&other)
 
const std::vector
< RTLIL::SigChunk > & 
chunks () const
 
const std::vector
< RTLIL::SigBit > & 
bits () const
 
int size () const
 
RTLIL::SigBitoperator[] (int index)
 
const RTLIL::SigBitoperator[] (int index) const
 
RTLIL::SigSpecIterator begin ()
 
RTLIL::SigSpecIterator end ()
 
RTLIL::SigSpecConstIterator begin () const
 
RTLIL::SigSpecConstIterator end () const
 
void sort ()
 
void sort_and_unify ()
 
void replace (const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
 
void replace (const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with, RTLIL::SigSpec *other) const
 
void replace (const std::map< RTLIL::SigBit, RTLIL::SigBit > &rules)
 
void replace (const std::map< RTLIL::SigBit, RTLIL::SigBit > &rules, RTLIL::SigSpec *other) const
 
void replace (int offset, const RTLIL::SigSpec &with)
 
void remove (const RTLIL::SigSpec &pattern)
 
void remove (const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other) const
 
void remove2 (const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
 
void remove (const std::set< RTLIL::SigBit > &pattern)
 
void remove (const std::set< RTLIL::SigBit > &pattern, RTLIL::SigSpec *other) const
 
void remove2 (const std::set< RTLIL::SigBit > &pattern, RTLIL::SigSpec *other)
 
void remove (int offset, int length=1)
 
void remove_const ()
 
RTLIL::SigSpec extract (const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
 
RTLIL::SigSpec extract (const std::set< RTLIL::SigBit > &pattern, const RTLIL::SigSpec *other=NULL) const
 
RTLIL::SigSpec extract (int offset, int length=1) const
 
void append (const RTLIL::SigSpec &signal)
 
void append_bit (const RTLIL::SigBit &bit)
 
void extend (int width, bool is_signed=false)
 
void extend_u0 (int width, bool is_signed=false)
 
RTLIL::SigSpec repeat (int num) const
 
bool operator< (const RTLIL::SigSpec &other) const
 
bool operator== (const RTLIL::SigSpec &other) const
 
bool operator!= (const RTLIL::SigSpec &other) const
 
bool is_wire () const
 
bool is_chunk () const
 
bool is_fully_const () const
 
bool is_fully_def () const
 
bool is_fully_undef () const
 
bool has_marked_bits () const
 
bool as_bool () const
 
int as_int (bool is_signed=false) const
 
std::string as_string () const
 
RTLIL::Const as_const () const
 
RTLIL::Wireas_wire () const
 
RTLIL::SigChunk as_chunk () const
 
bool match (std::string pattern) const
 
std::set< RTLIL::SigBitto_sigbit_set () const
 
std::vector< RTLIL::SigBitto_sigbit_vector () const
 
std::map< RTLIL::SigBit,
RTLIL::SigBit
to_sigbit_map (const RTLIL::SigSpec &other) const
 
RTLIL::SigBit to_single_sigbit () const
 
 operator std::vector< RTLIL::SigChunk > () const
 
 operator std::vector< RTLIL::SigBit > () const
 
void check () const
 

Static Public Member Functions

static bool parse (RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
 
static bool parse_sel (RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str)
 
static bool parse_rhs (const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
 

Private Member Functions

void pack () const
 
void unpack () const
 
void hash () const
 
bool packed () const
 
void inline_unpack () const
 

Private Attributes

int width_
 
unsigned long hash_
 
std::vector< RTLIL::SigChunkchunks_
 
std::vector< RTLIL::SigBitbits_
 

Detailed Description

Definition at line 961 of file rtlil.h.

Constructor & Destructor Documentation

RTLIL::SigSpec::SigSpec ( )

Definition at line 2015 of file rtlil.cc.

2016 {
2017  width_ = 0;
2018  hash_ = 0;
2019 }
unsigned long hash_
Definition: rtlil.h:965
int width_
Definition: rtlil.h:964
RTLIL::SigSpec::SigSpec ( const RTLIL::SigSpec other)

Definition at line 2021 of file rtlil.cc.

2022 {
2023  *this = other;
2024 }
RTLIL::SigSpec::SigSpec ( std::initializer_list< RTLIL::SigSpec parts)

Definition at line 2026 of file rtlil.cc.

2027 {
2028  cover("kernel.rtlil.sigspec.init.list");
2029 
2030  width_ = 0;
2031  hash_ = 0;
2032 
2033  std::vector<RTLIL::SigSpec> parts_vec(parts.begin(), parts.end());
2034  for (auto it = parts_vec.rbegin(); it != parts_vec.rend(); it++)
2035  append(*it);
2036 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( const RTLIL::Const value)

Definition at line 2075 of file rtlil.cc.

2076 {
2077  cover("kernel.rtlil.sigspec.init.const");
2078 
2079  chunks_.push_back(RTLIL::SigChunk(value));
2080  width_ = chunks_.back().width;
2081  hash_ = 0;
2082  check();
2083 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( const RTLIL::SigChunk chunk)

Definition at line 2085 of file rtlil.cc.

2086 {
2087  cover("kernel.rtlil.sigspec.init.chunk");
2088 
2089  chunks_.push_back(chunk);
2090  width_ = chunks_.back().width;
2091  hash_ = 0;
2092  check();
2093 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( RTLIL::Wire wire)

Definition at line 2095 of file rtlil.cc.

2096 {
2097  cover("kernel.rtlil.sigspec.init.wire");
2098 
2099  chunks_.push_back(RTLIL::SigChunk(wire));
2100  width_ = chunks_.back().width;
2101  hash_ = 0;
2102  check();
2103 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( RTLIL::Wire wire,
int  offset,
int  width = 1 
)

Definition at line 2105 of file rtlil.cc.

2106 {
2107  cover("kernel.rtlil.sigspec.init.wire_part");
2108 
2109  chunks_.push_back(RTLIL::SigChunk(wire, offset, width));
2110  width_ = chunks_.back().width;
2111  hash_ = 0;
2112  check();
2113 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( const std::string &  str)

Definition at line 2115 of file rtlil.cc.

2116 {
2117  cover("kernel.rtlil.sigspec.init.str");
2118 
2119  chunks_.push_back(RTLIL::SigChunk(str));
2120  width_ = chunks_.back().width;
2121  hash_ = 0;
2122  check();
2123 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( int  val,
int  width = 32 
)

Definition at line 2125 of file rtlil.cc.

2126 {
2127  cover("kernel.rtlil.sigspec.init.int");
2128 
2129  chunks_.push_back(RTLIL::SigChunk(val, width));
2130  width_ = width;
2131  hash_ = 0;
2132  check();
2133 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( RTLIL::State  bit,
int  width = 1 
)

Definition at line 2135 of file rtlil.cc.

2136 {
2137  cover("kernel.rtlil.sigspec.init.state");
2138 
2139  chunks_.push_back(RTLIL::SigChunk(bit, width));
2140  width_ = width;
2141  hash_ = 0;
2142  check();
2143 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( RTLIL::SigBit  bit,
int  width = 1 
)

Definition at line 2145 of file rtlil.cc.

2146 {
2147  cover("kernel.rtlil.sigspec.init.bit");
2148 
2149  if (bit.wire == NULL)
2150  chunks_.push_back(RTLIL::SigChunk(bit.data, width));
2151  else
2152  for (int i = 0; i < width; i++)
2153  chunks_.push_back(bit);
2154  width_ = width;
2155  hash_ = 0;
2156  check();
2157 }
RTLIL::Wire * wire
Definition: rtlil.h:907
#define cover(...)
Definition: log.h:131
RTLIL::State data
Definition: rtlil.h:909
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( std::vector< RTLIL::SigChunk chunks)

Definition at line 2159 of file rtlil.cc.

2160 {
2161  cover("kernel.rtlil.sigspec.init.stdvec_chunks");
2162 
2163  width_ = 0;
2164  hash_ = 0;
2165  for (auto &c : chunks)
2166  append(c);
2167  check();
2168 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void check() const
Definition: rtlil.cc:2642
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
int width_
Definition: rtlil.h:964
const std::vector< RTLIL::SigChunk > & chunks() const
Definition: rtlil.h:1016

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( std::vector< RTLIL::SigBit bits)

Definition at line 2170 of file rtlil.cc.

2171 {
2172  cover("kernel.rtlil.sigspec.init.stdvec_bits");
2173 
2174  width_ = 0;
2175  hash_ = 0;
2176  for (auto &bit : bits)
2177  append_bit(bit);
2178  check();
2179 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void append_bit(const RTLIL::SigBit &bit)
Definition: rtlil.cc:2562
const std::vector< RTLIL::SigBit > & bits() const
Definition: rtlil.h:1017
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( std::set< RTLIL::SigBit bits)

Definition at line 2181 of file rtlil.cc.

2182 {
2183  cover("kernel.rtlil.sigspec.init.stdset_bits");
2184 
2185  width_ = 0;
2186  hash_ = 0;
2187  for (auto &bit : bits)
2188  append_bit(bit);
2189  check();
2190 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void append_bit(const RTLIL::SigBit &bit)
Definition: rtlil.cc:2562
const std::vector< RTLIL::SigBit > & bits() const
Definition: rtlil.h:1017
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( bool  bit)

Definition at line 2192 of file rtlil.cc.

2193 {
2194  cover("kernel.rtlil.sigspec.init.bool");
2195 
2196  width_ = 0;
2197  hash_ = 0;
2198  append_bit(bit);
2199  check();
2200 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void append_bit(const RTLIL::SigBit &bit)
Definition: rtlil.cc:2562
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

RTLIL::SigSpec::SigSpec ( RTLIL::SigSpec &&  other)
inline

Definition at line 1001 of file rtlil.h.

1001  {
1002  width_ = other.width_;
1003  hash_ = other.hash_;
1004  chunks_ = std::move(other.chunks_);
1005  bits_ = std::move(other.bits_);
1006  }
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int width_
Definition: rtlil.h:964

Member Function Documentation

void RTLIL::SigSpec::append ( const RTLIL::SigSpec signal)

Definition at line 2523 of file rtlil.cc.

2524 {
2525  if (signal.width_ == 0)
2526  return;
2527 
2528  if (width_ == 0) {
2529  *this = signal;
2530  return;
2531  }
2532 
2533  cover("kernel.rtlil.sigspec.append");
2534 
2535  if (packed() != signal.packed()) {
2536  pack();
2537  signal.pack();
2538  }
2539 
2540  if (packed())
2541  for (auto &other_c : signal.chunks_)
2542  {
2543  auto &my_last_c = chunks_.back();
2544  if (my_last_c.wire == NULL && other_c.wire == NULL) {
2545  auto &this_data = my_last_c.data;
2546  auto &other_data = other_c.data;
2547  this_data.insert(this_data.end(), other_data.begin(), other_data.end());
2548  my_last_c.width += other_c.width;
2549  } else
2550  if (my_last_c.wire == other_c.wire && my_last_c.offset + my_last_c.width == other_c.offset) {
2551  my_last_c.width += other_c.width;
2552  } else
2553  chunks_.push_back(other_c);
2554  }
2555  else
2556  bits_.insert(bits_.end(), signal.bits_.begin(), signal.bits_.end());
2557 
2558  width_ += signal.width_;
2559  check();
2560 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
bool packed() const
Definition: rtlil.h:973
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

void RTLIL::SigSpec::append_bit ( const RTLIL::SigBit bit)

Definition at line 2562 of file rtlil.cc.

2563 {
2564  if (packed())
2565  {
2566  cover("kernel.rtlil.sigspec.append_bit.packed");
2567 
2568  if (chunks_.size() == 0)
2569  chunks_.push_back(bit);
2570  else
2571  if (bit.wire == NULL)
2572  if (chunks_.back().wire == NULL) {
2573  chunks_.back().data.push_back(bit.data);
2574  chunks_.back().width++;
2575  } else
2576  chunks_.push_back(bit);
2577  else
2578  if (chunks_.back().wire == bit.wire && chunks_.back().offset + chunks_.back().width == bit.offset)
2579  chunks_.back().width++;
2580  else
2581  chunks_.push_back(bit);
2582  }
2583  else
2584  {
2585  cover("kernel.rtlil.sigspec.append_bit.unpacked");
2586  bits_.push_back(bit);
2587  }
2588 
2589  width_++;
2590  check();
2591 }
RTLIL::Wire * wire
Definition: rtlil.h:907
#define cover(...)
Definition: log.h:131
RTLIL::State data
Definition: rtlil.h:909
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
int offset
Definition: rtlil.h:910
bool packed() const
Definition: rtlil.h:973
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::as_bool ( ) const

Definition at line 2818 of file rtlil.cc.

2819 {
2820  cover("kernel.rtlil.sigspec.as_bool");
2821 
2822  pack();
2824  if (width_)
2825  return RTLIL::Const(chunks_[0].data).as_bool();
2826  return false;
2827 }
bool as_bool() const
Definition: rtlil.cc:96
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
bool is_fully_const() const
Definition: rtlil.cc:2763
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::SigChunk RTLIL::SigSpec::as_chunk ( ) const

Definition at line 2877 of file rtlil.cc.

2878 {
2879  cover("kernel.rtlil.sigspec.as_chunk");
2880 
2881  pack();
2882  log_assert(is_chunk());
2883  return chunks_[0];
2884 }
#define cover(...)
Definition: log.h:131
bool is_chunk() const
Definition: rtlil.cc:2755
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define log_assert(_assert_expr_)
Definition: log.h:85
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::SigSpec::as_const ( ) const

Definition at line 2857 of file rtlil.cc.

2858 {
2859  cover("kernel.rtlil.sigspec.as_const");
2860 
2861  pack();
2863  if (width_)
2864  return chunks_[0].data;
2865  return RTLIL::Const();
2866 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
bool is_fully_const() const
Definition: rtlil.cc:2763
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int RTLIL::SigSpec::as_int ( bool  is_signed = false) const

Definition at line 2829 of file rtlil.cc.

2830 {
2831  cover("kernel.rtlil.sigspec.as_int");
2832 
2833  pack();
2835  if (width_)
2836  return RTLIL::Const(chunks_[0].data).as_int(is_signed);
2837  return 0;
2838 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
bool is_fully_const() const
Definition: rtlil.cc:2763
int as_int(bool is_signed=false) const
Definition: rtlil.cc:104
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string RTLIL::SigSpec::as_string ( ) const

Definition at line 2840 of file rtlil.cc.

2841 {
2842  cover("kernel.rtlil.sigspec.as_string");
2843 
2844  pack();
2845  std::string str;
2846  for (size_t i = chunks_.size(); i > 0; i--) {
2847  const RTLIL::SigChunk &chunk = chunks_[i-1];
2848  if (chunk.wire != NULL)
2849  for (int j = 0; j < chunk.width; j++)
2850  str += "?";
2851  else
2852  str += RTLIL::Const(chunk.data).as_string();
2853  }
2854  return str;
2855 }
#define cover(...)
Definition: log.h:131
RTLIL::Wire * wire
Definition: rtlil.h:885
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
std::string as_string() const
Definition: rtlil.cc:116
#define NULL
void pack() const
Definition: rtlil.cc:2202
std::vector< RTLIL::State > data
Definition: rtlil.h:886

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Wire * RTLIL::SigSpec::as_wire ( ) const

Definition at line 2868 of file rtlil.cc.

2869 {
2870  cover("kernel.rtlil.sigspec.as_wire");
2871 
2872  pack();
2873  log_assert(is_wire());
2874  return chunks_[0].wire;
2875 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
bool is_wire() const
Definition: rtlil.cc:2747
#define log_assert(_assert_expr_)
Definition: log.h:85
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

RTLIL::SigSpecIterator RTLIL::SigSpec::begin ( )
inline

Definition at line 1024 of file rtlil.h.

1024 { RTLIL::SigSpecIterator it; it.sig_p = this; it.index = 0; return it; }
RTLIL::SigSpec * sig_p
Definition: rtlil.h:941

+ Here is the caller graph for this function:

RTLIL::SigSpecConstIterator RTLIL::SigSpec::begin ( ) const
inline

Definition at line 1027 of file rtlil.h.

1027 { RTLIL::SigSpecConstIterator it; it.sig_p = this; it.index = 0; return it; }
const RTLIL::SigSpec * sig_p
Definition: rtlil.h:952
const std::vector<RTLIL::SigBit>& RTLIL::SigSpec::bits ( ) const
inline

Definition at line 1017 of file rtlil.h.

1017 { inline_unpack(); return bits_; }
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
void inline_unpack() const
Definition: rtlil.h:977

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::check ( ) const

Definition at line 2642 of file rtlil.cc.

2643 {
2644  if (width_ > 64)
2645  {
2646  cover("kernel.rtlil.sigspec.check.skip");
2647  }
2648  else if (packed())
2649  {
2650  cover("kernel.rtlil.sigspec.check.packed");
2651 
2652  int w = 0;
2653  for (size_t i = 0; i < chunks_.size(); i++) {
2654  const RTLIL::SigChunk chunk = chunks_[i];
2655  if (chunk.wire == NULL) {
2656  if (i > 0)
2657  log_assert(chunks_[i-1].wire != NULL);
2658  log_assert(chunk.offset == 0);
2659  log_assert(chunk.data.size() == (size_t)chunk.width);
2660  } else {
2661  if (i > 0 && chunks_[i-1].wire == chunk.wire)
2662  log_assert(chunk.offset != chunks_[i-1].offset + chunks_[i-1].width);
2663  log_assert(chunk.offset >= 0);
2664  log_assert(chunk.width >= 0);
2665  log_assert(chunk.offset + chunk.width <= chunk.wire->width);
2666  log_assert(chunk.data.size() == 0);
2667  }
2668  w += chunk.width;
2669  }
2670  log_assert(w == width_);
2671  log_assert(bits_.empty());
2672  }
2673  else
2674  {
2675  cover("kernel.rtlil.sigspec.check.unpacked");
2676 
2678  log_assert(chunks_.empty());
2679  }
2680 }
#define cover(...)
Definition: log.h:131
int width
Definition: rtlil.h:826
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
bool packed() const
Definition: rtlil.h:973
RTLIL::Wire * wire
Definition: rtlil.h:885
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
int width_
Definition: rtlil.h:964
std::vector< RTLIL::State > data
Definition: rtlil.h:886

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::vector<RTLIL::SigChunk>& RTLIL::SigSpec::chunks ( ) const
inline

Definition at line 1016 of file rtlil.h.

1016 { pack(); return chunks_; }
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::SigSpecIterator RTLIL::SigSpec::end ( )
inline

Definition at line 1025 of file rtlil.h.

1025 { RTLIL::SigSpecIterator it; it.sig_p = this; it.index = width_; return it; }
RTLIL::SigSpec * sig_p
Definition: rtlil.h:941
int width_
Definition: rtlil.h:964

+ Here is the caller graph for this function:

RTLIL::SigSpecConstIterator RTLIL::SigSpec::end ( ) const
inline

Definition at line 1028 of file rtlil.h.

1028 { RTLIL::SigSpecConstIterator it; it.sig_p = this; it.index = width_; return it; }
const RTLIL::SigSpec * sig_p
Definition: rtlil.h:952
int width_
Definition: rtlil.h:964
void RTLIL::SigSpec::extend ( int  width,
bool  is_signed = false 
)

Definition at line 2593 of file rtlil.cc.

2594 {
2595  cover("kernel.rtlil.sigspec.extend");
2596 
2597  pack();
2598 
2599  if (width_ > width)
2600  remove(width, width_ - width);
2601 
2602  if (width_ < width) {
2603  RTLIL::SigSpec padding = width_ > 0 ? extract(width_ - 1, 1) : RTLIL::SigSpec(RTLIL::State::S0);
2604  if (!is_signed && padding != RTLIL::SigSpec(RTLIL::State::Sx) && padding != RTLIL::SigSpec(RTLIL::State::Sz) &&
2606  padding = RTLIL::SigSpec(RTLIL::State::S0);
2607  while (width_ < width)
2608  append(padding);
2609  }
2610 }
#define cover(...)
Definition: log.h:131
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
Definition: rtlil.cc:2414
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
State
Definition: rtlil.h:29
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::extend_u0 ( int  width,
bool  is_signed = false 
)

Definition at line 2612 of file rtlil.cc.

2613 {
2614  cover("kernel.rtlil.sigspec.extend_u0");
2615 
2616  pack();
2617 
2618  if (width_ > width)
2619  remove(width, width_ - width);
2620 
2621  if (width_ < width) {
2622  RTLIL::SigSpec padding = width_ > 0 ? extract(width_ - 1, 1) : RTLIL::SigSpec(RTLIL::State::S0);
2623  if (!is_signed)
2624  padding = RTLIL::SigSpec(RTLIL::State::S0);
2625  while (width_ < width)
2626  append(padding);
2627  }
2628 
2629 }
#define cover(...)
Definition: log.h:131
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
Definition: rtlil.cc:2414
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
State
Definition: rtlil.h:29
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::SigSpec RTLIL::SigSpec::extract ( const RTLIL::SigSpec pattern,
const RTLIL::SigSpec other = NULL 
) const

Definition at line 2414 of file rtlil.cc.

2415 {
2416  std::set<RTLIL::SigBit> pattern_bits = pattern.to_sigbit_set();
2417  return extract(pattern_bits, other);
2418 }
std::set< RTLIL::SigBit > to_sigbit_set() const
Definition: rtlil.cc:2909
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
Definition: rtlil.cc:2414

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::SigSpec RTLIL::SigSpec::extract ( const std::set< RTLIL::SigBit > &  pattern,
const RTLIL::SigSpec other = NULL 
) const

Definition at line 2420 of file rtlil.cc.

2421 {
2422  if (other)
2423  cover("kernel.rtlil.sigspec.extract_other");
2424  else
2425  cover("kernel.rtlil.sigspec.extract");
2426 
2427  log_assert(other == NULL || width_ == other->width_);
2428 
2429  std::vector<RTLIL::SigBit> bits_match = to_sigbit_vector();
2430  RTLIL::SigSpec ret;
2431 
2432  if (other) {
2433  std::vector<RTLIL::SigBit> bits_other = other->to_sigbit_vector();
2434  for (int i = 0; i < width_; i++)
2435  if (bits_match[i].wire && pattern.count(bits_match[i]))
2436  ret.append_bit(bits_other[i]);
2437  } else {
2438  for (int i = 0; i < width_; i++)
2439  if (bits_match[i].wire && pattern.count(bits_match[i]))
2440  ret.append_bit(bits_match[i]);
2441  }
2442 
2443  ret.check();
2444  return ret;
2445 }
#define cover(...)
Definition: log.h:131
void append_bit(const RTLIL::SigBit &bit)
Definition: rtlil.cc:2562
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964
std::vector< RTLIL::SigBit > to_sigbit_vector() const
Definition: rtlil.cc:2921

+ Here is the call graph for this function:

RTLIL::SigSpec RTLIL::SigSpec::extract ( int  offset,
int  length = 1 
) const

Definition at line 2516 of file rtlil.cc.

2517 {
2518  unpack();
2519  cover("kernel.rtlil.sigspec.extract_pos");
2520  return std::vector<RTLIL::SigBit>(bits_.begin() + offset, bits_.begin() + offset + length);
2521 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
bool RTLIL::SigSpec::has_marked_bits ( ) const

Definition at line 2804 of file rtlil.cc.

2805 {
2806  cover("kernel.rtlil.sigspec.has_marked_bits");
2807 
2808  pack();
2809  for (auto it = chunks_.begin(); it != chunks_.end(); it++)
2810  if (it->width > 0 && it->wire == NULL) {
2811  for (size_t i = 0; i < it->data.size(); i++)
2812  if (it->data[i] == RTLIL::State::Sm)
2813  return true;
2814  }
2815  return false;
2816 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

void RTLIL::SigSpec::hash ( ) const
private

Definition at line 2259 of file rtlil.cc.

2260 {
2261  RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;
2262 
2263  if (that->hash_ != 0)
2264  return;
2265 
2266  cover("kernel.rtlil.sigspec.hash");
2267  that->pack();
2268 
2269  that->hash_ = 5381;
2270  for (auto &c : that->chunks_)
2271  if (c.wire == NULL) {
2272  for (auto &v : c.data)
2273  DJB2(that->hash_, v);
2274  } else {
2275  DJB2(that->hash_, c.wire->name.index_);
2276  DJB2(that->hash_, c.offset);
2277  DJB2(that->hash_, c.width);
2278  }
2279 
2280  if (that->hash_ == 0)
2281  that->hash_ = 1;
2282 }
#define cover(...)
Definition: log.h:131
#define DJB2(_hash, _value)
Definition: rtlil.cc:2257
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::inline_unpack ( ) const
inlineprivate

Definition at line 977 of file rtlil.h.

977  {
978  if (!chunks_.empty())
979  unpack();
980  }
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::is_chunk ( ) const

Definition at line 2755 of file rtlil.cc.

2756 {
2757  cover("kernel.rtlil.sigspec.is_chunk");
2758 
2759  pack();
2760  return GetSize(chunks_) == 1;
2761 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::is_fully_const ( ) const

Definition at line 2763 of file rtlil.cc.

2764 {
2765  cover("kernel.rtlil.sigspec.is_fully_const");
2766 
2767  pack();
2768  for (auto it = chunks_.begin(); it != chunks_.end(); it++)
2769  if (it->width > 0 && it->wire != NULL)
2770  return false;
2771  return true;
2772 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::is_fully_def ( ) const

Definition at line 2774 of file rtlil.cc.

2775 {
2776  cover("kernel.rtlil.sigspec.is_fully_def");
2777 
2778  pack();
2779  for (auto it = chunks_.begin(); it != chunks_.end(); it++) {
2780  if (it->width > 0 && it->wire != NULL)
2781  return false;
2782  for (size_t i = 0; i < it->data.size(); i++)
2783  if (it->data[i] != RTLIL::State::S0 && it->data[i] != RTLIL::State::S1)
2784  return false;
2785  }
2786  return true;
2787 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::is_fully_undef ( ) const

Definition at line 2789 of file rtlil.cc.

2790 {
2791  cover("kernel.rtlil.sigspec.is_fully_undef");
2792 
2793  pack();
2794  for (auto it = chunks_.begin(); it != chunks_.end(); it++) {
2795  if (it->width > 0 && it->wire != NULL)
2796  return false;
2797  for (size_t i = 0; i < it->data.size(); i++)
2798  if (it->data[i] != RTLIL::State::Sx && it->data[i] != RTLIL::State::Sz)
2799  return false;
2800  }
2801  return true;
2802 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::is_wire ( ) const

Definition at line 2747 of file rtlil.cc.

2748 {
2749  cover("kernel.rtlil.sigspec.is_wire");
2750 
2751  pack();
2752  return GetSize(chunks_) == 1 && chunks_[0].wire && chunks_[0].wire->width == width_;
2753 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::match ( std::string  pattern) const

Definition at line 2886 of file rtlil.cc.

2887 {
2888  cover("kernel.rtlil.sigspec.match");
2889 
2890  pack();
2891  std::string str = as_string();
2892  log_assert(pattern.size() == str.size());
2893 
2894  for (size_t i = 0; i < pattern.size(); i++) {
2895  if (pattern[i] == ' ')
2896  continue;
2897  if (pattern[i] == '*') {
2898  if (str[i] != 'z' && str[i] != 'x')
2899  return false;
2900  continue;
2901  }
2902  if (pattern[i] != str[i])
2903  return false;
2904  }
2905 
2906  return true;
2907 }
#define cover(...)
Definition: log.h:131
#define log_assert(_assert_expr_)
Definition: log.h:85
std::string as_string() const
Definition: rtlil.cc:2840
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

RTLIL::SigSpec::operator std::vector< RTLIL::SigBit > ( ) const
inline

Definition at line 1095 of file rtlil.h.

1095 { return bits(); }
const std::vector< RTLIL::SigBit > & bits() const
Definition: rtlil.h:1017

+ Here is the call graph for this function:

RTLIL::SigSpec::operator std::vector< RTLIL::SigChunk > ( ) const
inline

Definition at line 1094 of file rtlil.h.

1094 { return chunks(); }
const std::vector< RTLIL::SigChunk > & chunks() const
Definition: rtlil.h:1016

+ Here is the call graph for this function:

bool RTLIL::SigSpec::operator!= ( const RTLIL::SigSpec other) const
inline

Definition at line 1066 of file rtlil.h.

1066 { return !(*this == other); }
bool RTLIL::SigSpec::operator< ( const RTLIL::SigSpec other) const

Definition at line 2683 of file rtlil.cc.

2684 {
2685  cover("kernel.rtlil.sigspec.comp_lt");
2686 
2687  if (this == &other)
2688  return false;
2689 
2690  if (width_ != other.width_)
2691  return width_ < other.width_;
2692 
2693  pack();
2694  other.pack();
2695 
2696  if (chunks_.size() != other.chunks_.size())
2697  return chunks_.size() < other.chunks_.size();
2698 
2699  hash();
2700  other.hash();
2701 
2702  if (hash_ != other.hash_)
2703  return hash_ < other.hash_;
2704 
2705  for (size_t i = 0; i < chunks_.size(); i++)
2706  if (chunks_[i] != other.chunks_[i]) {
2707  cover("kernel.rtlil.sigspec.comp_lt.hash_collision");
2708  return chunks_[i] < other.chunks_[i];
2709  }
2710 
2711  cover("kernel.rtlil.sigspec.comp_lt.equal");
2712  return false;
2713 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void hash() const
Definition: rtlil.cc:2259
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

const RTLIL::SigSpec & RTLIL::SigSpec::operator= ( const RTLIL::SigSpec other)

Definition at line 2038 of file rtlil.cc.

2039 {
2040  cover("kernel.rtlil.sigspec.assign");
2041 
2042  width_ = other.width_;
2043  hash_ = other.hash_;
2044  chunks_ = other.chunks_;
2045  bits_.clear();
2046 
2047  if (!other.bits_.empty())
2048  {
2049  RTLIL::SigChunk *last = NULL;
2050  int last_end_offset = 0;
2051 
2052  for (auto &bit : other.bits_) {
2053  if (last && bit.wire == last->wire) {
2054  if (bit.wire == NULL) {
2055  last->data.push_back(bit.data);
2056  last->width++;
2057  continue;
2058  } else if (last_end_offset == bit.offset) {
2059  last_end_offset++;
2060  last->width++;
2061  continue;
2062  }
2063  }
2064  chunks_.push_back(bit);
2065  last = &chunks_.back();
2066  last_end_offset = bit.offset + 1;
2067  }
2068 
2069  check();
2070  }
2071 
2072  return *this;
2073 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
RTLIL::Wire * wire
Definition: rtlil.h:885
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964
std::vector< RTLIL::State > data
Definition: rtlil.h:886

+ Here is the call graph for this function:

const RTLIL::SigSpec& RTLIL::SigSpec::operator= ( RTLIL::SigSpec &&  other)
inline

Definition at line 1008 of file rtlil.h.

1008  {
1009  width_ = other.width_;
1010  hash_ = other.hash_;
1011  chunks_ = std::move(other.chunks_);
1012  bits_ = std::move(other.bits_);
1013  return *this;
1014  }
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int width_
Definition: rtlil.h:964
bool RTLIL::SigSpec::operator== ( const RTLIL::SigSpec other) const

Definition at line 2715 of file rtlil.cc.

2716 {
2717  cover("kernel.rtlil.sigspec.comp_eq");
2718 
2719  if (this == &other)
2720  return true;
2721 
2722  if (width_ != other.width_)
2723  return false;
2724 
2725  pack();
2726  other.pack();
2727 
2728  if (chunks_.size() != chunks_.size())
2729  return false;
2730 
2731  hash();
2732  other.hash();
2733 
2734  if (hash_ != other.hash_)
2735  return false;
2736 
2737  for (size_t i = 0; i < chunks_.size(); i++)
2738  if (chunks_[i] != other.chunks_[i]) {
2739  cover("kernel.rtlil.sigspec.comp_eq.hash_collision");
2740  return false;
2741  }
2742 
2743  cover("kernel.rtlil.sigspec.comp_eq.equal");
2744  return true;
2745 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
void hash() const
Definition: rtlil.cc:2259
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the call graph for this function:

RTLIL::SigBit& RTLIL::SigSpec::operator[] ( int  index)
inline

Definition at line 1021 of file rtlil.h.

1021 { inline_unpack(); return bits_.at(index); }
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
void inline_unpack() const
Definition: rtlil.h:977

+ Here is the call graph for this function:

const RTLIL::SigBit& RTLIL::SigSpec::operator[] ( int  index) const
inline

Definition at line 1022 of file rtlil.h.

1022 { inline_unpack(); return bits_.at(index); }
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
void inline_unpack() const
Definition: rtlil.h:977

+ Here is the call graph for this function:

void RTLIL::SigSpec::pack ( ) const
private

Definition at line 2202 of file rtlil.cc.

2203 {
2204  RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;
2205 
2206  if (that->bits_.empty())
2207  return;
2208 
2209  cover("kernel.rtlil.sigspec.convert.pack");
2210  log_assert(that->chunks_.empty());
2211 
2212  std::vector<RTLIL::SigBit> old_bits;
2213  old_bits.swap(that->bits_);
2214 
2215  RTLIL::SigChunk *last = NULL;
2216  int last_end_offset = 0;
2217 
2218  for (auto &bit : old_bits) {
2219  if (last && bit.wire == last->wire) {
2220  if (bit.wire == NULL) {
2221  last->data.push_back(bit.data);
2222  last->width++;
2223  continue;
2224  } else if (last_end_offset == bit.offset) {
2225  last_end_offset++;
2226  last->width++;
2227  continue;
2228  }
2229  }
2230  that->chunks_.push_back(bit);
2231  last = &that->chunks_.back();
2232  last_end_offset = bit.offset + 1;
2233  }
2234 
2235  check();
2236 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
RTLIL::Wire * wire
Definition: rtlil.h:885
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
void check() const
Definition: rtlil.cc:2642
std::vector< RTLIL::State > data
Definition: rtlil.h:886

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::packed ( ) const
inlineprivate

Definition at line 973 of file rtlil.h.

973  {
974  return bits_.empty();
975  }
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::parse ( RTLIL::SigSpec sig,
RTLIL::Module module,
std::string  str 
)
static

Definition at line 2972 of file rtlil.cc.

2973 {
2974  cover("kernel.rtlil.sigspec.parse");
2975 
2976  std::vector<std::string> tokens;
2977  sigspec_parse_split(tokens, str, ',');
2978 
2979  sig = RTLIL::SigSpec();
2980  for (int tokidx = int(tokens.size())-1; tokidx >= 0; tokidx--)
2981  {
2982  std::string netname = tokens[tokidx];
2983  std::string indices;
2984 
2985  if (netname.size() == 0)
2986  continue;
2987 
2988  if (('0' <= netname[0] && netname[0] <= '9') || netname[0] == '\'') {
2989  cover("kernel.rtlil.sigspec.parse.const");
2991  AST::AstNode *ast = VERILOG_FRONTEND::const2ast(netname);
2992  if (ast == NULL)
2993  return false;
2994  sig.append(RTLIL::Const(ast->bits));
2995  delete ast;
2996  continue;
2997  }
2998 
2999  if (module == NULL)
3000  return false;
3001 
3002  cover("kernel.rtlil.sigspec.parse.net");
3003 
3004  if (netname[0] != '$' && netname[0] != '\\')
3005  netname = "\\" + netname;
3006 
3007  if (module->wires_.count(netname) == 0) {
3008  size_t indices_pos = netname.size()-1;
3009  if (indices_pos > 2 && netname[indices_pos] == ']')
3010  {
3011  indices_pos--;
3012  while (indices_pos > 0 && ('0' <= netname[indices_pos] && netname[indices_pos] <= '9')) indices_pos--;
3013  if (indices_pos > 0 && netname[indices_pos] == ':') {
3014  indices_pos--;
3015  while (indices_pos > 0 && ('0' <= netname[indices_pos] && netname[indices_pos] <= '9')) indices_pos--;
3016  }
3017  if (indices_pos > 0 && netname[indices_pos] == '[') {
3018  indices = netname.substr(indices_pos);
3019  netname = netname.substr(0, indices_pos);
3020  }
3021  }
3022  }
3023 
3024  if (module->wires_.count(netname) == 0)
3025  return false;
3026 
3027  RTLIL::Wire *wire = module->wires_.at(netname);
3028  if (!indices.empty()) {
3029  std::vector<std::string> index_tokens;
3030  sigspec_parse_split(index_tokens, indices.substr(1, indices.size()-2), ':');
3031  if (index_tokens.size() == 1) {
3032  cover("kernel.rtlil.sigspec.parse.bit_sel");
3033  int a = atoi(index_tokens.at(0).c_str());
3034  if (a < 0 || a >= wire->width)
3035  return false;
3036  sig.append(RTLIL::SigSpec(wire, a));
3037  } else {
3038  cover("kernel.rtlil.sigspec.parse.part_sel");
3039  int a = atoi(index_tokens.at(0).c_str());
3040  int b = atoi(index_tokens.at(1).c_str());
3041  if (a > b) {
3042  int tmp = a;
3043  a = b, b = tmp;
3044  }
3045  if (a < 0 || a >= wire->width)
3046  return false;
3047  if (b < 0 || b >= wire->width)
3048  return false;
3049  sig.append(RTLIL::SigSpec(wire, a, b-a+1));
3050  }
3051  } else
3052  sig.append(wire);
3053  }
3054 
3055  return true;
3056 }
#define cover(...)
Definition: log.h:131
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
Definition: rtlil.h:595
int width
Definition: rtlil.h:826
int(* get_line_num)()
Definition: ast.cc:51
#define NULL
USING_YOSYS_NAMESPACE static PRIVATE_NAMESPACE_BEGIN std::string netname(std::set< std::string > &conntypes_code, std::set< std::string > &celltypes_code, std::set< std::string > &constcells_code, RTLIL::SigSpec sig)
Definition: intersynth.cc:30
static int sigspec_parse_get_dummy_line_num()
Definition: rtlil.cc:2967
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
AST::AstNode * const2ast(std::string code, char case_type=0, bool warn_z=false)
Definition: const2ast.cc:135
std::vector< RTLIL::State > bits
Definition: ast.h:157
static void sigspec_parse_split(std::vector< std::string > &tokens, const std::string &text, char sep)
Definition: rtlil.cc:2957

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::parse_rhs ( const RTLIL::SigSpec lhs,
RTLIL::SigSpec sig,
RTLIL::Module module,
std::string  str 
)
static

Definition at line 3078 of file rtlil.cc.

3079 {
3080  if (str == "0") {
3081  cover("kernel.rtlil.sigspec.parse.rhs_zeros");
3083  return true;
3084  }
3085 
3086  if (str == "~0") {
3087  cover("kernel.rtlil.sigspec.parse.rhs_ones");
3089  return true;
3090  }
3091 
3092  if (lhs.chunks_.size() == 1) {
3093  char *p = (char*)str.c_str(), *endptr;
3094  long int val = strtol(p, &endptr, 10);
3095  if (endptr && endptr != p && *endptr == 0) {
3096  sig = RTLIL::SigSpec(val, lhs.width_);
3097  cover("kernel.rtlil.sigspec.parse.rhs_dec");
3098  return true;
3099  }
3100  }
3101 
3102  return parse(sig, module, str);
3103 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int width_
Definition: rtlil.h:964
static bool parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
Definition: rtlil.cc:2972

+ Here is the caller graph for this function:

bool RTLIL::SigSpec::parse_sel ( RTLIL::SigSpec sig,
RTLIL::Design design,
RTLIL::Module module,
std::string  str 
)
static

Definition at line 3058 of file rtlil.cc.

3059 {
3060  if (str.empty() || str[0] != '@')
3061  return parse(sig, module, str);
3062 
3063  cover("kernel.rtlil.sigspec.parse.sel");
3064 
3065  str = RTLIL::escape_id(str.substr(1));
3066  if (design->selection_vars.count(str) == 0)
3067  return false;
3068 
3069  sig = RTLIL::SigSpec();
3070  RTLIL::Selection &sel = design->selection_vars.at(str);
3071  for (auto &it : module->wires_)
3072  if (sel.selected_member(module->name, it.first))
3073  sig.append(it.second);
3074 
3075  return true;
3076 }
#define cover(...)
Definition: log.h:131
bool selected_member(RTLIL::IdString mod_name, RTLIL::IdString memb_name) const
Definition: rtlil.cc:168
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
Definition: rtlil.h:595
static std::string escape_id(std::string str)
Definition: rtlil.h:251
std::map< RTLIL::IdString, RTLIL::Selection > selection_vars
Definition: rtlil.h:510
RTLIL::IdString name
Definition: rtlil.h:599
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523
static bool parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
Definition: rtlil.cc:2972

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::remove ( const RTLIL::SigSpec pattern)

Definition at line 2342 of file rtlil.cc.

2343 {
2344  remove2(pattern, NULL);
2345 }
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
Definition: rtlil.cc:2353
#define NULL

+ Here is the caller graph for this function:

void RTLIL::SigSpec::remove ( const RTLIL::SigSpec pattern,
RTLIL::SigSpec other 
) const

Definition at line 2347 of file rtlil.cc.

2348 {
2349  RTLIL::SigSpec tmp = *this;
2350  tmp.remove2(pattern, other);
2351 }
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
Definition: rtlil.cc:2353

+ Here is the call graph for this function:

void RTLIL::SigSpec::remove ( const std::set< RTLIL::SigBit > &  pattern)

Definition at line 2359 of file rtlil.cc.

2360 {
2361  remove2(pattern, NULL);
2362 }
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
Definition: rtlil.cc:2353
#define NULL
void RTLIL::SigSpec::remove ( const std::set< RTLIL::SigBit > &  pattern,
RTLIL::SigSpec other 
) const

Definition at line 2364 of file rtlil.cc.

2365 {
2366  RTLIL::SigSpec tmp = *this;
2367  tmp.remove2(pattern, other);
2368 }
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
Definition: rtlil.cc:2353

+ Here is the call graph for this function:

void RTLIL::SigSpec::remove ( int  offset,
int  length = 1 
)

Definition at line 2500 of file rtlil.cc.

2501 {
2502  cover("kernel.rtlil.sigspec.remove_pos");
2503 
2504  unpack();
2505 
2506  log_assert(offset >= 0);
2507  log_assert(length >= 0);
2508  log_assert(offset + length <= width_);
2509 
2510  bits_.erase(bits_.begin() + offset, bits_.begin() + offset + length);
2511  width_ = bits_.size();
2512 
2513  check();
2514 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
#define log_assert(_assert_expr_)
Definition: log.h:85
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

void RTLIL::SigSpec::remove2 ( const RTLIL::SigSpec pattern,
RTLIL::SigSpec other 
)

Definition at line 2353 of file rtlil.cc.

2354 {
2355  std::set<RTLIL::SigBit> pattern_bits = pattern.to_sigbit_set();
2356  remove2(pattern_bits, other);
2357 }
std::set< RTLIL::SigBit > to_sigbit_set() const
Definition: rtlil.cc:2909
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
Definition: rtlil.cc:2353

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::remove2 ( const std::set< RTLIL::SigBit > &  pattern,
RTLIL::SigSpec other 
)

Definition at line 2370 of file rtlil.cc.

2371 {
2372  if (other)
2373  cover("kernel.rtlil.sigspec.remove_other");
2374  else
2375  cover("kernel.rtlil.sigspec.remove");
2376 
2377  unpack();
2378 
2379  if (other != NULL) {
2380  log_assert(width_ == other->width_);
2381  other->unpack();
2382  }
2383 
2384  std::vector<RTLIL::SigBit> new_bits, new_other_bits;
2385 
2386  new_bits.resize(GetSize(bits_));
2387  if (other != NULL)
2388  new_other_bits.resize(GetSize(bits_));
2389 
2390  int k = 0;
2391  for (int i = 0; i < GetSize(bits_); i++) {
2392  if (bits_[i].wire != NULL && pattern.count(bits_[i]))
2393  continue;
2394  if (other != NULL)
2395  new_other_bits[k] = other->bits_[i];
2396  new_bits[k++] = bits_[i];
2397  }
2398 
2399  new_bits.resize(k);
2400  if (other != NULL)
2401  new_other_bits.resize(k);
2402 
2403  bits_.swap(new_bits);
2404  width_ = GetSize(bits_);
2405 
2406  if (other != NULL) {
2407  other->bits_.swap(new_other_bits);
2408  other->width_ = GetSize(other->bits_);
2409  }
2410 
2411  check();
2412 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

void RTLIL::SigSpec::remove_const ( )

Definition at line 2464 of file rtlil.cc.

2465 {
2466  if (packed())
2467  {
2468  cover("kernel.rtlil.sigspec.remove_const.packed");
2469 
2470  std::vector<RTLIL::SigChunk> new_chunks;
2471  new_chunks.reserve(GetSize(chunks_));
2472 
2473  width_ = 0;
2474  for (auto &chunk : chunks_)
2475  if (chunk.wire != NULL) {
2476  new_chunks.push_back(chunk);
2477  width_ += chunk.width;
2478  }
2479 
2480  chunks_.swap(new_chunks);
2481  }
2482  else
2483  {
2484  cover("kernel.rtlil.sigspec.remove_const.unpacked");
2485 
2486  std::vector<RTLIL::SigBit> new_bits;
2487  new_bits.reserve(width_);
2488 
2489  for (auto &bit : bits_)
2490  if (bit.wire != NULL)
2491  new_bits.push_back(bit);
2492 
2493  bits_.swap(new_bits);
2494  width_ = bits_.size();
2495  }
2496 
2497  check();
2498 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
bool packed() const
Definition: rtlil.h:973
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::SigSpec RTLIL::SigSpec::repeat ( int  num) const

Definition at line 2631 of file rtlil.cc.

2632 {
2633  cover("kernel.rtlil.sigspec.repeat");
2634 
2635  RTLIL::SigSpec sig;
2636  for (int i = 0; i < num; i++)
2637  sig.append(*this);
2638  return sig;
2639 }
#define cover(...)
Definition: log.h:131
void append(const RTLIL::SigSpec &signal)
Definition: rtlil.cc:2523

+ Here is the call graph for this function:

void RTLIL::SigSpec::replace ( const RTLIL::SigSpec pattern,
const RTLIL::SigSpec with 
)

Definition at line 2297 of file rtlil.cc.

2298 {
2299  replace(pattern, with, this);
2300 }
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
Definition: rtlil.cc:2297

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::replace ( const RTLIL::SigSpec pattern,
const RTLIL::SigSpec with,
RTLIL::SigSpec other 
) const

Definition at line 2302 of file rtlil.cc.

2303 {
2304  log_assert(pattern.width_ == with.width_);
2305 
2306  pattern.unpack();
2307  with.unpack();
2308 
2309  std::map<RTLIL::SigBit, RTLIL::SigBit> rules;
2310 
2311  for (int i = 0; i < GetSize(pattern.bits_); i++)
2312  if (pattern.bits_[i].wire != NULL)
2313  rules[pattern.bits_[i]] = with.bits_[i];
2314 
2315  replace(rules, other);
2316 }
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
Definition: rtlil.cc:2297
#define NULL
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

void RTLIL::SigSpec::replace ( const std::map< RTLIL::SigBit, RTLIL::SigBit > &  rules)

Definition at line 2318 of file rtlil.cc.

2319 {
2320  replace(rules, this);
2321 }
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
Definition: rtlil.cc:2297

+ Here is the call graph for this function:

void RTLIL::SigSpec::replace ( const std::map< RTLIL::SigBit, RTLIL::SigBit > &  rules,
RTLIL::SigSpec other 
) const

Definition at line 2323 of file rtlil.cc.

2324 {
2325  cover("kernel.rtlil.sigspec.replace");
2326 
2327  log_assert(other != NULL);
2328  log_assert(width_ == other->width_);
2329 
2330  unpack();
2331  other->unpack();
2332 
2333  for (int i = 0; i < GetSize(bits_); i++) {
2334  auto it = rules.find(bits_[i]);
2335  if (it != rules.end())
2336  other->bits_[i] = it->second;
2337  }
2338 
2339  other->check();
2340 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
#define log_assert(_assert_expr_)
Definition: log.h:85
#define NULL
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

void RTLIL::SigSpec::replace ( int  offset,
const RTLIL::SigSpec with 
)

Definition at line 2447 of file rtlil.cc.

2448 {
2449  cover("kernel.rtlil.sigspec.replace_pos");
2450 
2451  unpack();
2452  with.unpack();
2453 
2454  log_assert(offset >= 0);
2455  log_assert(with.width_ >= 0);
2456  log_assert(offset+with.width_ <= width_);
2457 
2458  for (int i = 0; i < with.width_; i++)
2459  bits_.at(offset + i) = with.bits_.at(i);
2460 
2461  check();
2462 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
#define log_assert(_assert_expr_)
Definition: log.h:85
void check() const
Definition: rtlil.cc:2642
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

int RTLIL::SigSpec::size ( ) const
inline

Definition at line 1019 of file rtlil.h.

1019 { return width_; }
int width_
Definition: rtlil.h:964
void RTLIL::SigSpec::sort ( )

Definition at line 2284 of file rtlil.cc.

2285 {
2286  unpack();
2287  cover("kernel.rtlil.sigspec.sort");
2288  std::sort(bits_.begin(), bits_.end());
2289 }
#define cover(...)
Definition: log.h:131
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RTLIL::SigSpec::sort_and_unify ( )

Definition at line 2291 of file rtlil.cc.

2292 {
2293  cover("kernel.rtlil.sigspec.sort_and_unify");
2294  *this = this->to_sigbit_set();
2295 }
#define cover(...)
Definition: log.h:131
std::set< RTLIL::SigBit > to_sigbit_set() const
Definition: rtlil.cc:2909

+ Here is the caller graph for this function:

std::map< RTLIL::SigBit, RTLIL::SigBit > RTLIL::SigSpec::to_sigbit_map ( const RTLIL::SigSpec other) const

Definition at line 2929 of file rtlil.cc.

2930 {
2931  cover("kernel.rtlil.sigspec.to_sigbit_map");
2932 
2933  unpack();
2934  other.unpack();
2935 
2936  log_assert(width_ == other.width_);
2937 
2938  std::map<RTLIL::SigBit, RTLIL::SigBit> new_map;
2939  for (int i = 0; i < width_; i++)
2940  new_map[bits_[i]] = other.bits_[i];
2941 
2942  return new_map;
2943 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
#define log_assert(_assert_expr_)
Definition: log.h:85
int width_
Definition: rtlil.h:964

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::set< RTLIL::SigBit > RTLIL::SigSpec::to_sigbit_set ( ) const

Definition at line 2909 of file rtlil.cc.

2910 {
2911  cover("kernel.rtlil.sigspec.to_sigbit_set");
2912 
2913  pack();
2914  std::set<RTLIL::SigBit> sigbits;
2915  for (auto &c : chunks_)
2916  for (int i = 0; i < c.width; i++)
2917  sigbits.insert(RTLIL::SigBit(c, i));
2918  return sigbits;
2919 }
#define cover(...)
Definition: log.h:131
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

std::vector< RTLIL::SigBit > RTLIL::SigSpec::to_sigbit_vector ( ) const

Definition at line 2921 of file rtlil.cc.

2922 {
2923  cover("kernel.rtlil.sigspec.to_sigbit_vector");
2924 
2925  unpack();
2926  return bits_;
2927 }
#define cover(...)
Definition: log.h:131
void unpack() const
Definition: rtlil.cc:2238
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967

+ Here is the caller graph for this function:

RTLIL::SigBit RTLIL::SigSpec::to_single_sigbit ( ) const

Definition at line 2945 of file rtlil.cc.

2946 {
2947  cover("kernel.rtlil.sigspec.to_single_sigbit");
2948 
2949  pack();
2950  log_assert(width_ == 1);
2951  for (auto &c : chunks_)
2952  if (c.width)
2953  return RTLIL::SigBit(c);
2954  log_abort();
2955 }
#define cover(...)
Definition: log.h:131
#define log_abort()
Definition: log.h:84
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define log_assert(_assert_expr_)
Definition: log.h:85
int width_
Definition: rtlil.h:964
void pack() const
Definition: rtlil.cc:2202

+ Here is the caller graph for this function:

void RTLIL::SigSpec::unpack ( ) const
private

Definition at line 2238 of file rtlil.cc.

2239 {
2240  RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;
2241 
2242  if (that->chunks_.empty())
2243  return;
2244 
2245  cover("kernel.rtlil.sigspec.convert.unpack");
2246  log_assert(that->bits_.empty());
2247 
2248  that->bits_.reserve(that->width_);
2249  for (auto &c : that->chunks_)
2250  for (int i = 0; i < c.width; i++)
2251  that->bits_.push_back(RTLIL::SigBit(c, i));
2252 
2253  that->chunks_.clear();
2254  that->hash_ = 0;
2255 }
#define cover(...)
Definition: log.h:131
unsigned long hash_
Definition: rtlil.h:965
std::vector< RTLIL::SigBit > bits_
Definition: rtlil.h:967
std::vector< RTLIL::SigChunk > chunks_
Definition: rtlil.h:966
#define log_assert(_assert_expr_)
Definition: log.h:85
int width_
Definition: rtlil.h:964

+ Here is the caller graph for this function:

Field Documentation

std::vector<RTLIL::SigBit> RTLIL::SigSpec::bits_
private

Definition at line 967 of file rtlil.h.

std::vector<RTLIL::SigChunk> RTLIL::SigSpec::chunks_
private

Definition at line 966 of file rtlil.h.

unsigned long RTLIL::SigSpec::hash_
private

Definition at line 965 of file rtlil.h.

int RTLIL::SigSpec::width_
private

Definition at line 964 of file rtlil.h.


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