-
-
Notifications
You must be signed in to change notification settings - Fork 94
Closed
Description
Given the following VHPI impl. of a procedure that sets an output to 1
. The one with an type of simply integer
works. The one with a more specific integer range 0 to 5
fails.
vhpi.vhd:
ENTITY vhpi IS
BEGIN
END ENTITY;
ARCHITECTURE arch OF vhpi IS
PROCEDURE intout (i : OUT INTEGER) IS
BEGIN
REPORT "ERROR: foreign subprogram 'vhpi_intout' not called" SEVERITY failure;
END PROCEDURE;
ATTRIBUTE foreign OF intout : PROCEDURE IS "VHPI vhpi.so vhpi_intout";
--
PROCEDURE rangedintout (i : OUT INTEGER RANGE 0 TO 5) IS
BEGIN
REPORT "ERROR: foreign subprogram 'vhpi_rangedintout' not called" SEVERITY failure;
END PROCEDURE;
ATTRIBUTE foreign OF rangedintout : PROCEDURE IS "VHPI vhpi.so vhpi_rangedintout";
BEGIN
test : PROCESS IS
VARIABLE i : INTEGER := 0;
VARIABLE j : INTEGER := 0;
BEGIN
intout(i);
ASSERT i = 1;
rangedintout(j);
ASSERT j = 1; -- fails
WAIT;
END PROCESS;
END ARCHITECTURE;
vhpi.c:
#include <vhpi_user.h>
static void vhpi_intout(const vhpiCbDataT *cb_data)
{
vhpiHandleT i_h = vhpi_handle_by_index(vhpiParamDecls, cb_data->obj, 0);
vhpiValueT int_v = {.format = vhpiIntVal};
int_v.value.intg = 1;
vhpi_put_value(i_h, &int_v, vhpiDepositPropagate);
vhpi_release_handle(i_h);
}
static void vhpi_register(const vhpiCbDataT *cb_data)
{
vhpiHandleT cb_h;
vhpiForeignDataT foreign_intout = {
vhpiProcF, "vhpi.so", "vhpi_intout", NULL, vhpi_intout};
cb_h = vhpi_register_foreignf(&foreign_intout);
vhpi_release_handle(cb_h);
vhpiForeignDataT foreign_rangedintout = {
vhpiProcF, "vhpi.so", "vhpi_rangedintout", NULL, vhpi_intout};
cb_h = vhpi_register_foreignf(&foreign_rangedintout);
vhpi_release_handle(cb_h);
}
void (*vhpi_startup_routines[])() = {
vhpi_register,
NULL};
vhpi.sh:
#!/usr/bin/env bash
set -ex
gcc -shared -fPIC -o vhpi.so vhpi.c
nvc -a vhpi.vhd
nvc -L. -e vhpi
nvc -L. -r --load ./vhpi.so --vhpi-debug vhpi
Output:
** Note: loading VHPI plugin ./vhpi.so
** Error: 0ms+0: Assertion violation.
> vhpi.vhd:25
|
25 | ASSERT j = 1; -- fails
| ^^^^^ 0 = 1 is false
I expected the out parameter to be set accordingly, or at least an error to be 1) returned by VHPI API or 2) emitted by NVC.
Cheers, Nik
Metadata
Metadata
Assignees
Labels
No labels