sel bit ordering question

classic Classic list List threaded Threaded
3 messages Options
Joe
Reply | Threaded
Open this post in threaded view
|

sel bit ordering question

Joe
Hi
I'm either doing something wrong or misunderstanding something. My tests for the Mux4Way16 were failing and when I looked into it the problem was that I was expecting the order of the sel[2] parameter to be the opposite of what it's coming in as.
In other words, if a 2 is supplied to that parm through the test interface I'd expect the 2 bits to be 10 and if I give it a 1 I'd expect it to be 01. As I can tell the order is the opposite.
Anyone have any idea what I'm missing?
Thanks
Joe


 
Reply | Threaded
Open this post in threaded view
|

Re: sel bit ordering question

cadet1620
Administrator
You probably missed that hardware bus bits are numbered from right to left.  For sel = 2 (decimal) = 10 (binary), sel[0] = 0 and sel[1] = 1.  See column headers in fig. 1.10, for example.

This is a common problem for people with programming experience since arrays are numbered from left to right.

The rational for this "backwards" numbering is that bus bit N carries the 2^N bit of a number.

--Mark
Joe
Reply | Threaded
Open this post in threaded view
|

Re: sel bit ordering question

Joe
Thanks for the reply Mark, I did miss that.
Joe