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.Received on Tue Sep 2 15:39:55 2008
This archive was generated by hypermail 2.1.8 : Tue Sep 02 2008 - 15:40:43 PDT