Subject: Re: DirectC: C layer
From: Stickley, John (john_stickley@mentorg.com)
Date: Fri Dec 13 2002 - 17:02:22 PST
Team,
Regretably I was on the road last week and was in solid
meetings.
I'm only now catching up with all the e-mail and want
to share my comments. My apologies for delayed response.
The debate has been interesting. Francois and Kevin have
certainly raised some valid concerns on the copy-by-value
issue.
However, my take is that we should deviate little from
Andrezj's proposal as written. In doing so I believe it
is still possible to provide much of the protection offered
by copy-by-value without enforcing it as a requirement,
while still allowing for implementations to chose the
performance of copy-by-reference.
Implementations may chose to use copy-by-value anyway,
but it should not be our place to mandate it one way or
the other. As long as we clearly state what we expect to see
on the C side and what on the HDL side and that input arguments
are not to be touched by function code, we should leave the
rest to the implementation to decide.
In cases where functions are used to establish heavily traveled
transaction communication channels between models in the
two language domains, copy-by-value of arrays can be a real
performance killer.
There are already enough performance killers in today's
HDL language simulators as the majority EDA users will
quickly attest to.
In particular consider the issue of passing a large
bit-vector which is a common representation of a transaction.
One of the (many) reasons C performance has dwarfed HDL
performance for years is that argument passing of
arrays is by reference. True, for many years this did
present a type safety danger to users because function
callees could indiscriminately alter arrays passed as input
arguments.
When C++ and later ANSI C introduced 'const' that did
a lot to help improve the type safety while still
allowing the efficiency of pass-by-reference. Sure the
mechanism can be bypassed by casting away const'ness.
But users who knowingly violate this are also knowingly
risking introduction of bugs. But my feeling is that,
in general, the mechanism has served its purpose well.
If I were designing a vendor implementation there are two
options I would consider putting in.
1. I have compile switches that let the user say
use copy-by-value semantics for safety or use copy-by-ref
for speed.
2. I would have my SV compiler generate convenience headers
with const for all the input arguments and thereby provide
a way for the user to let the C compiler naturally
perform the type safety checking.
Both of these options mostly accomplish what Kevin and
Francois are looking for while leaving Andrezj's proposal
unchanged.
-- johnS
__
______ | \
______________________/ \__ / \
\ 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 : Fri Dec 13 2002 - 17:06:29 PST