SourceSV Verification Directory

Static Cast

Casting refers to conversion of a variable to one data type to another data type. SystemVerilog provides two types of casting,

  1. Static Casting
  2. Dynamic Casting

Static Casting

Static casting converts one data type to another compartible datatypes, as the name suggest, the conversion data type is fixed. The cast (’) operator should be placed before the data along with the intended data type.

Example

module static_conv;

  int  i = 75;
  real r = 13.75;


  initial begin

    int  m = i * (int '(r));
    real k = (real '(i)) * r;

    $display("multiplication result in int  = %0f", m);
    $display("multiplication result in real = %0f", k);

  end

endmodule

Execute the code in EDA Playground