kulp / tenyr
1
#include "tenyr_vpi.h"
2

3 1
PLI_INT32 tenyr_sim_putchar(PLI_BYTE8 *userdata)
4
{
5 1
    struct tenyr_sim_state *state = (void*)userdata;
6 1
    (void)state;
7

8 1
    vpiHandle systfref  = vpi_handle(vpiSysTfCall, NULL),
9 1
              args_iter = vpi_iterate(vpiArgument, systfref),
10 1
              argh      = vpi_scan(args_iter);
11

12 1
    struct t_vpi_value argval = { .format = vpiIntVal };
13 1
    vpi_get_value(argh, &argval);
14 1
    putchar(argval.value.integer);
15

16 1
    vpi_free_object(args_iter);
17 1
    return 0;
18
}
19

20
#if 0
21
// XXX this code is not tenyr-correct -- it can block
22
PLI_INT32 tenyr_sim_getchar(PLI_BYTE8 *userdata)
23
{
24
    struct tenyr_sim_state *state = (void*)userdata;
25
    (void)state;
26

27
    vpiHandle systfref  = vpi_handle(vpiSysTfCall, NULL),
28
              args_iter = vpi_iterate(vpiArgument, systfref),
29
              argh      = vpi_scan(args_iter);
30

31
    struct t_vpi_value argval = {
32
        .format = vpiIntVal,
33
        .value.integer = getchar(),
34
    };
35
    vpi_put_value(argh, &argval, NULL, vpiNoDelay);
36

37
    vpi_free_object(args_iter);
38

39
    return 0;
40
}
41
#endif
42

Read our documentation on viewing source code .

Loading