Nand2Tetris MUX An internal pin may only be fed once

Viewed 21

I wrote this huge logic for MUX

should be functional on paper but somehow doesnt work here. Not very familiar to the HUJI HDL yet. I initially guessed maybe internal pins are not reusable so I rewrote with seperate pins for every expression.

The error its throwing me is

Line 39, An internal pin may only be fed once by a part's output pin.

Help me out I've been brainstorming this issue but I haven't found anything till rn

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux.hdl

/** 
 * Multiplexor:
 * out = a if sel == 0
 *       b otherwise
 */

CHIP Mux {
    IN a, b, sel;
    OUT out;

    PARTS:
    // Put your code here:
    /**
    * notA B sel
    * a notB notSel
    * a b notSel
    * a b sel
    */
    Not(in=a, out=notA);
    Not(in=b, out=notB);
    Not(in=sel, out=notSel);
    And(a=notA, b=b, out=notAB);
    And(a=notAB, b=sel, out=exp1);

    And(a=a, b=notB, out=anotB);
    And(a=aNotB, b=notSel, out=exp2);

    And(a=a, b=b, out=AB);
    And(a=AB, b=notSel, out=exp3);

    And(a=b, b=sel, out=bSel);
    And(a=a, b=bSel, out=exp4);

    Or(a=exp1, b=exp2, out=exp1_2);
    Or(a=exp3, b=exp4, out=exp3_4);

    Or(a=exp1_2, b=exp3_4, out=out);

}
0 Answers
Related