Re: Mux4way16 problem

Posted by WBahn on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Mux4way16-problem-tp4035690p4035718.html

Idrisadeniyi wrote
I thought wire numbers are all set by the script and sel is suppose to be the determinant for the out pin.
The value of the 'sel' input selects which data input is routed to the 'out' pin. That's the function you are trying to achieve. But you are the constructor of a chip that will behave like that. The simulator doesn't know or care about how what you construct behaves, it simply runs what you built.

You build a chip by taking wires and connecting this pin to that pin.

Consider the following chip:


CHIP Bubba
{
    IN tom[6];
    OUT sally[2];

    PARTS:
    Not(in = tom[4], out = lou, out = sally[1]);
    Mux4Way(a = tom[2], b = tom[5], c = tom[0], d = tom[3], sel[1] = lou, sel[0] = tom[1], out = sally[0]);
}


Now lets see what happens when I run this chip:

Let's set tom = 101010
This means that:
If tom[5] = 1
If tom[4] = 0
If tom[3] = 1
If tom[2] = 0
If tom[1] = 1
If tom[0] = 0

Since tom[4] = 0, that means that lou = 1 and sally[1] = 1

The inputs to the Mux are sel[1] = 1 (because that's the signal on low) and sel[0] = 1 because that's the signal on tom[1]). That means that what ever is on input 'd', which is tom[3], will get sent to the output, which is connected to sally[0]. So sally[0] will be whatever is on tom[3], which is currently a 1, so sally[0] = 1.

Hence the final output is

sally = sally[1],sally[0] = 11