comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@callnetuk.com>
Subject: Re: question about functions (bis)
Date: 2000/01/24
Date: 2000-01-24T00:00:00+00:00	[thread overview]
Message-ID: <388ce9c4@eeyore.callnetuk.com> (raw)
In-Reply-To: 8690s0$8tq$1@news.mgn.net

The 'nice' solution is simple: declare a temporary of the return type, pass
its address to the hardware, and return it at the end of the function.

   function Add (Left, Right: in T) return T is
      Result: T;
   begin
      ASIC_Add(Left'Address,Right'Address,Result'Address);
      return Result;
   end;

   pragma Inline(Add);

Couldn't be easier!

Note the use of a 'pragma Inline' to (hopefully) help with speed (which I
presume matters in this situation). With a bit of luck, the compiler will
optimise reasonably.

--
Nick Roberts
http://www.adapower.com/lab/adaos

"Pascal LEJEUNE" <pascal.lejeune@matra-transport.fr> wrote in message
news:8690s0$8tq$1@news.mgn.net...
> ...
> Finaly, my function ADD use a hardware component which do
> the operation with the addresses (it's an asic which needs
> to know on which variable the operation is done) :
>
> function ADD (A, B : in T) return T is
>    tmp : system.address;
> begin
>    << find the address of the result (that's my problem !!) >> and
>    put it in a local variable (tmp)
>
>    call a procedure which use directly the hardware :
>    proc (a'address, b'address, tmp);
> end ADD;
>
> So, the problem is quite simple : the type T is a "numerical" type
> on which it is normal to have operators ... but the hardware need
> to have the address of the arguments and the address of the result !!!







      parent reply	other threads:[~2000-01-24  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-21  0:00 question about functions (bis) Pascal LEJEUNE
2000-01-21  0:00 ` Philip Anderson
2000-01-21  0:00   ` Jeff Creem
2000-01-21  0:00 ` David C. Hoos, Sr.
2000-01-24  0:00 ` Nick Roberts [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox