Verification Guild
A Community of Verification Professionals

 Create an AccountHome | Calendar | Downloads | FAQ | Links | Site Admin | Your Account  

Login
Nickname

Password

Security Code: Security Code
Type Security Code
BACKWARD

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Modules
· Home
· Downloads
· FAQ
· Feedback
· Recommend Us
· Web Links
· Your Account

Advertising

Who's Online
There are currently, 63 guest(s) and 2 member(s) that are online.

You are Anonymous user. You can register for free by clicking here

  
Verification Guild: Forums

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile  ProfileDigest    Log inLog in 

Controlling random variables from test case

 
Post new topic   Reply to topic    Verification Guild Forum Index -> Main
View previous topic :: View next topic  
Author Message
kfathy2002
Newbie
Newbie


Joined: Mar 26, 2012
Posts: 3

PostPosted: Wed Apr 11, 2012 12:53 pm    Post subject: Controlling random variables from test case Reply with quote

Hi All,


How can i control a random variable in the configuration class to have a default value and to be another value only when needed,

as an example:

in a verification environment, i want to add a new configuration variable, this variable needed to carry Zero at any test case, while at a certain test case, it should carry ONE.
Back to top
View user's profile
Ajeetha
Senior
Senior


Joined: Mar 29, 2004
Posts: 424
Location: Bengaluru, India

PostPosted: Sat Apr 14, 2012 9:24 am    Post subject: Re: Controlling random variables from test case Reply with quote

kfathy2002 wrote:
Hi All,


How can i control a random variable in the configuration class to have a default value and to be another value only when needed,

as an example:

in a verification environment, i want to add a new configuration variable, this variable needed to carry Zero at any test case, while at a certain test case, it should carry ONE.


Classical case for UVM/VMM factory.

Code:

class cfg_c extends uvm_object;

  `uvm_object_utils(cfg_c)
  rand bit [3:0] bit_0;

  constraint cst_default { this.bit_0 == 3'b000;}
endclass : cfg_c



In a specific testcase:

Code:

class my_cfg_c extends cfg_c;
  `uvm_object_utils (my_cfg_c)
  constraint cst_default { this.bit_0 == 3'b001;}
endclass : my_cfg_c

class my_test extends my_proj_base_test;
  task build_phase (uvm_phase phase);
    my_cfg_c = new; // use factory/create if you like
    factory.set_override_by_type (.orig_type(cfg_c::get_type),
         .override_type(my_cfg_c::get_type));
  endtask : build_phase
endclass : my_test


Does that help you?

Ajeetha, CVC
www.cvcblr.com/blog
_________________
Ajeetha Kumari,
CVC Pvt Ltd. http://www.cvcblr.com
* A Pragmatic Approach to VMM Adoption http://www.systemverilog.us/
* SystemVerilog Assertions Handbook
* Using PSL/Sugar
Back to top
View user's profile Visit poster's website
kfathy2002
Newbie
Newbie


Joined: Mar 26, 2012
Posts: 3

PostPosted: Sun Apr 15, 2012 8:06 am    Post subject: Thanks Reply with quote

yes it's very helpful,
Thanks Ajeetha.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Verification Guild Forum Index -> Main All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Verification Guild © 2006 Janick Bergeron
Web site engine's code is Copyright © 2003 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.572 Seconds