Esempio n. 1
0
static PLI_INT32 my_hello_calltf(PLI_BYTE8 *xx)
#endif
{
      s_vpi_value value;

      (void)xx;  /* Parameter is not used. */

      vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
      vpiHandle argv = vpi_iterate(vpiArgument, sys);
      vpiHandle arg;

      if (argv == 0) {
	    vpi_printf("ERROR: $hello_poke requires one argument\n");
	    vpi_sim_control(vpiFinish, 1);
	    return 0;
      }

      arg = vpi_scan(argv);
      assert(arg != 0);

      value.format = vpiStringVal;
      value.value.str = "Hello";

      vpi_put_value(arg, &value, 0, vpiNoDelay);

      arg = vpi_scan(argv);
      if (arg != 0) {
	    vpi_printf("ERROR: too many arguments to $hello_poke\n");
	    vpi_sim_control(vpiFinish, 1);
      }

      return 0;
}
Esempio n. 2
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. 3
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);
}