"Not" gate always outputting 1

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

"Not" gate always outputting 1

hkva
Hello.

I'm just getting started in Chapter 1 and I came across trouble when trying to implement the 4-way demultiplexor: My Not gate is always outputting 1.

As an example, test the following chip with the "DMux4Way.tst" script:
CHIP DMux4Way {
    IN in, sel[2];
    OUT a, b, c, d;

    PARTS:
    // Put your code here:
    Not(in=sel[0], out=notsel0);
    Not(in=sel[1], out=notsel1);
}

Here's the source of my Not gate (linking offsite as to not spoil the solution for others): https://pastebin.com/raw/G0E88dna

If you watch the internal pins in the hardware simulator, you can see that notsel0 and notsel1 are always 1. This has had me stuck for the better part of an hour, so if anyone out there can tell me what I'm doing wrong, that would be greatly appreciated.

-HK
Reply | Threaded
Open this post in threaded view
|

Re: "Not" gate always outputting 1

ivant
Have you implemented it? By default only the NAND gate is implemented. All the others have to be implemented by you and in the order given in the book/course.
Reply | Threaded
Open this post in threaded view
|

Re: "Not" gate always outputting 1

hkva
Yes, I have. My implementation is linked in the original post. I've also been using it in some of the other chips without issue.
Reply | Threaded
Open this post in threaded view
|

Re: "Not" gate always outputting 1

WBahn
Administrator
In reply to this post by ivant
The outputs of your Not gates are just dangling and the simulator doesn't like that.

Route them to actual two of the actual chip outputs and see if you still see the same behavior.
Reply | Threaded
Open this post in threaded view
|

Re: "Not" gate always outputting 1

hkva
Alright, I tried the following code and now the outputs seem to be the opposite of what they should be:
CHIP DMux4Way {
    IN in, sel[2];
    OUT a, b, c, d;

    PARTS:
    // Put your code here:
    Not(in=sel[0], out=notsel0);
    Not(in=sel[1], out=notsel1);
    And(a=notsel0, b=notsel0, out=a);
    And(a=notsel1, b=notsel1, out=b);
}
When "sel" is 01, a is 0 and b is 1. Shouldn't it be the opposite? Routing the Not operations directly to the A and B pins gives the same output.

Here's a screenshot of the hardware simulator: https://i.imgur.com/pDLRmmO.png
Reply | Threaded
Open this post in threaded view
|

Re: "Not" gate always outputting 1

WBahn
Administrator
hkva wrote
Alright, I tried the following code and now the outputs seem to be the opposite of what they should be:
CHIP DMux4Way {
    IN in, sel[2];
    OUT a, b, c, d;

    PARTS:
    // Put your code here:
    Not(in=sel[0], out=notsel0);
    Not(in=sel[1], out=notsel1);
    And(a=notsel0, b=notsel0, out=a);
    And(a=notsel1, b=notsel1, out=b);
}
When "sel" is 01, a is 0 and b is 1. Shouldn't it be the opposite? Routing the Not operations directly to the A and B pins gives the same output.

Here's a screenshot of the hardware simulator: https://i.imgur.com/pDLRmmO.png
I don't see the problem.

If sel = 01, the sel[0] = 1 and sel[1] = 0. That means that notsel0 = 0 and notsel1 = 1. That means that a = 0 and b = 1, which is what you are seeing.
Reply | Threaded
Open this post in threaded view
|

Re: "Not" gate always outputting 1

hkva
Oh, I see. I was assuming the opposite. Thanks!