Subject: Re: DirectC: C layer
From: Stickley, John (john_stickley@mentorg.com)
Date: Tue Dec 17 2002 - 11:10:30 PST
I think that what Joao says here is well stated.
So, to summarize, Andrezj's proposal states that
complex (i.e. "non-small") input arguments such
as structs are passed by reference. Nonetheless,
1. Those references can be designated as 'const'
in any compiler generated headers. (And therefore
realize benefits of input arg protection to a
reasonable degree)
2. An implementation may still choose to use
"copy-by-value" semantics by simply creating a
temporary of the arg then passing a const * ref to
that temporary. Or they may choose pass const * ref
that points directly the internal representation of the
actual (assuming it is identical to the C representation)
- which has potentially better performance. It should
be totally up to the implementation.
As for what's going to cause more or fewer crashes
if the C code over indexes the arg, both copy-by-value
or copy-by-ref are equally susceptible to this. So,
no inherent gain is realized by copy-by-value in this
regard. The only thing you guarantee with copy-by-value
is that it is impossible to avoid memory-to-memory
copy no matter what the implementation - which can have
unecessary performance impact.
-- johnS
Joao Geada wrote:
> Francoise:
>
> You said
>> A direct memory interface may also restrict the optimizations on the
> SV side
>> since it reveals the internal memory layout which will need to stay
> stable.
> Please note that, with the proposed interface no such thing is required.
> It is *permitted*, not *required*.
>
> For output/inout ports passed by "reference", an implementation is free
> to choose whether it is providing
> pointers to datastructures inside the simulator or pointers to some
> temporaries. In either case the implementation
> has to propagate any changes made by the user into the simulator (for a
> direct pointer implementation this
> is "merely" invoking the propagation functions of the necessary signals,
> for an indirect pointer implementation,
> this means first copying out the new data and then propagating)
>
> As I have stated before, you are free to implement this whichever way
> you choose. It is even legitimate for
> an implementation to use both approaches for different types of data or
> in different usage modes. Note also
> that a user application really has no means of identifying which
> implementation approach is being used (other
> than perhaps by benchmarking).
> This works because, semantically, the interface relies on the following:
> 1- user must *never* write to input ports (ie input ports are "const")
> 2- propagation occurs *only* when a DirectC call returns
> These items ensure that, from the SV side, a DirectC call behaves the
> same as a SV function call
> (ie as-if pass-by-value had occurred).
>
> Joao
>
> ==============================================================================
> Joao Geada, PhD Principal Engineer Verif Tech
> Group
> Synopsys, Inc TEL: (508)
> 263-8083
> 344 Simarano Drive, Suite 300, FAX: (508)
> 263-8069
> Marlboro, MA 01752, USA
> ==============================================================================
>
>
--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. __ ______ | \ ______________________/ \__ / \ \ H Dome ___/ | John Stickley E | a __ ___/ / \____ Principal Engineer l | l | \ / Verification Solutions Group | f | \/ ____ Mentor Graphics Corp. - MED C \ -- / / 17 E. Cedar Place a \ __/ / / Ramsey, NJ 07446 p | / ___/ | / / mailto:John_Stickley@mentor.com \ / Phone: (201)818-2585 \ / ---------
This archive was generated by hypermail 2b28 : Tue Dec 17 2002 - 11:14:41 PST