Beispiel #1
0
void
Ticket_ATTLC::Validate(Bits& b)
{
	unsigned int count = 0;

	while (b[count])
		count++;

	while (count >= b.size())
		b.size(b.size() + bits_increment);

	num = count;
	b.set(num);
}
Beispiel #2
0
void EagerBitblaster::makeVariable(TNode var, Bits& bits) {
  Assert(bits.size() == 0);
  for (unsigned i = 0; i < utils::getSize(var); ++i) {
    bits.push_back(utils::mkBitOf(var, i)); 
  }
  d_variables.insert(var); 
}
Beispiel #3
0
void
print_bitset(Bits b, size_t size = 0)
{
    if (size == 0)
        size = b.size();
    for (size_t pos = b.find_first(); pos < size && pos != string::npos; pos = b.find_next(pos))
    {
        std::cout << pos << ", ";
    }
    std::cout << std::endl;
}
Beispiel #4
0
/**
 * Returns the value a is currently assigned to in the SAT solver
 * or null if the value is completely unassigned.
 *
 * @param a
 * @param fullModel whether to create a "full model," i.e., add
 * constants to equivalence classes that don't already have them
 *
 * @return
 */
Node TLazyBitblaster::getVarValue(TNode a, bool fullModel) {
  if (!hasBBTerm(a)) {
    Assert(isSharedTerm(a));
    return Node();
  }
  Bits bits;
  getBBTerm(a, bits);
  Integer value(0);
  for (int i = bits.size() -1; i >= 0; --i) {
    prop::SatValue bit_value;
    if (d_cnfStream->hasLiteral(bits[i])) {
      prop::SatLiteral bit = d_cnfStream->getLiteral(bits[i]);
      bit_value = d_satSolver->value(bit);
      Assert (bit_value != prop::SAT_VALUE_UNKNOWN);
    } else {
      // the bit is unconstrainted so we can give it an arbitrary value
      bit_value = prop::SAT_VALUE_FALSE;
    }
    Integer bit_int = bit_value == prop::SAT_VALUE_TRUE ? Integer(1) : Integer(0);
    value = value * 2 + bit_int;
  }
  return utils::mkConst(BitVector(bits.size(), value));
}
Beispiel #5
0
void __hashbits(hash_t *hash, void *data, uint32_t size) {
  // compute hash of data.
  Bits bits(size * 8);
  ByteArrayToBits(data, size, bits);
  Bits hashBits = _hasher->hash(bits);

  for (uint32_t i = 0; i < hashBits.size() / 8; i++) {
    uint8_t* chunk = &(((uint8_t*)hash)[i]);
    *chunk = 0;
    for (uint32_t j = 0; j < 8; j++) {
      *chunk |= (hashBits[DB_HASH_NUM_BITS - (i * 8 + j) - 1] << j);
    }
  }
}
Beispiel #6
0
void EagerBitblaster::bbTerm(TNode node, Bits& bits) {
  if (hasBBTerm(node)) {
    getBBTerm(node, bits);
    return;
  }

  d_bv->spendResource(options::bitblastStep());
  Debug("bitvector-bitblast") << "Bitblasting node " << node <<"\n";

  d_termBBStrategies[node.getKind()] (node, bits, this);

  Assert (bits.size() == utils::getSize(node));

  storeBBTerm(node, bits);
}
Beispiel #7
0
/**
 * Returns the value a is currently assigned to in the SAT solver
 * or null if the value is completely unassigned.
 *
 * @param a
 * @param fullModel whether to create a "full model," i.e., add
 * constants to equivalence classes that don't already have them
 *
 * @return
 */
Node EagerBitblaster::getModelFromSatSolver(TNode a, bool fullModel) {
  if (!hasBBTerm(a)) {
    return fullModel? utils::mkConst(utils::getSize(a), 0u) : Node();
  }
  
  Bits bits;
  getBBTerm(a, bits);
  Integer value(0);
  for (int i = bits.size() -1; i >= 0; --i) {
    prop::SatValue bit_value;
    if (d_cnfStream->hasLiteral(bits[i])) {
      prop::SatLiteral bit = d_cnfStream->getLiteral(bits[i]);
      bit_value = d_satSolver->value(bit);
      Assert (bit_value != prop::SAT_VALUE_UNKNOWN);
    } else {
      if (!fullModel) return Node();
      // unconstrained bits default to false
      bit_value = prop::SAT_VALUE_FALSE;
    }
    Integer bit_int = bit_value == prop::SAT_VALUE_TRUE ? Integer(1) : Integer(0);
    value = value * 2 + bit_int;
  }
  return utils::mkConst(BitVector(bits.size(), value));
}
Beispiel #8
0
void TLazyBitblaster::bbTerm(TNode node, Bits& bits) {

  if (hasBBTerm(node)) {
    getBBTerm(node, bits);
    return;
  }

  Debug("bitvector-bitblast") << "Bitblasting node " << node <<"\n";
  ++d_statistics.d_numTerms;

  d_termBBStrategies[node.getKind()] (node, bits,this);

  Assert (bits.size() == utils::getSize(node));

  storeBBTerm(node, bits);
}
Beispiel #9
0
bool TLazyBitblaster::hasValue(TNode a) {
  Assert (hasBBTerm(a)); 
  Bits bits;
  getBBTerm(a, bits); 
  for (int i = bits.size() -1; i >= 0; --i) {
    prop::SatValue bit_value;
    if (d_cnfStream->hasLiteral(bits[i])) {
      prop::SatLiteral bit = d_cnfStream->getLiteral(bits[i]);
      bit_value = d_satSolver->value(bit);
      if (bit_value ==  prop::SAT_VALUE_UNKNOWN)
        return false;
    } else {
      return false;
    }
  }
  return true;
}
Signal
BluetoothTransmitter::modulate(const Bits& input, double df) {
    Signal modOut(Ns * input.size());
    int offset = 0;
    double phase=getPhase();

    for (int i=0; i<input.size(); ++i) {
        for(int j=0; j<Ns; ++j) {
            double tt=twopi*df*(j+Ns*i)/((double)Ns);
            if (tt>twopi) { tt=fmod(tt,twopi); }
            double state = qsign(input[i])*s_qcoef[j] +
                           qsign(m_prev)*s_qcoef[j+Ns] + phase;
            modOut[offset+j] = exp(Sample(0.0,twopi* (m_hf * state)+tt));
        } // end j

        // Update phase and previous bit value
        phase += (m_prev ? -0.5 : 0.5);
        m_prev = input[i];
        offset += Ns;
    } // end i

    setPhase(phase);
    return modOut;
}