• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. DPI and Classes

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 65
  • Views 17272
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DPI and Classes

archive
archive over 18 years ago

I'm using the DPI to instantiate and run our firmware and have a problem when the firmware tries to call exported tasks.

I cannot seem to do an export on a class tasks so I have to declare my export tasks outside of the class.

However, I don't know how to call the class member task (which is what I really want) from these outside tasks.


This is my code.  I've tried hierarchical names to get the the write and read member tasks in the driver but get the following error from ncvlog:

  test.prgm.sys.spi.drv.read(address, data);
                                                 |
ncvlog: *E,ILLHIN (../tb/spi/spi_driver.sv,52|49): illegal location for a hierarchical name (in a package).

-------------------------------------------

export

"DPI-C" SV_spi_read = task spi_read;
export "DPI-C" SV_spi_write = task spi_write;

class spi_driver;
extern function new;
extern task write;
extern task read;
endclass : spi_driver

function spi_driver::new;
$display("spi_driver::new()");
endfunction : new

task spi_driver::write(input byte address, input byte data);
$display("spi_write of %x to address %x", data, address);
endtask : write

task spi_driver::read( input byte address, output byte data);;
$display("spi_read of address %x", address);
endtask : read



/////////////////////////////////////////////////////////////
//
// I cannot figure out how to export a class member task to the DPI so
// these two functions are stand-alone functions.
//
task spi_read( input byte address, output byte data);
$display("spi_read of address %x", address);
spi_driver
::spi_read(Address, data);  // I don't know how to call class member from here.
endtask
: spi_read

task spi_write(input byte address, input byte data);
$display("spi_write of %x to address %x", data, address);
spi_driver
::spi_write(Address, data);  // I don't know how to call class member from here.
endtask : spi_write

----------------------------
Originally posted in cdnusers.org by dfechser
  • Cancel
Parents
  • archive
    archive over 18 years ago

    I was playing around with some example code - modifying my previous example on this forum called "Example Test Bench Using Interface and Classes". I inserted the dpi import/export declarations, and the export function inside the interface, and I was able to access the import function from both modules attached to the interface. Perhaps you can use this methodology. Email me for the complete example: tmackett@cadence.com


    Originally posted in cdnusers.org by tmackett
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • archive
    archive over 18 years ago

    I was playing around with some example code - modifying my previous example on this forum called "Example Test Bench Using Interface and Classes". I inserted the dpi import/export declarations, and the export function inside the interface, and I was able to access the import function from both modules attached to the interface. Perhaps you can use this methodology. Email me for the complete example: tmackett@cadence.com


    Originally posted in cdnusers.org by tmackett
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information