RE: [sv-cc] dynamic arrays and open arrays


Subject: RE: [sv-cc] dynamic arrays and open arrays
From: Joao Geada (Joao.Geada@synopsys.com)
Date: Wed Aug 13 2003 - 11:47:35 PDT


I am unsure about this simplification. On one side, yes, it simplifies the
implementation of DPI; however, I believe it also removes some necessary
flexibility.

Specifically, in SV users typically use parameterization to control the "shape"**
of objects and would use dynamic arrays to permit an arbitrary number of these
objects to be stored in an array. Even without dynamic arrays parameterization
permits flexibility in the size of dimensions.
** shape = number & size of each dimension

For example:

module foo #(parameter SIZE, WIDTH)(input bit [0:WIDTH][0:SIZE] packetarray,
                                              input bit [0:SIZE] packet);

  integer c;

  function integer findpacket(input bit [0:WIDTH][0:SIZE] packetarray, input bit [0:SIZE] packet);
        // some code to locate entry containing a specific packet
  endfunction

  always @(posedge someclock) begin
        c = findpacket(packetarray, packet);
  end
endmodule

In the DPI as currently in the standard we can model the same kind of capabilty
as follows:

module foo #(parameter SIZE, WIDTH)(input bit [0:WIDTH][0:SIZE] packetarray,
                                                input bit [0:SIZE] packet);

  integer c;

  import "DPI" function integer findpacket(input bit [][] packetarray, input bit [] packet);

  always @(posedge someclock) begin
        c = findpacket(packetarray, packet);
  end
endmodule

NOTE that the DPI function *must* use open arrays with 2 unspecified dimensions because
the signature of all the "findpacket" imported functions across all instances of "foo"
must match. Given that the dimension is paramerized, this can only be accomplished
by use of open arrays.
Note also that, from the usage side, none of the code invoking "findpacket" needs to
be modified. *THIS*, I believe, is the important point: there is no incompatibility
between open arrays and normal SV arrays. It is merely a required interfacing
syntax/mechanism to address the "impedence mismatch" between the Verilog and C domains.
On the usage side and on the Verilog side there is no semantic mismatch: open
arrays behave exactly the same as if that particular argument happened to be
specified as an array with the appr. number of dimensions of right size.

Joao
==============================================================================
Joao Geada, PhD Principal Engineer Verif Tech Group
Synopsys, Inc TEL: (508) 263-8083
377 Simarano Drive, Suite 300, FAX: (508) 263-8069
Marlboro, MA 01752, USA
==============================================================================



This archive was generated by hypermail 2b28 : Wed Aug 13 2003 - 12:31:38 PDT