diff options
author | Marlon James <marlon.james@gmail.com> | 2021-04-17 15:08:50 -0700 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-04-18 17:34:57 +0200 |
commit | 90ac6b099104d285babbf0bce15cd735bf790336 (patch) | |
tree | d099bc04b7d897b239b263fc9f4d7ec0ea6b01c4 /testsuite/vhpi | |
parent | e9de3601fcd8e164ffcbf8243b45619d72a4ef3a (diff) | |
download | ghdl-90ac6b099104d285babbf0bce15cd735bf790336.tar.gz ghdl-90ac6b099104d285babbf0bce15cd735bf790336.tar.bz2 ghdl-90ac6b099104d285babbf0bce15cd735bf790336.zip |
VHPI: add tracing tests
Diffstat (limited to 'testsuite/vhpi')
-rw-r--r-- | testsuite/vhpi/001load_lib/vhpi_lib.c | 2 | ||||
-rw-r--r-- | testsuite/vhpi/002load_entrypoint/vhpi_lib.c | 2 | ||||
-rw-r--r-- | testsuite/vhpi/003load_multi_lib/vhpi_lib1.c | 2 | ||||
-rw-r--r-- | testsuite/vhpi/003load_multi_lib/vhpi_lib2.c | 2 | ||||
-rw-r--r-- | testsuite/vhpi/004trace_stdout/mydesign.vhdl | 9 | ||||
-rwxr-xr-x | testsuite/vhpi/004trace_stdout/testsuite.sh | 36 | ||||
-rw-r--r-- | testsuite/vhpi/004trace_stdout/vhpi_lib.c | 33 | ||||
-rw-r--r-- | testsuite/vhpi/005trace_file/mydesign.vhdl | 9 | ||||
-rwxr-xr-x | testsuite/vhpi/005trace_file/testsuite.sh | 32 | ||||
-rw-r--r-- | testsuite/vhpi/005trace_file/vhpi_lib.c | 31 |
10 files changed, 154 insertions, 4 deletions
diff --git a/testsuite/vhpi/001load_lib/vhpi_lib.c b/testsuite/vhpi/001load_lib/vhpi_lib.c index 46b70ede4..a137ecd43 100644 --- a/testsuite/vhpi/001load_lib/vhpi_lib.c +++ b/testsuite/vhpi/001load_lib/vhpi_lib.c @@ -1,5 +1,5 @@ #include <stdio.h> -#include <vpi_user.h> +#include <vhpi_user.h> void my_startup() { diff --git a/testsuite/vhpi/002load_entrypoint/vhpi_lib.c b/testsuite/vhpi/002load_entrypoint/vhpi_lib.c index 414eac731..625dbf408 100644 --- a/testsuite/vhpi/002load_entrypoint/vhpi_lib.c +++ b/testsuite/vhpi/002load_entrypoint/vhpi_lib.c @@ -1,5 +1,5 @@ #include <stdio.h> -#include <vpi_user.h> +#include <vhpi_user.h> void my_startup() { diff --git a/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c b/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c index 3a9ceaf2a..5798ca88d 100644 --- a/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c +++ b/testsuite/vhpi/003load_multi_lib/vhpi_lib1.c @@ -1,5 +1,5 @@ #include <stdio.h> -#include <vpi_user.h> +#include <vhpi_user.h> void my_startup() { diff --git a/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c b/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c index b1f6c7119..329d6acec 100644 --- a/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c +++ b/testsuite/vhpi/003load_multi_lib/vhpi_lib2.c @@ -1,5 +1,5 @@ #include <stdio.h> -#include <vpi_user.h> +#include <vhpi_user.h> void my_startup() { diff --git a/testsuite/vhpi/004trace_stdout/mydesign.vhdl b/testsuite/vhpi/004trace_stdout/mydesign.vhdl new file mode 100644 index 000000000..38fdfda98 --- /dev/null +++ b/testsuite/vhpi/004trace_stdout/mydesign.vhdl @@ -0,0 +1,9 @@ +library ieee ; +use ieee.std_logic_1164.all; + +entity myentity is +end myentity; + +architecture arch of myentity is +begin +end arch; diff --git a/testsuite/vhpi/004trace_stdout/testsuite.sh b/testsuite/vhpi/004trace_stdout/testsuite.sh new file mode 100755 index 000000000..870aef605 --- /dev/null +++ b/testsuite/vhpi/004trace_stdout/testsuite.sh @@ -0,0 +1,36 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze mydesign.vhdl +elab myentity + +if c_compiler_is_available && ghdl_has_feature myentity vhpi; then + $GHDL --vpi-compile -v gcc -c vhpi_lib.c + $GHDL --vpi-link -v gcc -o vhpi_lib.vhpi vhpi_lib.o + + add_vpi_path + + simulate myentity --vhpi=./vhpi_lib.vhpi --vhpi-trace | tee myentity.out + if grep -q Error myentity.out; then + echo "Error in output" + exit 1; + fi + if grep -q error myentity.out; then + echo "error in output" + exit 1; + fi + if ! grep -q "vhpi_register_cb (" myentity.out; then + echo "VHPI trace missing" + exit 1; + fi + if ! grep -q "VHPI printf" myentity.out; then + echo "VHPI printf missing" + exit 1; + fi + + rm -f vhpi_lib.vhpi vhpi_lib.o myentity.out +fi +clean + +echo "Test successful" diff --git a/testsuite/vhpi/004trace_stdout/vhpi_lib.c b/testsuite/vhpi/004trace_stdout/vhpi_lib.c new file mode 100644 index 000000000..1bc1fca00 --- /dev/null +++ b/testsuite/vhpi/004trace_stdout/vhpi_lib.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <vhpi_user.h> + + +void my_callback(const vhpiCbDataT * cb_data) { +} + +void my_startup() +{ + printf ("VHPI lib\n"); + + vhpi_printf("VHPI printf\n"); + + vhpiCbDataT cb_data; + vhpiTimeT time; + + cb_data.reason = vhpiCbStartOfSimulation; + cb_data.cb_rtn = my_callback; + cb_data.obj = NULL; + cb_data.time = &time; + cb_data.value = NULL; + cb_data.user_data = (char *)NULL; + time.high = 0; + time.low = 0; + + vhpi_register_cb(&cb_data, NULL); +} + +void (*vhpi_startup_routines[]) () = +{ + my_startup, + 0 +}; diff --git a/testsuite/vhpi/005trace_file/mydesign.vhdl b/testsuite/vhpi/005trace_file/mydesign.vhdl new file mode 100644 index 000000000..38fdfda98 --- /dev/null +++ b/testsuite/vhpi/005trace_file/mydesign.vhdl @@ -0,0 +1,9 @@ +library ieee ; +use ieee.std_logic_1164.all; + +entity myentity is +end myentity; + +architecture arch of myentity is +begin +end arch; diff --git a/testsuite/vhpi/005trace_file/testsuite.sh b/testsuite/vhpi/005trace_file/testsuite.sh new file mode 100755 index 000000000..24f3ddd9f --- /dev/null +++ b/testsuite/vhpi/005trace_file/testsuite.sh @@ -0,0 +1,32 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze mydesign.vhdl +elab myentity + +if c_compiler_is_available && ghdl_has_feature myentity vhpi; then + $GHDL --vpi-compile -v gcc -c vhpi_lib.c + $GHDL --vpi-link -v gcc -o vhpi_lib.vhpi vhpi_lib.o + + add_vpi_path + + simulate myentity --vhpi=./vhpi_lib.vhpi --vhpi-trace=./vhpi_trace.log | tee myentity.out + if grep -q Error myentity.out; then + echo "Error in output" + exit 1; + fi + if grep -q error myentity.out; then + echo "error in output" + exit 1; + fi + if ! grep -q "vhpi_register_cb (" vhpi_trace.log; then + echo "VHPI trace missing" + exit 1; + fi + + rm -f vhpi_lib.vhpi vhpi_lib.o myentity.out vhpi_trace.log +fi +clean + +echo "Test successful" diff --git a/testsuite/vhpi/005trace_file/vhpi_lib.c b/testsuite/vhpi/005trace_file/vhpi_lib.c new file mode 100644 index 000000000..66ce5e115 --- /dev/null +++ b/testsuite/vhpi/005trace_file/vhpi_lib.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <vhpi_user.h> + + +void my_callback(const vhpiCbDataT * cb_data) { +} + +void my_startup() +{ + printf ("VHPI lib\n"); + + vhpiCbDataT cb_data; + vhpiTimeT time; + + cb_data.reason = vhpiCbStartOfSimulation; + cb_data.cb_rtn = my_callback; + cb_data.obj = NULL; + cb_data.time = &time; + cb_data.value = NULL; + cb_data.user_data = (char *)NULL; + time.high = 0; + time.low = 0; + + vhpi_register_cb(&cb_data, NULL); +} + +void (*vhpi_startup_routines[]) () = +{ + my_startup, + 0 +}; |