コード例 #1
0
ファイル: KeyMap.cpp プロジェクト: Senzaki/tipne_net
static bool extractEnd(std::istringstream &strm, std::string &end)
{
	std::stringbuf temp;
	strm.get(temp);
	end = temp.str();
	return !strm.fail();
}
コード例 #2
0
/**
 * @brief Recurse internal function to parse a Boolean formula from a line in the input file
 * @param is the input stream from which the tokens in the line are read
 * @param allowedTypes a list of allowed variable types - this allows to check that assumptions do not refer to 'next' output values.
 * @return a BF that represents the transition constraint read from the line
 */
BF GR1Context::parseBooleanFormulaRecurse(std::istringstream &is,std::set<VariableType> &allowedTypes, std::vector<BF> &memory) {
    std::string operation = "";
    is >> operation;
    if (operation=="") {
        SlugsException e(false);
        e << "Error reading line " << lineNumberCurrentlyRead << ". Premature end of line.";
        throw e;
    }
    if (operation=="|") return parseBooleanFormulaRecurse(is,allowedTypes,memory) | parseBooleanFormulaRecurse(is,allowedTypes,memory);
    if (operation=="^") return parseBooleanFormulaRecurse(is,allowedTypes,memory) ^ parseBooleanFormulaRecurse(is,allowedTypes,memory);
    if (operation=="&") return parseBooleanFormulaRecurse(is,allowedTypes,memory) & parseBooleanFormulaRecurse(is,allowedTypes,memory);
    if (operation=="!") return !parseBooleanFormulaRecurse(is,allowedTypes,memory);
    if (operation=="1") return mgr.constantTrue();
    if (operation=="0") return mgr.constantFalse();

    // Memory Functionality - Create Buffer
    if (operation=="$") {
        unsigned nofElements;
        is >> nofElements;
        if (is.fail()) {
            SlugsException e(false);
            e << "Error reading line " << lineNumberCurrentlyRead << ". Expected number of memory elements.";
            throw e;
        }
        std::vector<BF> memoryNew(nofElements);
        for (unsigned int i=0; i<nofElements; i++) {
            memoryNew[i] = parseBooleanFormulaRecurse(is,allowedTypes,memoryNew);
        }
        return memoryNew[nofElements-1];
    }
コード例 #3
0
ファイル: stdiofile.cpp プロジェクト: macressler/anaconda
 bool seek(size_t v, int origin)
 {
     if (origin == SEEK_CUR)
         stream.seekg(v, std::ios_base::cur);
     else if (origin == SEEK_END)
         stream.seekg(v, std::ios_base::end);
     else
         stream.seekg(v, std::ios_base::beg);
     return !stream.fail();
 }
コード例 #4
0
template<typename T> void me_traffic_generator::do_do_store(std::istringstream &iss) {
  tlm::tlm_generic_payload  *req_transaction_ptr = m_txn_pool.pop();

  sc_dt::uint64 addr;
  iss >> hex >> addr >> dec;

  T *buffer = (T *)m_buffer;
  int len;
  for(len=0; len < m_buffer_size; len++) {
    unsigned tmp;
    iss >> hex >> tmp >> dec;
    if(iss.fail()) break;
    *(buffer++) = T(tmp);
  }
  if(len == 0) return;

  req_transaction_ptr->set_command(tlm::TLM_WRITE_COMMAND);
  req_transaction_ptr->set_address(addr);
  req_transaction_ptr->set_data_ptr(m_buffer);
  req_transaction_ptr->set_data_length(len * sizeof(T));
  req_transaction_ptr->set_streaming_width(len * sizeof(T));
  req_transaction_ptr->set_byte_enable_ptr(0);
  req_transaction_ptr->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE);

  if(m_endianness != m_host_endianness)
    tlm::tlm_to_hostendian_word<T>(req_transaction_ptr,4);

  request_out_port->write(req_transaction_ptr);
  tlm::tlm_generic_payload  *resp_transaction_ptr = response_in_port->read();

  if (resp_transaction_ptr != req_transaction_ptr) {
    std::ostringstream msg;
    msg << m_ID << "Response to wrong request";
    REPORT_FATAL(filename, __FUNCTION__, msg.str());
  }
  if (resp_transaction_ptr->get_response_status() != tlm::TLM_OK_RESPONSE) {
    std::ostringstream msg;
    msg << m_ID << "Transaction ERROR";
    REPORT_FATAL(filename, __FUNCTION__, msg.str());
  }

  if(m_endianness != m_host_endianness)
    tlm::tlm_from_hostendian_word<T>(req_transaction_ptr,4);

  std::cout << m_prompt << ":: " << "write transaction length " << len
            << " (10) x " << sizeof(T)*8 << "-bit completed" << std::endl;

  m_txn_pool.push(resp_transaction_ptr);
}