diff --git a/ivtest/vpi/br_gh1041b.c b/ivtest/vpi/br_gh1041b.c new file mode 100644 index 000000000..b7d5947a6 --- /dev/null +++ b/ivtest/vpi/br_gh1041b.c @@ -0,0 +1,74 @@ +#include + +static void step(void); + +static vpiHandle w; + +static PLI_INT32 tick_cb(struct t_cb_data *cb) +{ + static struct t_vpi_value val = { .format = vpiIntVal }; + static int idx; + + (void)cb; + + ++idx; + val.value.integer = idx & 1; + vpi_put_value(w, &val, NULL, vpiNoDelay); + step(); + return 0; +} + +/* Request a callback after a delay. */ + +static void step(void) +{ + static struct t_vpi_time now = { .type = vpiSimTime, .low = 2 }; + static struct t_cb_data cbd = + { .reason = cbAfterDelay, .cb_rtn = tick_cb, .time = &now }; + + /* Callback after delay. */ + + vpi_register_cb(&cbd); +} + +/* Callback function - simulation is starting. */ + +static PLI_INT32 start_cb(struct t_cb_data *cb) +{ + static struct t_vpi_value val = { .format = vpiIntVal }; + + (void)cb; + + w = vpi_handle_by_name("test.w", NULL); + if (!w) + vpi_printf("No handle!\n"); + vpi_printf("Got handle for %s\n", vpi_get_str(vpiFullName, w)); + val.value.integer = 0; + vpi_put_value(w, &val, NULL, vpiNoDelay); + step(); + return 0; +} + +/* VPI initialisation. */ + +static void start(void) +{ + static struct t_vpi_time now = { .type = vpiSimTime }; + static struct t_cb_data cbd = { .reason = cbStartOfSimulation, + .time = &now, .cb_rtn = start_cb }; + + /* At this point VPI objects do not exist, + * so request a callback once they do. + */ + + vpi_register_cb(&cbd); +} + +/* This is a table of registration functions. This table is the external + * symbol that the VVP simulator looks for when loading this .vpi module. + */ + +void (*vlog_startup_routines[])(void) = { + start, + 0 +}; diff --git a/ivtest/vpi/br_gh1041b.v b/ivtest/vpi/br_gh1041b.v new file mode 100644 index 000000000..c4a6acc71 --- /dev/null +++ b/ivtest/vpi/br_gh1041b.v @@ -0,0 +1,18 @@ +module test(w); + input wire w; + wire a, b; + + + initial begin + #11 $finish; + end + + assign b = 0; + + assign a = !w | b; + + always @(a) begin + $display($time, ": Wire a is now ", a); + end +endmodule + diff --git a/ivtest/vpi_gold/br_gh1041b.gold b/ivtest/vpi_gold/br_gh1041b.gold new file mode 100644 index 000000000..d8c1193f6 --- /dev/null +++ b/ivtest/vpi_gold/br_gh1041b.gold @@ -0,0 +1,10 @@ +Compiling vpi/br_gh1041b.c... +Making br_gh1041b.vpi from br_gh1041b.o... +Got handle for test.w + 0: Wire a is now 1 + 2: Wire a is now 0 + 4: Wire a is now 1 + 6: Wire a is now 0 + 8: Wire a is now 1 + 10: Wire a is now 0 +vpi/br_gh1041b.v:7: $finish called at 11 (1s) diff --git a/ivtest/vpi_regress.list b/ivtest/vpi_regress.list index a8e22b524..226080081 100644 --- a/ivtest/vpi_regress.list +++ b/ivtest/vpi_regress.list @@ -72,6 +72,7 @@ br_gh317 normal br_gh317.c br_gh317.gold br_gh496 normal,-g2009 br_gh496.c br_gh496.gold br_gh1037 normal,-g2009 br_gh1037.c br_gh1037.gold br_gh1041 normal br_gh1041.c br_gh1041.gold +br_gh1041b normal br_gh1041b.c br_gh1041b.gold br_ml20191013 normal br_ml20191013.c br_ml20191013.gold by_index normal by_index.c by_index.gold by_name normal by_name.c by_name.log