aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/vpi/vpi004/vpi1.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/vpi/vpi004/vpi1.c')
-rw-r--r--testsuite/vpi/vpi004/vpi1.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/testsuite/vpi/vpi004/vpi1.c b/testsuite/vpi/vpi004/vpi1.c
new file mode 100644
index 000000000..96c6f3809
--- /dev/null
+++ b/testsuite/vpi/vpi004/vpi1.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <vpi_user.h>
+#define N_NAMES 12
+
+void
+vpi_proc (void)
+{
+ s_vpi_vlog_info info;
+ printf ("Trying to get vlog_info\n");
+ int ret = vpi_get_vlog_info(&info);
+ if (ret != 1) {
+ printf ("Error: Failed to get vlog_info\n");
+ return;
+ }
+
+ if (info.argc < 1) {
+ printf ("Error: Argc was 0\n");
+ return;
+ }
+ printf ("Argc: %d\n", info.argc);
+
+ for (int i = 0; i < info.argc; i++) {
+ printf ("Argv[%d]: %s\n", i, info.argv[i]);
+ }
+
+ if (info.product == NULL) {
+ printf ("Error: product is NULL\n");
+ return;
+ }
+ printf ("Product: %s\n", info.product);
+
+ if (info.version == NULL) {
+ printf ("Error: version is NULL\n");
+ return;
+ }
+ printf ("Version: %s\n", info.version);
+}
+
+void my_handle_register()
+{
+ s_cb_data cb;
+ printf ("Hello world\n");
+
+ cb.reason = cbStartOfSimulation;
+ cb.cb_rtn = &vpi_proc;
+ cb.user_data = NULL;
+ if (vpi_register_cb (&cb) == NULL)
+ vpi_printf ("Error: Cannot register StartOfSimulation call back\n");
+}
+
+void (*vlog_startup_routines[]) () =
+{
+ my_handle_register,
+ 0
+};