 |
bluespec.com Bluespec Forums
|
View previous topic :: View next topic |
Author |
Message |
asutherland
Joined: 16 Dec 2013 Posts: 4
|
Posted: Wed Sep 24, 2014 6:49 pm Post subject: BSC 2014.05.C Generated VPI wrapper crashes iverilog sim |
|
|
I have a BDPI function:
import "BDPI" function ActionValue#(Bit#(32)) read_pixel();
The generated vpi_wrapper causes iverilog simulator to crash trying to free a null pointer. This can be corrected by commenting out 3 lines of unused code. (see version below)
Code: | /* VPI wrapper function */
PLI_INT32 read_pixel_calltf(PLI_BYTE8 *user_data)
{
vpiHandle hCall;
unsigned int vpi_result;
vpiHandle *handle_array;
/* retrieve handle array */
hCall = vpi_handle(vpiSysTfCall, 0);
handle_array = vpi_get_userdata(hCall);
if (handle_array == NULL)
{
vpiHandle hArgList;
hArgList = vpi_iterate(vpiArgument, hCall);
handle_array = malloc(sizeof(vpiHandle) * 1u);
handle_array[0u] = hCall;
vpi_put_userdata(hCall, handle_array);
vpi_free_object(hArgList); <----------------------------------------------------------------------------
}
/* create return value */
make_vpi_result(handle_array[0u], &vpi_result, DIRECT);
/* call the imported C function */
vpi_result = read_pixel();
/* copy out return value */
put_vpi_result(handle_array[0u], &vpi_result, DIRECT);
vpi_free_object(hCall);
return 0;
}
|
Comment out unused hArgList to correct.
Code: | ...
if (handle_array == NULL)
{
// vpiHandle hArgList;
// hArgList = vpi_iterate(vpiArgument, hCall);
handle_array = malloc(sizeof(vpiHandle) * 1u);
handle_array[0u] = hCall;
vpi_put_userdata(hCall, handle_array);
// vpi_free_object(hArgList);
}
... |
|
|
Back to top |
|
 |
quark Site Admin
Joined: 02 Nov 2007 Posts: 496
|
Posted: Thu Sep 25, 2014 2:10 pm Post subject: Re: BSC 2014.05.C Generated VPI wrapper crashes iverilog sim |
|
|
I am able to reproduce this problem, with iverilog 0.9.7. I get this error:
Code: | vvp: vpi_priv.cc:138: PLI_INT32 vpi_free_object(__vpiHandle*): Assertion `ref' failed.
Abort
|
The example works when using a commercial simulator, though. So it may be a bug in iverilog. I'll have a look. Thank you for reporting this issue. |
|
Back to top |
|
 |
asutherland
Joined: 16 Dec 2013 Posts: 4
|
Posted: Mon Sep 29, 2014 3:24 pm Post subject: |
|
|
Just realized that adding a dummy param is a work around for this.
Obvious, but it took me a while to get there. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|