Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > How to put part of one array into another

Reply
Thread Tools

How to put part of one array into another

 
 
none
Guest
Posts: n/a
 
      09-11-2008
I have 2 arrays declared in my code :

type Array6Deep96Bit is array (6 downto 1) of std_logic_vector (95
downto 0) ;
type Array16Deep96Bit is array (16 downto 1) of std_logic_vector (95
downto 0) ;


In an instantiation of a block of code, I'd like to port the first 6
array words into the block:

port map (
BackplaneSerialDataIn => DataFromPackToMux(6 downto 1),

where BackplaneSerialDataIn is of type Array6Deep96Bit and
DataFromPackToMux is of type Array16Deep96Bit.

I'm using Aldec Active-HDL and it gives me an error stating "Actual
parameter type in port map does not match the port formal type
"BackplaneSerialDataIn"

I've tried different permutations of the instantiation such as
explicitly referencing the array index, but I either get the previous
error message or on that says "No actual specified for local port
"BackplaneSerialDataIn"

Any ideas on how to write this without having to expand out the array to
it's individual elements?

Thanks

Ron
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      09-11-2008
On Sep 11, 2:47*pm, none <(E-Mail Removed)> wrote:
> I have 2 arrays declared in my code :
>
> type Array6Deep96Bit * *is array (6 downto 1) of std_logic_vector (95
> downto 0) ;
> type Array16Deep96Bit * is array (16 downto 1) of std_logic_vector (95
> downto 0) ;
>
> In an instantiation of a block of code, I'd like to port the first 6
> array words into the block:
>
> port map (
> * * * * BackplaneSerialDataIn => DataFromPackToMux(6 downto 1),
>
> where BackplaneSerialDataIn is of type Array6Deep96Bit and
> DataFromPackToMux is of type Array16Deep96Bit.
>
> I'm using Aldec Active-HDL and it gives me an error stating "Actual
> parameter type in port map does not match the port formal type
> "BackplaneSerialDataIn"
>


This is what is known as data type checking. The entity parameter
BackplaneSerialDataIn is type 'Array6Deep96Bit', but you're trying to
give it DataFromPackToMux(6 downto 1) which is a slice of an array of
type 'Array16Deep96Bit', those elements being of type
'std_logic_vector (95 downto 0)'. Since these are two different types
you're getting the error.

Instead you might want to try out the following approach:

type Array96Bit is array(natural range <>) of std_logic_vector (95
downto 0);
subtype Array6Deep96Bit is array (6 downto 1) of Array96Bit;
subtype Array16Deep96Bit is array (16 downto 1) of Array96Bit;

Now the new types 'Array6Deep96Bit' and 'Array16Deep96Bit' are arrays
of the same type and any slice of them will also be of that same type
(i.e. type 'Array96Bit').

It's confusing when you get started creating your types because you
tend to think of it in terms of the definitions of the types that the
thing is made up of. In this case you were looking at your new types
as both being simply different sized collections of the same type of
thing (std_logic_vector(95 downto 0). But a strongly typed language
does not allow for such syntax. It looks at the type that is expected
and expects to find something of that same type being assigned.
Things of type 'xyz' cannot be assigned to something that is of type
'abc' even if the definitions of those two types is identical.

What you need to do is just not look so deeply (i.e. don't look at the
definition of the new types when trying to deduce what the type
mismatch is), just look at the actual types being passed around. By
first defining a generic array type as I did ( i.e. 'Array96Bit') that
can be used to define any range of subtypes from it, you're writing
the code in a manner that it is type correct...and as you can see,
it's not that difficult or different from your original code.

Kevin Jennings
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
stack a array into another array jliu66 Python 0 10-21-2007 04:58 PM
Variable displays at one part while does not in another part in a Jack ASP General 8 05-10-2005 07:26 PM
Need to concatenate all files in a dir together into one file and read the first 225 characters from each file into another file. Tony Perl Misc 5 04-19-2004 03:28 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments