1. Export declarations require:

 

-        a means to declare that a SV function is to be made accessible to a foreign programming language (e.g. C);

-        specifying a function as exported does not change its semantics or usage

-        must allow an optional identifier to be used in the foreign code; by default foreign name and System Verilog name will be identical

-        must provide full hierarchical path identifying a unique instance (unless $root scope function)

 

Note: tasks may not be exported; therefore there is no need for redundant keyword "function"; similarly there is no need for repeating function result types and argument specification. However such redundancy may be desirable for language consistency.

 

2. Extern declarations require:

 

-        a means to declare that a SV visible function is to be provided by a foreign programming language (eg C) (ie function's body is foreign)

-        must provide function result type and directions and types of formal arguments; the syntax should be as close as possible to the syntax for SV function declarations; note that DirectC extends the syntax for specifying types of formal arguments by allowing unsized ranges, denoted by '[]'.

-        in SV syntax, invocation of the functions declared as extern must be identical to invocation of any other normally declared SV function

-        additionally provide further information about the function. Specifically, as SV compiler will not have visibility into the implementation of the function, it needs to know:

1.    whether the function is 'pure', meaning all invocations with same arguments result in the same output values and have no side effects whatsoever; 'pure' function must not have inout or output arguments.

2.    whether the function needs to be aware of its context (such as current instance)

3.    whether the function will make use of any other SV API such that it may access (read or write) signals other than those being passed through the function's argument list.

 

Actually, we plan to bundle 2 and 3 together, they are also mutually exclusive with 1; therefore there are 3 possible combinations:

1)    default

2)    'pure'

3)    'context' denoting (ii)+(iii)

 

Note: It is an option to have an identifier representing the foreign function name. This is only supported for symmetry with export declaration, if required, but this is not required by SV-CC.