From eb77ae0e52d9870105674677c6ec4914dda995ec Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 23 Sep 2016 03:21:39 +0200 Subject: Add testcase for issue #152 --- testsuite/gna/issue152/ax_wb_pli.vhdl | 30 ++++++++++++++++++++++++++ testsuite/gna/issue152/ax_wb_pli_c.c | 35 +++++++++++++++++++++++++++++++ testsuite/gna/issue152/ax_wb_pli_pkg.vhdl | 29 +++++++++++++++++++++++++ testsuite/gna/issue152/testsuite.sh | 12 +++++++++++ 4 files changed, 106 insertions(+) create mode 100644 testsuite/gna/issue152/ax_wb_pli.vhdl create mode 100644 testsuite/gna/issue152/ax_wb_pli_c.c create mode 100644 testsuite/gna/issue152/ax_wb_pli_pkg.vhdl create mode 100755 testsuite/gna/issue152/testsuite.sh (limited to 'testsuite/gna') diff --git a/testsuite/gna/issue152/ax_wb_pli.vhdl b/testsuite/gna/issue152/ax_wb_pli.vhdl new file mode 100644 index 000000000..13ac69253 --- /dev/null +++ b/testsuite/gna/issue152/ax_wb_pli.vhdl @@ -0,0 +1,30 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library work; +use work.ax_wb_pli_pkg.all; + +entity ax_wb_pli is +end entity ax_wb_pli; + +architecture behav of ax_wb_pli is + + constant cQUEUE_ID : integer := 0; + shared variable queue_handle : integer; + +begin + + + init_bus_handle : process + begin + queue_handle := init_queue(cQUEUE_ID); + if (queue_handle = 0) then + assert false report "Failed to register Message Queue"; + end if; + wait for 1 us; + delete_queue(cQUEUE_ID); + end process; + + +end behav; diff --git a/testsuite/gna/issue152/ax_wb_pli_c.c b/testsuite/gna/issue152/ax_wb_pli_c.c new file mode 100644 index 000000000..da5f3ce62 --- /dev/null +++ b/testsuite/gna/issue152/ax_wb_pli_c.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include + +int sim_init_queue (int qid) +{ + key_t key; + int msgqueue_id; + //struct mymsgbuf qbuf; + + /* Create unique key via call to ftok() */ + key = ftok(".", 'm'); + + /* Open the queue - create if necessary */ + if((msgqueue_id = msgget(key, IPC_CREAT|0660)) == -1) { + perror("msgget"); + exit(1); + } + return msgqueue_id; + +} + +int sim_delete_queue(int qid) +{ + + /* Remove the queue */ + msgctl(qid, IPC_RMID, 0); + + return 0; + +} + diff --git a/testsuite/gna/issue152/ax_wb_pli_pkg.vhdl b/testsuite/gna/issue152/ax_wb_pli_pkg.vhdl new file mode 100644 index 000000000..034da335e --- /dev/null +++ b/testsuite/gna/issue152/ax_wb_pli_pkg.vhdl @@ -0,0 +1,29 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package ax_wb_pli_pkg is + + type bus_t is access integer; + + function init_queue(queue_id : integer) return integer; + attribute foreign of init_queue : function is "VHPIDIRECT sim_init_queue"; + + procedure delete_queue(queue_id : integer); + attribute foreign of delete_queue : procedure is "VHPIDIRECT sim_delete_queue"; + +end package; + +package body ax_wb_pli_pkg is + + function init_queue(queue_id : integer) return integer is + begin + assert false report "VHPI" severity failure; + end function; + + procedure delete_queue(queue_id : integer) is + begin + assert false report "VHPI" severity failure; + end procedure; + +end package body; diff --git a/testsuite/gna/issue152/testsuite.sh b/testsuite/gna/issue152/testsuite.sh new file mode 100755 index 000000000..24d87992d --- /dev/null +++ b/testsuite/gna/issue152/testsuite.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze ax_wb_pli_pkg.vhdl +analyze ax_wb_pli.vhdl + +# Don't try to compile the C file, it's unix specific + +clean + +echo "Test successful" -- cgit v1.2.3