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

Data Structures

struct  IdString
 
struct  sort_by_name_id
 
struct  sort_by_name_str
 
struct  sort_by_id_str
 
struct  ObjIterator
 
struct  ObjRange
 
struct  Const
 
struct  Selection
 
struct  Monitor
 
struct  Design
 
struct  Module
 
struct  Wire
 
struct  Memory
 
struct  Cell
 
struct  SigChunk
 
struct  SigBit
 
struct  SigSpecIterator
 
struct  SigSpecConstIterator
 
struct  SigSpec
 
struct  CaseRule
 
struct  SwitchRule
 
struct  SyncRule
 
struct  Process
 

Typedefs

typedef std::pair< SigSpec,
SigSpec
SigSig
 

Enumerations

enum  State : unsigned char {
  S0 = 0, S1 = 1, Sx = 2, Sz = 3,
  Sa = 4, Sm = 5
}
 
enum  SyncType : unsigned char {
  ST0 = 0, ST1 = 1, STp = 2, STn = 3,
  STe = 4, STa = 5, STi = 6
}
 
enum  ConstFlags : unsigned char { CONST_FLAG_NONE = 0, CONST_FLAG_STRING = 1, CONST_FLAG_SIGNED = 2, CONST_FLAG_REAL = 4 }
 

Functions

static std::string escape_id (std::string str)
 
static std::string unescape_id (std::string str)
 
static std::string unescape_id (RTLIL::IdString str)
 
static const char * id2cstr (const RTLIL::IdString &str)
 
RTLIL::Const const_not (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_or (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_xor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_xnor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_reduce_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_reduce_or (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_reduce_xor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_reduce_xnor (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_reduce_bool (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_logic_not (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_logic_and (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_logic_or (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_shl (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_shr (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_sshl (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_sshr (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_shift (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_shiftx (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_lt (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_le (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_eq (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_ne (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_eqx (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_nex (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_ge (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_gt (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_add (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_sub (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_mul (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_div (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_mod (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_pow (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_pos (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 
RTLIL::Const const_neg (const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
 

Typedef Documentation

typedef std::pair<SigSpec, SigSpec> RTLIL::SigSig

Definition at line 71 of file rtlil.h.

Enumeration Type Documentation

enum RTLIL::ConstFlags : unsigned char
Enumerator
CONST_FLAG_NONE 
CONST_FLAG_STRING 
CONST_FLAG_SIGNED 
CONST_FLAG_REAL 

Definition at line 48 of file rtlil.h.

48  : unsigned char {
49  CONST_FLAG_NONE = 0,
51  CONST_FLAG_SIGNED = 2, // only used for parameters
52  CONST_FLAG_REAL = 4 // unused -- to be used for parameters
53  };
enum RTLIL::State : unsigned char
Enumerator
S0 
S1 
Sx 
Sz 
Sa 
Sm 

Definition at line 29 of file rtlil.h.

29  : unsigned char {
30  S0 = 0,
31  S1 = 1,
32  Sx = 2, // undefined value or conflict
33  Sz = 3, // high-impedance / not-connected
34  Sa = 4, // don't care (used only in cases)
35  Sm = 5 // marker (used internally by some passes)
36  };
enum RTLIL::SyncType : unsigned char
Enumerator
ST0 
ST1 
STp 
STn 
STe 
STa 
STi 

Definition at line 38 of file rtlil.h.

38  : unsigned char {
39  ST0 = 0, // level sensitive: 0
40  ST1 = 1, // level sensitive: 1
41  STp = 2, // edge sensitive: posedge
42  STn = 3, // edge sensitive: negedge
43  STe = 4, // edge sensitive: both edges
44  STa = 5, // always active
45  STi = 6 // init
46  };

Function Documentation

RTLIL::Const RTLIL::const_add ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 464 of file calc.cc.

465 {
466  int undef_bit_pos = -1;
467  BigInteger y = const2big(arg1, signed1, undef_bit_pos) + const2big(arg2, signed2, undef_bit_pos);
468  return big2const(y, result_len >= 0 ? result_len : std::max(arg1.bits.size(), arg2.bits.size()), undef_bit_pos);
469 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
Definition: calc.cc:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_and ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 165 of file calc.cc.

166 {
167  return logic_wrapper(logic_and, arg1, arg2, signed1, signed2, result_len);
168 }
static RTLIL::Const logic_wrapper(RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), RTLIL::Const arg1, RTLIL::Const arg2, bool signed1, bool signed2, int result_len=-1)
Definition: calc.cc:146
static RTLIL::State logic_and(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:93

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_div ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 485 of file calc.cc.

486 {
487  int undef_bit_pos = -1;
488  BigInteger a = const2big(arg1, signed1, undef_bit_pos);
489  BigInteger b = const2big(arg2, signed2, undef_bit_pos);
490  if (b.isZero())
491  return RTLIL::Const(RTLIL::State::Sx, result_len);
492  bool result_neg = (a.getSign() == BigInteger::negative) != (b.getSign() == BigInteger::negative);
493  a = a.getSign() == BigInteger::negative ? -a : a;
494  b = b.getSign() == BigInteger::negative ? -b : b;
495  return big2const(result_neg ? -(a / b) : (a / b), result_len >= 0 ? result_len : std::max(arg1.bits.size(), arg2.bits.size()), std::min(undef_bit_pos, 0));
496 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
bool isZero() const
Definition: BigInteger.hh:89
Sign getSign() const
Definition: BigInteger.hh:80
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
Definition: calc.cc:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_eq ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 379 of file calc.cc.

380 {
381  RTLIL::Const arg1_ext = arg1;
382  RTLIL::Const arg2_ext = arg2;
383  RTLIL::Const result(RTLIL::State::S0, result_len);
384 
385  int width = std::max(arg1_ext.bits.size(), arg2_ext.bits.size());
386  extend_u0(arg1_ext, width, signed1 && signed2);
387  extend_u0(arg2_ext, width, signed1 && signed2);
388 
389  RTLIL::State matched_status = RTLIL::State::S1;
390  for (size_t i = 0; i < arg1_ext.bits.size(); i++) {
391  if (arg1_ext.bits.at(i) == RTLIL::State::S0 && arg2_ext.bits.at(i) == RTLIL::State::S1)
392  return result;
393  if (arg1_ext.bits.at(i) == RTLIL::State::S1 && arg2_ext.bits.at(i) == RTLIL::State::S0)
394  return result;
395  if (arg1_ext.bits.at(i) > RTLIL::State::S1 || arg2_ext.bits.at(i) > RTLIL::State::S1)
396  matched_status = RTLIL::State::Sx;
397  }
398 
399  result.bits.front() = matched_status;
400  return result;
401 }
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
Definition: calc.cc:29
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
State
Definition: rtlil.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_eqx ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 413 of file calc.cc.

414 {
415  RTLIL::Const arg1_ext = arg1;
416  RTLIL::Const arg2_ext = arg2;
417  RTLIL::Const result(RTLIL::State::S0, result_len);
418 
419  int width = std::max(arg1_ext.bits.size(), arg2_ext.bits.size());
420  extend_u0(arg1_ext, width, signed1 && signed2);
421  extend_u0(arg2_ext, width, signed1 && signed2);
422 
423  for (size_t i = 0; i < arg1_ext.bits.size(); i++) {
424  if (arg1_ext.bits.at(i) != arg2_ext.bits.at(i))
425  return result;
426  }
427 
428  result.bits.front() = RTLIL::State::S1;
429  return result;
430 }
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
Definition: calc.cc:29
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:

RTLIL::Const RTLIL::const_ge ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 442 of file calc.cc.

443 {
444  int undef_bit_pos = -1;
445  bool y = const2big(arg1, signed1, undef_bit_pos) >= const2big(arg2, signed2, undef_bit_pos);
446  RTLIL::Const result(undef_bit_pos >= 0 ? RTLIL::State::Sx : y ? RTLIL::State::S1 : RTLIL::State::S0);
447 
448  while (int(result.bits.size()) < result_len)
449  result.bits.push_back(RTLIL::State::S0);
450  return result;
451 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_gt ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 453 of file calc.cc.

454 {
455  int undef_bit_pos = -1;
456  bool y = const2big(arg1, signed1, undef_bit_pos) > const2big(arg2, signed2, undef_bit_pos);
457  RTLIL::Const result(undef_bit_pos >= 0 ? RTLIL::State::Sx : y ? RTLIL::State::S1 : RTLIL::State::S0);
458 
459  while (int(result.bits.size()) < result_len)
460  result.bits.push_back(RTLIL::State::S0);
461  return result;
462 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_le ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 368 of file calc.cc.

369 {
370  int undef_bit_pos = -1;
371  bool y = const2big(arg1, signed1, undef_bit_pos) <= const2big(arg2, signed2, undef_bit_pos);
372  RTLIL::Const result(undef_bit_pos >= 0 ? RTLIL::State::Sx : y ? RTLIL::State::S1 : RTLIL::State::S0);
373 
374  while (int(result.bits.size()) < result_len)
375  result.bits.push_back(RTLIL::State::S0);
376  return result;
377 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_logic_and ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 241 of file calc.cc.

242 {
243  int undef_bit_pos_a = -1, undef_bit_pos_b = -1;
244  BigInteger a = const2big(arg1, signed1, undef_bit_pos_a);
245  BigInteger b = const2big(arg2, signed2, undef_bit_pos_b);
246 
247  RTLIL::State bit_a = a.isZero() ? undef_bit_pos_a >= 0 ? RTLIL::State::Sx : RTLIL::State::S0 : RTLIL::State::S1;
248  RTLIL::State bit_b = b.isZero() ? undef_bit_pos_b >= 0 ? RTLIL::State::Sx : RTLIL::State::S0 : RTLIL::State::S1;
249  RTLIL::Const result(logic_and(bit_a, bit_b));
250 
251  while (int(result.bits.size()) < result_len)
252  result.bits.push_back(RTLIL::State::S0);
253  return result;
254 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
bool isZero() const
Definition: BigInteger.hh:89
State
Definition: rtlil.h:29
static RTLIL::State logic_and(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:93

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_logic_not ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 230 of file calc.cc.

231 {
232  int undef_bit_pos_a = -1;
233  BigInteger a = const2big(arg1, signed1, undef_bit_pos_a);
234  RTLIL::Const result(a.isZero() ? undef_bit_pos_a >= 0 ? RTLIL::State::Sx : RTLIL::State::S1 : RTLIL::State::S0);
235 
236  while (int(result.bits.size()) < result_len)
237  result.bits.push_back(RTLIL::State::S0);
238  return result;
239 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
bool isZero() const
Definition: BigInteger.hh:89
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:

RTLIL::Const RTLIL::const_logic_or ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 256 of file calc.cc.

257 {
258  int undef_bit_pos_a = -1, undef_bit_pos_b = -1;
259  BigInteger a = const2big(arg1, signed1, undef_bit_pos_a);
260  BigInteger b = const2big(arg2, signed2, undef_bit_pos_b);
261 
262  RTLIL::State bit_a = a.isZero() ? undef_bit_pos_a >= 0 ? RTLIL::State::Sx : RTLIL::State::S0 : RTLIL::State::S1;
263  RTLIL::State bit_b = b.isZero() ? undef_bit_pos_b >= 0 ? RTLIL::State::Sx : RTLIL::State::S0 : RTLIL::State::S1;
264  RTLIL::Const result(logic_or(bit_a, bit_b));
265 
266  while (int(result.bits.size()) < result_len)
267  result.bits.push_back(RTLIL::State::S0);
268  return result;
269 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
bool isZero() const
Definition: BigInteger.hh:89
static RTLIL::State logic_or(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:102
State
Definition: rtlil.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_lt ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 357 of file calc.cc.

358 {
359  int undef_bit_pos = -1;
360  bool y = const2big(arg1, signed1, undef_bit_pos) < const2big(arg2, signed2, undef_bit_pos);
361  RTLIL::Const result(undef_bit_pos >= 0 ? RTLIL::State::Sx : y ? RTLIL::State::S1 : RTLIL::State::S0);
362 
363  while (int(result.bits.size()) < result_len)
364  result.bits.push_back(RTLIL::State::S0);
365  return result;
366 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_mod ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 498 of file calc.cc.

499 {
500  int undef_bit_pos = -1;
501  BigInteger a = const2big(arg1, signed1, undef_bit_pos);
502  BigInteger b = const2big(arg2, signed2, undef_bit_pos);
503  if (b.isZero())
504  return RTLIL::Const(RTLIL::State::Sx, result_len);
505  bool result_neg = a.getSign() == BigInteger::negative;
506  a = a.getSign() == BigInteger::negative ? -a : a;
507  b = b.getSign() == BigInteger::negative ? -b : b;
508  return big2const(result_neg ? -(a % b) : (a % b), result_len >= 0 ? result_len : std::max(arg1.bits.size(), arg2.bits.size()), std::min(undef_bit_pos, 0));
509 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
bool isZero() const
Definition: BigInteger.hh:89
Sign getSign() const
Definition: BigInteger.hh:80
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
Definition: calc.cc:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_mul ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 478 of file calc.cc.

479 {
480  int undef_bit_pos = -1;
481  BigInteger y = const2big(arg1, signed1, undef_bit_pos) * const2big(arg2, signed2, undef_bit_pos);
482  return big2const(y, result_len >= 0 ? result_len : std::max(arg1.bits.size(), arg2.bits.size()), std::min(undef_bit_pos, 0));
483 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
Definition: calc.cc:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_ne ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 403 of file calc.cc.

404 {
405  RTLIL::Const result = RTLIL::const_eq(arg1, arg2, signed1, signed2, result_len);
406  if (result.bits.front() == RTLIL::State::S0)
407  result.bits.front() = RTLIL::State::S1;
408  else if (result.bits.front() == RTLIL::State::S1)
409  result.bits.front() = RTLIL::State::S0;
410  return result;
411 }
RTLIL::Const const_eq(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
Definition: calc.cc:379
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:

RTLIL::Const RTLIL::const_neg ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 570 of file calc.cc.

571 {
572  RTLIL::Const arg1_ext = arg1;
574 
575  return RTLIL::const_sub(zero, arg1_ext, true, signed1, result_len);
576 }
RTLIL::Const const_sub(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
Definition: calc.cc:471

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_nex ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 432 of file calc.cc.

433 {
434  RTLIL::Const result = RTLIL::const_eqx(arg1, arg2, signed1, signed2, result_len);
435  if (result.bits.front() == RTLIL::State::S0)
436  result.bits.front() = RTLIL::State::S1;
437  else if (result.bits.front() == RTLIL::State::S1)
438  result.bits.front() = RTLIL::State::S0;
439  return result;
440 }
RTLIL::Const const_eqx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
Definition: calc.cc:413
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:

RTLIL::Const RTLIL::const_not ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 125 of file calc.cc.

126 {
127  if (result_len < 0)
128  result_len = arg1.bits.size();
129 
130  RTLIL::Const arg1_ext = arg1;
131  extend_u0(arg1_ext, result_len, signed1);
132 
133  RTLIL::Const result(RTLIL::State::Sx, result_len);
134  for (size_t i = 0; i < size_t(result_len); i++) {
135  if (i >= arg1_ext.bits.size())
136  result.bits[i] = RTLIL::State::S0;
137  else if (arg1_ext.bits[i] == RTLIL::State::S0)
138  result.bits[i] = RTLIL::State::S1;
139  else if (arg1_ext.bits[i] == RTLIL::State::S1)
140  result.bits[i] = RTLIL::State::S0;
141  }
142 
143  return result;
144 }
if(!(yy_init))
Definition: ilang_lexer.cc:846
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
Definition: calc.cc:29
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:

RTLIL::Const RTLIL::const_or ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 170 of file calc.cc.

171 {
172  return logic_wrapper(logic_or, arg1, arg2, signed1, signed2, result_len);
173 }
static RTLIL::Const logic_wrapper(RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), RTLIL::Const arg1, RTLIL::Const arg2, bool signed1, bool signed2, int result_len=-1)
Definition: calc.cc:146
static RTLIL::State logic_or(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_pos ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 562 of file calc.cc.

563 {
564  RTLIL::Const arg1_ext = arg1;
565  extend_u0(arg1_ext, result_len, signed1);
566 
567  return arg1_ext;
568 }
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
Definition: calc.cc:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_pow ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 511 of file calc.cc.

512 {
513  int undef_bit_pos = -1;
514 
515  BigInteger a = const2big(arg1, signed1, undef_bit_pos);
516  BigInteger b = const2big(arg2, signed2, undef_bit_pos);
517  BigInteger y = 1;
518 
519  if (a == 0 && b < 0)
520  return RTLIL::Const(RTLIL::State::Sx, result_len);
521 
522  if (a == 0 && b > 0)
523  return RTLIL::Const(RTLIL::State::S0, result_len);
524 
525  if (b < 0)
526  {
527  if (a < -1 || a > 1)
528  y = 0;
529  if (a == -1)
530  y = (-b % 2) == 0 ? 1 : -1;
531  }
532 
533  if (b > 0)
534  {
535  // Power-modulo with 2^result_len as modulus
536  BigInteger modulus = 1;
537  int modulus_bits = (result_len >= 0 ? result_len : 1024);
538  for (int i = 0; i < modulus_bits; i++)
539  modulus *= 2;
540 
541  bool flip_result_sign = false;
542  if (a < 0) {
543  a *= -1;
544  if (b % 2 == 1)
545  flip_result_sign = true;
546  }
547 
548  while (b > 0) {
549  if (b % 2 == 1)
550  y = (y * a) % modulus;
551  b = b / 2;
552  a = (a * a) % modulus;
553  }
554 
555  if (flip_result_sign)
556  y *= -1;
557  }
558 
559  return big2const(y, result_len >= 0 ? result_len : std::max(arg1.bits.size(), arg2.bits.size()), std::min(undef_bit_pos, 0));
560 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
Definition: calc.cc:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_reduce_and ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 198 of file calc.cc.

199 {
200  return logic_reduce_wrapper(RTLIL::State::S1, logic_and, arg1, result_len);
201 }
static RTLIL::Const logic_reduce_wrapper(RTLIL::State initial, RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), const RTLIL::Const &arg1, int result_len)
Definition: calc.cc:185
static RTLIL::State logic_and(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:93

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_reduce_bool ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 225 of file calc.cc.

226 {
227  return logic_reduce_wrapper(RTLIL::State::S0, logic_or, arg1, result_len);
228 }
static RTLIL::Const logic_reduce_wrapper(RTLIL::State initial, RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), const RTLIL::Const &arg1, int result_len)
Definition: calc.cc:185
static RTLIL::State logic_or(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_reduce_or ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 203 of file calc.cc.

204 {
205  return logic_reduce_wrapper(RTLIL::State::S0, logic_or, arg1, result_len);
206 }
static RTLIL::Const logic_reduce_wrapper(RTLIL::State initial, RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), const RTLIL::Const &arg1, int result_len)
Definition: calc.cc:185
static RTLIL::State logic_or(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_reduce_xnor ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 213 of file calc.cc.

214 {
215  RTLIL::Const buffer = logic_reduce_wrapper(RTLIL::State::S0, logic_xor, arg1, result_len);
216  if (!buffer.bits.empty()) {
217  if (buffer.bits.front() == RTLIL::State::S0)
218  buffer.bits.front() = RTLIL::State::S1;
219  else if (buffer.bits.front() == RTLIL::State::S1)
220  buffer.bits.front() = RTLIL::State::S0;
221  }
222  return buffer;
223 }
static RTLIL::State logic_xor(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:111
static RTLIL::Const logic_reduce_wrapper(RTLIL::State initial, RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), const RTLIL::Const &arg1, int result_len)
Definition: calc.cc:185
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:

RTLIL::Const RTLIL::const_reduce_xor ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 208 of file calc.cc.

209 {
210  return logic_reduce_wrapper(RTLIL::State::S0, logic_xor, arg1, result_len);
211 }
static RTLIL::State logic_xor(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:111
static RTLIL::Const logic_reduce_wrapper(RTLIL::State initial, RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), const RTLIL::Const &arg1, int result_len)
Definition: calc.cc:185

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_shift ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 347 of file calc.cc.

348 {
349  return const_shift_shiftx(arg1, arg2, signed1, signed2, result_len, RTLIL::State::S0);
350 }
static RTLIL::Const const_shift_shiftx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool, bool signed2, int result_len, RTLIL::State other_bits)
Definition: calc.cc:324

+ Here is the call graph for this function:

RTLIL::Const RTLIL::const_shiftx ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 352 of file calc.cc.

353 {
354  return const_shift_shiftx(arg1, arg2, signed1, signed2, result_len, RTLIL::State::Sx);
355 }
static RTLIL::Const const_shift_shiftx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool, bool signed2, int result_len, RTLIL::State other_bits)
Definition: calc.cc:324

+ Here is the call graph for this function:

RTLIL::Const RTLIL::const_shl ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 296 of file calc.cc.

297 {
298  RTLIL::Const arg1_ext = arg1;
299  extend_u0(arg1_ext, result_len, signed1);
300  return const_shift_worker(arg1_ext, arg2, false, -1, result_len);
301 }
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
Definition: calc.cc:29
static RTLIL::Const const_shift_worker(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool sign_ext, int direction, int result_len)
Definition: calc.cc:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_shr ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 303 of file calc.cc.

304 {
305  RTLIL::Const arg1_ext = arg1;
306  extend_u0(arg1_ext, std::max(result_len, GetSize(arg1)), signed1);
307  return const_shift_worker(arg1_ext, arg2, false, +1, result_len);
308 }
int GetSize(RTLIL::Wire *wire)
Definition: yosys.cc:334
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
Definition: calc.cc:29
static RTLIL::Const const_shift_worker(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool sign_ext, int direction, int result_len)
Definition: calc.cc:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_sshl ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 310 of file calc.cc.

311 {
312  if (!signed1)
313  return const_shl(arg1, arg2, signed1, signed2, result_len);
314  return const_shift_worker(arg1, arg2, true, -1, result_len);
315 }
RTLIL::Const const_shl(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
Definition: calc.cc:296
static RTLIL::Const const_shift_worker(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool sign_ext, int direction, int result_len)
Definition: calc.cc:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_sshr ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 317 of file calc.cc.

318 {
319  if (!signed1)
320  return const_shr(arg1, arg2, signed1, signed2, result_len);
321  return const_shift_worker(arg1, arg2, true, +1, result_len);
322 }
RTLIL::Const const_shr(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
Definition: calc.cc:303
static RTLIL::Const const_shift_worker(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool sign_ext, int direction, int result_len)
Definition: calc.cc:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_sub ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 471 of file calc.cc.

472 {
473  int undef_bit_pos = -1;
474  BigInteger y = const2big(arg1, signed1, undef_bit_pos) - const2big(arg2, signed2, undef_bit_pos);
475  return big2const(y, result_len >= 0 ? result_len : std::max(arg1.bits.size(), arg2.bits.size()), undef_bit_pos);
476 }
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
Definition: calc.cc:42
std::vector< RTLIL::State > bits
Definition: rtlil.h:438
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
Definition: calc.cc:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_xnor ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 180 of file calc.cc.

181 {
182  return logic_wrapper(logic_xnor, arg1, arg2, signed1, signed2, result_len);
183 }
static RTLIL::State logic_xnor(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:118
static RTLIL::Const logic_wrapper(RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), RTLIL::Const arg1, RTLIL::Const arg2, bool signed1, bool signed2, int result_len=-1)
Definition: calc.cc:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RTLIL::Const RTLIL::const_xor ( const RTLIL::Const arg1,
const RTLIL::Const arg2,
bool  signed1,
bool  signed2,
int  result_len 
)

Definition at line 175 of file calc.cc.

176 {
177  return logic_wrapper(logic_xor, arg1, arg2, signed1, signed2, result_len);
178 }
static RTLIL::State logic_xor(RTLIL::State a, RTLIL::State b)
Definition: calc.cc:111
static RTLIL::Const logic_wrapper(RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), RTLIL::Const arg1, RTLIL::Const arg2, bool signed1, bool signed2, int result_len=-1)
Definition: calc.cc:146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static std::string RTLIL::escape_id ( std::string  str)
inlinestatic

Definition at line 251 of file rtlil.h.

251  {
252  if (str.size() > 0 && str[0] != '\\' && str[0] != '$')
253  return "\\" + str;
254  return str;
255  }

+ Here is the caller graph for this function:

static const char* RTLIL::id2cstr ( const RTLIL::IdString str)
inlinestatic

Definition at line 267 of file rtlil.h.

267  {
268  return log_id(str);
269  }
const char * log_id(RTLIL::IdString str)
Definition: log.cc:283

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static std::string RTLIL::unescape_id ( std::string  str)
inlinestatic

Definition at line 257 of file rtlil.h.

257  {
258  if (str.size() > 1 && str[0] == '\\' && str[1] != '$')
259  return str.substr(1);
260  return str;
261  }

+ Here is the caller graph for this function:

static std::string RTLIL::unescape_id ( RTLIL::IdString  str)
inlinestatic

Definition at line 263 of file rtlil.h.

263  {
264  return unescape_id(str.str());
265  }
std::string str() const
Definition: rtlil.h:182
static std::string unescape_id(RTLIL::IdString str)
Definition: rtlil.h:263

+ Here is the call graph for this function: