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.

Negative array index

Status
Not open for further replies.

mahmood.n

Member level 5
Joined
Dec 2, 2011
Messages
85
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
2,046
What is the purpose of defining an array with negative index?! If I define
Code:
type myArray is (Natural <>) of bit;
Then I can use

Code:
signal myBitArray : myArray( 10 downto 0 )

and use myBitArray(10)...myBitArray(0)

But
Code:
type myArray is (Negative <>) of bit;
Means
Code:
signal myBitArray : myArray( -10 to 0 )
So what does myBitArray(-10) means?
 

its just a way of indexing. In VHDL you can use any type you want as the index, so if you wanted, you could to this:

Code:
type my_ar_t is array( character range <> ) of integer;

signal my_ar : my_ar_t('n' to 'y');

my_ar('r') <= 10;
 
You would need a purpose for a negative index. This currently is used for fixed point numbers in VHDL 2008. negative indicies represent fractions. x(-1) represents 0.5, x(-2) is 0.25, etc...

In other languages, negative values can be used to represent samples before a triggered event.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top