ISSUE 329

Number 329
Category errata
Synopsis 27.29: vpi_put_data not used in example
State ptfpassed
Class errata-ptf
Arrival-DateApr 13 2003
Originator Shalom.Bresticker@motorola.com
Release 2001b: 27.29
Environment
Description

In 27.29, the last paragraph says,
"The following example illustrates using vpi_put_data():"

But vpi_put_data does not appear in the example.
Fix
Change the example in this section to the following.
Replace the example in section 27.8 with a reference to
this example.

============================================================


#include "vpi_user.h"

#define NULL 0L

typedef struct myStruct *myStruct_p;
typedef struct myStruct {
  PLI_INT32 d1;
  PLI_INT32 d2;
  myStruct_p next;
} myStruct_s;

static myStruct_p firstWrk = NULL;

PLI_INT32 consumer_restart(p_cb_data data)
{
  struct myStruct *wrk; /* myStruct is defined in vpi_put_data() example */
  PLI_INT32 status;
  PLI_INT32 cnt, size;
  PLI_INT32 id = (PLI_INT32)data->user_data;

  /* Get the number of structures. */
  status = vpi_get_data(id,(PLI_BYTE8 *)&cnt,sizeof(PLI_INT32));
  assert(status > 0); /* Check returned status. */

  /* allocate memory for the structures */
  size = cnt * sizeof(struct myStruct);
  firstWrk = (myStruct_p)malloc(size);

  /* retrieve the data structures */
  if (cnt != vpi_get_data(id, (PLI_BYTE8 *)firstWrk,cnt))
    return(1); /* error. */

  firstWrk = wrk;
  /* Fix the next pointers in the link list. */
  for (wrk = firstWrk; cnt > 0; cnt--)
    {
      wrk->next = wrk + 1;
      wrk = wrk->next;
    }
  wrk->next = NULL;
  return(0); /* SUCCESS. */
}

PLI_INT32 consumer_save(p_cb_data data)
{
  myStruct_p wrk;
  s_cb_data cbData;
  vpiHandle cbHdl;
  PLI_INT32 id = 0;
  PLI_INT32 cnt = 0;

  /* Get the number of structures */
  wrk = firstWrk;
  while (wrk)
    {
      cnt++;
      wrk = wrk->next;
    }

  /* now save the data */
  wrk = firstWrk;
  id = vpi_get(vpiSaveRestartID, NULL);

  /* save the number of data structures */
  vpi_put_data(id,(PLI_BYTE8 *)cnt,sizeof(PLI_INT32));

  /* Save the different data structures.  Please note that
   * a pointer is being saved.  While this is allowed, an
   * application must change it to something useful on a
   * restart.
   */
  while (wrk)
    {
      vpi_put_data(id,(PLI_BYTE8 *)wrk,sizeof(myStruct_s));
      wrk = wrk->next;
    }
  /* register a call for restart */
  /* We need the "id" so that the saved data can be
   * retrieved.  Using the user_data field of the
   * callback structure is the easiest way to pass this
   * information to retrieval operation.
   */
  cbData.user_data = (PLI_BYTE8 *)id;
  cbData.reason = cbStartOfRestart;

  /* Please see 27.8 vpi_get_data() for a description of
   * how the callback routine can be used to retrieve the
   * data.
   */
  cbData.cb_rtn = consumer_restart;

  cbData.value = NULL;
  cbData.time = NULL;
  cbHdl = vpi_register_cb(&cbData);
  vpi_free_object(cbHdl);
  return(0);
}






This has been resolved via:
http://www.eda.org/svdb/bug_view_page.php?bug_id=0000311
Audit-Trail

Fix replaced by etf@boyd.com on Mon Feb 9 11:59:25 2004
Here is an updated example. Please note that there is a cross reference in one of the comments. Also, the example in section 27.8 should reference this example.


struct myStruct{
PLI_INT32 d1;
PLI_INT32 d2;
struct myStruct *next;
}
struct myStruct *firstWrk;

PLI_INT32 consumer_save(p_cb_data data)
{
struct myStruct *wrk;
s_cb_data cbData;
vpiHandle cbHdl;
PLI_INT32 id = 0;
PLI_INT32 cnt = 0;

/* Get the number of structures */
wrk = firstWrk;
while (wrk)
{
cnt++;
wrk = wrk->next;
}

/* now save the data */
wrk = firstWrk;
id = vpi_get(vpiSaveRestartID, NULL);

/* save the number of data structures */
vpi_put_data(id,cnt,sizeof(PLI_INT32));

/* Save the different data structures. Please note that
* a pointer is being saved. While this is allowed, an
* application must change it to something useful on a
* restart.
*/
while (wrk)
{
vpi_put_data(id,wrk,sizeof(myStruct));
wrk = wrk->next;
}

/* register a call for restart */
/* We need the "id" so that the saved data can be
* retrieved. Using the user_data field of the
* callback structure is the easiest way to pass this
* information to retrieval operation.
*/
cbData.user_data = (PLI_BYTE8 *)id;
cbData.reason = cbStartOfRestart;

/* Please see 27.8 vpi_get_data() for a description of
* how the callback routine can be used to retrieve the
* data.
*/
cbData.cb_rtn = consumer_restart;

cbData.value = NULL;
cbData.time = NULL;
cbHdl = vpi_register_cb(&cbData);
vpi_free_object(cbHdl);
return(0);
}


Fix replaced by Shalom.Bresticker@motorola.com on Thu Mar 11 06:56:40 2004

2004-03-11, Shalom:

I have only enclosed the example in "PRE" and "/PRE"
directives to the HTML so that the indentation can be seen.
I have not changed anything in the contents of the proposal.

============================================================

Here is an updated example.
Please note that there is a cross reference in one of the comments.
Also, the example in section 27.8 should reference this example.


struct myStruct{
  PLI_INT32 d1;
  PLI_INT32 d2;
  struct myStruct *next;
}
struct myStruct *firstWrk;

PLI_INT32 consumer_save(p_cb_data data)
{
  struct myStruct *wrk;
  s_cb_data cbData;
  vpiHandle cbHdl;
  PLI_INT32 id = 0;
  PLI_INT32 cnt = 0;

  /* Get the number of structures */
  wrk = firstWrk;
  while (wrk)
    {
      cnt++;
      wrk = wrk->next;
    }

  /* now save the data */
  wrk = firstWrk;
  id = vpi_get(vpiSaveRestartID, NULL);

  /* save the number of data structures */
  vpi_put_data(id,cnt,sizeof(PLI_INT32));

  /* Save the different data structures.  Please note that 
   * a pointer is being saved.  While this is allowed, an
   * application must change it to something useful on a
   * restart.
   */
  while (wrk)
    {
      vpi_put_data(id,wrk,sizeof(myStruct));
      wrk = wrk->next;
    }

  /* register a call for restart */
  /* We need the "id" so that the saved data can be 
   * retrieved.  Using the user_data field of the 
   * callback structure is the easiest way to pass this
   * information to retrieval operation.
   */
  cbData.user_data = (PLI_BYTE8 *)id;
  cbData.reason = cbStartOfRestart;

  /* Please see 27.8 vpi_get_data() for a description of 
   * how the callback routine can be used to retrieve the 
   * data.
   */
  cbData.cb_rtn = consumer_restart;

  cbData.value = NULL;
  cbData.time = NULL;
  cbHdl = vpi_register_cb(&cbData);
  vpi_free_object(cbHdl);
  return(0);
}





Fix replaced by etf@boyd.com on Mon Apr 5 09:57:51 2004
I've attempted to compile this example, and found a few
issues (which leads me to conclude that no one had tried
it before). In any case, the following compiles without
error on Solaris:

============================================================

Here is an updated example.
Please note that there is a cross reference in one of the comments.
Also, the example in section 27.8 should reference this example.


#include "vpi_user.h"

#define NULL 0L

extern PLI_INT32 consumer_restart(p_cb_data data);

typedef struct myStruct *myStruct_p;
typedef struct myStruct {
  PLI_INT32 d1;
  PLI_INT32 d2;
  myStruct_p next;
} myStruct_s;
myStruct_p firstWrk;

PLI_INT32 consumer_save(p_cb_data data)
{
  myStruct_p wrk;
  s_cb_data cbData;
  vpiHandle cbHdl;
  PLI_INT32 id = 0;
  PLI_INT32 cnt = 0;

  /* Get the number of structures */
  wrk = firstWrk;
  while (wrk)
    {
      cnt++;
      wrk = wrk->next;
    }

  /* now save the data */
  wrk = firstWrk;
  id = vpi_get(vpiSaveRestartID, NULL);

  /* save the number of data structures */
  vpi_put_data(id,(PLI_BYTE8 *)cnt,sizeof(PLI_INT32));

  /* Save the different data structures.  Please note that
   * a pointer is being saved.  While this is allowed, an
   * application must change it to something useful on a
   * restart.
   */
  while (wrk)
    {
      vpi_put_data(id,(PLI_BYTE8 *)wrk,sizeof(myStruct_s));
      wrk = wrk->next;
    }
  /* register a call for restart */
  /* We need the "id" so that the saved data can be
   * retrieved.  Using the user_data field of the
   * callback structure is the easiest way to pass this
   * information to retrieval operation.
   */
  cbData.user_data = (PLI_BYTE8 *)id;
  cbData.reason = cbStartOfRestart;

  /* Please see 27.8 vpi_get_data() for a description of
   * how the callback routine can be used to retrieve the
   * data.
   */
  cbData.cb_rtn = consumer_restart;

  cbData.value = NULL;
  cbData.time = NULL;
  cbHdl = vpi_register_cb(&cbData);
  vpi_free_object(cbHdl);
  return(0);
}






Fix replaced by chas@cadence.com on Mon May 17 08:33:07 2004
Change the example in this section to the following.
Replace the example in section 17.8 with a reference to
this example.

============================================================


#include "vpi_user.h"

#define NULL 0L

typedef struct myStruct *myStruct_p;
typedef struct myStruct {
  PLI_INT32 d1;
  PLI_INT32 d2;
  myStruct_p next;
} myStruct_s;

static myStruct_p firstWrk = NULL;

PLI_INT32 consumer_restart(p_cb_data data)
{
  struct myStruct *wrk; /* myStruct is defined in vpi_put_data() example */
  PLI_INT32 status;
  PLI_INT32 cnt, size;
  PLI_INT32 id = (PLI_INT32)data->user_data;

  /* Get the number of structures. */
  status = vpi_get_data(id,(PLI_BYTE8 *)&cnt,sizeof(PLI_INT32));
  assert(status > 0); /* Check returned status. */

  /* allocate memory for the structures */
  size = cnt * sizeof(struct myStruct);
  firstWrk = (myStruct_p)malloc(size);

  /* retrieve the data structures */
  if (cnt != vpi_get_data(id, (PLI_BYTE8 *)firstWrk,cnt))
    return(1); /* error. */

  firstWrk = wrk;
  /* Fix the next pointers in the link list. */
  for (wrk = firstWrk; cnt > 0; cnt--)
    {
      wrk->next = wrk + 1;
      wrk = wrk->next;
    }
  wrk->next = NULL;
  return(0); /* SUCCESS. */
}

PLI_INT32 consumer_save(p_cb_data data)
{
  myStruct_p wrk;
  s_cb_data cbData;
  vpiHandle cbHdl;
  PLI_INT32 id = 0;
  PLI_INT32 cnt = 0;

  /* Get the number of structures */
  wrk = firstWrk;
  while (wrk)
    {
      cnt++;
      wrk = wrk->next;
    }

  /* now save the data */
  wrk = firstWrk;
  id = vpi_get(vpiSaveRestartID, NULL);

  /* save the number of data structures */
  vpi_put_data(id,(PLI_BYTE8 *)cnt,sizeof(PLI_INT32));

  /* Save the different data structures.  Please note that
   * a pointer is being saved.  While this is allowed, an
   * application must change it to something useful on a
   * restart.
   */
  while (wrk)
    {
      vpi_put_data(id,(PLI_BYTE8 *)wrk,sizeof(myStruct_s));
      wrk = wrk->next;
    }
  /* register a call for restart */
  /* We need the "id" so that the saved data can be
   * retrieved.  Using the user_data field of the
   * callback structure is the easiest way to pass this
   * information to retrieval operation.
   */
  cbData.user_data = (PLI_BYTE8 *)id;
  cbData.reason = cbStartOfRestart;

  /* Please see 27.8 vpi_get_data() for a description of
   * how the callback routine can be used to retrieve the
   * data.
   */
  cbData.cb_rtn = consumer_restart;

  cbData.value = NULL;
  cbData.time = NULL;
  cbHdl = vpi_register_cb(&cbData);
  vpi_free_object(cbHdl);
  return(0);
}







Fix replaced by chas@cadence.com on Mon May 17 12:12:11 2004
Change the example in this section to the following.
Replace the example in section 27.8 with a reference to
this example.

============================================================


#include "vpi_user.h"

#define NULL 0L

typedef struct myStruct *myStruct_p;
typedef struct myStruct {
  PLI_INT32 d1;
  PLI_INT32 d2;
  myStruct_p next;
} myStruct_s;

static myStruct_p firstWrk = NULL;

PLI_INT32 consumer_restart(p_cb_data data)
{
  struct myStruct *wrk; /* myStruct is defined in vpi_put_data() example */
  PLI_INT32 status;
  PLI_INT32 cnt, size;
  PLI_INT32 id = (PLI_INT32)data->user_data;

  /* Get the number of structures. */
  status = vpi_get_data(id,(PLI_BYTE8 *)&cnt,sizeof(PLI_INT32));
  assert(status > 0); /* Check returned status. */

  /* allocate memory for the structures */
  size = cnt * sizeof(struct myStruct);
  firstWrk = (myStruct_p)malloc(size);

  /* retrieve the data structures */
  if (cnt != vpi_get_data(id, (PLI_BYTE8 *)firstWrk,cnt))
    return(1); /* error. */

  firstWrk = wrk;
  /* Fix the next pointers in the link list. */
  for (wrk = firstWrk; cnt > 0; cnt--)
    {
      wrk->next = wrk + 1;
      wrk = wrk->next;
    }
  wrk->next = NULL;
  return(0); /* SUCCESS. */
}

PLI_INT32 consumer_save(p_cb_data data)
{
  myStruct_p wrk;
  s_cb_data cbData;
  vpiHandle cbHdl;
  PLI_INT32 id = 0;
  PLI_INT32 cnt = 0;

  /* Get the number of structures */
  wrk = firstWrk;
  while (wrk)
    {
      cnt++;
      wrk = wrk->next;
    }

  /* now save the data */
  wrk = firstWrk;
  id = vpi_get(vpiSaveRestartID, NULL);

  /* save the number of data structures */
  vpi_put_data(id,(PLI_BYTE8 *)cnt,sizeof(PLI_INT32));

  /* Save the different data structures.  Please note that
   * a pointer is being saved.  While this is allowed, an
   * application must change it to something useful on a
   * restart.
   */
  while (wrk)
    {
      vpi_put_data(id,(PLI_BYTE8 *)wrk,sizeof(myStruct_s));
      wrk = wrk->next;
    }
  /* register a call for restart */
  /* We need the "id" so that the saved data can be
   * retrieved.  Using the user_data field of the
   * callback structure is the easiest way to pass this
   * information to retrieval operation.
   */
  cbData.user_data = (PLI_BYTE8 *)id;
  cbData.reason = cbStartOfRestart;

  /* Please see 27.8 vpi_get_data() for a description of
   * how the callback routine can be used to retrieve the
   * data.
   */
  cbData.cb_rtn = consumer_restart;

  cbData.value = NULL;
  cbData.time = NULL;
  cbHdl = vpi_register_cb(&cbData);
  vpi_free_object(cbHdl);
  return(0);
}






From: Charles Dawson <chas@cadence.com>
To: ptf-bugs@boyd.com
Cc:
Subject: errata/329: Tested example
Date: Mon, 20 Sep 2004 15:30:48 -0400

Hi All,

I tested the example for these two sections. We should be able to pass
this one now.

-Chas




Fix replaced by chas@cadence.com on Thu Mar 17 10:07:34 2005
Change the example in this section to the following.
Replace the example in section 27.8 with a reference to
this example.

============================================================


#include "vpi_user.h"

#define NULL 0L

typedef struct myStruct *myStruct_p;
typedef struct myStruct {
  PLI_INT32 d1;
  PLI_INT32 d2;
  myStruct_p next;
} myStruct_s;

static myStruct_p firstWrk = NULL;

PLI_INT32 consumer_restart(p_cb_data data)
{
  struct myStruct *wrk; /* myStruct is defined in vpi_put_data() example */
  PLI_INT32 status;
  PLI_INT32 cnt, size;
  PLI_INT32 id = (PLI_INT32)data->user_data;

  /* Get the number of structures. */
  status = vpi_get_data(id,(PLI_BYTE8 *)&cnt,sizeof(PLI_INT32));
  assert(status > 0); /* Check returned status. */

  /* allocate memory for the structures */
  size = cnt * sizeof(struct myStruct);
  firstWrk = (myStruct_p)malloc(size);

  /* retrieve the data structures */
  if (cnt != vpi_get_data(id, (PLI_BYTE8 *)firstWrk,cnt))
    return(1); /* error. */

  firstWrk = wrk;
  /* Fix the next pointers in the link list. */
  for (wrk = firstWrk; cnt > 0; cnt--)
    {
      wrk->next = wrk + 1;
      wrk = wrk->next;
    }
  wrk->next = NULL;
  return(0); /* SUCCESS. */
}

PLI_INT32 consumer_save(p_cb_data data)
{
  myStruct_p wrk;
  s_cb_data cbData;
  vpiHandle cbHdl;
  PLI_INT32 id = 0;
  PLI_INT32 cnt = 0;

  /* Get the number of structures */
  wrk = firstWrk;
  while (wrk)
    {
      cnt++;
      wrk = wrk->next;
    }

  /* now save the data */
  wrk = firstWrk;
  id = vpi_get(vpiSaveRestartID, NULL);

  /* save the number of data structures */
  vpi_put_data(id,(PLI_BYTE8 *)cnt,sizeof(PLI_INT32));

  /* Save the different data structures.  Please note that
   * a pointer is being saved.  While this is allowed, an
   * application must change it to something useful on a
   * restart.
   */
  while (wrk)
    {
      vpi_put_data(id,(PLI_BYTE8 *)wrk,sizeof(myStruct_s));
      wrk = wrk->next;
    }
  /* register a call for restart */
  /* We need the "id" so that the saved data can be
   * retrieved.  Using the user_data field of the
   * callback structure is the easiest way to pass this
   * information to retrieval operation.
   */
  cbData.user_data = (PLI_BYTE8 *)id;
  cbData.reason = cbStartOfRestart;

  /* Please see 27.8 vpi_get_data() for a description of
   * how the callback routine can be used to retrieve the
   * data.
   */
  cbData.cb_rtn = consumer_restart;

  cbData.value = NULL;
  cbData.time = NULL;
  cbHdl = vpi_register_cb(&cbData);
  vpi_free_object(cbHdl);
  return(0);
}






This has been resolved via:
http://www.eda.org/svdb/bug_view_page.php?bug_id=0000311

Unformatted








Hosted by Boyd Technology