From: Karen L. Pieper (pieper@synopsys.com)
Date: Fri Apr 03 1998 - 11:00:28 PST
BAD MSG:
I'd like to see some language that also says that sizeof cannot be used
n parameter statements. Using it in parameter statements creates a
situation where it can be used to declare identifiers and create circularity.
Content-Length: 2957
X-Lines: 96
X-Status: $$$$
X-UID: 0000000359
Status: RO
K
> From owner-btf@boyd.com Fri Apr 3 09:36:28 1998
> X-Authentication-Warning: gw.boyd.com: majordomo set sender to owner-btf@boyd.com using -f
> From: Adam Krolnik <adamk@cyrix.com>
> Date: Fri, 3 Apr 98 10:41:02 +0600
> To: btf@boyd.com
> Subject: BTF - B15 - Built-in sizeof(x) function
>
>
>
> Behavioral Task Force - Enhancement Request
> Assigned Enhancement Request Number: B15
> Enhancement Name (Description): Built-in sizeof(x) function
> Date Submitted: 970319
> Requestor: adamk@cyrix.com (Adam Krolnik)
> Status:
>
> Is enhancement intended to be synthesizable?: yes
>
>
> 7. Size of registers.
> It would be nice to access the size of the registers without having to
> define a macro, or a symbol to hold the value. If the width of constants can
> be based on the lhs then this becomes less of a need and more of a
> nice-to-have. E.g. instead of
>
> `define SIZE_A 32
> reg [SIZE_A-1:0] a;
>
> if (a == `SIZE_A h 123)
>
> From: mac@silicon-sorcery.com
> Date: Wed, 19 Mar 97 14:22:50 PST
>
> Another justification would be:
>
> for (i = 0; i < sizeof(a); i = i + 1) begin
> if (a[i]) $display($stime,,"a[%d] is set",i);
> end
>
> I could support adding this to the language.
>
>
> Karen's comment on this enhancement was to restrict it usage to run-time
> statements. I.e. Declarations can't use this function.
>
> If this needs to be defined within the BNF, these definitions will need to be
> separated into declaration and run-time: "constant expression", "range".
>
> Once this is done, one can extend the BNF as follows:
>
> Add to the "constant_primary" definition,
> "| sizeof '(' sizeof_identifier ')'"
>
> Add to the "primary" definition,
> "| sizeof '(' sizeof_identifier ')'"
>
> Add the definition of "sizeof_identifier"
>
> sizeof_identifier ::=
> reg_identifier
> | net_identifier
>
>
> To section 4 "Expressions" add the following lines to the last unordered list:
>
> " - Size of a net"
> " - Size of a parameter, reg, integer, and time."
>
> To section 4.2 "Operands" add the following lines to the third paragraph:
>
> "The size of a vector net or register is also an operand."
>
> Insert this section in between sections 4.2.2 "Memory addressing" and 4.2.3 "Strings":
>
> "4.2.3 Size of an identifier"
>
> "The size of an identifier may be obtained by the use of the sizeof function. The value returned is the number of bits that compose the given identifier. An identifier composed
> of 1 bit has a size of 1. A vector has the size of the number of bits declared. This
> function shall not be used when declaring identifiers.
>
> Example:
>
> reg [31:0] selection;
> integer i;
>
> always @(event)
> for(i=0;i<sizeof(selection); i = i + 1)
> begin
> if (selection[i]) $display("Bit %0d set in selection.", i);
> end
>
> This example shows a code fragment that iterate through all the bits of 'selection'
> regardless of its size in the declaration."
>
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:52:47 PDT
and
sponsored by Boyd Technology, Inc.