OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [vpi/] [c/] [rsp-rtl_sim.c] - Diff between revs 49 and 397

Show entire file | Details | Blame | View Log

Rev 49 Rev 397
Line 76... Line 76...
  return crc ^ (d ^ crc_32) & DBG_CRC_POLY;
  return crc ^ (d ^ crc_32) & DBG_CRC_POLY;
}
}
 
 
/* VPI communication prototyopes */
/* VPI communication prototyopes */
static void get_response_from_vpi();
static void get_response_from_vpi();
static void get_data_from_vpi();
static void get_word_from_vpi();
 
static void get_byte_from_vpi();
static void get_block_data_from_vpi(int len, uint32_t *data);
static void get_block_data_from_vpi(int len, uint32_t *data);
static void send_data_to_vpi(uint32_t data);
static void send_data_to_vpi(uint32_t data);
static void send_block_data_to_vpi(int len, uint32_t *data);
static void send_block_data_to_vpi(int len, uint32_t *data);
static void send_address_to_vpi(uint32_t address);
static void send_address_to_vpi(uint32_t address);
static void send_command_to_vpi(char CMD);
static void send_command_to_vpi(char CMD);
Line 160... Line 161...
 
 
  return;
  return;
 
 
}
}
 
 
void get_data_from_vpi(uint32_t* data)
 
 
void get_byte_from_vpi(uint8_t* data)
 
{
 
 
 
  int n;
 
 
 
  uint8_t inc_data;
 
 
 
  char* recv_buf;
 
 
 
  recv_buf = (char*) &inc_data;
 
 
 
  n = read(vpi_to_rsp_pipe[0],recv_buf,1); // block and wait for the data
 
 
 
  if (DBG_VPI) printf("rsp-rtl_sim: get_byte_from_vpi: 0x%.8x\n",inc_data);
 
 
 
  *data = inc_data;
 
 
 
  return;
 
 
 
}
 
 
 
void get_word_from_vpi(uint32_t* data)
{
{
 
 
  int n;
  int n;
 
 
  uint32_t inc_data;
  uint32_t inc_data;
Line 173... Line 196...
 
 
  recv_buf = (char*) &inc_data;
  recv_buf = (char*) &inc_data;
 
 
  n = read(vpi_to_rsp_pipe[0],recv_buf,4); // block and wait for the data
  n = read(vpi_to_rsp_pipe[0],recv_buf,4); // block and wait for the data
 
 
  if (DBG_VPI) printf("rsp-rtl_sim: get_data_from_vpi: 0x%.8x\n",inc_data);
  if (DBG_VPI) printf("rsp-rtl_sim: get_word_from_vpi: 0x%.8x\n",inc_data);
 
 
  *data = inc_data;
  *data = inc_data;
 
 
  return;
  return;
 
 
Line 231... Line 254...
  // by blocking wait on recv
  // by blocking wait on recv
 
 
  int n = 0;
  int n = 0;
  char tmp;
  char tmp;
 
 
  if (DBG_CALLS)printf("get_response_from_vpi\n");
  if (DBG_CALLS)printf("get_response_from_vpi..");
 
 
  n = read(vpi_to_rsp_pipe[0],&tmp,1); // block and wait
  n = read(vpi_to_rsp_pipe[0],&tmp,1); // block and wait
 
 
 
  if (DBG_CALLS)printf("OK\n");
 
 
  return;
  return;
}
}
 
 
static void jp2_reset_JTAG() {
static void jp2_reset_JTAG() {
  int i;
  int i;
Line 269... Line 294...
  get_response_from_vpi();
  get_response_from_vpi();
 
 
  /* now read out the jtag id */
  /* now read out the jtag id */
  send_command_to_vpi(CMD_READ_JTAG_ID);
  send_command_to_vpi(CMD_READ_JTAG_ID);
 
 
  //id = get_data_from_vpi();  
  //id = get_word_from_vpi();  
  get_data_from_vpi((uint32_t *)&id);
  get_word_from_vpi((uint32_t *)&id);
 
 
  get_response_from_vpi();
  get_response_from_vpi();
 
 
  printf("JTAG ID = %08x\n", id);
  printf("JTAG ID = %08x\n", id);
 
 
Line 372... Line 397...
 
 
  dbg_set_chain(dbg_chain);
  dbg_set_chain(dbg_chain);
 
 
  send_command_to_vpi(CMD_CPU_CTRL_RD);
  send_command_to_vpi(CMD_CPU_CTRL_RD);
 
 
  get_data_from_vpi((uint32_t *)&resp);
  get_word_from_vpi((uint32_t *)&resp);
 
 
  if (DBG_VPI) printf("rsp-rtl_sim: dbg_ctrl_read: 0x%.8x\n",resp);
  if (DBG_VPI) printf("rsp-rtl_sim: dbg_ctrl_read: 0x%.8x\n",resp);
 
 
  get_response_from_vpi();
  get_response_from_vpi();
 
 
Line 396... Line 421...
 
 
  send_command_to_vpi(CMD_WB_RD32);
  send_command_to_vpi(CMD_WB_RD32);
 
 
  send_address_to_vpi(adr);
  send_address_to_vpi(adr);
 
 
  get_data_from_vpi(data);
  get_word_from_vpi(data);
 
 
 
  get_response_from_vpi();
 
 
 
  return 0;
 
}
 
 
 
/* read a word from wishbone */
 
int dbg_wb_read8(uint32_t adr, uint8_t *data)
 
{
 
  if (DBG_CALLS)printf("dbg_wb_read8: adr 0x%.8x \n",adr);
 
 
 
  dbg_set_chain(DC_WISHBONE);
 
 
 
  send_command_to_vpi(CMD_WB_RD8);
 
 
 
  send_address_to_vpi(adr);
 
 
 
  get_byte_from_vpi(data);
 
 
  get_response_from_vpi();
  get_response_from_vpi();
 
 
  return 0;
  return 0;
}
}
Line 525... Line 568...
 
 
  send_address_to_vpi(adr);
  send_address_to_vpi(adr);
 
 
  send_data_to_vpi(length); // Added 090901 --jb
  send_data_to_vpi(length); // Added 090901 --jb
 
 
  get_block_data_from_vpi(length, data); // changed 090901 --jb //get_data_from_vpi(data);
  get_block_data_from_vpi(length, data); // changed 090901 --jb //get_word_from_vpi(data);
 
 
  get_response_from_vpi();
  get_response_from_vpi();
 
 
  return 0;
  return 0;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.