diff options
Diffstat (limited to 'testsuite/gna/issue1228')
-rw-r--r-- | testsuite/gna/issue1228/test_load.vhdl | 29 | ||||
-rwxr-xr-x | testsuite/gna/issue1228/testsuite.sh | 24 | ||||
-rw-r--r-- | testsuite/gna/issue1228/vpi1.c | 46 |
3 files changed, 99 insertions, 0 deletions
diff --git a/testsuite/gna/issue1228/test_load.vhdl b/testsuite/gna/issue1228/test_load.vhdl new file mode 100644 index 000000000..dcfc0d7ce --- /dev/null +++ b/testsuite/gna/issue1228/test_load.vhdl @@ -0,0 +1,29 @@ +library ieee ; +use ieee.std_logic_1164.all; + +entity test_load is +end test_load; + +architecture RTL of test_load is + signal w : std_ulogic_vector(0 to 47); + signal \extend.id\ : std_ulogic := 'H'; + signal clk : std_logic; +begin + process + begin + for i in 1 to 10 loop + clk <= '0'; + wait for 1 ns; + clk <= '1'; + wait for 1 ns; + end loop; + wait; + end process; + + process(clk) + begin + if (clk'event and clk = '1') then + w <= not w; + end if; + end process; +end RTL; diff --git a/testsuite/gna/issue1228/testsuite.sh b/testsuite/gna/issue1228/testsuite.sh new file mode 100755 index 000000000..8f6ae63f1 --- /dev/null +++ b/testsuite/gna/issue1228/testsuite.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze test_load.vhdl +elab test_load + +if ghdl_has_feature test_load vpi; then + if [ "$OS" = "Windows_NT" ]; then + vpi_lib=`$GHDL --vpi-library-dir | sed -e 's!\\\\!/!g' -e 's!^C:!/C!g'` + echo vpi_lib: $vpi_lib + PATH="$PATH:$vpi_lib" + fi + + $GHDL --vpi-compile -v gcc -c vpi1.c + $GHDL --vpi-link -v gcc -o vpi1.vpi vpi1.o + + simulate test_load --vpi=./vpi1.vpi + + rm -f vpi1.vpi vpi1.o +fi +clean + +echo "Test successful" diff --git a/testsuite/gna/issue1228/vpi1.c b/testsuite/gna/issue1228/vpi1.c new file mode 100644 index 000000000..5b33087c0 --- /dev/null +++ b/testsuite/gna/issue1228/vpi1.c @@ -0,0 +1,46 @@ +#include <stdio.h> +#include <stdlib.h> +#include <vpi_user.h> + +static void +show_value (const char *name) +{ + vpiHandle net; + s_vpi_value val; + + net = vpi_handle_by_name ((char *)name, NULL); + if (net == NULL) + { + printf ("cannot get net: %s\n", name); + exit(1); + return; + } + val.format = vpiBinStrVal; + vpi_get_value (net, &val); + printf ("%s= %s\n", name, val.value.str); +} + +static PLI_INT32 +vpi_proc (struct t_cb_data *cb) +{ + show_value ("test_load.w"); + show_value ("test_load.\\extend.id\\"); + return 0; +} + +static void my_handle_register(void) +{ + s_cb_data cb; + + cb.reason = cbEndOfCompile; + cb.cb_rtn = &vpi_proc; + cb.user_data = NULL; + if (vpi_register_cb (&cb) == NULL) + vpi_printf ("cannot register EndOfCompile call back\n"); +} + +void (*vlog_startup_routines[]) () = +{ + my_handle_register, + 0 +}; |