Exemplo n.º 1
0
static int insert_var(RStr *output, FmtInfo *fi, int pn)
{
  switch(fi->cvt_spec)
  {
   case 'm':
    expanding_strcat(output,tf_mipname()); /* calling module */
    break;
   case 't':
    expanding_strcat(output,tf_strgettime()); /* current simulator time */
    break;
   case '%':
    expanding_strcat(output,"%"); /* percent sign */
    break;
   default:
    /* don't need this check if checktf errors */
    if(strchr(has_nfld,fi->cvt_spec))
    {
      char *text;
      /* translate x's to h's for hex; NC segfaults if you don't */
      if(fi->cvt_spec=='x')
	fi->cvt_spec='h';
      if(fi->cvt_spec=='X')
	fi->cvt_spec='H';
      text= format_val(fi,
		       fi->cvt_spec=='s' ? tf_getcstringp(pn) :
		       tf_strgetp(pn,fi->cvt_spec));
      expanding_strcat(output,text);
      free(text);
      pn++;
    }
  }
  return pn;
}
Exemplo n.º 2
0
static int
mytest(int ud, int reason)
{
    PLI_INT32 ht, lt;
    PLI_BYTE8 *cp;
    PLI_BYTE8 *inst = tf_getinstance();
    PLI_BYTE8 *name = tf_spname();

    (void)ud;  /* Parameter is not used. */
    (void)reason;  /* Parameter is not used. */

    io_printf("Module %s\n", name);

    lt = tf_gettime();
    io_printf("\ttf_gettime()\t\t\t-> %d\n", (int)lt);

    cp = tf_strgettime();
    io_printf("\ttf_strgettime()\t\t\t-> %s\n", cp);

    lt = tf_getlongtime(&ht);
    io_printf("\ttf_getlongtime()\t\t-> %d/%d\n", (int)ht, (int)lt);

    lt = tf_igetlongtime(&ht, inst);
    io_printf("\ttf_igetlongtime(inst)\t\t-> %d/%d\n", (int)ht, (int)lt);

    lt = tf_getlongsimtime(&ht);
    io_printf("\ttf_getlongsimtime()\t\t-> %d/%d\n", (int)ht, (int)lt);

    lt = tf_gettimeprecision();
    io_printf("\ttf_gettimeprecision()\t\t-> %d\n", (int)lt);

    lt = tf_igettimeprecision(inst);
    io_printf("\ttf_igettimeprecision(inst)\t-> %d\n", (int)lt);

    lt = tf_gettimeunit();
    io_printf("\ttf_gettimeunit()\t\t-> %d\n", (int)lt);

    lt = tf_igettimeunit(inst);
    io_printf("\ttf_gettimeunit(inst)\t\t-> %d\n", (int)lt);

    lt = tf_igettimeunit(0);
    io_printf("\ttf_gettimeunit(0)\t\t-> %d\n", (int)lt);

    return 0;
}
Exemplo n.º 3
0
/*----------------------------------------------------------------------------
* int
* errorCheck()
* checks to see if we've reached max_errors
*
* Return Value --
* 1 on error kill, 0 otherwise
*
* Design --
* inhibit printing warnings and errors if we've reached max_errors
* either by dying or turning them off
*
* Side effects --
* possible death, modifies finish_pending and finish_type
*----------------------------------------------------------------------------
*/
static int 
errorCheck()
{
  int l_r=0;
  if (ms.global_errors >= ms.max_errors)
  {
    if(ms.external_finish!=0)
    {
      if (ms.finish_pending==0)
      {
	UnitInfo **l_ul=(UnitInfo **)ht_sorted_list(ms.unit_tbl, UnitInfo_cmp);
	UnitInfo **l_uit=0;
	//printf("Setting finish pending for verilog, and warn_stop as type.\n");
	ms.finish_pending = 1;
	ms.finish_type = 1;
	/* termination pending due to max error */
	/* disable further warn/errors till external */
	/* verilog shuts down simulator. */
	for(l_uit=l_ul; *l_uit; l_uit++)
	{
	  (*l_uit)->enable[MON_WARN]=0;
	  (*l_uit)->enable[MON_ERR]=0;
	}
	l_r=1;
	free(l_ul);
      }
    } else
    {
      printf("\nINFO(%s): MAX ERRORS REACHED - SIMULATION TERMINATED\n", 
	     modulename);
      printf("INFO(%s): TIME %s, ABNORMAL END--"
	     "MONITOR CAUSED END OF SIMULATION\n", modulename, tf_strgettime());
      printf("Ending simulation \nSIM_ERR_STATUS:1 \n");
      tf_dofinish();
    }
  }
  return l_r;
}
Exemplo n.º 4
0
/*----------------------------------------------------------------------------
* int
* warningCheck()
* checks to see if we've reached max_warnings
*
* Return Value --
* 1 on warning kill, 0 otherwise
*
* Design --
* inhibit printing warnings and errors if we've reached max_warnings
* either by dying or turning them off
*
* Side effects --
* possible death, modifies finish_pending and finish_type
*----------------------------------------------------------------------------
*/
static int 
warningCheck()
{   
  int l_r=0;

  if (ms.global_warnings >= ms.max_warnings)
  {
    if(ms.external_finish!=0)
    {
      if(ms.finish_pending==0)
      {
	UnitInfo **l_ul=(UnitInfo **)ht_sorted_list(ms.unit_tbl, UnitInfo_cmp);
	UnitInfo **l_uit=0;
	//printf("Setting finish pending for verilog, and warn_stop as type.\n");
	ms.finish_pending = 1;
	ms.finish_type = 2;
	for(l_uit=l_ul; *l_uit; l_uit++)
	{
	  (*l_uit)->enable[MON_WARN]=0;
	  (*l_uit)->enable[MON_ERR]=0;
	}
	l_r=1;
	free(l_ul);
      }
    } else
    {
      printf("\nINFO(%s): MAX WARNINGS REACHED - SIMULATION TERMINATED\n",
	     modulename);
      printf("INFO(%s): TIME %s, ABNORMAL END--"
	     "MONITOR CAUSED END OF SIMULATION\n", modulename, tf_strgettime());
      printf("Ending simulation \nSIM_ERR_STATUS:2 \n");
      tf_dofinish();
    }
  }
  return l_r;
}
Exemplo n.º 5
0
/*----------------------------------------------------------------------------
* static void
* print_tagged_line(char *p_prefix, char *p_unit, char *p_output, 
*                   int p_mon_type, int p_add_newline)
* print out the line with timestamp and unit responsible
*
* Return Value --
* none
*
* Design --
* Get timestamp. Go through way too much effort to come up with a module name 
* put it together to get a tag, call smart_write_tagged_output
* Side effects --
* possible death since it calls warningCheck() and errorCheck()
* may modify global_errors or global_warnings
*----------------------------------------------------------------------------
*/
static void 
print_tagged_line(const char *p_prefix, const char *p_unit, char *p_output, 
		  int p_mon_type, int p_add_newline)
{
  char *l_instance=tf_mipname();
  char *l_pt1=0;
  char *l_modname=0;
  char *l_tag_gen[]={"%s%s%s%s", "%s: WARNING: %s[%s%s]: ",
		     "%s: ERROR: %s[%s%s]: ", "%s: %s[%s%s]: ", 
             "%s: INFO: %s[%s%s]: ", "%s: DBG: %s[%s%s]: "};
  
  /* If l_instance == NULL, then we may be in a callback */
  if (l_instance == NULL)
  {
    l_instance = "pli callback";
  }

  /* get the module instance name. */
  /* Generally, ch_sys.cheetah_mod.cpu..... */
  /* Display as: (<mod>...<end_path_name>) */
  if (0==(l_pt1 = strchr(l_instance, '.')))
  {
    /* No module */
    l_modname=strdup(l_instance);
  } 
  else
  {
    /* we just want the full instance name from the mod level down. */
    /* that's what we print out, always!  If that's too long and your */
    /* printouts end up hard to read, tough! Post process. */
    l_modname=strdup(l_pt1+1);
  }
  
  if(0!=l_modname)
  {
    char *l_tagbuffer=0;
    /* lacking a predictable snprintf or asprintf, we guess at how large
       tagbuffer needs to be */
    if(0==(l_tagbuffer=(char*)malloc(strlen(l_tag_gen[p_mon_type])+strlen(p_unit)+
			      strlen(p_prefix)+strlen(l_modname)+20)))
    {
      printf("ERROR(%s): Can not generate tag for output\n",modulename);
      tf_dofinish();
    }
    sprintf(l_tagbuffer, l_tag_gen[p_mon_type], tf_strgettime(), p_unit, 
	    p_prefix, l_modname);
    if(WARNING_MON_TYPE==p_mon_type)
      ms.global_warnings++;
    if(ERROR_MON_TYPE==p_mon_type)
    {
      ms.global_errors++;
      /* if we do a dispmon (not writemon!) with an error monitor type. 
	 Force the start of a new line. */
      if(p_add_newline && 0==ms.newLine)
      {
	puts("");
	ms.newLine=1;
      }
    }
    smart_write_tagged_output(l_tagbuffer, p_output, p_add_newline);
    free(l_modname);
    free(l_tagbuffer);
    warningCheck();
    errorCheck();
  }
}