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

3
static struct tenyr_sim_state tstate = { .cb.posedge = 0 }, *const pstate = &tstate;
4
static void *const pud = (void*)&tstate;
5

6 1
static int tenyr_sim_dummy(struct tenyr_sim_state *state, void *userdata)
7
{
8 1
    (void)state;
9 1
    (void)userdata;
10 1
    return 0;
11
}
12

13 1
static void register_genesis(void)
14
{
15 1
    s_cb_data data = { cbStartOfSimulation, tenyr_sim_genesis, NULL, 0, 0, 0, pud };
16 1
    pstate->handle.cb.genesis = vpi_register_cb(&data);
17
}
18

19 1
static void register_general(void)
20
{
21 1
    s_vpi_systf_data load = { vpiSysTask, 0, "$tenyr_load", tenyr_sim_load, NULL, NULL, pud };
22 1
    pstate->handle.tf.tenyr_load = vpi_register_systf(&load);
23

24 1
    pstate->cb.genesis = tenyr_sim_dummy;
25 1
    pstate->cb.posedge = tenyr_sim_dummy;
26 1
    pstate->cb.negedge = tenyr_sim_dummy;
27 1
    pstate->cb.apocalypse = tenyr_sim_dummy;
28
}
29

30 1
static void register_apocalypse(void)
31
{
32 1
    s_cb_data data = { cbEndOfSimulation, tenyr_sim_apocalypse, NULL, 0, 0, 0, pud };
33 1
    pstate->handle.cb.apocalypse = vpi_register_cb(&data);
34
}
35

36 1
static void register_serial(void)
37
{
38 1
    s_vpi_systf_data put = { vpiSysTask, 0, "$tenyr_putchar", tenyr_sim_putchar, NULL, NULL, pud };
39 1
    pstate->handle.tf.tenyr_putchar = vpi_register_systf(&put);
40
#if 0
41
    // XXX this code is not tenyr-correct -- it can block
42
    s_vpi_systf_data get = { vpiSysTask, 0, "$tenyr_getchar", tenyr_sim_getchar, NULL, NULL, pud };
43
    pstate->handle.tf.tenyr_getchar = vpi_register_systf(&get);
44
#endif
45
}
46

47
void (*vlog_startup_routines[])() = {
48
    register_genesis,
49
    register_general,
50
    register_apocalypse,
51

52
    register_serial,
53

54
    NULL
55
};
56

Read our documentation on viewing source code .

Loading