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

3
#include "common.h"
4
#include <stdlib.h>
5

6 1
int tenyr_sim_genesis(p_cb_data data)
7
{
8 1
    struct tenyr_sim_state *d = (void*)data->user_data;
9

10 1
    extern int tenyr_sim_clock(p_cb_data data);
11 1
    vpiHandle clock = vpi_handle_by_name("Top.tenyr.clk", NULL);
12 1
    s_cb_data cbd = {
13
        .reason    = cbValueChange,
14
        .cb_rtn    = tenyr_sim_clock,
15
        .obj       = clock,
16 1
        .time      = &(s_vpi_time ){ .type   = vpiSimTime },
17 1
        .value     = &(s_vpi_value){ .format = vpiIntVal  },
18 1
        .user_data = data->user_data,
19
    };
20

21 1
    vpi_register_cb(&cbd);
22

23 1
    int rc = 0;
24 1
    if ((rc = setjmp(errbuf)))
25 0
        exit(rc);
26

27 1
    if (d->cb.genesis)
28 1
        d->cb.genesis(d, data);
29

30 1
    return 0;
31
}
32

33 1
int tenyr_sim_apocalypse(p_cb_data data)
34
{
35 1
    struct tenyr_sim_state *d = (void*)data->user_data;
36

37 1
    if (d->cb.apocalypse)
38 1
        d->cb.apocalypse(d, data);
39

40 1
    return 0;
41
}
42

43 1
int tenyr_sim_clock(p_cb_data data)
44
{
45 1
    struct tenyr_sim_state *d = (void*)data->user_data;
46 1
    int clk = data->value->value.integer;
47

48 1
    if (clk) {
49 1
        if (d->cb.posedge)
50 1
            d->cb.posedge(d, &clk);
51
    } else {
52 1
        if (d->cb.negedge)
53 1
            d->cb.negedge(d, &clk);
54
    }
55

56 1
    return 0;
57
}
58

Read our documentation on viewing source code .

Loading