Subject: Re: arrays in SystemVerilog
From: Peter Flake (flake@co-design.com)
Date: Mon Feb 25 2002 - 11:11:29 PST
Hi Paul,
At 08:04 AM 2/25/02 -0800, Paul Graham wrote:
>Sorry for being so late with comments on arrays, but better late than
>never...
>
>I still don't understand the point of distinguishing between packed and
>unpacked arrays, except to maintain backwards compatibility with verilog.
This is an important factor. The key is that a packed object is just a bit
vector which may be further subdivided as a multidimensional array. This
is useful for serial/parallel conversion, for example.
>Is it possible for a typedef to declare an unpacked array dimension? For
>instance, I might want to declare an array of structs. Yet the syntax for
>data_type in section 3.2 says that the dimensions specified in a data_type
>are packed dimensions:
>
> <data_type> ::= ... | <type_identifier> { <packed_dimension> }
You can define an unpacked array type foo as follows (like C):
typedef int foo [9:0];
>It is possible to assign a whole array if all its dimensions are packed,
>but not
>possible to assign a whole array with unpacked dimensions. Why not?
This is a simulation efficiency issue, rather than fundamental to the
language. It makes it harder to copy a megabyte.
>Arithmetic operations are allowed for packed arrays. Even for
>multidimensional packed arrays? For instance:
>
> wire [3:0][7:0] x, y, z;
> assign z = x + y;
>
>Does this treat x and y as 32-bit integers and then add them? Or does it
>independently add corresponding 8-bit fields of x and y?
It treats them as 32 bit integers. A packed object x is just a bit vector
which may be further subdivided.
>Why not rationalize arrays as follows:
>
>1. Eliminate the packed array syntax, except to allow a single dimension to
>the left of the declarator, to remain compatible with verilog.
So the concept of packed would still exist, just be one dimensional.
>2. If you want some way of specifiying an efficient, packed representation,
>using the existing keyword 'vectored'.
How would it work in a multi-dimensional context?
>3. Allow reading and assigning of full arrays.
>
>4. Allow constant part selects of arrays.
>
>5. Arithmetic operations can be allowed on arrays by defining them to act on
>corresponding words.
Please clarify (5).
Peter.
This archive was generated by hypermail 2b28 : Mon Feb 25 2002 - 11:32:00 PST