DMux8Way.."Line 39, A pin name is expected"

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

DMux8Way.."Line 39, A pin name is expected"

hyeonwoo
I've done 'And', 'And16', 'DMux', 'DMux4Way', right this way:Only using Nand Gate.
But while trying DMux8Way, the error is occured.
Can you change this file?
(I'm sorry about lack of comment)



DMux8Way.hdl
// 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/DMux8Way.hdl

/**
 * 8-way demultiplexor:
 * {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000
 *                            {0, in, 0, 0, 0, 0, 0, 0} if sel == 001
 *                            etc.
 *                            {0, 0, 0, 0, 0, 0, 0, in} if sel == 111
 */

CHIP DMux8Way {
    IN in, sel[3];
    OUT a, b, c, d, e, f, g, h;

    PARTS:
//Initialization
    Nand(a=sel[0], b=sel[0], out=nsel0); //not of sel[0]
    Nand(a=sel[1], b=sel[1], out=nsel1);
    Nand(a=sel[2], b=sel[2], out=nsel2);

//Path : 'And' processing
    Nand(a=nsel2, b=nsel1, out=n00);
    Nand(a=n00, b=n00, out=s00);

    Nand(a=nsel2, b=sel[1], out=n01);
    Nand(a=n01, b=n01, out=s01);

    Nand(a=sel[2], b=nsel1, out=n10);
    Nand(a=n10, b=n10, out=s10);

    Nand(a=sel[2], b=sel[1], out=n11);
    Nand(a=n11, b=n11, out=s11);


    Nand(a=s00, b=nsel0, out=n000); //'not' of value of sel for a
    Nand(a=n000,, b=n000, out=sel000); //value of sel for a

    Nand(a=s00, b=sel[0], out=n001);
    Nand(a=n001, b=n001, out=sel001);

    Nand(a=s01, b=nsel0, out=n010);
    Nand(a=n010, b=n010, out=sel010);

    Nand(a=s01, b=sel[0], out=n011);
    Nand(a=n011, b=n011, out=sel011);

    Nand(a=s10, b=nsel0, out=n100);
    Nand(a=n100, b=n100, out=sel100);

    Nand(a=s10, b=sel[0], out=n101);
    Nand(a=n101, b=n101, out=sel101);

    Nand(a=s11, b=nsel0, out=n110);
    Nand(a=n110, b=n110, out=sel110);

    Nand(a=s11, b=sel[0], out=n111);
    Nand(a=n111, b=n111, out=sel111);

//Result
    Nand(a=in, b=sel000, out=aa);
    Nand(a=aa, b=aa, out=a);

    Nand(a=in, b=sel001, out=bb);
    Nand(a=bb, b=bb, out=b);

    Nand(a=in, b=sel010, out=cc);
    Nand(a=cc, b=cc, out=c);

    Nand(a=in, b=sel011, out=dd);
    Nand(a=dd, b=dd, out=d);

    Nand(a=in, b=sel100, out=ee);
    Nand(a=ee, b=ee, out=e);

    Nand(a=in, b=sel101, out=ff);
    Nand(a=ff, b=ff, out=f);

    Nand(a=in, b=sel110, out=gg);
    Nand(a=gg, b=gg, out=g);

    Nand(a=in, b=sel111, out=hh);
    Nand(a=hh, b=hh, out=h);


}

Reply | Threaded
Open this post in threaded view
|

Re: DMux8Way.."Line 39, A pin name is expected"

cadet1620
Administrator
    Nand(a=s00, b=nsel0, out=n000); //'not' of value of sel for a
    Nand(a=n000,, b=n000, out=sel000); //value of sel for a
               ^^
Two commas in this line.

You should be using the parts that you have already built to build new parts.  The easiest way to build DMux8Way is to use two DMux4Way and a DMux.  The easiest way to build DMux4Way is with three DMux.

--Mark


Reply | Threaded
Open this post in threaded view
|

Re: DMux8Way.."Line 39, A pin name is expected"

hyeonwoo
Thanks for your kind comment!