Subject: Re: $root, prototypes etc.
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Fri Mar 15 2002 - 10:06:06 PST
[Previous post - http://www.eda.org/vlog-pp/hm/0125.html
- includes proposals]
C programming uses a global namespace similar to $root for
all routines. Originally it didn't use prototypes, you just
found routines by their name at link time. That's fine as
long as there isn't a lot of code, once you do have a lot
of code you need to add checks to make sure that you are
calling the right routine e.g. always include the routine
prototype so that you get the declaring module checked
against it and the the module using it has the same
interface. C++ uses "name mangling" which transforms the
simple name of the routine into one dependent on its
parameter types so that their is no confusion about what
code to call (and you can overload the routine).
The addition of new data types and the $root namespace
in SystemVerilog will lead to the same problems as seen
in C programming. So in an effort to be preemptive I
think we should add all the prototyping mechanisms now
rather than later, and disallow "lazy" linkage from
the start. This will also help with modular compilation
and hence compiled IP/library reuse, and interfacing
to foreign languages.
Proposal:
1. All items used from $root should be declared fully by
prototype, or by forward reference before use, unless
backward compatibility dictates otherwise.
2. Add syntax:
Tasks and functions without statements are considered
prototypes.
'extern' before 'module' and 'interface' indicate a
prototype and limit the contents to structural items
and public methods - which should match the actual
declaration if seen.
Ellipsis "..." can be used when there is an unknown
number of a arguments.
'extern' before an (unsized) variable declaration
behaves as in "C".
While we are not doing function/module overloading at
the moment it may be necessary to do it in future
(particularly for AMS) to make automatic configuration
during elaboration possible - i.e. I'm not suggesting
this stuff because I like excessive typing [ pun
intended :-) ], it'll just make some other things
easier later.
Regards,
Kev.
-- National Semiconductor 2900 Semiconductor Drive, Mail Stop D3-500, Santa Clara, CA 95052-8090
This archive was generated by hypermail 2b28 : Fri Mar 15 2002 - 10:11:02 PST