Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

vhdl 2 dimensional array range

Status
Not open for further replies.

rourabpaul

Member level 3
Joined
Aug 14, 2010
Messages
67
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
kolkata
Activity points
1,747
I am using ise14.1 vhdl
I have a record

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
type t_ChargeProperties is record
    Charge : t_Charge; --10
    Time   : t_Time;--10
    Row    : t_Row;--6
    Pad    : t_Pad;--8
    --Gain   : t_Gain;--13
    --Branch : t_Branch;--1
    FLPad  : std_logic;--1
end record;


and types

Code VHDL - [expand]
1
2
3
type t_ChargeProperties_stream is array ( 0 to 7) of t_ChargeProperties;
type t_ChargeProperties_stream_n is array ( 0 to 3) of t_ChargeProperties;
type t_ChargeProperties_stream_7 is array ( 0 to 8 ) of t_ChargeProperties_stream;



I declared 2 signals

Code VHDL - [expand]
1
2
signal buffer_7 : t_ChargeProperties_stream_7;
signal buffer_n : t_ChargeProperties_stream_n;



now I want a slice of buffer_7 into buffer_n which is giving array index error when I wrote this line

Code VHDL - [expand]
1
buffer_n<=buffer_7(0)(0 to 3);

 

The signals have different type and aren't assignment compatible. You need to refer to the common base type, using a generate or loop statement.
Code:
GEN1:
FOR I IN 0 TO 3 GENERATE
  buffer_n(I)<=buffer_7(0)(I);
END GENERATE;
 

1
2
3
what will be happen if I write this


type t_ChargeProperties_stream is array ( 0 to 7) of t_ChargeProperties;
type t_ChargeProperties_stream_n is array ( 0 to 3) of t_ChargeProperties;
type t_ChargeProperties_stream_7 is array ( 0 to 8, 0 to 7 ) of t_ChargeProperties_;
 

you may get away with this because the slice you created and buffer_n are similar types, so you should be able to do it via a type conversion:

buffer_n <=t_ChargeProperties_stream_n ( buffer_7(0)(0 to 3) );

The slice itself is a different type from buffer_n - hence the need for a type conversion.

Your second attempt is going to fail, as you cannot slice a 2D array at all.
 

type t_ChargeProperties_stream is array ( 0 to 7) of t_ChargeProperties;
type t_ChargeProperties_stream_n is array ( 0 to 3) of t_ChargeProperties;
type t_ChargeProperties_stream_7 is array ( 0 to 8, 0 to 7 ) of t_ChargeProperties_;
You should define the type as an unconstrained array like this...
Code:
type t_ChargeProperties_stream is array (natural range <>) of t_ChargeProperties;
That way you don't need the 'stream_n' or the 'stream_7' versions. You just declare signals of that type and whatever range you want. You'll still need to define the 2D version as a new type, but I would do it like this...
Code:
type t_ChargeProperties_stream_7 is array ( natural range <>, natural range <> ) of t_ChargeProperties;
There is no way to take a slice of a 2d array without writing your own function to do so. If you are intent on using slices, then you need to redefine your 2d array type to be an array of an array like this...
Code:
type t_ChargeProperties_stream_7 is array (natural range <>) of t_ChargeProperties(0 to 7);
Note that when you choose to do it this way as an array of an array rather than a 2d array, the outermost range can be left unconstrained, but the innermost range must be defined as I've shown. I think this might have changed with VHDL-2008 though, don't recall for sure.

Hope that helps.

Kevin Jennings
 

I think this might have changed with VHDL-2008 though, don't recall for sure.

Yes it has:

Code:
type t_ChargeProperties_stream is array (natural range <>) of t_ChargeProperties;
type t_ChargeProperties_stream_arr is array (natural range <>) of t_ChargeProperties_stream;


my_sig : t_ChargeProperties_stream_arr(0 to 7)(7 downto 0);
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top