Fatal: (SIGSEGV) Bad handle or reference, Error

Hi,

I’m student. And I’m new to the SystemVerilog and UVM. So, forgive me in advance if my question might be basic.
I try to add “Test” and “Config Database” in my verification environment. When I try to simulate, I face the following error:
(the error refer to the connect phase of my class.)

** Fatal: (SIGSEGV) Bad handle or reference.

Time: 0 ns Iteration: 13 Process: /uvm_pkg::uvm_phase::m_run_phases/#FORK#1813_f4e5341 File: Driver.sv

Fatal error at Driver.sv

here is my Driver code:



// Deriver of our Verification

import uvm_pkg::*;
import my_pkg::*; //import our package here

`include"uvm_macros.svh"

class Driver extends uvm_driver #(my_transaction); // the Deriver that has been parametrize with our Transaction -- #(my_transaction);
  `uvm_component_utils(Driver);
  
  virtual Exc1_if Exc1_if_instance;     // Virtual Interface to connect to the DUT, *****AcademyVerification Basic Session 3
  
  my_config m_config; // -------------Database config 
  
  
  function new(string name, uvm_component parent=null);
    super.new(name, parent);
  endfunction: new
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    if(!uvm_config_db #(my_config)::get(this, "*", "my_config", m_config))
      `uvm_info("ALU TEST", "my_config exists", UVM_LOW);
  endfunction: build_phase

// Connect phase
function void connect_phase(uvm_phase phase);
    Exc1_if_instance = m_config.config_vif;
  endfunction: connect_phase
  
  
// Run Phase
virtual task run_phase(uvm_phase phase);
phase.raise_objection(this, "commence");    

 repeat(10)
  begin
    my_transaction seqitem;
      seq_item_port.get_next_item(seqitem); // we get next item, This is the connection that we made between the Driver and Sequence, ****AcademyVerification Basic Session 5
          // drive the Pin Wiggles in Virtual Interface
          Exc1_if_instance.oprnd_a = seqitem.oprnd_a;
          Exc1_if_instance.oprnd_b = seqitem.oprnd_b;
          Exc1_if_instance.operation = seqitem.operation;
          
          $display("operation = %x", Exc1_if_instance.operation);
          $display("operand a = %x", Exc1_if_instance.oprnd_a);
          $display("operand b = %x", Exc1_if_instance.oprnd_b);
          $display("result = %x", Exc1_if_instance.result);
        seq_item_port.item_done(); //signal back to the sequence indicating that we are done ****AcademyVerification Basic Session 5
  end
 
phase.drop_objection(this, "finish");       
endtask: run_phase
endclass: Driver


This is most likely due to m_config not being read correctly from the uvm_config_db. Check that the set() and get() are using the same names. I see that your get() call has “*” for the hierarchy (second argument). This should normally be “”.

In reply to Neshagar:

Please check your set and get method!!

hai neshagar.
the error is probably due to creation of component or object.some where in top of the scope you have not created the object and your are trying to use that class handle.verify the config db is created or not in the top level scope.

First of all, Thank you so much for advices.

But, I’ve checked my set() and get (). I could not find any fault yet… Everything seems all right. When I compile, Everything is ok even, But when I simulate. Same error again.

Here is my Test, And Config class as well:



// --------------------------Config class
import uvm_pkg::*;
import my_pkg::*; //import our package here
`include "uvm_macros.svh"

class my_config extends uvm_object;
  `uvm_object_utils(my_config); 
  virtual Exc1_if config_vif; //virtual interface to driver
  int iterations;  
  function new(string name = "");
    super.new(name);
  endfunction  
endclass




// more information on Test class on ***** VerificationAcademy Basic UVM, session 6 video ******
// And Course Slide, Lecture 4
// ---------------------------------Test class (my_test1)

import uvm_pkg::*;
import my_pkg::*; //import our package here

`include "uvm_macros.svh"  

class my_test1 extends uvm_test;    // typically we start the sequences with a Test.  *** VerificationAcademy Basic Session 6 Video
  
    `uvm_component_utils(my_test1)   // Register the test as a component
       
    my_env my_env_h;   // the test will instantiate the Environment
    
    my_config m_config;  // ----------------------------------------------- 
    
    my_seq seq;
    
    function new(string name, uvm_component parent=null);
      super.new(name, parent);
    endfunction: new
   
    // ----------------------------------------------- 
    function void set_config_params();
      m_config = my_config::type_id::create("m_config");
      
      if (!uvm_config_db #(virtual Exc1_if)::get(this, "","top_pif", m_config.config_vif))
        `uvm_fatal("ALU test", "Can't read the VI - config_vif");  
      
     uvm_config_db #(my_config)::set(this, "", "my_config", m_config);
      m_config.iterations = 10;
      
    endfunction; 
    // -----------------------------------------------
   
    function void build_phase(uvm_phase phase);
      m_config = new();
      super.build_phase(phase);
      set_report_verbosity_level_hier(UVM_MEDIUM);
      my_env_h = my_env::type_id::create("my_env_h", this);
      set_config_params();
      
    endfunction: build_phase
    
   task run_phase (uvm_phase phase);
      seq = my_seq ::type_id::create("seq");   // create an instance of our "sequence", in my case "my_seq"
      phase.raise_objection(this);
      seq.start ( my_env_h.sequencer_h);      // Starting the test , the argument is the sequence that will start , *** VerificationAcademy Basic session 6 Video
      phase.drop_objection(this);
    endtask
    
  endclass: my_test1

In reply to Neshagar:

I changed the “*” to “” in both the Driver, and the Test.

In reply to Neshagar:

You want to set the target hierarchy in the set() method. Using “” will not work. You can use “*” to begin with but it applies to the entire sub-hierarchy and might cause conflicts as you progress.

You want “” in the get() method.

In reply to cgales:

Yes, you right. But I have change it all to “*”, again same error.

In reply to Neshagar:

Hi Neshagar,

Looks like you might have not created an object of the ‘my_config’ class and you are just trying to push an empty handle into the configuration database. Try creating a new object of the ‘my_config’ class using ::type_id::create in the build phase of your test for eg. Hope that helps.

In reply to avi_rohan:

Thanks for the help avi_rohan,

Actually, I’ve create it on the function called “set_config_params()” and call the function on build phase.

But, I did what you advised. again, same error.

In reply to Neshagar:

Please use +UVM_CONFIG_DB_TRACE option from your command line. This should give you more information to debug.

In reply to avi_rohan:

The issue is that you are calling set_config_parms() AFTER you are creating the environment. You need to ensure that all your config_db set() calls are done BEFORE creating the env.

In reply to cgales:

Thanks cgales,

you are right, but, I’ve tried this. Same error.

In reply to Neshagar:

You need to post the complete code so that it can be compiled. You are missing a lot of packages that prevent compilation. Also post the complete log. I’m guessing there are additional messages that can be helpful.

Make sure you have “*” as the hierarchy in the set() and “” as the hierarchy in the get(). Your comments make it seem like you change them both to be the same when they should be different.

In reply to cgales:

Thanks for the help cgales, Here is my log, and complete code.

Here is my log :

vlog -f compile.f

QuestaSim vlog 10.0d Compiler 2011.10 Oct 30 2011

– Compiling package my_pkg

– Importing package mtiUvm.uvm_pkg (uvm-1.0p1 Built-in)

** Note: (vlog-2286) Using implicit +incdir+/soft/Mentor/Questa_10.0d/questasim/uvm-1.1/…/verilog_src/uvm-1.1/src from import uvm_pkg

– Compiling interface Exc1_if

– Compiling module ALU

– Compiling module top

Top level modules:

top

vsim -do “run -all” top

vsim -do {run -all} top

** Note: (vsim-3813) Design is being optimized due to module recompilation…

Loading sv_std.std

Loading mtiUvm.uvm_pkg

Loading work.my_pkg(fast)

Loading work.top(fast)

Loading /soft/Mentor/Questa_10.0d/questasim/uvm-1.1/linux/uvm_dpi.so

run -all

----------------------------------------------------------------

UVM-1.1

(C) 2007-2011 Mentor Graphics Corporation

(C) 2007-2011 Cadence Design Systems, Inc.

(C) 2006-2011 Synopsys, Inc.

(C) 2011 Cypress Semiconductor Corp.

----------------------------------------------------------------

UVM_INFO @ 0: reporter [RNTST] Running test my_test1…

UVM_INFO @ 0: reporter [UVMTOP] UVM testbench topology:

----------------------------------------------------------

Name Type Size Value

----------------------------------------------------------

env_h my_env - @444

Driver_h Driver - @468

rsp_port uvm_analysis_port - @485

sqr_pull_port uvm_seq_item_pull_port - @476

sequencer_h uvm_sequencer - @494

rsp_export uvm_analysis_export - @502

seq_item_export uvm_seq_item_pull_imp - @608

arbitration_queue array 0 -

lock_queue array 0 -

num_last_reqs integral 32 'd1

num_last_rsps integral 32 'd1

uvm_test_top my_test1 - @456

----------------------------------------------------------

UVM_INFO Driver.sv(29) @ 0: env_h.Driver_h [ALU TEST] my_config exists

UVM_INFO @ 0: reporter [UVMTOP] UVM testbench topology:

------------------------------------------------------------

Name Type Size Value

------------------------------------------------------------

env_h my_env - @444

Driver_h Driver - @468

rsp_port uvm_analysis_port - @485

sqr_pull_port uvm_seq_item_pull_port - @476

sequencer_h uvm_sequencer - @494

rsp_export uvm_analysis_export - @502

seq_item_export uvm_seq_item_pull_imp - @608

arbitration_queue array 0 -

lock_queue array 0 -

num_last_reqs integral 32 'd1

num_last_rsps integral 32 'd1

uvm_test_top my_test1 - @456

my_env_h my_env - @660

Driver_h Driver - @677

rsp_port uvm_analysis_port - @694

sqr_pull_port uvm_seq_item_pull_port - @685

sequencer_h uvm_sequencer - @703

rsp_export uvm_analysis_export - @711

seq_item_export uvm_seq_item_pull_imp - @817

arbitration_queue array 0 -

lock_queue array 0 -

num_last_reqs integral 32 'd1

num_last_rsps integral 32 'd1

------------------------------------------------------------

** Fatal: (SIGSEGV) Bad handle or reference.

Time: 0 ns Iteration: 13 Process: /uvm_pkg::uvm_phase::m_run_phases/#FORK#1813_f4e5341 File: Driver.sv

Fatal error at Driver.sv line 36

HDL call sequence:

Stopped at Driver.sv 36

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_common_phases.svh 101

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_bottomup_phase.svh 104

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_bottomup_phase.svh 81

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_bottomup_phase.svh 61

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_bottomup_phase.svh 61

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_phase.svh 1189

called from /soft/Mentor/Questa_10.0d/questasim/linux/…/verilog_src/uvm-1.1/src/base/uvm_phase.svh 1814

quit -sim

Here is my full code. Each class in in separate .sv file.


// this is the DUT, It is a simple ALU -- ALU.sv

module ALU (
  input wire [3:0] operation,     //The ALU ports as specified
  input wire[2:0] sr_operation,
  input wire [7:0] oprnd_a,oprnd_b,
  input wire [7:0] input_port,
  input wire [7:0] port_address,
  output reg [7:0] result,
  output reg zero, carry,
  output reg output_port, port_id);
  
  always @*
  begin
    case(operation)
      4'd0: begin
        result= oprnd_a;
      end
      4'd1: begin
        result = (oprnd_a & oprnd_b);
      end
      4'd2: begin
        result = (oprnd_a | oprnd_b);
      end
      4'd3: begin
        result = (oprnd_a ^ oprnd_b); //XOR
      end
      4'd4: begin
        result = (oprnd_a + oprnd_b);
      end
      4'd5: begin
        result = (oprnd_a - oprnd_b);
      end
      4'd6: begin
        result = (oprnd_a ~^ oprnd_b); //XNOR
      end
      4'd7: begin
        result = (oprnd_a * oprnd_b); //multiplication
      end
      4'd8: begin
        result = oprnd_b;
      end
      4'd9: begin        
        result = ~oprnd_a;
      end      
      4'd10: begin
        result = ~oprnd_b;
      end
      4'd11: begin  //b
        result = -oprnd_a;
      end
      4'd12: begin
        result = -oprnd_b;
      end
      default: begin
        result = 4'd0;
      end
    endcase
  end
endmodule



// Sequence.sv -------- our sequencea
import uvm_pkg::*;
import my_pkg::*; //import our package here

`include"uvm_macros.svh"

// Our Sequence definition, **** VerificationAcadamy Basic Session 5
class my_seq extends uvm_sequence #(my_transaction);
  `uvm_object_utils(my_seq)
  
  function new(string name = "");
    super.new(name);
  endfunction: new
  
  // This where we define the behavior of the sequence, **** VerificationAcadamy Basic Session 5
  task body();
    uvm_test_done.raise_objection(this);
    repeat(10)
    begin
      my_transaction seqitem;
      seqitem = my_transaction::type_id::create("seqitem");  //we creat a transaction
     //hand shaking mechanisim, we use to comminucate to the Derivver **** VerificationAcadamy Basic Session 5
      start_item(seqitem); // indicate to Driver that we have a transction to go
      assert(seqitem.randomize()); // randomize
      finish_item(seqitem);  // sends the transaction to the Deriver, **** VerificationAcadamy Basic Session 5
    end
    
    uvm_test_done.drop_objection(this);
  endtask: body
endclass: my_seq



// Transaction.sv  ---- the transaction class
import uvm_pkg::*;
import my_pkg::*; //import our package here

`include"uvm_macros.svh"

class my_transaction extends uvm_sequence_item;   //Transaction extends from UVM_item  *** VerificationAcademy Basic Session 5
  
  
   `uvm_object_utils(my_transaction)
  
  function new (string name = "");
    super.new(name);  
  endfunction: new
 
  //Data field, randam data generation 
  rand logic[7:0] oprnd_a;
  rand logic[7:0] oprnd_b;
  rand logic[3:0]  operation;
  
endclass: my_transaction



// Env.sv ----- the environmenta
import uvm_pkg::*;
import my_pkg::*; //import our package here

`include "uvm_macros.svh"

 class my_env extends uvm_env;   // Setting up the Environment

  typedef uvm_sequencer #(my_transaction) my_sequencer; // we use base sequencer,  **** VerificationAcademy Basic Session 5

    `uvm_component_utils(my_env)
    
    Driver Driver_h;             
    my_sequencer sequencer_h;
    my_seq seq;
    
    function new(string name, uvm_component parent = null);
      super.new(name, parent);
    endfunction: new
    
    function void build_phase(uvm_phase phase);
       // instantiate components (if any)
       super.build_phase(phase);
    Driver_h= Driver::type_id::create("Driver_h", this);
    sequencer_h = my_sequencer::type_id::create("sequencer_h", this);     //ex2
    uvm_top.print_topology();
    endfunction: build_phase

// Connect Phase
function void connect_phase(uvm_phase phase);
    Driver_h.seq_item_port.connect(sequencer_h.seq_item_export);
  endfunction: connect_phase

// Run phase for the simiulation 
    task run_phase(uvm_phase phase);
      seq = my_seq::type_id::create("seq");  
      phase.raise_objection(this);  
      seq.start(sequencer_h);                
       phase.drop_objection(this);
    endtask: run_phase
    
    function void end_of_elaboration_phase(uvm_phase phase);
    uvm_top.print_topology();
    endfunction
     
  endclass: my_env




// Interface.sv  ---- the interface
// Interface decleration for "Excersice 1" - it will include necessry singlas to communicate with the DUT
interface Exc1_if();

logic [3:0] operation;    
logic [2:0] sr_operation;
logic [7:0] oprnd_a, oprnd_b;
logic [7:0] input_port, port_address;

logic output_port, port_id;
logic [7:0] result;
logic zero, carry;

endinterface: Exc1_if





// Pakage to include important UVM stuff


package my_pkg;
  import uvm_pkg::*;
  `include "uvm_macros.svh"
  
  `include "Transaction.sv"
  `include "Sequence.sv"
  `include "Config.sv"
  `include "Driver.sv"
  `include "Env.sv" 
  `include "Test.sv" 
  
  endpackage: my_pkg




// Top.sv -- the top madule
module top;

  import uvm_pkg::*;
  import my_pkg::*; //import our package here
  
  Exc1_if Exc1_if1 ();
  my_env env_h;
  
  ALU dut ( .operation(Exc1_if1.operation),          // The connections are made to the Interface and the DUT, using the interface object and the pins of the DUT. 
            .sr_operation(Exc1_if1.sr_operation),
            .oprnd_a(Exc1_if1.oprnd_a),
            .oprnd_b(Exc1_if1.oprnd_b),
            .input_port(Exc1_if1.input_port),
            .port_address(Exc1_if1.port_address),
            .result(Exc1_if1.result),
            .carry(Exc1_if1.carry),
            .zero(Exc1_if1.zero),
            .output_port(Exc1_if1.output_port),
            .port_id(Exc1_if1.port_id));



initial
begin
  env_h = new("env_h");
  uvm_config_db # (virtual Exc1_if)::set(null, "*", "top_pif", Exc1_if1);
  run_test("my_test1");    // to execute the task,-- in case we have more than 1 test, we can specify wich test  would be run  *** VerificationAcademy session 6 video 
end                        // in case we don't want to put the name hare, we can use "run_test();" . but in command line
endmodule: top             // we can use "Vsim +UVM_TESTNAME=my_test1", to indicate the test name           *** VerificationAcademy session 6 video ****


In reply to Neshagar:

The error message points to line 36 of Driver.sv. Based on what you posted above for Driver.sv, this correlates to the repeat(10) statement. Which statement is line 36?

In reply to cgales:

no, i delete the comment here.

this error refers to the last line of this code:




  function void connect_phase(uvm_phase phase);
    Exc1_if_instance = m_config.config_vif;
  endfunction: connect_phase
 

In reply to Neshagar:

The issue is that you are creating an instance of “my_env” in the top level module. You shouldn’t do this as the environment is contained within the test. Remove my_env env_h from the top() module and try it again.