Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Arrays in VHDL ( DOWNTO and TO)

3 views
Skip to first unread message

Ramnath

unread,
Nov 10, 2001, 6:52:05 AM11/10/01
to
hi,

I am using vhdl for analysising the network packets.
The trouble started with the way array are decleared.
Why is that all most all use "downto" rather than "to", i really
got confused with this.

Is it some way related to Big Indian and Small Endian ( i do not
know which one is the correct spelling).

What is the use of downto---

Sorry if the question is very simple.

Ramnath

Reto Zimmermann

unread,
Nov 10, 2001, 3:35:42 PM11/10/01
to
Ramnath wrote:

> I am using vhdl for analysising the network packets.
> The trouble started with the way array are decleared.
> Why is that all most all use "downto" rather than "to", i really
> got confused with this.
>
> Is it some way related to Big Indian and Small Endian ( i do not
> know which one is the correct spelling).
>
> What is the use of downto---

In the hardware world, it is common to denote signal buses as vectors of
bits that go from MSB (left) to LSB (right). Since buses often
represent binary numbers, it is meaningful to give a bit an index that
corresponds to its magnitude in the number representation, which is 0
for the LSB (right) and n-1 for the MSB (left) for an n-bit bus.

Therefore, you often see buses denoted as BUS[15:0] (like in Verilog) or
BUS(15 downto 0) (in VHDL).

Reto

Mike Treseler

unread,
Nov 11, 2001, 3:53:41 PM11/11/01
to

Ramnath wrote:
>
> hi,
>
> I am using vhdl for analysising the network packets.
> The trouble started with the way array are decleared.
> Why is that all most all use "downto" rather than "to", i really
> got confused with this.

Lets say I have a vector "10000000"
If I declare it DOWNTO, then the '1' bit has the largest index.
If I declare it TO, then the '1' bit has the smallest index.

> Is it some way related to Big Indian and Small Endian ( i do not
> know which one is the correct spelling).

It's related, but endianness
concerns the order of slicing octets out
of a 16, 32 or 64 bit vector.

> What is the use of downto---
>

I use DOWNTO for numeric vectors
and TO for bitstreams where the
the least significant bit goes first.

--Mike Treseler

Ray Andraka

unread,
Nov 11, 2001, 9:38:21 PM11/11/01
to
I also use TO for shift registers used as delay lines, that way the index
is equal to the number of clock cycles delay.

Mike Treseler wrote:

--
--Ray Andraka, P.E.
President, the Andraka Consulting Group, Inc.
401/884-7930 Fax 401/884-7950
email r...@andraka.com
http://www.andraka.com

"They that give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety."
-Benjamin Franklin, 1759


Allan Herriman

unread,
Nov 11, 2001, 10:54:57 PM11/11/01
to
On Mon, 12 Nov 2001 02:38:21 GMT, Ray Andraka <r...@andraka.com> wrote:

>I also use TO for shift registers used as delay lines, that way the index
>is equal to the number of clock cycles delay.

That's funny, I use DOWNTO for shift registers, and the index is equal


to the number of clock cycles delay.

I guess you shift right, and I shift left.

BTW, the OP should read Jonathan Swift's Gulliver's Travels.

From http://www.maxmon.com/1726ad.htm

In 1980, a famous paper written by Danny Cohen entitled
"On Holy Wars and a Plea for Peace" used the terms
big-endian and little-endian to refer to the two techniques for
storing data. These terms, which are still in use today, were
derived from that part of Gulliver's tale whereby two countries
go to war over which end of a hard-boiled egg should be
eaten first -- the little end or the big end!

Regards,
Allan.

Andy Peters

unread,
Nov 12, 2001, 4:53:15 PM11/12/01
to
Ramnath wrote:
> I am using vhdl for analysising the network packets.
> The trouble started with the way array are decleared.
> Why is that all most all use "downto" rather than "to", i really
> got confused with this.


I use "downto" when dealing with most busses, and things that are likely
to be numbers (counters, addresses, etc).

I use "to" when indexing memory elements.

For instance, an eight-bit wide, 1024-word deep RAM type could be declared:

type RAM_TYPE is array (0 to 1023) of std_logic_vector (7 downto 0);

[NB: The clever coder would use generics for the RAM's depth and width.]

--a

0 new messages