Exemple #1
0
void tlm_dfs::b_transport(ac_tlm2_payload &payload,
                          sc_core::sc_time &time_info) {
  int temp;

  time_info = time_info + sc_core::sc_time(TIME_DFS, SC_NS);

  uint32_t addr = (uint32_t)payload.get_address();
  unsigned char *d = payload.get_data_ptr();

  tlm_command command = payload.get_command();

  unsigned int procId = payload.get_streaming_width();

  if (measures)
    count_dfs++;

  uint32_t *T = reinterpret_cast<uint32_t *>(d);

  switch (command) {
  case TLM_READ_COMMAND:

    T[0] = getPowerState(procId);

    if (DFS_DEBUG) {
      printf("\nDFS: tlm_dfs received a READ request from processor %d",
             procId);
      printf("\nDFS: Current Power State -> %d", T[0]); //*d);
    }

    payload.set_response_status(tlm::TLM_OK_RESPONSE);
    break;
  case TLM_WRITE_COMMAND:

    temp = (int)T[0];

#ifdef AC_GUEST_BIG_ENDIAN
    temp = be32toh(temp);
#endif

    if (DFS_DEBUG) {
      printf("\nDFS: received a WRITE request from processor %d", procId);
      printf("\nDFS: Current Power State -> %d", getPowerState(procId));
      printf("\nDFS: New Required Power State -> %d", temp);
    }

    setPowerState(procId, temp);
    payload.set_response_status(tlm::TLM_OK_RESPONSE);
    break;
  default:
    break;
  }

  if (DFS_DEBUG)
    printf("\ntlm_dfs b_transport returning");

  wait(TIME_DFS, SC_NS);
}
Exemple #2
0
void tlm_memory::b_transport(ac_tlm2_payload &payload,
                             sc_core::sc_time &time_info) {

  time_info = time_info + sc_core::sc_time(TIME_MEMORY, SC_NS);

  uint32_t addr = (uint32_t)payload.get_address();
  unsigned char *data_pointer = payload.get_data_ptr();
  unsigned int len = payload.get_data_length();
  /* Novo atributo recuperado - numero do processador */
  unsigned int procId = payload.get_streaming_width();
  tlm_command command = payload.get_command();

  if (MEMORY_DEBUG)
    printf("\nMEMORY TRANSPORT: command--> %d  address--> %d lenght-->%u",
           command, addr, len);

  // if (addr > MEM_SIZE) printf("\nMEMORY TRANSPORT WARNING: address %d out of
  // limits...MEM_SIZE=%d", addr,MEM_SIZE);

  switch (command) {
  case TLM_READ_COMMAND:
    count_read_memory++;
    readm(addr, data_pointer, len);
    /* Incremento de leitura do vetor processors, de acordo com o processador
     * que leu dado */
    if (procId > this->processorsReads.size()) {
      this->processorsReads.resize(procId);
    }
    this->processorsReads[procId] = this->processorsReads[procId] + 1;
    payload.set_response_status(tlm::TLM_OK_RESPONSE);
    break;
  case TLM_WRITE_COMMAND:
    count_write_memory++;
    writem(addr, data_pointer, len);
    if (procId > this->processorsWrites.size()) {
      this->processorsWrites.resize(procId);
    }
    /* Incremento de leitura do vetor processors, de acordo com o processador
     * que escreveu dado */
    this->processorsWrites[procId] = this->processorsWrites[procId] + 1;
    payload.set_response_status(tlm::TLM_OK_RESPONSE);
    break;
  default:
    break;
  }
  if (MEMORY_DEBUG)
    printf("\ntlm_memory b_transport returning...");
}