Creating a new circuit using 3 inputs

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

Creating a new circuit using 3 inputs

Daniel J
So, i am trying to create a circuit using 3 inputs, a,b,c. but the and gate i am trying to use wont accept c as a valid input, i am altering a copy of the tst,cmp, and hdl files in order to get this to work. i built the circuit in logism and got it to work, but converting it to the files offered with the nand2tetris built in chips, i cannot get it to work since the and gate will not accept c as an input.

Sincerely,

Daniel J
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new circuit using 3 inputs

cadet1620
Administrator
Here's an example of a three input gate in HDL:
CHIP And3Way {

    IN a, b, c;
    OUT out;

    PARTS:
    And(a=a, b=b, out=x);
    And(a=c, b=x, out=out);
}
Corresponding test and compare files:
    And3Way.tst
    And3Way.cmp

--Mark