Search the Community

Showing results for tags 'randomize'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Accellera Systems Initiative
    • Information
    • Announcements
    • In the News
  • SystemC
    • SystemC Language
    • SystemC AMS (Analog/Mixed-Signal)
    • SystemC TLM (Transaction-level Modeling)
    • SystemC Synthesizable Subset v1.4 Public Review
    • SystemC Verification (UVM-SystemC, SCV)
  • UVM (Universal Verification Methodology)
    • UVM 1.2 Public Review
    • Methodology and BCL Forum
    • UVM SystemVerilog Discussions
    • Simulator Specific Issues
    • UVM Commercial Announcements
  • Portable Stimulus
    • Portable Stimulus Discussion
    • IP-XACT Discussion
  • IEEE 1735/IP Encryption
    • IEEE 1735/IP Encryption Discussion
  • OCP (Open Core Protocol)
  • UCIS (Unified Coverage Interoperability Standard)
  • Commercial Announcements
    • Announcements


  • SystemC
  • UVM
  • UCIS
  • IEEE 1735/IP Encryption


  • Community Calendar

Found 3 results

  1. Is it possible to randomize a string without home-brewing a function to do it? Can only integral data types be randomized, hence not strings? How much memory is allocated when a string is declared? Is a string just a dynamic array 'underneath'?
  2. Yesterday, I learned that when randomize is called, all active constraints in the scope must be met ... even if you are passing a specific member as an argument to the randomize call. i.e. If you try to randomize a specific class member by passing it to the randomize call, like this: randomize(var2), all constraints in the scope of the randomize must still be met, even if they have nothing to do with the member being randomized. ***Someone please jump in if I phrased that poorly or am incorrect. In the below example there are two variables and a constraint on one. Uncommenting the line that causes the constraint on var1 to be violated will cause the later call to randomize to fail, even though it is passed an argument (var2) that has nothing to do with var1. class showit; rand int var1; rand int var2; constraint c_1 { var1<100; } endclass ////////////////////////////////////// module top; showit showit; initial begin showit=new(); //showit.var1=101; UNCOMMENT ME, PLEASE FOR FAIL as_myassert : assert(showit.randomize(var2)) begin $display("\n********** Victory : var2=%0d var1=%0d \n",showit.var2, showit.var1); end else begin $display("\n********** Defeat : var2=%0d var1=%0d \n",showit.var2, showit.var1); end end endmodule : top Pass result: ********** Victory : var2=-1424717967 var1=0 Fail result: ********** Defeat : var2=0 var1=101 I now understand randomize better. I had thought that only the constraints that pertained to the items being randomized were relevant.
  3. I had expected all 3 of these calls to randomize to return values using the constraint. However, the first does not. Can anyone tell me why? (note: In the following code, there is no local randomize method defined. So, I think that all randomize functions are the same...and perhaps only scope varies.) Code, followed by sim results: class thursday_seq extends junk_seq_seq; //which extends uvm_sequence rand int count; constraint c1 { count >= 2; count <= 9; } function new(string name="thursday_seq");; if (std::randomize(count)) begin `uvm_info("",$psprintf(" cnt=%0d .....",count),UVM_LOW) end else $finish; if (randomize(count)) begin `uvm_info("",$psprintf(" cnt=%0d .....",count),UVM_LOW) end else $finish; if (this.randomize()) begin `uvm_info("",$psprintf(" cnt=%0d .....",count),UVM_LOW) end else $finish; $finish; endfunction:new `uvm_object_utils(thursday_seq) UVM_INFO @ 0: reporter@ [] cnt=415747889 ..... UVM_INFO @ 0: reporter@ [] cnt=9 ..... UVM_INFO @ 0: reporter@ [] cnt=2 ..... It seems what is happening is that while std::randomize and randomize are calling the same method in the standard package, the standard version is oblivious to local constraints. I see in 1800-2012.pdf (SV spec), sec. 18.5.2 "The randomize() method is virtual and therefore honors constraints of the object on which it was called, ..." (highlighting mine) Later in the spec, there is reference to the 'scope of the randomize(' which confuses me a bit, if the constraints are always to be honored. (Although, I suppose in the first two cases above "of the object on which it was called" is not true, b/c I don't call it on the object, but on a property of the object.) Is that correct? After doing a bunch more reading, I am going to continue with this post for feedback. Here is something more I learned. This quote in section "18.12 Randomization of scope variablesā€”std::randomize()" I think explains it all for me. "The scope randomize function, std::randomize(), enables users to randomize data in the current scope without the need to define a class or instantiate a class object." I'm a bit unsure, but I think the answer to my question is this. "without the need to define a class" and "in the current scope", from above, imply that std::randomize performs only on the scope that is passed to it. i.e. if I pass it a class object, then it knows of that object's constraints. If I pass it a data-member of a class, then the scope that data-member exists in is not seen (i.e. any constraints which are in the scope above that data-member are not seen). Though they could be replicated as inline constraints.). The local randomize knows of all the constraints in the object from which it is called. Do I understand this correctly? I think I just walked myself through understanding this. Comments welcome. thx, note: using Cadence's IUS12.1-s004