• 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. Manipulating Unpacked Arrays using DPI

Stats

  • Locked Locked
  • Replies 0
  • Subscribers 64
  • Views 13814
  • 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

Manipulating Unpacked Arrays using DPI

archive
archive over 18 years ago

I'm sharing this code which is a demo of how to manipulate a SystemVerilog Unpacked Array using DPI. This code will work with IUS5.83. -----file top.v-------- module top (); `define ARRAY_LO 4 `define ARRAY_HI 13 int xyz[`ARRAY_HI: `ARRAY_LO]; // define import function to pass reference to // open array of int's. This makes the call generic for // any array size. import "DPI-C" context function void doArray(inout int abc[] ); initial begin // stuff the packed structure with data for (int i = `ARRAY_LO; i #include // Created by Todd Mackett (tmackett@cadence.com) with some help from // Abhishek Raheja void doArray(const svOpenArrayHandle x ) { // pass in open handle io_printf("Array Handle is %x \n", x); io_printf("Array Pointer is %x \n", svGetArrayPtr(x) ); io_printf("Array Left %d, Array Right %d \n", svLeft(x,1), svRight(x, 1) ); io_printf("Array Low %d, Array High %d \n", svLow(x,1), svHigh(x, 1) ); //io_printf("Length %d \n", svLength(x,1) ); // not implemented 6.02v138 // io_printf("%d \n", svDimensions(x )); // not implemented 6.02v138 io_printf("Size of Array in bytes %d \n", svSizeOfArray(x) ); // returns bytes // Print out 1Darray contents using Array Low to High indexes int i; for (i= svLow(x,1); i run Array Handle is 938d8c8 Array Pointer is 93f6a00 Array Left 13, Array Right 4 Array Low 4, Array High 13 Size of Array in bytes 40 DPI: 4 is: 77775559 DPI: 5 is: 7777555a DPI: 6 is: 7777555b DPI: 7 is: 7777555c DPI: 8 is: 7777555d DPI: 9 is: 7777555e DPI: 10 is: 7777555f DPI: 11 is: 77775560 DPI: 12 is: 77775561 DPI: 13 is: 77775562 DPI2: 0 22221111 DPI2: 1 22221112 DPI2: 2 22221113 DPI2: 3 22221114 DPI2: 4 22221115 DPI2: 5 22221116 DPI2: 6 22221117 DPI2: 7 22221118 DPI2: 8 22221119 DPI2: 9 2222111a Vlog: 4 22221111 Vlog: 5 22221112 Vlog: 6 22221113 Vlog: 7 22221114 Vlog: 8 22221115 Vlog: 9 22221116 Vlog: 10 22221117 Vlog: 11 22221118 Vlog: 12 22221119 Vlog: 13 2222111a ncsim: *W,RNQUIE: Simulation is complete. ncsim> exit TOOL: ncverilog 05.83-p003: Exiting on Feb 05, 2007 at 11:29:36 EST (total: 00:00:03)


Originally posted in cdnusers.org by tmackett
  • 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