diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-15 22:08:47 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-15 22:09:25 +0200 |
commit | 7631efdb99efa6dd0cd1689127f5b7dcfe5d3d07 (patch) | |
tree | 7d348e48039494bbacc94a31af7df519d6cbe4b4 /testsuite/gna/issue1228 | |
parent | 80c4f065d529ea257dd6e364c8a97a1c649e0bcc (diff) | |
download | ghdl-7631efdb99efa6dd0cd1689127f5b7dcfe5d3d07.tar.gz ghdl-7631efdb99efa6dd0cd1689127f5b7dcfe5d3d07.tar.bz2 ghdl-7631efdb99efa6dd0cd1689127f5b7dcfe5d3d07.zip |
testsuite/gna: add a test for #1228
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 +}; |