⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show_all_signals3_acc.c

📁 pli_handbook_examples_pc verilog hdl 与C的接口的典型例子
💻 C
字号:
/**********************************************************************
 * $show_all_signals example -- C source code using TF/ACC PLI routines
 *
 * C source to scan through a module and list the names of all nets,
 * regs and variables in the module with the current logic value.  A
 * null argument or no argument is interpreted as the current module.
 * Multiple hierarchy levels can be listed as system task arguments.
 *
 * For the book, "The Verilog PLI Handbook" by Stuart Sutherland
 *  Book copyright 1999, Kluwer Academic Publishers, Norwell, MA, USA
 *   Contact: www.wkap.il
 *  Example copyright 1998, Sutherland HDL Inc, Portland, Oregon, USA
 *   Contact: www.sutherland.com or (503) 692-0898
 *
 * Usage: $show_all_nets(<module_instance>?, <module_instance>?, ...);
 *
 * Routine definitions for a veriusertfs array:
 *  /* routine prototypes -/
 *   extern int PLIbook_ShowSignals3_checktf(),
 *              PLIbook_ShowSignals3_calltf();
 *  /* table entries -/
 *   {usertask,                       /* type of PLI routine -/
 *     0,                             /* user_data value -/
 *     PLIbook_ShowSignals3_checktf,  /* checktf routine -/
 *     0,                             /* sizetf routine -/
 *     PLIbook_ShowSignals3_calltf,   /* calltf routine -/
 *     0,                             /* misctf routine -/
 *     "$show_all_signals3",          /* system task/function name -/
 *     1                              /* forward reference = true -/
 *   },
 *********************************************************************/

#include "veriuser.h"         /* IEEE 1364 PLI TF  routine library */
#include "acc_user.h"         /* IEEE 1364 PLI ACC routine library */
/**********************************************************************
 * checktf routine
 *********************************************************************/
int PLIbook_ShowSignals3_checktf()
{
  int i, numargs;
  
  acc_initialize();
  numargs = tf_nump();
  if (numargs == 0)
    return(0); /* no arguments is OK, skip remaining checks */
  for (i = 1; i <= numargs; i++) {
    if (tf_typep(i) == TF_NULLPARAM)
      break;  /* null argument is OK, skip other checks for this arg */
    else if (acc_fetch_type(acc_handle_tfarg(i)) != accModule)
      tf_error("$show_all_signals arg must be a module instance.");
  }
  acc_close();
  return(0);
}

/**********************************************************************
 * calltf routine
 *********************************************************************/
void PLIbook_GetAllSignals();  /* prototype function used by calltf */

int PLIbook_ShowSignals3_calltf()
{
  handle module_h;
  int i, numargs;
  acc_initialize();
  numargs = tf_nump();
  if (numargs == 0) {
    module_h = acc_handle_scope(acc_handle_tfinst());
    PLIbook_GetAllSignals(module_h);
  }
  else
    for (i = 1; i <= numargs; i++) {
      if (tf_typep(i) == tf_nullparam)
        module_h = acc_handle_scope(acc_handle_tfinst());
      else
        module_h = acc_handle_tfarg(i);
      PLIbook_GetAllSignals(module_h);
    }
  acc_close();
  return(0);
}

void PLIbook_GetAllSignals(handle module_h)
{
  handle signal_h;
  static int signal_types[6] = {accNet, accReg, accIntegerVar,
                                accTimeVar, accRealVar, 0 };
  acc_initialize();
  io_printf("\nAt time %s, signals in module %s (%s):\n",
            tf_strgettime(),
            acc_fetch_fullname(module_h),
            acc_fetch_defname(module_h));
  signal_h = null;    /* start with known value for target handle */
  while (signal_h = acc_next(signal_types, module_h, signal_h)) {
    io_printf("  %-13s %-13s  value is  %s (hex)\n",
              acc_fetch_type_str(acc_fetch_fulltype(signal_h)),
              acc_fetch_name(signal_h),
              acc_fetch_value(signal_h, "%h", null));
  }
  acc_close();
  return;
}
/*********************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -