Non integral expressions

Hi,

Can someone please tell me what the SV LRM means by 'nonintegral expressions" ? Thanks

In reply to laureen.giac:

Not having an integral value, not an integer. Reals and class variables are non integral types

In reply to dave_59:

Are strings too considered non-integral?

In reply to laureen.giac:

No. See Section 6.11.1 Integral types in the 1800-2017 LRM for a definition. Everything else is nonintegral.

Hi Sir,

6.11.1 Integral types

The term integral is used throughout this standard to refer to the data types
that can represent a single basic integer data type, packed array, packed structure, packed union, or enum.

6.16 String data type says a string variable can be accessed from index 0 (leftmost character) to N-1 (where N is the length of the string)

As per my understanding since a string variable can be indexed similar to a packed array it’s considered an integral type. Please correct me if I am wrong

Since the leaf level expression in a constraint comprises of integral types, why are random string variables not legal ?

Is it because the (packed) length of the string can’t be constrained unlike size of dynamic array or queue ?

Selecting a character from a string is an integral value, but the variable itself and a range of characters selected from it are not.

The rules for what can be declared as a random variable with rand are stricter than what variables can be used in a constraint. I suppose there’s no technical reason why you couldn’t declare a string as a random variable, but they just never thought it was useful enough to put into the LRM.

Hello Sir,

Do you mean to say a string variable isn’t considered an integral type ?

I am confused as I believed that string variables are integer type based on your earlier response

(also as per LRM string variable can be indexed similar to a packed array)

A string variable is not an integral type because integral types have a fixed bit size at compile time, while strings are dynamically sized. You can have types like unpacked arrays and structs composed of integral types, but the aggregate is not an integral type.

Strings indeed behave like packed arrays but they are not.