Exemplo n.º 1
0
void
vmm_xvc_tcl_execute_file(char *test_file) {
   int tcl_error;

   char xvc_home_path[200];  
   char *xvc_tcl_utils_file_fullpath;
   char xvc_tcl_cmd_buf[1000];

   /* perform creation and inits of the TCL interpreter */
   tcl_error = xvc_tcl_init();
   if (tcl_error != TCL_OK) {
      io_printf("Error in initialization of TCL for VMM xvc manager\n");
      abort();
   }

   /* Source the startup script */
   /* Check for +vmm_path=%s string, if present, it overrides
      VCS_HOME/etc/vmm as the location to pickup the vmm_xvc_parse.tcl
      initialization file */
   if (mc_scan_plusargs("vmm_path")) {
      char *str;
      str = mc_scan_plusargs("vmm_path") + 1;
      strcpy(xvc_home_path,str);
      strcat(xvc_home_path,"/");
   } else {
      /* get VCS_HOME env. variable */
      char *vcs_home_path;
      vcs_home_path = getenv("VCS_HOME");
      if (vcs_home_path == NULL) {
         io_printf("VCS_HOME env. variable not set, needed for xvc manager\n");
         abort(); 
      }
      strcpy(xvc_home_path,vcs_home_path);
      strcat(xvc_home_path,"/etc/vmm/");
   }
   //ToDo: Error out if xvc_home_path is NULL
   xvc_tcl_utils_file_fullpath = strcat(xvc_home_path, "vmm_xvc_parse.tcl");

   tcl_error = Tcl_EvalFile(xvc_tcl_interp, xvc_tcl_utils_file_fullpath);
   if (tcl_error != TCL_OK) {
      io_printf("Error: xvc manager: could not eval file %s\n",xvc_tcl_utils_file_fullpath);
      io_printf("  Either +vmm_path=<str> or VCS_HOME env. variable needs to be provided\n");
      abort();
   }

   /* register user TCL functions */
   xvc_register_tcl_functions();

   //execute the parse-start command from C
   sprintf(xvc_tcl_cmd_buf, "execute_file %s", test_file);
   tcl_error = Tcl_Eval(xvc_tcl_interp, xvc_tcl_cmd_buf);
   if (tcl_error != TCL_OK) {
      io_printf("Error: xvc manager: in executing file %s: File does not exist ?\n",
         test_file);
      abort();
   }

}
Exemplo n.º 2
0
/*----------------------------------------------------------------------------
* static void
* parse_dispmon_plusargs()
* parse command line plus args for dispmon, +maxerror, +maxwarning
* +debug_all +mon+<name>+<level>
*
* Return Value --
* none
*
* Design --
* looks at plusargs, sets variable values
*
* Side effects --
* sets max_errors and max_warnings and updates hash tables
*----------------------------------------------------------------------------
*/
static void 
parse_dispmon_plusargs()
{
  char *l_cp;
  char *m_cp;
  int  n;

  // Max err/warn check
  if (!((l_cp=mc_scan_plusargs("maxerror=")) || 
	(l_cp=mc_scan_plusargs("maxerror"))) ||
      !(ms.max_errors=strtoul(l_cp, 0,10)))
  {
    cDispmon("disp", MON_NORMAL, "Can't find valid +maxerror arg, setting to 1");
    ms.max_errors = 1;
  }
    
  if (!((l_cp=mc_scan_plusargs("maxwarning=")) || 
	(l_cp=mc_scan_plusargs("maxwarning"))) ||
      !(ms.max_warnings=strtoul(l_cp, 0,10)))
  {
    cDispmon("disp", MON_NORMAL, "Can't find valid +maxwarning arg, setting to 5");
    ms.max_warnings = 5;
  }

  // Debug mode for all
  if (mc_scan_plusargs("debug_all")) {
    cDispmon("disp", MON_NORMAL, "Detected global debug mode request. Setting all units");
    ch_dispmon("all", MON_DEBUG, 1);
  }

  // Info mode for all
  if (mc_scan_plusargs("info_all")) {
    cDispmon("disp", MON_NORMAL, "Detected global info mode request. Setting all units");
    ch_dispmon("all", MON_INFO, 1);
  }

  // Parse generic options of the form
  // +mon+<unit>=<level>=<value>(,<unit>=<level>=<value>)*
  l_cp = mc_scan_plusargs("mon+");
  if (!(l_cp == NULL)) {
    n = strlen(l_cp);
    m_cp = (char*)malloc(sizeof(char) * n);
    strcpy(m_cp,l_cp);
    cDispmon ("disp", MON_NORMAL, "Scanned Monitors specification: %s", m_cp); 
    scan_n_chdispmon(m_cp);
  }

  // Quiet mode - overrides all 
  if (mc_scan_plusargs("quiet") && !mc_scan_plusargs("noquiet")) {
    cDispmon("disp", MON_NORMAL, "Detected global quiet mode request.");
    ch_dispmon("all", MON_ERR, 1);
    ch_dispmon("all", MON_NORMAL, 0);
  }

}
Exemplo n.º 3
0
void genDumpMod_call(int data, int reason)
{
  handle child_handle, module_handle;
  char   *pargs, *ptr, *mod_name;
  int    pargs_found, level;
  char   buf[128];

  pargs = mc_scan_plusargs ("gen_dump_module="); 

  pargs_found = 0;
  if (pargs != (char *)0) {
    strcpy(buf, pargs);
    mod_name = strtok (buf, ":");
    ptr = strtok (NULL, " \n");
    level = atoi (ptr);
    if (level > 0 ) {pargs_found = 1;}
  }

  if (pargs_found == 0) return;
  io_printf ("%s %d\n", mod_name, level);
  
  if ((fp = fopen("dump.mod", "w")) == 0)
    tf_error ("can't open dump.mod file\n");

  acc_initialize();

  module_handle = acc_handle_object (mod_name);
  child_handle = null;

  next_level (module_handle, level);
  acc_close();
  fclose (fp);
  tf_dofinish();
}
Exemplo n.º 4
0
/*
 * routine to setup memory filling routine - set param to 0 on error else 1
 * function: $plisetupmemfill(memsiz, memwid)
 */
static void plisetupmemfill(int data, int reason)
{
    char *chp;

    /* get file name as + verilog argument */
    if ((chp = mc_scan_plusargs("memfile+")) == NULL || strcmp(chp, "") == 0)
    {
        tf_error("missing or empty +memfile+[file name] memory file argument");
        tf_putp(0, 0);
        return;
    }
    /* open the file */
    if ((memval_s = fopen(chp, "r")) == NULL)
    {
        tf_error("unable to open +memfile+ memory file %s", chp);
        tf_putp(0, 0);
        return;
    }
    /* need memory size for checking */
    memsiz = tf_getp(1);
    memwid = tf_getp(2);
    tf_putp(0, 1);
    /* assume memory goes from 1 to size */
    last_i = 0;
}
int util_get_plus_args_num() {

/* Example use

integer         num_vectors;            // number of test vectors
integer         MAX_FAILURES;           // max failed vectors before aborting

initial
  begin
    // get integers from plus argument values
    num_vectors = $util_get_plus_args_num("num_vectors");
    MAX_FAILURES = $util_get_plus_args_num("max_failures");
    $display("%d VECTORS IN TEST FILE.", num_vectors);
    $display("Maximum number of failures is %d", MAX_FAILURES);
  end
*/

   /*  Input: [unsigned int which is a string |
    *                            C string ]
    *  Returns: Arg. value in 32 bit integer.
    *            On error returns VERILOG_C_ERROR
    *  Action:  Gets the parameter, calls  'mc_scan_plusargs'
    *            to get the arg. value.
    *     
    */
					   
				
    int np;
    char *cp;

    np = tf_nump();
    if ( np != 1 ) {
        if (DEBUG_PLUS_ARGS) {
	    io_printf("get_plus_args_num(): Error: Number of args != 1.\n");
        }
	tf_putp(0, VERILOG_ERROR);
	return(VERILOG_ERROR);
    }

    cp = mc_scan_plusargs(tf_getcstringp(1));
    if (cp == NULL ) {
      if (DEBUG_PLUS_ARGS) {
	  io_printf("get_plus_args_num():  Matching number is not found:  %d\n", tf_getcstringp(1));
      }
      tf_putp(0, VERILOG_ERROR);
      return(VERILOG_ERROR);
    }

    if (DEBUG_PLUS_ARGS)
	io_printf("get_plus_args_num():  Got integer value: %d\n", atoi(cp));

    tf_putp(0, atoi(cp) );
    return(VERILOG_OK);
}
Exemplo n.º 6
0
int get_bank_set_mask(){
    char *bank_set_mask_val = 0;
    unsigned int bank_set_mask = 0;
    bank_set_mask_val=mc_scan_plusargs("bank_set_mask=");
    if (!bank_set_mask_val){
	bank_set_mask=0;
    }
    else
        bank_set_mask=strtoul(bank_set_mask_val, 0, 16);
    return(bank_set_mask);
}
int util_get_plus_args_str() {

/* Example use:

invocation script (bosox is passed in as first argument)
-----------------
set basename = $1
verilog mymodule.v +tst_file_name${basename}.tst +log_file_name${basename}.log
  +err_file_name${basename}.err +result_file_name${basename}.result

mymodule.v
----------
reg   [32*8:1]  tst_file_name;		// plus argument string value 
reg   [32*8:1]  err_file_name;		// plus argument string value
reg   [32*8:1]  log_file_name;		// plus argument string value
reg   [32*8:1]  result_file_name;	// plus argument string value
integer         plus_arg_ok;            // 0 if ok, 1 if no plus argument value

initial
  begin
    // get strings from plus argument values
    plus_arg_ok = $util_get_plus_args_str("tst_file_name", tst_file_name);
    plus_arg_ok = $util_get_plus_args_str("err_file_name", err_file_name);
    plus_arg_ok = $util_get_plus_args_str("log_file_name", log_file_name);
    plus_arg_ok = $util_get_plus_args_str("result_file_name",result_file_name);

    $display("tst_file_name is %s", tst_file_name);
    $display("err_file_name is %s", err_file_name);
    $display("log_file_name is %s", log_file_name);
    $display("result_file_name is %s", result_file_name);
  end

*/


/* Input is string
	Returning value is string.
*/

    handle		wrk_out;
    char		*strArgIn;
    int			sizeOut,sizeS_in;
    int			numArgs;
    int			cnt,size;
    char		*buffer, *bufferout;
    s_setval_value	value_out;
    s_setval_delay	delay_out;

    delay_out.model = accNoDelay;
    delay_out.time.type = accRealTime;
    delay_out.time.real = 0.0;
    value_out.format = accHexStrVal;

    acc_initialize();

    numArgs = tf_nump();
    if(numArgs !=2) {
	tf_error("$get_plus_arg_string must have two arguments");
	tf_putp(0,VERILOG_ERROR);
	return(VERILOG_ERROR);
    }

/* Fetch the input register and size */

    wrk_out = acc_handle_tfarg(2);
    sizeOut = (acc_fetch_size(wrk_out)/8);

/* Get the string value */
    
    strArgIn = mc_scan_plusargs(tf_getcstringp(1));

    if (strArgIn == NULL) {
	if (DEBUG_PLUS_ARGS)
	    io_printf("get_plus_args_str():  Matching string is not found: %s.\n", tf_getcstringp(1));
	tf_putp(0,VERILOG_ERROR);
	return(VERILOG_ERROR);
    }

    if (strArgIn) {
        if (DEBUG_PLUS_ARGS)
	    io_printf("get_plus_args_str():  Got string value: %s\n",strArgIn);
    }
    else {
	io_printf("get_plus_args_str():  Bad input string value.\n");
	tf_putp(0,VERILOG_ERROR);
	return(VERILOG_ERROR);
    }


/* Build new string */

    sizeS_in = strlen(strArgIn);
    bufferout = (char *) malloc(sizeS_in + 1);
    sprintf(bufferout, "%s",strArgIn);

    if (sizeOut < sizeS_in) {
	tf_error("get_plus_args_str():  Register %s is not large enough.\n",
		 acc_fetch_fullname(wrk_out));
	tf_putp(0,VERILOG_ERROR);
	return(VERILOG_ERROR);
    }

    size = sizeS_in*2;
    buffer = (char *) malloc(size + 1);
    for (cnt =0; cnt < size; cnt +=2){
	if (cnt < size){
	    /* Convert string into HEX code */
	    sprintf(&buffer[cnt],"%x",bufferout[cnt/2]);
	}
    }

/*	 Null out the rest of the register 
	else {
	buffer[cnt] = '\0';
	buffer[cnt +1] = '\0';
}
*/

    /* assign buffer to the verilog register */
	
    value_out.value.str = buffer;
    acc_set_value(wrk_out, &value_out, &delay_out);  
    tf_putp(0,VERILOG_OK);
    acc_close();

    free(buffer);
    free(bufferout);
    return(VERILOG_OK);
}
Exemplo n.º 8
0
void monInit_check(int data, int reason)
{
   int i;
   char *string, *name, *ptr, ch;

   if (monInit_done) return ;
   monInit_done = 1 ;

   /* 
    * plus args for info.
    * +mon0=cpu0:25 +mon1=ccx:35
    */

   mon_path_num = 0;
   while (1) {
     sprintf (mon_name_buf, "mon%d=\0", mon_path_num);
     string = mc_scan_plusargs(mon_name_buf);
     if (string != 0) {
       strcpy(mon_name_buf, string);
       ptr = strtok (mon_name_buf, ":");
       if (ptr == 0) {
	 tf_error("Syntax error in mon%i plus arg (instance path)\n", mon_path_num);
	 tf_dofinish();
	 return;
       }
       mon_inst_path[mon_path_num] = strdup (ptr);
       ptr = strtok (NULL, ":");
       if (ptr == 0) {
	 tf_error("Syntax error in mon%i plus arg (level)\n", mon_path_num);
	 tf_dofinish();
	 return;
       }
       mon_level[mon_path_num] = atoi (ptr);
     }
     else {
       break;
     }
     mon_path_num++;
   }

   /* 
    * plus args for diserr.
    * +diserr=uce:cer:xyz
    */
   diserr_num = 0;
   string = mc_scan_plusargs("diserr=");
   if (string != 0) {
     ptr = strtok (string, ":");
     if (ptr == 0) {
       tf_error("Syntax error in diserr plus arg\n");
       tf_dofinish();
       return;
     }
     while (1) {
       diserr_arr[diserr_num] = strdup (ptr);
       diserr_num++;
       ptr = strtok (NULL, ":");
       if (ptr == 0) break;
     }
   }

   /* 
    * plus args for diswarn.
    * +diswarn=mem0:mem3
    */
   diswarn_num = 0;
   string = mc_scan_plusargs("diswarn=");
   if (string != 0) {
     ptr = strtok (string, ":");
     if (ptr == 0) {
       tf_error("Syntax error in diswarn plus arg\n");
       tf_dofinish();
       return;
     }
     while (1) {
       diswarn_arr[diswarn_num] = strdup (ptr);
       diswarn_num++;
       ptr = strtok (NULL, ":");
       if (ptr == 0) break;
     }
   }
}