diff options
Diffstat (limited to 'testsuite/vhpi/004trace_stdout')
-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 |
3 files changed, 78 insertions, 0 deletions
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 +}; |