0% found this document useful (0 votes)
101 views26 pages

On Configuration

The document discusses configuration in UVM and provides examples of: 1. Defining an environment configuration class and automatically configuring agents using uvm_config_db. 2. The different methods of uvm_config_db - set, get, exists, and wait_modified - and their syntax. 3. An example flow of how configuration is set from the top level to agents using uvm_config_db.

Uploaded by

rishifrnds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views26 pages

On Configuration

The document discusses configuration in UVM and provides examples of: 1. Defining an environment configuration class and automatically configuring agents using uvm_config_db. 2. The different methods of uvm_config_db - set, get, exists, and wait_modified - and their syntax. 3. An example flow of how configuration is set from the top level to agents using uvm_config_db.

Uploaded by

rishifrnds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

CONFIGURATION

Presented by
Deepika p v v
• Definition(easily change the entire tb arch)

• Use(reusability)

• All the methods of the uvm_config_db class


are the static. So they must be called with
scope resolution operator
Comparision
module top; module top;
bit clk; import test_pkg::*;
bridge_interface if0(clk); import uvm_pkg::*;
ahb_apb_top DUT ( ); bit clk;
Test test_h; bridge_interface if0(clk);
ahb_apb_top DUT ( );
initial initial
begin begin
test_h = new(in0,in0,in0,in0); uvm_config_db #(virtual
test_h.build_and_run(); bridge_interface )::
#500 ; set(null,"*","vif",if0);
$finish; run_test();
end #500 ;
$finish;
end
• Null (or) uvm_root::get();

• Null: it will call set method of uvm_root

• Because of module we are writing the


argument as null

• Class – this
Uvm_config_db methods
1. Set

2. Get

3.Exists

4.Wait_modified
Syntax for set method
• The full signature of the set method is void uvm_config_db
#( type T = int )::set( uvm_component cntxt , string
inst_name , string field_name , T value );
• T is the type of the element being configured - usually a
virtual interface or a configuration object.
• cntxt and inst_name together form a scope that is used to
locate the resource within the database. The scope is formed
by appending the instance name to the full hierarchical
name of the context, i.e.
• Field_name supplies the name of the resource
• value is the thing which is actually going to be put into the
database
Syntax for get method
Syntax for exists method
• Static function bit exists (uvm_component cntxt, string
inst_name,string field_name, bit spell_check);

• Check if a value for field_name is available in inst_name, using


component cntxt as the starting search point.

• The spell_chk arg can be set to 1 to turn spell checking on if it


is expected that the field should exist in the database. The
function returns 1 if a config parameter exists and 0 if it
doesn’t exist.
Synatx for wait_modified method
• Static task wait_modified(uvm_component
cntxt, string inst_name,string field_name);

• Wait for a configuration setting to be set for


file name in cntxt and inst_name .

• The task blocks until a new configuration


setting is applied that effects the specific field
Flow of setting and getting configuration
1. TOP
uvm_config_db #(virtual bridge_interface ):: set(null,"*","vif",if0);
2. TEST(a)creating env cfg b) get the vif c) set env cfg)
function void base_test::build_phase(uvm_phase phase);
super.build_phase(phase);
tb_cfg=env_config::type_id::create("tb_cfg",this);
if(has_magent)
begin
h_cfg=ahb_config::type_id::create("ahb_config",this);
if(!uvm_config_db #(virtual bridge_interface)::get(this,"","vif",h_cfg.vif))
`uvm_fatal(get_full_name,"cannot get interface")
h_cfg.is_active=UVM_ACTIVE;
tb_cfg.h_cfg = h_cfg;
end
// fr rd agent also //
uvm_config_db #(env_config) :: set(this,"*","env_config",tb_cfg);
endfunction
3. ENV
function void env::build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(env_config)::get(this,"","env_config",tb_cfg))
`uvm_fatal(get_full_name,"not getting from tb")
if(tb_cfg.has_magent)
begin
uvm_config_db#(ahb_config)::set(this,"*","ahb_config",tb_cfg.h_cfg);
h_agt_toph=ahb_agt_top::type_id::create("h_agt_toph",this);
end
// fr rd agent also //
Endfunction

4. Agent top(its not mandatory)


function void ahb_agt_top::build_phase(uvm_phase phase);
super.build_phase( phase);
if(!uvm_config_db #(ahb_config):: get(this,"","ahb_config",h_cfg))
`uvm_fatal(get_full_name,"not getting rom the ahb_config")
h_agt= ahb_agent::type_id::create("h_agt",this);
endfunction
5. Agent
function void ahb_agent:: build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db #(ahb_config)::get(this,"","ahb_config",h_cfg))
`uvm_fatal(get_full_name,"not getting from ahb_agent")
Endfunction

6. DRIVER
function void ahb_driver::build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db #(ahb_config):: get(this,"","ahb_config",h_cfg))
`uvm_fatal(get_full_name,"not getting from ahb_agent")
endfunction
7. Monitor
function void ahb_monitor::build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db #(ahb_config):: get(this,"","ahb_config",h_cfg))
`uvm_fatal(get_full_name,"not getting from ahb_agent")
Endfunction
class base_test extends uvm_test;
`uvm_component_utils(base_test)
if(!uvm_config_db #(virtual
env_config tb_cfg; bridge_interface)::get(this,"","vif",h_
ahb_config h_cfg; cfg.vif))
apb_config p_cfg;
env tbh; uvm_fatal(get_full_name,"cannot
get interface")
int has_virtual_sequencer; h_cfg.is_active=UVM_ACTIVE;
int has_magent=1; tb_cfg.h_cfg = h_cfg;
int has_sagent=1; end
function void tb_cfg.has_magent = has_magent;
base_test::build_phase(uvm_phase tb_cfg.has_sagent =
phase); has_sagent;
super.build_phase(phase); uvm_config_db #(env_config) ::
tb_cfg=env_config::type_id::create(" set(this,"*","env_config",tb_cfg);
tb_cfg",this);
if(has_magent) tbh=env::type_id::create("tbh",this);
Begin endfunction
h_cfg=ahb_config::type_id::create("a
hb_config",this);
`
Uvm_config_db_options
1. Turn_on_tracing : turn tracing on for the configuration
database

syntax:
Static function void turn_on_tracing();

a) This causes all reads and writes to the database to display


information about the accesses.

b) Tracing is off by default.

c) This method is implicitly called by


the +UVM_CONFIG_DB_TRACE.
2. turn_off_tracing: turn tracing off for the configuration
database.
Syntax:
Static function void turn_off_tracing();

3. is_tracing : Returns 1 if the tracing facility is on and 0 if it is off.

Syntax:
Static function bit is_tracing();
Environment config
class env_config extends uvm_object;

`uvm_object_utils(env_config)

int has_scoreboard=1;
int has_magent;
int has_sagent;
int has_virtual_sequencer=1;

ahb_config h_cfg;
apb_config p_cfg;

extern function new(string name ="env_config");

endclass

function env_config::new(string name="env_config");


super.new(name);
endfunction
Automatic configuration
• In order to have the resource automatically retrieved two things
must happen.
a) First, that resource has to be registered with the factory using
the field automation macros.
b) Second, super.build_phase(phase) must be called in the
build_phase() function.

Example:
class pipe_agent extends uvm_agent;

protected int my_param = 10;


pipe_sequencer sequencer;
pipe_driver driver;
pipe_monitor monitor;
`
• `uvm_component_utils_begin(pipe_agent)
`uvm_field_int(my_param, UVM_ALL_ON)
`uvm_component_utils_end
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(is_active == UVM_ACTIVE)
begin
sequencer = pipe_sequencer::type_id::create("sequencer",this);
driver = pipe_driver::type_id::create("driver", this);
end
• monitor = pipe_monitor::type_id::create("monitor", this);
`uvm_info(get_full_name( ), "Build stage complete.",
UVM_LOW)
endfunction: build_phase
// connect phase
Enclass

Test:
Uvm_config_db #(int) ::set(this,”env.agent”,”my_param”,888);
Thank you

You might also like