Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dpi exported tasks with array inputs don't compile. #385

Closed
veripoolbot opened this issue Sep 2, 2011 · 8 comments
Closed

Dpi exported tasks with array inputs don't compile. #385

veripoolbot opened this issue Sep 2, 2011 · 8 comments
Assignees
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800

Comments

@veripoolbot
Copy link
Contributor


Author Name: Thomas Watts
Original Redmine Issue: 385 from https://www.veripool.org

Original Assignee: Wilson Snyder (@wsnyder)


Compiling the following with verilator --lint_only gives the error message

Unsupported: Assignment between packed arrays of different dimensions

    export "DPI-C" task dpi_bytes;
    task dpi_bytes;
       input byte bytes [1:0];
    endtask

I've also tried declaring an input string (which admittedly is documented as unsupported).

Are there any plans to support this sort of thing, or any workarounds?

Thanks,
Tom.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2011-09-04T21:26:44Z


Are you trying to pass a string? Strings aren't represented as an array of bytes in verilog, but rather one long number, so you'd do this

task dpi_bytes;
input field [2*8-1:0];

Then in C you'd need to convert the null terminated string to the proper width. Or use a SystemVerilog string, but ;)

As for the original question, there isn't any array support across the DPI yet. If that is really what you're trying to do, and this example code works in other simulators, it shouldn't be too hard, let me know and I'll look.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Thomas Watts
Original Date: 2011-09-05T10:03:33Z


I'm actually trying to pass a transaction of 10s of bytes from C to Verilog. I was hoping to assemble the bytes in a C char array and pass through the DPI to a System Verilog array of bytes. Although using a string or large vector wouldn't be too difficult as you suggest.

However I can't get any of these three approaches to work with Verilator. 2-D arrays get the message as described in the original bug report, strings and vectors larger than 32-bits are unsupported.

I am developing this code to be portable and it does work in another simulator. I pass the dpi function a const char * and can index the bytes in System Verilog.

Let me know if I can help with testcases or beta testing.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2011-09-05T16:44:00Z


DPI exports of wide vectors should be supported, there's a test case in test_regress/t/t_dpi_export.v; if you could modify that file to show the failure and to show an example of what you'd like I'll do what I can. (Run it with test_regress/t/t_dpi_export.pl [--vcs] [--nc])

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Thomas Watts
Original Date: 2011-09-06T16:54:59Z


I was using 3.812, updating to 3.820 fixes large vectors. So I have things working with packing / unpacking across the dpi call.

The passing of arrays would be useful, as it would be much cleaner, but can be worked around.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2011-11-29T03:13:06Z


Have workaround; revisit when data type changes in.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Guy Hutchison
Original Date: 2012-06-27T20:31:04Z


I'd like to bump this as a requested feature; I'm working on a driver where passing variable-length data would be very helpful, of the form:

integer nq_insert_packet (input string qname, input bit [7:0] in_pkt[]);

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-07-15T15:19:25Z


I'm not actively working on DPI improvements, so there will be a good wait. If you would like to try to make the improvements yourself, this would be greatly appreciated, and I can provide pointers.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-06-29T10:24:32Z


Forgot to close; open array support was added in 3.918 2018-01-02.

@veripoolbot veripoolbot added resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800 labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800
Projects
None yet
Development

No branches or pull requests

2 participants