# How does uvm\_hdl\_force different from force?

**URL:** <https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374>\
**Category:** UVM\
**Tags:** UVM, uvm\_hdl\_force\
**Created:** [April 22, 2018, 8:28pm UTC](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374 "2018-04-22T20:28:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlsxdx](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/ba9def/32.png) [@mlsxdx](https://verificationacademy.com/forums/u/mlsxdx)\
**Post date:** [April 22, 2018, 8:28pm UTC](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374/1 "2018-04-22T20:28:23Z")

</div>

Hi,

I am trying to use uvm\_hdl\_force to force design signals, however, it doesn’t work. However, force works. I wonder what is the difference between uvm\_hdl\_force and force except the syntax.

Interestingly, VCS and Incisive give different results on uvm\_hdl\_force.  
For the below example,  
VCS output: X  
Incisive: Z 1 0 X Z

```verilog
import uvm_pkg::*;

module tb;
  dut dutI();
  
  initial run_test("test1");
  initial $monitor($time,,dutI.force_bit);
  
  initial begin
    $dumpfile("test.vcd");
    $dumpvars(0, tb);
  end
  
  `ifdef USE_FORCE
  initial begin
      force tb.dutI.force_bit = 1;
      #1ns;
      force tb.dutI.force_bit = 0;
      #1ns;
      force tb.dutI.force_bit = 'x;
      #1ns;
      force tb.dutI.force_bit = 'z;
      #1ns;
  end
  `endif
endmodule

class test1 extends uvm_test;
  string force_path = "tb.dutI.force_bit";
  
  `uvm_component_utils(test1)
  
  function new(string name, uvm_component parent);
    super.new(name,parent); 
  endfunction
  
  virtual function void start_of_simulation_phase(uvm_phase phase);
    super.start_of_simulation_phase(phase);
    //uvm_hdl_force force the value of 'z
    `ifndef USE_FORCE
    uvm_hdl_force(force_path,'z);
    `endif
  endfunction
  
  virtual task run_phase(uvm_phase phase);
    logic val_set[$] = '{1,0,'x,'z};
    
    phase.raise_objection(this);
    #1ns;
    `ifndef USE_FORCE
    foreach(val_set[i]) begin
      uvm_hdl_force(force_path,val_set[i]);
      #1ns;
    end
    `endif
    
    #10ns;
    phase.drop_objection(this);
  endtask
  
endclass

```

```verilog
module dut();
  logic[1:0] force_bit;
  model modelI(.*);
endmodule

module model(input logic[1:0] force_bit);
  parameter ONE = 1;
  //initial force force_bit = ONE;
endmodule

```

> **[EDA Playground](https://www.edaplayground.com/x/3UTP)**
>
> Edit, save, simulate, synthesize SystemVerilog, Verilog, VHDL and other HDLs from your web browser.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [April 23, 2018, 7:18am UTC](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374/2 "2018-04-23T07:18:56Z")

</div>

_In reply to [mlsxdx](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374):_

The difference is that SystemVerilog’s **force** construct searches for pathnames at the compilation time and symbolically binds the path to the assignment statement, the same as it does for any kind of hierarchical reference in any kind of statement.

The UVM’s uvm\_hdl\_force() method uses the C VPI interface to search for signal using a string pathname at runtime. Once it finds the signal via a string loop-up, it uses another C VPI routine that applies a force. In order to lookup a signal using a string pathname, certain optimizations need to be turned off that keeps the signal visible, and the string names have to be stored as well. There may be tool specific options to make this work, and this forum is not for tool specific help.

---

<div class="post-metadata">

**Author:** ![VaishnaviBalasubramanian](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/d2c977/32.png) [@VaishnaviBalasubramanian](https://verificationacademy.com/forums/u/VaishnaviBalasubramanian)\
**Post date:** [July 26, 2021, 9:00pm UTC](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374/3 "2021-07-26T21:00:27Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374/2):_

Would this mean that uvm\_hdl\_force takes non-zero simulation time as comepared to SV force?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [July 26, 2021, 9:22pm UTC](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374/4 "2021-07-26T21:22:53Z")

</div>

_In reply to [Vaishnavi Balasubramanian](https://verificationacademy.com/forums/t/how-does-uvm-hdl-force-different-from-force/34374/3):_

Both constructs do not consume time (or block). The uvm\_hdl\_force can only apply a constant forced value, whereas the SV force can apply non-constant expression as well as constants.
