Regression test for vvp scheduler fix.
This is for the latent bug exposed when testing the original fix for issue #1041. Contributed by gatk555 in PR #1065.
This commit is contained in:
parent
b128508841
commit
fc9fcb0bf8
|
|
@ -0,0 +1,74 @@
|
|||
#include <vpi_user.h>
|
||||
|
||||
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
|
||||
};
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue