Proposal Update


Subject: Proposal Update
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Tue Dec 10 2002 - 13:57:17 PST


I think I have this fairly complete now. Latest additions are:

 Scoping rules for extern.
 Support pass-by-value and pass-by-reference, with type coercion for
pass by value
   for SV types on arguments and return values (follows from Andrzej's
proposal).
 Note on type promotion.

Note: I renamed "vec32" to "svcInteger"since vec32 seemed rather short
and not
SV specific. That and other types I expect to go in an appendix later.

On the question of when you bind dynamic routines:

You can bind a routine any time between its SV context being created and
actually
calling it. The cheaper options are to bind when the context is created
or on the
the first call. Doing it directly after elaboration has some advantages
but has extra
overhead. Doing it on the first call can be implemented by using an
"extended"
context that includes the routine pointer:

        svcContextIntrnl {
            void (*func_or_bind)(handle,svcContext...);
            svcContext cntxt; /* external context */
         } CI;

The simulator always calls (*CI.func_or_bind)(&CI.cntxt) but the initial
value of
func_or_bind is a call to a loader routine which locates the right
routine and
updates func_or_bind. This kind of thing is usually refered to as "lazy"
loading
and has the downside that it may be (too?) late before you find the
object code
is not available, the upside is that DLLs don't get loaded until they
are actually
needed (faster startup, lower memory usage).

Note: for lazy binding the user_context field of CI.cntxt can be used
to save data
from elaboration time.

Since my interest is in linking C++ I'm assuming that I can use static
constructors
to register locator functions. If you are just using C you won't need
the locator
functions (so there isn't a problem).

Regards,
Kev.

-- 
National Semiconductor, Tel: (408) 721 3251
2900 Semiconductor Drive, Mail Stop D3-500, Santa Clara, CA 95052-8090


sv2c.pdf



This archive was generated by hypermail 2b28 : Tue Dec 10 2002 - 13:58:38 PST