More draft 4 errata

From: Stuart Sutherland (stuart@sutherland-hdl.com)
Date: Wed Feb 02 2000 - 01:05:12 PST


BTF,

There is some errata in section 10.3.5 regarding constant functions:

----------------
The example for a constant function violates the rules for constant
functions. Either the example is wrong, or one of the rules is wrong. I
suspect it is the latter.

Section 10.3.5, 7th bullet says:

  "They shall not use any parameter value that is affected directly or
   indirectly by a defparam statement (see 12.2.1)"

But the example that follows passes a redefinable parameter as an input to
the function:

  parameter ram_depth = 256;
  localparam adder_width = clogb2(ram_depth);
  input [adder_width - 1:0] address;

----------------
Section 10.3.5, The 4th bullet contradicts the 2th bullet. The 2nd bullet
says:
  "Any function invoked within a constant function shall be a constant
   function local to the current module. System functions shall not be
invoked."
But the 4th bullet says:
  "The only system task that may be invoked is $display, and it shall be
ignored
   when invoked at elaboration time."
I suggest striking the 2nd sentence of the 2nd bullet.

----------------
The indentation in the example is not a good, intuitive style.

----------------
It was not clear to me from reading section 10.3.5 where it is legal to
call a constant function at elaboration time. The example assigns the
return of the constant function to a localparam, and uses the localparam in
a constant expression. Would it also have been legal to use the return of
the constant function directly in the constant expression? That is:

  input [clogb2(ram_depth)-1:0] address;

Verilog part selects are also based on constant expressions. Can a
constant function be used in this context? I hope not! Code like that
would not be intuitive. It contexts such as a continuous assignment would
be hard to tell that the function was called at elaboration time, and not
during run time. For example:

  wire [31:0] foo;
  wire [7:0] bar = foo[myFunc(2)+8:myFunc(2)]; //assume myFunc returns 0 to 23

If either or both of these are not legal, then the rules for calling
constant functions need clarification (IMHO).
----------------

Stu

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stuart Sutherland Sutherland HDL Inc.
stuart@sutherland-hdl.com 22805 SW 92nd Place
phone: 503-692-0898 Tualatin, OR 97062
www.sutherland-hdl.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:54:11 PDT and
sponsored by Boyd Technology, Inc.