Add regression test for undriven net initialisation (issue #1041).

This commit is contained in:
Martin Whitaker 2024-01-07 09:31:22 +00:00
parent 435c9797b2
commit a9eed015c3
4 changed files with 77 additions and 0 deletions

52
ivtest/vpi/br_gh1041.c Normal file
View File

@ -0,0 +1,52 @@
#include <vpi_user.h>
static PLI_INT32 start_cb(struct t_cb_data *cb)
{
static struct t_vpi_value val;
vpiHandle wire;
(void)cb; // suppress unused parameter warning
wire = vpi_handle_by_name("test.w4", NULL);
if (wire) {
val.format = vpiIntVal;
val.value.integer = 1;
vpi_put_value(wire, &val, NULL, vpiNoDelay);
} else {
vpi_printf("Failed to get handle for w4\n");
}
wire = vpi_handle_by_name("test.w8", NULL);
if (wire) {
val.format = vpiIntVal;
val.value.integer = 1;
vpi_put_value(wire, &val, NULL, vpiNoDelay);
} else {
vpi_printf("Failed to get handle for w8\n");
}
wire = vpi_handle_by_name("test.wr", NULL);
if (wire) {
val.format = vpiRealVal;
val.value.real = 1.0;
vpi_put_value(wire, &val, NULL, vpiNoDelay);
} else {
vpi_printf("Failed to get handle for wr\n");
}
return 0;
}
static void register_cb(void)
{
struct t_cb_data cbd = {};
cbd.reason = cbStartOfSimulation;
cbd.cb_rtn = start_cb;
vpi_register_cb(&cbd);
}
void (*vlog_startup_routines[])(void) = {
register_cb,
0
};

20
ivtest/vpi/br_gh1041.v Normal file
View File

@ -0,0 +1,20 @@
module test;
wire w4;
tri0 w8;
wire real wr;
reg failed = 0;
initial begin
#0;
$display("w4 %b w8 %b wr %f", w4, w8, wr);
if (w4 !== 1'b1) failed = 1;
if (w8 !== 1'b1) failed = 1;
if (wr != 1.0) failed = 1;
if (failed)
$display("FAILED");
else
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,4 @@
Compiling vpi/br_gh1041.c...
Making br_gh1041.vpi from br_gh1041.o...
w4 1 w8 1 wr 1.000000
PASSED

View File

@ -71,6 +71,7 @@ br_gh308 normal br_gh308.c br_gh308.gold
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_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