# Fatal: (SIGSEGV) Bad handle or reference, Error

**URL:** <https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336>\
**Category:** UVM\
**Tags:** UVM\
**Created:** [April 10, 2014, 2:18pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336 "2014-04-10T14:18:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 10, 2014, 2:18pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/1 "2014-04-10T14:18:28Z")

</div>

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:

```verilog

// 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

```

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 10, 2014, 4:18pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/2 "2014-04-10T16:18:20Z")

</div>

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 “”.

---

<div class="post-metadata">

**Author:** ![sagar.aceic.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sagar.aceic.com](https://verificationacademy.com/forums/u/sagar.aceic.com)\
**Post date:** [April 11, 2014, 3:27am UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/3 "2014-04-11T03:27:37Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/2):_

Please check your set and get method!!

---

<div class="post-metadata">

**Author:** ![siva\_kantamreddy](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@siva\_kantamreddy](https://verificationacademy.com/forums/u/siva_kantamreddy)\
**Post date:** [April 11, 2014, 8:14am UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/4 "2014-04-11T08:14:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 11:28am UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/5 "2014-04-11T11:28:53Z")

</div>

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:

```verilog

// --------------------------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

```

```verilog

// 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

```

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 11:31am UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/6 "2014-04-11T11:31:56Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/5):_

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

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 11, 2014, 12:08pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/7 "2014-04-11T12:08:43Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/6):_

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.

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 12:10pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/8 "2014-04-11T12:10:40Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/7):_

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

---

<div class="post-metadata">

**Author:** ![avi\_rohan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@avi\_rohan](https://verificationacademy.com/forums/u/avi_rohan)\
**Post date:** [April 11, 2014, 12:20pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/9 "2014-04-11T12:20:29Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/8):_

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.

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 12:28pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/10 "2014-04-11T12:28:02Z")

</div>

_In reply to [avi\_rohan](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/9):_

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.

---

<div class="post-metadata">

**Author:** ![avi\_rohan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@avi\_rohan](https://verificationacademy.com/forums/u/avi_rohan)\
**Post date:** [April 11, 2014, 12:43pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/11 "2014-04-11T12:43:45Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/10):_

Please use +UVM\_CONFIG\_DB\_TRACE option from your command line. This should give you more information to debug.

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 11, 2014, 12:58pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/12 "2014-04-11T12:58:19Z")

</div>

_In reply to [avi\_rohan](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/11):_

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.

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 1:05pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/13 "2014-04-11T13:05:15Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/12):_

Thanks cgales,

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

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 11, 2014, 1:52pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/14 "2014-04-11T13:52:38Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/13):_

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.

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 1:58pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/15 "2014-04-11T13:58:22Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/14):_

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

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 1:59pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/16 "2014-04-11T13:59:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 2:15pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/17 "2014-04-11T14:15:44Z")

</div>

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

```verilog

// 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

```

```verilog

// 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

```

```verilog

// 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

```

```verilog

// 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

```

```verilog

// 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

```

```verilog

// 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

```

```verilog

// 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****

```

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 11, 2014, 2:18pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/18 "2014-04-11T14:18:25Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/17):_

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?

---

<div class="post-metadata">

**Author:** ![Neshagar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/n/ba9def/32.png) [@Neshagar](https://verificationacademy.com/forums/u/Neshagar)\
**Post date:** [April 11, 2014, 2:50pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/19 "2014-04-11T14:50:55Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/18):_

no, i delete the comment here.

this error refers to the last line of this code:

```verilog

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

```

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [April 11, 2014, 3:18pm UTC](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/20 "2014-04-11T15:18:12Z")

</div>

_In reply to [Neshagar](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336/19):_

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.

[Next page](https://verificationacademy.com/forums/t/fatal-sigsegv-bad-handle-or-reference-error/29336.md?page=2)
