From a883f2afe65e5f7800edd21b1fdd2d3b7d47d1a4 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 8 Jul 2025 21:52:13 +0100 Subject: [PATCH] Add regression test for vpi_control() return value (issue #1208). --- ivtest/vpi/vpi_control.c | 49 +++++++++++++++++++++++++++++++++ ivtest/vpi/vpi_control.v | 9 ++++++ ivtest/vpi_gold/vpi_control.log | 5 ++++ ivtest/vpi_regress.list | 1 + 4 files changed, 64 insertions(+) create mode 100644 ivtest/vpi/vpi_control.c create mode 100644 ivtest/vpi/vpi_control.v create mode 100644 ivtest/vpi_gold/vpi_control.log diff --git a/ivtest/vpi/vpi_control.c b/ivtest/vpi/vpi_control.c new file mode 100644 index 000000000..6625da1fc --- /dev/null +++ b/ivtest/vpi/vpi_control.c @@ -0,0 +1,49 @@ +#include + +static PLI_INT32 test_control(PLI_BYTE8 *xx) +{ + int ret_val; + int failed = 0; + + (void)xx; /* Parameter is not used. */ + + ret_val = vpi_control(9999); + //vpi_printf("vpi_control(9999) returned %i\n", ret_val); + if (ret_val != 0) failed = 1; + + ret_val = vpi_sim_control(9999); + //vpi_printf("vpi_sim_control(9999) returned %i\n", ret_val); + if (ret_val != 0) failed = 1; + + ret_val = vpi_control(vpiFinish, 0); + //vpi_printf("vpi_control(vpiFinish, 1) returned %i\n", ret_val); + if (ret_val != 1) failed = 1; + + ret_val = vpi_sim_control(vpiFinish, 0); + //vpi_printf("vpi_sim_control(vpiFinish, 1) returned %i\n", ret_val); + if (ret_val != 1) failed = 1; + + if (failed) { + vpi_printf("FAILED\n"); + } else { + vpi_printf("PASSED\n"); + } + return 0; +} + +static void register_test_control(void) +{ + s_vpi_systf_data tf_data; + + tf_data.type = vpiSysTask; + tf_data.tfname = "$test_control"; + tf_data.calltf = test_control; + tf_data.compiletf = 0; + tf_data.sizetf = 0; + vpi_register_systf(&tf_data); +} + +void (*vlog_startup_routines[])(void) = { + register_test_control, + 0 +}; diff --git a/ivtest/vpi/vpi_control.v b/ivtest/vpi/vpi_control.v new file mode 100644 index 000000000..a21384b2d --- /dev/null +++ b/ivtest/vpi/vpi_control.v @@ -0,0 +1,9 @@ +module main(); + +initial begin + $test_control; + $display("Error: simulation should have finished"); + $display("FAILED"); +end + +endmodule diff --git a/ivtest/vpi_gold/vpi_control.log b/ivtest/vpi_gold/vpi_control.log new file mode 100644 index 000000000..15e1810c2 --- /dev/null +++ b/ivtest/vpi_gold/vpi_control.log @@ -0,0 +1,5 @@ +Compiling vpi/vpi_control.c... +Making vpi_control.vpi from vpi_control.o... +Unsupported VPI control operation 9999. +Unsupported VPI control operation 9999. +PASSED diff --git a/ivtest/vpi_regress.list b/ivtest/vpi_regress.list index 963c94c44..c3085accb 100644 --- a/ivtest/vpi_regress.list +++ b/ivtest/vpi_regress.list @@ -141,6 +141,7 @@ value_change_cb1 normal,-g2009 value_change_cb1.c value_change_cb1.gold value_change_cb2 normal,-g2009 value_change_cb2.c value_change_cb2.gold value_change_cb3 normal,-g2009 value_change_cb3.c value_change_cb3.gold value_change_cb4 normal,-g2009 value_change_cb4.c value_change_cb4.gold +vpi_control normal vpi_control.c vpi_control.log # Add new tests in alphabetic/numeric order. If the test needs # a compile option or a different log file to run with an older