aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/vpi/vpi002/vpi1.c
blob: d6f1b42fb701a82e928bd7d9fba2623cb2e3c2e3 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <vpi_user.h>
#define N_NAMES 12

void
vpi_proc (void)
{
  vpiHandle net;
  s_vpi_value val;
  char names[N_NAMES][64] =
    {
     // Enum
     "myentity.sigenum",
     "myentity.portenum",
     "myentity.genenum",
     //"myentity.constenum" // Not supported

     // Array1 (unbounded static)
     "myentity.sigarray1",
     "myentity.portarray1",
     //"myentity.genarray1",  // Not supported
     //"myentity.constarray1" // Not supported
     //"myentity.sigarray1[0]", // Not supported
     //"myentity.portarray1[0]", // Not supported

     // Array2 (unbounded complex)
     "myentity.sigarray2",
     "myentity.portarray2",
     //"myentity.constarray2" // Not supported

     // Array3 (bounded static)
     "myentity.sigarray3",
     "myentity.portarray3",
     //"myentity.genarray3",  // Not supported
     //"myentity.constarray3" // Not supported

     // Array4 (bounded complex)
     "myentity.sigarray4",
     //"myentity.constarray4" // Not supported

     // Array4 (bounded static) array of bit
     "myentity.sigarray5",
     "myentity.portarray5",
     //"myentity.constarray5", // Not supported
     //"myentity.genarray5", // Not supported
     //"myentity.sigarray5[0]", // Not supported
     //"myentity.portarray5[0]" // Not supported
    };
  int name_index;
                       
  for (name_index=0; name_index<N_NAMES; name_index+=1) {
    printf ("Trying to find name %s\n", names[name_index]);
    net = vpi_handle_by_name (names[name_index], NULL);
    if (net == NULL)
        {
        printf ("Error: Failed to find the net %s\n", names[name_index]);
        return;
        }
    val.format = vpiBinStrVal;
    vpi_get_value (net, &val);
    printf ("value: %s\n", val.value.str);
  }
}

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

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

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