Subject: [sv-ec] [Opaque] Pointers
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Mon Jan 06 2003 - 13:09:55 PST
We seem to be missing an "opaque pointer" proposal in the extensions
list (EXT-18). Since
I seem to have been tasked with the problem from the CC/BC here's my
proposed text for
addition:
Pointers
Pointers in SystemVerilog can be declared as in C by prepending "*"
to a declaration e.g.:
int a, // value
*ap, // pointer to an int
*argv[5]; // array of pointers
These pointers cannot be dereferenced within SystemVerilog i.e.
"*ap" has no valid meaning
in an expression. Pointers in SystemVerilog are the same size as
they are for C on the simulation
host and can be included in unions. Their primary purpose is to pass
data from one external C
function to another. Pointers can be assigned a value from a pointer
of the same type or by casting
a scalar value to the same type as the pointer, but no other
operations can modify the value e.g.:
ap = (int *)'32'h100fffed;
ap = (int *)'$data_address("gen_packet"); // User PLI
ap = argv[0];
Similarly the value of a pointer can be read by casting it to a
scalar type:
a = int'ap;
Pointers can also be tested for equality if they are of the same
type with == and != but no other
comparisons are allowed. Pointers are initially 0 and can be tested
against 0 or null directly:
if (ap != null) ...
--I think this is an easy-to-implement minimum that won't interfere with future enhancements, and fits with using C syntax for external function declarations (direct inclusion of headers). It violates requirement 2.h and 3, but it's not clear to me that those requirements are necessary since the pointer value is never dereferenced inside SV, and req. 3 precludes using predefined C structures that do make unions of pointers and integers.
Regards, Kev.
-- National Semiconductor, Tel: (408) 721 3251 2900 Semiconductor Drive, Mail Stop D3-500, Santa Clara, CA 95052-8090
This archive was generated by hypermail 2b28 : Mon Jan 06 2003 - 13:11:16 PST