The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Modeling >> Behavioral Models >> 2D vector (i.e. array) as an input for an analog function?
https://designers-guide.org/forum/YaBB.pl?num=1393284099

Message started by Vince Lee on Feb 24th, 2014, 3:21pm

Title: 2D vector (i.e. array) as an input for an analog function?
Post by Vince Lee on Feb 24th, 2014, 3:21pm

Hi, I wonder if it is possible to pass a 2D vector into an analog function as an input argument? e.g.

analog function myfunc;
   input x[0:2][0:2];
   real x[0:2][0:2];
   ...
endfunction

Thanks!

Title: Re: 2D vector (i.e. array) as an input for an analog function?
Post by Geoffrey_Coram on Feb 25th, 2014, 12:44pm

There's an example in LRM 2.3.1, section 4.7.1:

Example 3 — Initialization of a vector variable
The analog user defined function called arrayadd adds the contents of a second array to the first.

Code:
 analog function real arrayadd;
   inout [0:1]a;
   input [0:1]b;
   real a[0:1], b[0:1];
   integer i;
   begin
     for(i = 0; i < 2; i = i + 1) begin
       a[i] = a[i] + b[i];
     end
   end
 endfunction


I can't say whether it works in all simulators.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.