Esempio n. 1
0
static char *
srl_const (BtorMemMgr * mm, const char *a, const char *b)
{
  char *result, *temp;
  int i, len;

  assert (mm != NULL);
  assert (a != NULL);
  assert (b != NULL);
  assert ((int) strlen (a) > 1);
  assert (btor_is_power_of_2_util ((int) strlen (a)));
  assert (btor_log_2_util ((int) strlen (a)) == (int) strlen (b));
  assert (is_valid_const_3vl (a));
  assert (is_valid_const (b));

  len = (int) strlen (b);
  if (b[len - 1] == '1')
    result = btor_srl_n_bits_const (mm, a, 1);
  else
    result = btor_copy_const (mm, a);
  for (i = len - 2; i >= 0; i--)
    {
      temp = result;
      if (b[i] == '1')
        result = btor_srl_n_bits_const (mm, temp, 
	                                btor_pow_2_util (len - i - 1));
      else
        result = btor_copy_const (mm, temp);
      btor_delete_const (mm, temp);
    }
  return result;
}
Esempio n. 2
0
char *
btor_srl_const (BtorMemMgr * mm, const char *a, const char *b)
{
  assert (mm != NULL);
  assert (a != NULL);
  assert (b != NULL);
  assert ((int) strlen (a) > 1);
  assert (btor_is_power_of_2_util ((int) strlen (a)));
  assert (btor_log_2_util ((int) strlen (a)) == (int) strlen (b));
  assert (is_valid_const (a));
  assert (is_valid_const (b));

  return srl_const (mm, a, b);
}
Esempio n. 3
0
char *
btor_srl_const_3vl (BtorMemMgr * mm, const char *a, const char *b)
{

  int min_shifts, max_shifts, len, found, i, j;
  char *result, *temp, cur;

  assert (mm != NULL);
  assert (a != NULL);
  assert (b != NULL);
  assert ((int) strlen (a) > 1);
  assert (btor_is_power_of_2_util ((int) strlen (a)));
  assert (btor_log_2_util ((int) strlen (a)) == (int) strlen (b));
  assert (is_valid_const_3vl (a));
  assert (is_valid_const_3vl (b));

  if (is_valid_const (b))
    result = srl_const (mm, a, b);
  else
    {
      len = (int) strlen (a);
      temp = btor_x_const_3vl (mm, len);
      compute_min_max_num_shifts (mm, b, &min_shifts, &max_shifts);
      result = btor_srl_n_bits_const (mm, temp, min_shifts);
      for (i = len - 1; i >= 0; i--)
        {
	  cur = a[i];
	  if (cur != 'x')
	    {
	      found = 0;
	      for (j = i - 1; j >= 0; j--)
		{
		  if (a[j] == cur)
		    found++;
		  else
		   break;
		}
	      if (found >= max_shifts)
		result[i] = cur;
	    }
	}
      btor_delete_const (mm, temp);
    }
  return result;
}
Esempio n. 4
0
BtorNode *
boolector_ror (Btor * btor, BtorNode * e0, BtorNode * e1)
{
  int len;
  BTOR_ABORT_ARG_NULL_BOOLECTOR (btor);
  BTOR_ABORT_ARG_NULL_BOOLECTOR (e0);
  BTOR_ABORT_ARG_NULL_BOOLECTOR (e1);
  BTOR_ABORT_REFS_NOT_POS_BOOLECTOR (e0);
  BTOR_ABORT_REFS_NOT_POS_BOOLECTOR (e1);
  e0 = btor_pointer_chase_simplified_exp (btor, e0);
  e1 = btor_pointer_chase_simplified_exp (btor, e1);
  BTOR_ABORT_ARRAY_BOOLECTOR (e0);
  BTOR_ABORT_ARRAY_BOOLECTOR (e1);
  len = BTOR_REAL_ADDR_NODE (e0)->len;
  BTOR_ABORT_BOOLECTOR (!btor_is_power_of_2_util (len),
			"bit-width of 'e0' must be a power of 2");
  BTOR_ABORT_BOOLECTOR (btor_log_2_util (len) != BTOR_REAL_ADDR_NODE (e1)->len,
			"bit-width of 'e1' must be equal to log2(bit-width of 'e0')");
  btor->external_refs++;
  return btor_ror_exp (btor, e0, e1);
}