aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/vpi/vpi004/vpi1.c
blob: 25d426fe7b4f97f939d3560c265469c84a66d31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <vpi_user.h>
#define N_NAMES 12

void
vpi_proc (void)
{
  s_vpi_vlog_info info;
  int i;
  printf ("Trying to get vlog_info\n");
  int ret = vpi_get_vlog_info(&info);
  if (ret != 1) {
    printf ("Error: Failed to get vlog_info\n");
    return;
  }

  if (info.argc < 1) {
     printf ("Error: Argc was 0\n");
     return;
  }
  printf ("Argc: %d\n", info.argc);

  for (i = 0; i < info.argc; i++) {
   printf ("Argv[%d]: %s\n", i, info.argv[i]);
  }

  if (info.product == NULL) {
    printf ("Error: product is NULL\n");
    return;
  }
  printf ("Product: %s\n", info.product);

  if (info.version == NULL) {
    printf ("Error: version is NULL\n");
    return;
  }
  printf ("Version: %s\n", info.version);
}

void my_handle_register()
{
  s_cb_data cb;
  printf ("Hello world\n");

  cb.reason = cbStartOfSimulation;
  cb.cb_rtn = &vpi_proc;
  cb.user_data = NULL;
  if (vpi_register_cb (&cb) == NULL)
    vpi_printf ("Error: Cannot register StartOfSimulation call back\n");
}

void (*vlog_startup_routines[]) () =
{
  my_handle_register,
  0
};