User guide

2-32
Modeling Your Design
2. A nested begin block executes only if the current scope is either
top.c1 or top.c3.
3. VCS displays whether $activeinst points to a zero or non-zero
value.
The C code is as follows:
#include <stdio.h>
void showInst(unsigned str_arg)
{
const char *str = (const char *)str_arg;
printf("DirectC: [%s]\n", str);
}
Function showInst declares the char pointer str and assigns to it
the value of its parameter, which is the pointer in $activeinst in
the Verilog code. Then with a printf statement it displays the
hierarchical name that str is pointing to. Notice that the function
begins the information it displays with DirectC: so that you can
differentiate it from what VCS displays.
During simulation VCS and the C function display the following:
DirectC: [top.c1]
for instance top.c1 the pointer is non-zero
DirectC: [top.c2]
DirectC: [top.c3]
for instance top.c3 the pointer is non-zero
DirectC: [top.c4]