Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the uses of force - release statements?

Tags:

verilog

From a hardware point of view, what do force and release statements model? What are the uses of these statements?

like image 626
pradeep Avatar asked Jul 11 '15 09:07

pradeep


People also ask

What is force statement used for?

The force/release statements are generally used to aid in simulations. One scenario is to avoid X-propagation in gate simulations. The RTL code sometimes contains registers without asynchronous resets.

What is force and release in Verilog?

force release The LHS can be a bit-select of a net, part-select of a net, variable or a net but cannot be the reference to an array and bit/part select of a variable. The force statment will override all other assignments made to the variable until it is released using the release keyword.

How force and release statement is different from assign?

The assign-deassign and force-release constructs in Verilog have similar effects, but differ in the fact that force-release can be applicable to nets and variables, whereas assign-deassign is applicable only to variables.

How many types of procedural assignments are there?

There are three varieties of the procedural assignment: The simple procedural assignment, the procedural assignment with an intra-assignment delay, and the nonblocking procedural assignment, all of which are described in this section.


2 Answers

The force/release statements are generally used to aid in simulations.

One scenario is to avoid X-propagation in gate simulations. The RTL code sometimes contains registers without asynchronous resets. Although the RTL simulations will run cleanly, gate simulations often do not. Either the X's never get resolved, or they take so many cycles to resolve so as to make simulations take an impractical amount of time to run. By forcing and releasing a random known value into the register during reset, the simulation is allowed to proceed cleanly and complete in a timely manner.

Another scenario involves large counters. For example, to see a 32-bit counter roll over, it requires 4 billion cycles. Typically, you want it to roll over several times in one simulation. Again, this could take an impractically long time to simulate. The force/release can be used to deposit a random value into the counter close to the roll-over value.

Another scenario involves boosting code coverage results. It can be difficult to achieve 100% coverage on all metrics, especially when using IP which can not be modified. The force can be used to toggle an unused signal.

The force/release should be used sparingly and only when you are convinced it is valid to do so.

like image 118
toolic Avatar answered Sep 27 '22 23:09

toolic


Based on IEEE Std 1364-2005, the force procedural continuous assignment statement shall override all procedural assignments to a variable or net. The release procedural statement shall end a procedural continuous assignment to a variable or net. The value of the variable shall remain the same until the variable is assigned a new value through a procedural assignment or a procedural continuous assignment.

For example:

module test;  
    reg a, b, c, d;
    wire e;
    and and1 (e, a, b, c);

    initial begin
      $monitor("%d d=%b,e=%b", $stime, d, e);
      assign d = a & b & c;
      a = 1;
      b = 0;
      c = 1;
      #10;
      force d = (a | b | c);
      force e = (a | b | c);
      #10;
      release d;
      release e;
      #10 $finish;
    end
endmodule

In the example above and gate and1 is patched to work as or gate. If you simulate it, you'd get following results:

Results:
00 d=0,e=0
10 d=1,e=1
20 d=0,e=0

Without force statement, for t = 10, e should be equal to 0 (since 1 & 0 & 1 = 0). Using force statement overrides result of and1 and force e = 1. But as soon as release is applied to e, the value is change to 0 (the functionality of and gate is restored).

In the example above you can also see that force/release can be applied both to regs (d) and wires (e). This statements are used in testbenches, when you want to force determined value in reg or wire.

like image 39
Qiu Avatar answered Sep 28 '22 00:09

Qiu