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
|
#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] =
{
// Integers
"myentity.sigint",
"myentity.iportint",
"myentity.genint",
"myentity.constint",
// Std_logic
"myentity.sigsl",
"myentity.iportsl",
"myentity.gensl",
"myentity.constsl",
// Boolean
"myentity.sigbool",
"myentity.iportbool",
"myentity.genbool",
"myentity.constbool",
// String
//"myentity.genstring", -- Not supported
//"myentity.conststring" -- Not supported
};
for (int 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
};
|