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

Wreal Arrays

You can declare an array of real nets by specifying the upper and lower indexes of the range. And, each index must be a constant expression that evaluates to an integer value. For example:

wreal w[3:2]; // Declares w as a wreal array.

Similar to buses, a wreal array groups multiple real values into a single, indexible entity. The following example demonstrates the definition of a wreal array:

module ams_tb;
  wreal y[3:2];
  sub_design d1(y);
  initial begin
  #10 $display("%f,%f",y[2],y[3]);
  end
endmodule

module sub_design(r);
  output wreal r [1:0];
  assign r[1] = 2.7182818;
  assign r[0] = 3.142818;
endmodule

Assigning a Complete Array to Another Array

Direct assignment of a complete array to another array is currently not supported. Therefore, assignments have to be split on the scalar level as follows:

module foo(p,r);
  output wreal r [1:0];
  input wreal p [1:0];
  // this is currently not supported
  // assign r=p;
  assign r[0]=p[0];
  assign r[1]=p[1];
endmodule

Connecting Wire Vectors to Wreal Arrays

Wreal vectors have no useful meaning to them when considered as a single entity.

// wreal [7:0] r;
// What would be the meaning of r as a whole?

However, wire vectors can be connected to wreal arrays, as shown in the following example.

module ams_tb;
  wreal y[3:2];
  wire [1:0]x; //Internally, the wreal vector is converted into a wreal array of the same size
  foo f1 (x,y);
  sub_design d1 (x);

  initial begin
    #10 $display("%f,%f",y[2],y[3]);
  end
endmodule

Related Topics




 ⠀
X