[sv-bc] Type bounds and "type" operator

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Fri Aug 26 2005 - 11:42:21 PDT
Consider the following:

module top;
    wire [63:33] a;

    typedef type(a[40:33]) t1;
    typedef type(a[40:33] + 5) t2;
    typedef type(a) t3;

    wire t1 c;
    wire t2 d;
    wire t3 e;
endmodule


It certainly appears that all types are legal.  I
think I have the right syntax for c, d, and e.

Given that, what is the range of the types?  This is
obviously important for SDF reasons, etc.  What is
the type calculus that is supposed to be at work?

The sizes are clearly defined (t1 is width 8,
t2 is width 32, t3 is width 31) but the bounds are
not at all clear to me.


I think that the rule should be that for a simple
reference to a element of an unpacked type, the type
should be the type of the element.  For other integral
expressions, the type is [width-1:0]; for other types
it is the self-determined type.

For the above this implies a range of [7:0] for t1,
a range of [31:0] for t2, and a range of [63:33] for
t3.

Note that this is similar to the untyped parameter rules
except that untyped parameters will always go from
[width-1:0] whereas I am suggesting that "type" should
retain the specified bounds for references to elements
in unpacked types.

Note that such issues are also exposable in other (less
obvious) situations such as:

        for (i=$right(type(a[40:33]));
             i < i=$left(type(a[40:33]));
             i++)
           $display(a[i]);


Do my suggested rules make sense?  The general problem is
that the "self determined type" rules don't define ctual
bounds, they define widths for integral types.

Gord.

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
Received on Fri Aug 26 11:42:41 2005

This archive was generated by hypermail 2.1.8 : Fri Aug 26 2005 - 11:45:34 PDT