Thursday, 11 December 2014

To Generate Seprate Log files for Easy Debugging in SOC verification

For easy debugging in SOC verification, generate separate log files for different IPs/Instances.

How to Generate separate Log files for different Functions/Layers/Instances/Files?

You can implement the below logic in your uvm environment to generate the separate Log files for each instances. Below I have written a piece of code to generate the separate Log files and you can refer the same.

For Example:

Without generating the Separate Log files,

///////////////////////////////////////////////////////////////////////////////////
// Test driver
class test_driver extends uvm_component;
`uvm_component_utils(test_driver) 

function new(string name,uvm_component parent);
super.new(name, parent);
endfunction 

task run();
uvm_report_info(get_name(), "Driver Info :: dump into the Log ",UVM_HIGH);
endtask

endclass

// Test monitor
class test_monitor extends uvm_component;
`uvm_component_utils(test_monitor) 

function new(string name,uvm_component parent);
super.new(name, parent);
endfunction 

task run();
uvm_report_info(get_name(), "Monitor Info :: dump into the Log ",UVM_HIGH);
endtask

endclass

// Test agent
class test_agent extends uvm_component;
test_driver log_drv;
test_monitor log_mon;
`uvm_component_utils(test_agent) 

function new(string name,uvm_component parent);
super.new(name, parent);
endfunction 

function void build();
super.build();
log_drv = test_driver::type_id::create("log_drv",this);
log_mon = test_driver::type_id::create("log_mon",this);
endfunction

endclass
///////////////////////////////////////////////////////////////////////////////////

With generating the Separate Log files,

///////////////////////////////////////////////////////////////////////////////////
// Test driver
class test_driver extends uvm_component;
string test;
`uvm_component_utils(test_driver) 

function new(string name,uvm_component parent);
super.new(name, parent);
test = “TEST”;
endfunction

task run();
uvm_report_info(test, "Driver Info :: dump into the Log ",UVM_HIGH);
endtask

endclass

// Test monitor
class test_monitor extends uvm_component;
string test;
`uvm_component_utils(test_monitor) 

function new(string name,uvm_component parent);
super.new(name, parent);
test = “TEST”;
endfunction

task run();
uvm_report_info(test, "Monitor Info :: dump into the Log ",UVM_HIGH);
endtask

endclass

// Test agent
class test_agent extends uvm_component;
integer log_ptr, log_ptr_id;
test_driver log_drv;
test_monitor log_mon;
`uvm_component_utils(test_agent) 

function new(string name,uvm_component parent);
super.new(name, parent);
endfunction

function void build();
super.build();
log_drv = test_driver::type_id::create("log_drv",this);
log_mon = test_driver::type_id::create("log_mon",this);
// set the uvm action for that ID
log_drv.set_report_id_action(“TEST”,UVM_LOG);
log_mon.set_report_id_action(“TEST”,UVM_LOG);
// open the file to dump
log_ptr = $fopen(“test.log”);
log_ptr_id = $fopen(“test_id.log”);
// to dump all log in the file
log_drv.set_report_default_file(log_ptr);
log_mon.set_report_default_file(log_ptr);
// to dump the particular ID log in the file
log_drv.set_report_id_file(TEST,log_ptr_id);
log_mon.set_report_id_file(TEST,log_ptr_id);
endfunction

endclass
///////////////////////////////////////////////////////////////////////////////////


With an above example you can have a display test case status without any signal/variable from the test environment.

Thursday, 20 November 2014

Print all elements of Array in the Transaction class

If we print the Transaction class, it will not print our complete Array`s element which is inside the Transaction class. 

How to get the complete element printing of Arrays which is inside Transaction class?

You can implement the below logic in your uvm environment build phase to print the complete Array. Below I have written a piece of code to print all element of array in the transaction class and you can refer the same.

 

  In the environment file, Build phase
    Uvm_default_printer = uvm_default_table_printer;
    Uvm_default_printer.knobs.begin_elements = -1;

Then we can use, wherever you want to use print call inside the environment.
For example:
Print the transaction class without enabling the array printer:
class Packet extends uvm_sequence_item; 
rand bit [15:0] length; 
rand bit [7:0] data[]; 

constraint payload_size_c { data.size inside { [1024 : 4096]};} 
constraint length_c { length == data.size; } 

function new(string name = ""); 
super.new(name); 
endfunction : new 

`uvm_object_utils_begin(Packet) 
`uvm_field_int(length, UVM_ALL_ON|UVM_NOPACK) 
`uvm_field_array_int(data, UVM_ALL_ON|UVM_NOPACK) 
`uvm_object_utils_end 
endclass : Packet 
module test; 
Packet pkt1 = new();
pkt1.print();
endmodule


Output:

-------------------------------------------------------------------------------------------------------------------------
Name                                             Type                                size                      Value
-------------------------------------------------------------------------------------------------------------------------
Pkt1                                             packet                                 -                         @10
   Length                                         integral                             16                      ‘h7D0
   Data                                            da(integral)                      2000                      -
       [0]                                          integral                              8                        ‘h51
       [1]                                          integral                              8                        ‘h6b
       [2]                                          integral                              8                        ‘h66
       …                                              …                                    …                         …
       [1998]                                    integral                              8                        ‘h15
       [1999]                                    integral                              8                        ‘hA2
       [2000]                                    integral                              8                        ‘h5B
-------------------------------------------------------------------------------------------------------------------------

Print the transaction class after enabling the array printer:
-------------------------------------------------------------------------------------------------------------------------
Name                                             Type                                size                      Value
-------------------------------------------------------------------------------------------------------------------------
Pkt1                                             packet                                 -                         @10
   Length                                         integral                             16                      ‘h7D0
   Data                                            da(integral)                      2000                      -
       [0]                                          integral                              8                        ‘h51
       [1]                                          integral                              8                        ‘h6b
       [2]                                          integral                              8                        ‘h66
       [3]                                          integral                              8                        ‘h51
       [4]                                          integral                              8                        ‘h6b
       [5]                                          integral                              8                        ‘h66
       [6]                                          integral                              8                        ‘h51
       [7]                                          integral                              8                        ‘h6b
       [8]                                          integral                              8                        ‘h66
It will print all 2000 elements
-------------------------------------------------------------------------------------------------------------------------


With an above example you can have a display the complete element in the array.

Generate Testcase Status


The Report phase is used for reporting the pass/fail status. 


How to get the Pass/Fail status without any interrupt from our test environment?

You can implement the below logic in your uvm environment report phase to generate the Test status. 
Below I have written a piece of code to generate the Test status and you can refer the same.

/////////////////////////////////////////////////////////////////////////////////////////
Function void report ();
uvm_report_server svr; // Creates the handle for report server
svr = uvm_report_server::get_server();  //Gets the global report server

// Function returns the severity count
if(svr.get_severity_count(UVM_ERROR) + svr. get_severity_count(UVM_FATAL) > 0) begin
   $display(“Test Fail”);
  // Display the count of message for the particular module.
   $display(“Number of Error in the module = %0d”,svr.get_id_count(“<UNIQUE_ID>”));
end
else begin
   $display(“Test Fail”);
end
endfunction

/////////////////////////////////////////////////////////////////////////////////////////

With an above example you can have a display test case status without any signal/variable from the test environment.