Ray, Here's my take on your questions: Assume that there is such a thing as an array's rand_mode. The rand_mode of a particular array element is the AND of the rand_mode of the element and the rand_mode of the array. I believe this clarifies your questions. 1) Applying rand_mode(0) to the entire array should do two things: a) set the rand_mode of each element of the array to inactive, and b) set to inactive the rand_mode of the array size (for resizable arrays). I thought we had written that in the LRM, but can't remember where it is. This means that calling rand_mode on a re-sizeable array is different from calling rand_mode on each array element. 2) There is no semantic difference if the order of the two statements is reversed, that is, the rand_mode of the array continues to be inactive, and hence, the rand_mode of each array element is inactive. In your particular example, constraint c1 will be violated and randomize will fail and trigger the assertion. Given this definition, one could arguably implement the function version of h1.x.rand_mode as returning the array's rand_mode. But, I realize that this is not well defined at the moment. Arturo -----Original Message----- From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Ryan, Ray Sent: Tuesday, September 02, 2008 3:39 PM To: sv-ec@eda.org Subject: [sv-ec] rand_mode applied to a dynamic array We have had some questions about the behavior of the rand_mode method for a dynamic array. Consider the following example: module top; class my_class; rand int x[]; constraint c1 { x.size() == 5; } endclass my_class h1 = new(); initial begin h1.x = new[3]; h1.x.rand_mode(0); assert( h1.randomize() ); $display(h1.x[0].rand_mode(), h1.x[1].rand_mode(),h1.x[2].rand_mode(),h1.x[3].rand_mode(),h1.x[4].rand _mode() ); $display( h1.x ); end endmodule Questions: 1) Does the call to h1.x.rand_mode(0) effect whether the dynamic array h1.x is resized in the subsequent call to h1.randomize() ? 2) If the order of first two statements of the initial block are reversed which elements of the dynamic array are considered 'active' in the subsequent randomize call ? IE, if the initial block was: initial begin h.x.rand_mode(0); h.x = new[3]; assert (h1.randomize() ); end ----------------- I'd expect: 1) h1.x.rand_mode(0) sets each element to 'inactive'. In the subsequent randomize the array will be resize to 5 elements. The first 3 will be inactive, the last two will be active. 2) With the statements reversed: in the call to h.x.rand_mode(0), there are no elements so this statement does nothing. When the array is resized, the rand_mode status of the new elements is 'active'. - Ray Ryan -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Sep 11 16:15:17 2008
This archive was generated by hypermail 2.1.8 : Thu Sep 11 2008 - 16:15:52 PDT