Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Arrays of real in the port declaration

 
Thread Tools Search this Thread
Old 03-25-2006, 03:58 PM   #1
Default Arrays of real in the port declaration


Hi,

I'm trying to write a simple grammar for VHDL and I'm stuck on how to
declare an array of real numbers in the port declaration. Why is it that the
straightforward representation [2] similar to the one used using bit_vector
[1] doesn't work? How should it be declared? Is there an elegant way around
it besides listing all the elements in the port declaration, for instance,
d0, d1, d2, d3?


[1]:
entity myModel is
port (d: in bit_vector (0 to 3);
result: out bit);
end myModel;


[2]:
entity myModel is
port (d: in array (0 to 3) of real;
result: out real);
end myModel;


Many thanks.

Candida

---
Candida Ferreira, Ph.D.
Chief Scientist, Gepsoft
http://www.gene-expression-programming.com/author.asp

GEP: Mathematical Modeling by an Artificial Intelligence
(Springer Verlag edition 2006)
http://www.gene-expression-programmi...ooks/index.asp
Online Version:
http://www.gene-expression-programmi...troduction.htm

Modeling Software:
http://www.gepsoft.com/




Candida Ferreira
  Reply With Quote
Old 03-25-2006, 06:11 PM   #2
Duane Clark
 
Posts: n/a
Default Re: Arrays of real in the port declaration
Candida Ferreira wrote:
> Hi,
>
> I'm trying to write a simple grammar for VHDL and I'm stuck on how to
> declare an array of real numbers in the port declaration. Why is it that the
> straightforward representation [2] similar to the one used using bit_vector
> [1] doesn't work? How should it be declared? Is there an elegant way around
> it besides listing all the elements in the port declaration, for instance,
> d0, d1, d2, d3?


Normally I would have a package file for the project with a declaration
like:
type RealArr_Type is array (0 to 3) of real;

Then use that in the port declaration.

entity myModel is
port (d: in RealArr_Type;
result: out real);
end myModel;


Duane Clark
  Reply With Quote
Old 03-25-2006, 06:29 PM   #3
KJ
 
Posts: n/a
Default Re: Arrays of real in the port declaration
Try...
type arr_Reals is array <> of real; -- Defines a new type called
'arr_Reals' which is an array of reals (size is not yet determined).
entity myModel is
port (d: in arr_Reals(0 to 3); -- Defines 'd' to be an array of 4
reals....indexed from 0 to 3
result: out bit);
end myModel;

KJ

"Candida Ferreira" <> wrote in message
news:TMdVf.122084$ .uk...
> Hi,
>
> I'm trying to write a simple grammar for VHDL and I'm stuck on how to
> declare an array of real numbers in the port declaration. Why is it that
> the straightforward representation [2] similar to the one used using
> bit_vector [1] doesn't work? How should it be declared? Is there an
> elegant way around it besides listing all the elements in the port
> declaration, for instance, d0, d1, d2, d3?
>
>
> [1]:
> entity myModel is
> port (d: in bit_vector (0 to 3);
> result: out bit);
> end myModel;
>
>
> [2]:
> entity myModel is
> port (d: in array (0 to 3) of real;
> result: out real);
> end myModel;
>
>
> Many thanks.
>
> Candida
>
> ---
> Candida Ferreira, Ph.D.
> Chief Scientist, Gepsoft
> http://www.gene-expression-programming.com/author.asp
>
> GEP: Mathematical Modeling by an Artificial Intelligence
> (Springer Verlag edition 2006)
> http://www.gene-expression-programmi...ooks/index.asp
> Online Version:
> http://www.gene-expression-programmi...troduction.htm
>
> Modeling Software:
> http://www.gepsoft.com/
>
>





KJ
  Reply With Quote
Old 03-26-2006, 12:39 AM   #4
Candida Ferreira
 
Posts: n/a
Default Re: Arrays of real in the port declaration
Duane Clark wrote:
> Normally I would have a package file for the project with a declaration
> like:
> type RealArr_Type is array (0 to 3) of real;
>
> Then use that in the port declaration.
>
> entity myModel is
> port (d: in RealArr_Type;
> result: out real);
> end myModel;


That was really helpful; thank you so much Duane and KJ. The kind of code
I'm trying to generate automatically using APS is shown below:

library IEEE;

use ieee.math_real.all;



package apsModelTypes is

type RealArr_Type is array (0 to 3) of real;

end apsModelTypes;



use work.apsModelTypes.all;



entity apsModel is

port (d: in RealArr_Type;

result: out real);

end apsModel;



architecture apsGeneratedCode of apsModel is



function apsOR1(x, y: real) return real is

begin

if (x < 0.0 or y < 0.0) then

return 1.0;

else

return 0.0;

end if;

end apsOR1;



begin



geneConcatenation: process(d)

constant g1c1: real := 2.5;

constant g1c2: real := -2.3;

variable varTemp: real := 0.0;

begin

varTemp := apsOR1(d(1),d(3));

varTemp := varTemp + (-((d(1) / d(0))));

varTemp := varTemp + (-(((d(2) * (d(3) + d(1))) - d(2))));

varTemp := (g1c1 - d(3));

result <= varTemp;

end process geneConcatenation;



end apsGeneratedCode;





Thanks again.

Candida




Candida Ferreira
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not access console port of Cisco 7200 vxr mansurbd Hardware 1 01-12-2009 06:53 PM
How to check current event and port status for Aliwei FXO gateway Robin wang Hardware 0 04-11-2008 09:54 AM
Port 445: Effective/Safe Blocking Samwise General Help Related Topics 0 01-06-2008 09:19 PM
Long, regarding a "lost" COM port smackedass A+ Certification 4 02-05-2007 04:55 PM
New Releases: Troy, Ultimate Matrix & status changes: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 1 08-31-2004 01:02 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46