DMux4Way confusion

classic Classic list List threaded Threaded
11 messages Options
pas
Reply | Threaded
Open this post in threaded view
|

DMux4Way confusion

pas
This post was updated on .
I have solved DMux4Way twice. Both times, I end up very confused.

Solution 1:

[Redacted code using And() and Not()]

Solution 2:

[Redacted code using DMux()]

Can anyone help me understand why conditions B and C always feel backwards?

Thanks!
pas
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

pas
Wait... do I have the bit order backwards?
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

WBahn
Administrator
Look at Fig 1.10 and see what it says.

It says that the output should be 'b' if sel[1]=0 and sel[0]=1.

What does your logic do under those conditions?
pas
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

pas
Thanks for the reply! Fig 1.10 seems to indicate that I do indeed have the bit order backwards. Is sel[0] the rightmost bit?
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

WBahn
Administrator
This post was updated on .
Yes. Think of the index in a multibit bus as representing the exponents in a binary representation of a value. Consider our normal base-10 representation.

234 is 2x10^2 + 2x10^1 + 4x10^0

So we could call the individual digits d[2] = 2, d[1] = 3, and d[0] = 4.

So if we say d = 234, it is understood that the rightmost digit is d[0] and that the indices then increase as we move to the left.

It's the same on a bus representing a binary value.

Even if the signals on the bus don't represent a binary value, it is widely customary to number them the same way for consistency.
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

WBahn
Administrator
BTW, I would agree that the authors didn't make it clear that they are using this convention when they say something like

sel = 10

and they really should have.
pas
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

pas
Got it. Thanks so much for the prompt attention and clear explanation.

I will edit my original post to remove the code.
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

WBahn
Administrator
No problem and thanks for being sensitive to the desire to keep solutions off the board long term.

Good luck with the projects as you progress. You should learn a lot!
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

SirGouki
In reply to this post by WBahn
If you use the drop down in the Hardware simulator that says decimal on it, you can change it to binary and see what sel is set to, it's displayed little endian so it'll show the bits from 7-0 left to right.
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

WBahn
Administrator
SirGouki wrote
If you use the drop down in the Hardware simulator that says decimal on it, you can change it to binary and see what sel is set to, it's displayed little endian so it'll show the bits from 7-0 left to right.
Endianess has no meaning for the hack since it has no concept (within the confines of the project) for multi-word values.

Little endian means that the least significant word (usually a byte) is stored at the lowest memory address. It has nothing to do with bit order within a memory location as this is arbitrary and, by pretty universal convention, when the bit pattern represents a value the least significant bits use lower bus signal indices than more significant bits.

In the basic hack hardware/software stack all values are single-word entities stored at a single memory location. If you wanted to support multi-word values, then you would need to define whether those values are big or little endian (or some other convention -- though I can't think of a good reason for doing so).
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way confusion

nrivera
In reply to this post by WBahn
Yes, I struggled hours.

In the edition2, appendix a2.2 or page 286 they said, but it was easy to miss

On their coursera they said as-well https://www.coursera.org/learn/build-a-computer/lecture/iyL0J/unit-1-7-project-1-overview Unit 1.7: Project 1 Overview about minute 13:30 and 23:00


but I still missed it, until I debugged line by line