RE: [sv-ec] Specifying rand_mode for packed array elements

From: Ryan, Ray <Ray_Ryan@mentorg.com>
Date: Mon Apr 12 2004 - 09:39:36 PDT

Mehdi,

In that case, I'd recommend adding "unpacked" to the text:

"For unpacked array variables, random_variable can specify individual
elements
using the corresponding index."

-----

How about fields of a packed or unpacked struct. I noticed in the BNF
that the

> -----Original Message-----
> From: Mehdi Mohtashemi [ <mailto:Mehdi.Mohtashemi@synopsys.com>
mailto:Mehdi.Mohtashemi@synopsys.com]
> Sent: Tuesday, April 06, 2004 5:41 PM
> To: sv-ec@eda.org; Ryan, Ray
> Subject: Re: [sv-ec] Specifying rand_mode for packed array elements
>
>
> Ray,
> That paragraph refers to unpacked arrays. For packed arrays
> the part selection is not allowed with rand_mode method,
> i.e, one can not turn
> off randomization for individual bit. It works on elements
> of unpacked arrays. I have changed your example slightly
> and show a sample result from Vera simulation, in your
> example wheel is unpacked array of 8bits.
> For individual bit manipulation after the declaration of
> class one can use the in-line constraints- with() upon
> randomize call. Regards,
> - Mehdi
>
> -----------------------------------
> class Spin;
> rand [7:0] bit wheel[0:7];
> rand [7:0] x;
> constraint c { x < 50; }
> constraint c2 { foreach ( wheel[i] inside {0:100};}
> // ... other declarations
> endclass
>
> int j;
> Spin big = new;
> big.wheel.rand_mode(1); // enable randomization of all bits
> for (i=0; i<8; i++)
> begin
> big.wheel[i].rand_mode(0); // disable randomization of
> another bit
> big.randomize();
> ... other test code
> end
>
> Sample result:
> -- All eight randomized on --
> ----------------- 0 1 2 3 4 5 6 7
> ------------------------------------------------------
> [eight wheeler] 2, 34, 74, 19, 0, 72, 95, 83,
> -- rand_mode off one wheel at a time, from 0 to 7 --
> ----------------- 0 1 2 3 4 5 6 7
> ------------------------------------------------------
> [eight wheeler] 2, 19, 0, 51, 10, 35, 47, 89,
> [eight wheeler] 2, 19, 13, 61, 79, 95, 6, 22,
> [eight wheeler] 2, 19, 13, 45, 46, 18, 17, 58,
> [eight wheeler] 2, 19, 13, 45, 57, 23, 67, 55,
> [eight wheeler] 2, 19, 13, 45, 57, 10, 73, 69,
> [eight wheeler] 2, 19, 13, 45, 57, 10, 96, 49,
> [eight wheeler] 2, 19, 13, 45, 57, 10, 96, 51,
> [eight wheeler] 2, 19, 13, 45, 57, 10, 96, 51,
> --------------------------------------------------------
>
> > X-UIDL: b01c87cb662ddc632fc7430e2a102935
> > To: sv-ec@eda.org
> > Subject: [sv-ec] Specifying rand_mode for packed array elements
> > Date: Mon, 5 Apr 2004 16:51:34 -0700
> > X-Scan-Signature: 5f5707d583650bc631c837957f10fbee
> > X-pstn-levels: (S:29.04579/99.33400 R:95.9108 P:95.9108
> M:98.0742 C:79.5348 )
> >
> > Section 12.7 the first paragraph after Table 12-1 states:
> >
> > "For array variables, random_variable can specify
> individual elements
> > using the corresponding index. Omitting the index results
> in all the
> > elements of the array being affected by the call."
> >
> > As stated, I believe this allows disabling of randomization for the
> > individual bits of a packed random variable. Is this the intended
> > semantics?
> >
> > For example, is the following legal?
> >
> > class Spin;
> > rand [7:0] bit wheel, x;
> > constraint c { x < wheel; };
> > ... other declarations
> > endclass
> >
> > int i;
> > Spin big = new;
> > big.wheel.rand_mode(1); // enable randomization of all bits
> > for (i=7; i+0; i=i-1)
> > begin
> > big.wheel[i].rand_mode(0); // disable randomization
> of another bit
> > big.randomize();
> > ... other test code
> > end
> >
> >
> > -- Ray
>
Received on Mon Apr 12 09:39:52 2004

This archive was generated by hypermail 2.1.8 : Mon Apr 12 2004 - 09:39:56 PDT