mantis items 1456 and 1488 from sv-cc committee

From: John Stickley <john_stickley_at_.....>
Date: Mon Oct 23 2006 - 13:41:35 PDT
Greetings ITC Techies,

As per one of my AIs from last meeting, I've attached
the full text of Mantis items 1456 and 1488.

This is the reworded text regarding calling exported
functions and SV utility functions from areas in C
code outside of imported DPI function contexts.

-- johnS

This email may contain material that is confidential, privileged
and/or attorney work product for the sole use of the intended
recipient.  Any review, reliance or distribution by others or
forwarding without express permission        /\
is strictly prohibited. If you are     /\   |  \
not the intended recipient please     |  \ /   |
contact the sender and delete        /    \     \
all copies.                      /\_/  K2  \_    \_
______________________________/\/            \     \
John Stickley                   \             \     \
Mgr., Acceleration Methodologies \             \________________
Mentor Graphics - MED             \_
17 E. Cedar Place                   \   john_stickley@mentor.com
Ramsey, NJ  07446                    \     Phone: (201) 818-2585
________________________________________________________________

In 5

 

In F.5.5 Context and noncontext tasks and functions

 

Replace

 

The SystemVerilog context of DPI export tasks and functions must be known when they are called, including when they are called by imports. When an import invokes the svSetScope utility prior to calling the export, it sets the context explicitly. Otherwise, the context will be the context of the instantiated scope where the import declaration is located. Because imports with diverse instantiated scopes can export the same task or function, multiple instances of such an export can exist after elaboration. Prior to any invocations of svSetScope, these export instances would have different contexts, which would reflect their imported caller’s instantiated scope.

 

With

 

The SystemVerilog context of DPI export tasks and functions must be known when they are called, including when they are called by SystemVerilog functions or tasks, or they are called by DPI imports . When an import invokes the svSetScope utility prior to calling the export, it sets the context explicitly. Otherwise, the context will be the context of the instantiated scope where the import declaration is located. Because imports with diverse instantiated scopes can export the same task or function, multiple instances of such an export can exist after elaboration. Prior to any invocations of svSetScope, these export instances would have different contexts, which would reflect their imported caller’s instantiated scope.

 

 

In F.8. Context tasks and functions

 

Replace

 

To avoid any unnecessary overhead, imported task and function calls in SystemVerilog code are not instrumented unless the imported task or function is specified as context in its SystemVerilog import declaration. A small set of DPI utility functions are available to assist programmers when working with context tasks or functions (see F.8.3). If those utility  functions are used with any noncontext function, a system error shall result.

 

With

 

To avoid any unnecessary overhead, imported task and function calls in SystemVerilog code are not instrumented unless the imported task or function is specified as context in its SystemVerilog import declaration. A DPI-C context ‘call chain’ is a sequence of C function or task invocations that starts with a SystemVerilog entity calling a DPI-C import declared with the context keyword and continues in C, unbroken by a call back into SystemVerilog.  A small set of DPI utility functions are is available to assist programmers when working with context tasks or functions (see F.8.3). If those The behavior of DPI utility  functions are used with any noncontext function, a system error shall result that manipulate context is undefined when they are invoked by any function or task that is not part of a DPI context call chain (see 26.4.3). Similarly, the behavior of exported tasks or functions is undefined when they are invoked by a DPI call chain that lacks the context characteristic.

 

In F 8.2 Context of imported and export tasks and functions

 

Replace

 

The context property is transitive through imported and export context tasks and functions… The system shall behave identically regardless if f() or f’() is on the call chain able g(). g() has the proper execution context in both cases.

 

With

 

The context property is transitive through imported and export context tasks and functions… The system shall behave identically regardless if f() or f’() is on the call chain able g(). g() has the proper execution context in both cases.

 

When control passes across the boundary between SystemVerilog and a DPI import call chain with the context property, the value of the import’s context is potentially either set or reset (26.4.3). Therefore, user code behavior is undefined for DPI import C code that circumvents SystemVerilog exports unwinding across the boundary to their import caller (e.g., by using C setjmp and longjmp constructs).

 

In F 8.3 Working with DPI context tasks and functions in C code

 

Replace

 

DPI defines a small set of functions to help programmers work with DPI context tasks and functions. The term scope is used in the task or function names for consistency with other SystemVerilog terminology. The terms scope and context are equivalent for DPI tasks and functions.

 

There are functions that allow the user to retrieve and manipulate the current operational scope. It is an error to use these functions with any C code that is not executing under a call to a DPI context imported task or function.

 

With

 

DPI defines a small set of functions to help programmers work with DPI context tasks and functions. The term scope is used in the task or function names for consistency with other SystemVerilog terminology. The terms scope and context are equivalent for DPI tasks and functions. A DPI context imported task or function is declared with the context keyword. A DPI-C context ‘call chain’ is a sequence of calls to C functions or tasks that begins with a SystemVerilog entity calling a DPI context import and continues in C, unbroken by a call back into SystemVerilog.

 

There are functions that allow the user to retrieve and manipulate the current operational scope. It is an error to use The behavior of these functions is undefined if they are invoked by an entity other than with any C code that is not executing under a call to a member of a DPI context call chain imported task or function. The behavior of exported tasks or functions is undefined when they are invoked by a DPI call chain that lacks the context characteristic.

 

 

In 5

 

In 26.4.3 Context tasks and functions

 

Replace

 

The SystemVerilog context of DPI export tasks and functions must be known when they are called, including when they are called by imports. When an import invokes the svSetScope utility prior to calling the export, it sets the context explicitly. Otherwise, the context will be the context of the instantiated scope where the import declaration is located. Because imports with diverse instantiated scopes can export the same task or function, multiple instances of such an export can exist after elaboration. Prior to any invocations of svSetScope, these export instances would have different contexts, which would reflect their imported caller’s instantiated scope.

 

With

 

The SystemVerilog context of DPI export tasks and functions must be known when they are called, including when they are called by imports. When an import invokes the svSetScope utility prior to calling the export, it sets the context explicitly. Otherwise, the context will be the context of the instantiated scope where the import declaration is located. Because imports with diverse instantiated scopes can export the same task or function, multiple instances of such an export can exist after elaboration. Prior to any invocations of svSetScope, these export instances would have different contexts, which would reflect their imported caller’s instantiated scope.

 

The concept of ‘call chains’ is useful for understanding how context works as control weaves in and out of SystemVerilog and another language through a DPI interface. A DPI import call chain is a series of task or function invocations that begin with a call from SystemVerilog into a task or function that is defined in a DPI-supported language and is declared in a DPI import declaration.  The import call chain consists of successive calls to routines in the imported language. One of those routines becomes the last routine in the import call chain when it calls a SystemVerilog exported task or function.  The import call chain can also end by simply unwinding without calling any SystemVerilog export.  Once entered, an exported SystemVerilog task or function can transfer control to new import chains by invoking imports and, when exiting, can return control to its caller in the original import call chain.

 

The following behavior characterizes context mechanics for imported call chains:

 

      The actions below determine an import call chain’s context value:

o        When a SystemVerilog task or function calls a DPI context import, a context for the import call chain is created that is equal to the instantiated scope of the import declaration.

o        When a routine in an import call chain invokes svSetScope with a legal argument, the call chain’s context is set to the indicated scope.

o        When a call from an import call chain to an exported SystemVerilog task or function finishes and returns to the chain, the call chain’s context is set equal to its value when the call to the export was made.

      Detecting when control moves across the language boundary between SystemVerilog and an imported language is critical for simulators managing DPI context.  Therefore, if user code circumvents unwinding an export call chain back to its import chain caller (e.g., by using C setjmp/longjmp constructs) the results are undefined.

 

      Whether a DPI import call-chain is a context chain or not is determined by whether the chain's first task or function was declared with the context keyword in the import declaration that governs its invocation; when an import declared with the context keyword  appears in a call chain position other than the first position it has no effect on whether the chain has the context characteristic or not.

      Whether a DPI import call chain has the context characteristic or not cannot be dynamically changed after the initial call into the chain is made.

 

      The context characteristic adheres to the calling-chain, not to an individual imported task or function; thus, the same imported task or function can appear in both context and non-context call chains.

Received on Mon Oct 23 13:41:44 2006

This archive was generated by hypermail 2.1.8 : Mon Oct 23 2006 - 13:41:54 PDT