Product Documentation
Real Number Modeling Guide
Product Version 22.09, September 2022

SystemVerilog Real Variables

In SystemVerilog-2009, there is no concept of real-valued nets. To provide a similar capability as real signals, real data types are can be defined as variables to be driven like nets. That is, real variable port connections can be passed between modules by copying values between variables.

 

You can drive a real variable with a continuous assign:

real r, xr;
assign r = xr;

Here, the variable r is updated whenever the value of xr changes.

Since non-collapsed ports are modeled as continuous assigns, a salutary effect of this is the ability to connect variables as a “reader” to port, either:

Here, SV real ports must be declared as:

input real p,n;
output real out;

Example

The following is an example of a simple amplifier with real variable input/output

module realAmp (p, n, out);
  input real p,n;                  // real variable inputs
  output real out;                 // real variable outputs
  parameter real Av=50;            // gain from input to output [V/V]
  parameter real Vhi=2.5,Vlo=0;    // output voltage limits [V]
  real Vnom;                       // local variable: nominal output

  always_comb begin                // evaluate when any variable changes
    Vnom = Av*(p-n);               // compute nominal output
    if      (Vnom>Vhi) out = Vhi;  // saturated high
    else if (Vnom<Vlo) out = Vlo;  // saturated low
    else               out = Vnom; // normal output
  end
endmodule

Limitations

However, there are certain limitations with real variables in SystemVerilog and Verilog:




 ⠀
X