On Wednesday 14 June 2006 06:13, Andy Fong wrote:
> In this statement, [3:0] is used to declare that "c" has 4 bits. Treat
> it as 4 wires if you will but this way, you can refer the 4 wires
> collectively as "c". Or if you want to refer to just 1 of those wires,
> you use c[n] where n is between 3 and 0. e.g to refer to the third
> wire you use c[2] where c[0] will be the first wire. Or if you want to
> refer to 2 of those wires, you use something link c[2:1] to refer to
> the 2nd and the 3rd wire.
> 
> Note that the order to put the two number x and y in [x:y] is
> important. This determine the order of the wires. eg you have a "wire
> [3:0] a" and a "wire [0:3] b". When you "assign a = b", you are
> connecting the 4th wire (bit 3) of b to the 1st wire (bit 0) of a, 3rd
> wire (bit 2) of b to the 2nd wire (bit 1) of a and so on...

Further to this: it's a convention to have

 - the MSB ("most significant" bit) of a signal on the "left" of the
   declaration

 - highest index is the MSB, lowest index the LSB ("least significant" bit)

 - and most of the time the LSB has index 0.

The reason for this convention is to make it easier to work out which bit of a 
signal is which, and it makes dealing with numeric signals much easier.

Peter

-- 
Quake II build tools maintainer             http://tinyurl.com/fkldd

v2sw6YShw7$ln5pr6ck3ma8u6/8Lw3+2m0l7Ci6e4+8t4Eb8Aen5+6g6Pa2Xs5MSr5p4
  hackerkey.com

Attachment: pgpqmGRCl3lWG.pgp
Description: PGP signature

_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)

Reply via email to