Esempio n. 1
0
/*
 * check - must be at end of compile after sim data structure set up
 */
PLI_INT32 hello_chk(struct t_cb_data *cbp)
{
 vpiHandle href, iref;
 struct t_vpi_error_info einfotab;

 vpi_printf("... executing EndOfCompile callback for checking.\n");
 href = vpi_handle(vpiSysTfCall, NULL); 
 if (vpi_chk_error(&einfotab))
  {  
   if (href != NULL) vpi_printf("... why is handle not nil\n"); 
   vpi_printf("** ERR: $hello PLI 2.0 can not access systf call handle\n");
   prtvpiemsg(&einfotab);
   /* vpi_sim_control(vpiFinish, 0); */
  }
 iref = vpi_iterate(vpiArgument, href);
 if (vpi_chk_error(&einfotab))
  {
   vpi_printf("** ERR: vpi_iterate error:\n");
   prtvpiemsg(&einfotab);
   vpi_sim_control(vpiFinish, 0);
  }
 if (iref != NULL) 
  { 
   vpi_printf(
    "** ERR: $hello PLI 2.0 task called with %d arguments but none allowed",
    count_systf_args(iref));
   vpi_free_object(iref);
   vpi_sim_control(vpiFinish, 0);
  }
 return(0);
}
Esempio n. 2
0
/*
 * routine to build an error indication string 
 */
int my_error_handler(struct t_cb_data *cbp)
{
 struct t_vpi_error_info einfotab;
 struct t_vpi_error_info *einfop;
 char s1[128];

 einfop = &einfotab;
 vpi_chk_error(einfop);

 if (einfop->state == vpiCompile) strcpy(s1, "vpiCompile");
 else if (einfop->state == vpiPLI) strcpy(s1, "vpiPLI");
 else if (einfop->state == vpiRun) strcpy(s1, "vpiRun");
 else strcpy(s1, "**unknown**");

 vpi_printf("**ERR(%s) %s (level %d) at **%s(%d):\n  %s\n",
  einfop->code, s1, einfop->level, einfop->file, einfop->line,
  einfop->message);

 /* if serious error give up */
 if (einfop->level == vpiSystem || einfop->level == vpiInternal)
  {
   vpi_printf("**FATAL: encountered error - giving up\n");
   vpi_sim_control(vpiFinish, 0);
  }
 /* will just return and leave 0 in vpi_fopen return value */
 return(0);
}
Esempio n. 3
0
int _mon_check_string() {
    static struct {
        const char *name;
        const char *initial;
        const char *value;
    } text_test_obs[] = {
        {"t.text_byte", "B", "xxA"}, // x's dropped
        {"t.text_half", "Hf", "xxT2"}, // x's dropped
        {"t.text_word", "Word", "Tree"},
        {"t.text_long", "Long64b", "44Four44"},
        {"t.text"     , "Verilog Test module", "lorem ipsum"},
    };

    for (int i=0; i<5; i++) {
        VlVpiHandle vh1 = vpi_handle_by_name((PLI_BYTE8*)text_test_obs[i].name, NULL);
        CHECK_RESULT_NZ(vh1);

        s_vpi_value v;
        s_vpi_time t = { vpiSimTime, 0, 0};
        s_vpi_error_info e;

        v.format = vpiStringVal;
        vpi_get_value(vh1, &v);
        if (vpi_chk_error(&e)) {
            printf("%%vpi_chk_error : %s\n", e.message);
        }

        CHECK_RESULT_CSTR_STRIP(v.value.str, text_test_obs[i].initial);

        v.value.str = (PLI_BYTE8*)text_test_obs[i].value;
        vpi_put_value(vh1, &v, &t, vpiNoDelay);
    }

    return 0;
}
Esempio n. 4
0
/*
 * set a handle to a real value
 *
 * user must make sure href can have have a value put into it
 * notice the key to vpi_ processing is to save and pass handles
 */
static void vpiset_to_real(vpiHandle href, double d1)
{
 struct t_vpi_value valrec;
 struct t_vpi_error_info einfotab;

 valrec.format = vpiRealVal;
  valrec.value.real = d1; 
 vpi_put_value(href, &valrec, NULL, vpiNoDelay);
 if (vpi_chk_error(&einfotab))
  {
   vpi_printf("** ERR: vpi_put_value of real error:\n");
   prtvpiemsg(&einfotab);
  }
}
Esempio n. 5
0
static int chkvpierr()
{
  s_vpi_error_info info;
  int level;

  if ((level = vpi_chk_error(&info)) != 0) {
    fprintf(stderr, "+++ VPI ERROR +++ level %d\n", level);
    fprintf(stderr, "+++ MESS: %s\n", info.message);
    fprintf(stderr, "+++ PROD: %s\n", info.product);
    fprintf(stderr, "+++ CODE: %s\n", info.code);
    fprintf(stderr, "+++ FILE: %s\n", info.file);
    fprintf(stderr, "+++\n");
  }
  return level;
}