• 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 64
  • Views 16991
  • 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
  • archive
    archive over 18 years ago

    Hi,
      Refer to IEEE LRM 26.6, it clearly says:

    "One important restriction exists. Class member functions cannot be exported, but all other SystemVerilog functions can be exported."

    So what you are seeing is legal restriction as per LRM.

    Regards
    Ajeetha, CVC
    www.noveldv.com


    Originally posted in cdnusers.org by ajeetha
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • 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
  • archive
    archive over 18 years ago

    I think you may have missed my problem due to the comments in my example.
    1. My C code is finding the exported functions just fine.
    2. My exported tasks need to access 'read' and 'write' tasks within the spi_driver class but I cannot find a way to do this.

    Hiererchical names don't work in a task declared at the package level so I can't refer to "read" and "write" with their full hierarchical names - which would seem illogical anyway as the package would no longer be portable. My question is, how can the spi_write task access the spi_driver.write task?


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

    Hi,

    We now have a product called Incisive Software Extensions (ISX) which, reading between the lines of your request, might be of interest, though it does not directly answer your System Verilog question. 

    ISX provides a mechanism to build a link between an advanced verification environment and your embedded software so that you can call embedded software functions and drive and monitor embedded software variables from the verification environment. The main difference between this and what you are doing right now is that ISX will maintain this interface capability irrespective of the Processor model kind, i.e. you can run it on you firmware compiled for the workstation as you are doing right now, and you can still use it when the embedded software is running on a processor model in the simulation, even if the model is an abstract ISS (Instruction Set Simulator) or the final RTL. We can even link to it if the design including the processor and software resides on an Accelerator or Emulator. 

    If you are interested to learn more about ISX please fell free to drop me a mail at giles@cadence.com 

    Best regards

    Giles


    Originally posted in cdnusers.org by giles
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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