Hardware Simulator Won't Load Chip

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

Hardware Simulator Won't Load Chip

Tim
This post was updated on .
The Hardware simulator won't load the chip below. The error is: Line 3, 'Missing CHIP' keyword.

CHIP Mux4Way16 {
    IN a[16], b[16], c[16], d[16], sel[2];
    OUT out[16];

    PARTS:
[Functional code deleted by admin.]
}
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

cadet1620
Administrator
I see nothing wrong with this code; I could load it in the simulator after I made a Mux4Way. Check that the error is not actually coming from your Mux4Way.

Once you find your problem, please edit your post to remove the correct solution.

--Mark
Tim
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

Tim
I am having the same issue.

This is my code for each chip part:
CHIP Mux4Way {
        IN a, b, c, d, sel[2];
        OUT out;
       
        PARTS:
        Mux(a=a, b=b, sel=sel[0], out=pass1);
        Mux(a=c, b=d, sel=sel[0], out=pass2);
        Mux(a=pass1, b=pass2, sel=sel[1], out=out);
}

CHIP Mux4Way16 {
    IN a[16], b[16], c[16], d[16], sel[2];
    OUT out[16];

    PARTS:
    Mux4Way(a=a[0], b=b[0], c=c[0], d=d[0], sel=sel[0..1], out=out[0]);
        Mux4Way(a=a[1], b=b[1], c=c[1], d=d[1], sel=sel, out=out[1]);
        Mux4Way(a=a[2], b=b[2], c=c[2], d=d[2], sel=sel, out=out[2]);
        Mux4Way(a=a[3], b=b[3], c=c[3], d=d[3], sel=sel, out=out[3]);
        Mux4Way(a=a[4], b=b[4], c=c[4], d=d[4], sel=sel, out=out[4]);
        Mux4Way(a=a[5], b=b[5], c=c[5], d=d[5], sel=sel, out=out[5]);
        Mux4Way(a=a[6], b=b[6], c=c[6], d=d[6], sel=sel, out=out[6]);
        Mux4Way(a=a[7], b=b[7], c=c[7], d=d[7], sel=sel, out=out[7]);
        Mux4Way(a=a[8], b=b[8], c=c[8], d=d[8], sel=sel, out=out[8]);
        Mux4Way(a=a[9], b=b[9], c=c[9], d=d[9], sel=sel, out=out[9]);
        Mux4Way(a=a[10], b=b[10], c=c[10], d=d[10], sel=sel, out=out[10]);
        Mux4Way(a=a[11], b=b[11], c=c[11], d=d[11], sel=sel, out=out[11]);
        Mux4Way(a=a[12], b=b[12], c=c[12], d=d[12], sel=sel, out=out[12]);
        Mux4Way(a=a[13], b=b[13], c=c[13], d=d[13], sel=sel, out=out[13]);
        Mux4Way(a=a[14], b=b[14], c=c[14], d=d[14], sel=sel, out=out[14]);
        Mux4Way(a=a[15], b=b[15], c=c[15], d=d[15], sel=sel, out=out[15]);

}

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

    PARTS:
        //~sel AND A
        Nand(a=sel, b=sel, out=notSel);
        Nand(a=notSel, b=a, out=notSelNandA);
        Nand(a=notSelNandA, b=notSelNandA, out=notSelAndA);
       
        //sel AND B
        Nand(a=sel, b=b, out=selNandB);
        Nand(a=selNandB, b=selNandB, out=selAndB);
       
        //~sel and A OR sel AND B
        Nand(a=notSelAndA, b=notSelAndA, out=OR1);
        Nand(a=selAndB, b=selAndB, out=OR2);
        Nand(a=OR1, b=OR2, out=out);
}

I have tried this code on multiple computers and still have been getting the same error.

The Exact Error is: Mux4Way16.hdl, Line 3, Missing 'CHIP' keyword: load Myx4Wat16.hdl Is there a platform problem? Does the hardware simulator need a specific version to run? Because I have the CHIP keyword in all of the above code.
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

cadet1620
Administrator
I don't know of any platform specific problems.

Your code loads and passes the test when cut and pasted from your post.

Please email me your .hdl files as attachments to
   
so I can see if there is some strange formatting in your specific files.

--Mark
Tim
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

Tim
Ok thanks,
I sent them to you.
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

cadet1620
Administrator
Tim's problem was Unicode text encoding. The Hardware Simulator can't handle it. You need to make sure that your editor is saving files in ANSI encoding.

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

Re: Hardware Simulator Won't Load Chip

rbilkie
I am using Text Editor with Mac as well, having the same problem (when I try to load a chip, it just says "loading chip..." and nothing happens).  I tried changing the encoding to Western ASCII, Latin Dos I, virtually all the different non-unicode options.  I then downloaded TextWrangler and re-saved the files under every conceivable type of encoding.  Same result.  I don't understand.

I'm not a computer wiz -- that's the reason I'm taking this course.  But I've been wrestling with this for five hours and my assignments are due by midnight tonight.  
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

cadet1620
Administrator
rbilkie wrote
I am using Text Editor with Mac as well, having the same problem (when I try to load a chip, it just says "loading chip..." and nothing happens).  I tried changing the encoding to Western ASCII, Latin Dos I, virtually all the different non-unicode options.  I then downloaded TextWrangler and re-saved the files under every conceivable type of encoding.  Same result.  I don't understand.

I'm not a computer wiz -- that's the reason I'm taking this course.  But I've been wrestling with this for five hours and my assignments are due by midnight tonight.
The most common cause for the Hardware Simulator to hang when loading an HDL file is if the chip tries to use itself in its PARTS section
    CHIP Not {
    ...
    PARTS:
        Not(...);
    }
This can also happen indirectly if chip A uses chip B which uses chip A.

If you don't spot your problem, you can email your HDL to me and I'll let you know what I see.

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

Re: Hardware Simulator Won't Load Chip

ivant
In reply to this post by rbilkie
You can send me your chip file via email and I'll try to find the problem. My email is Ivan at toshkov dot org
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

tahamitofique


NOT ABLE TO LOAD CHIP IN HARDWARE SIMULATOR

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    Not (in=a, out=nota);
    Not (in=b, out=notb);
    And (a=a, b=notb, out=x);
    And (a=nota, b=b, out=y);
    Or (a=x, b=y, out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

tahamitofique
In reply to this post by cadet1620


NOT LOADING MY CHIP IN HARDWARE SIMULATOR

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    Not (in=a, out=nota);
    Not (in=b, out=notb);
    And (a=a, b=notb, out=x);
    And (a=nota, b=b, out=y);
    Or (a=x, b=y, out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

ivant
The chip looks correct (please remove the code from the post).

One reason you might get a problem would be if you haven't implemented the some of the chips it's using. In general, it's best to implement the chips in the order they come up in the book.

The other possible reason for failure is a bit far fetched: Windows used to have problems if you name a directory exactly as its parent directory. In this case nand2tetris\nand2tetris. I know that was the case for much older version of Windows, but I'm not sure if they fixed this or not. In any case it's easy to try and see for yourself.

You can also try running the hardware simulator from the command line and see what the logs say to get a better idea about the error.
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

tortellinigratis
In reply to this post by Tim
I know this is 10 years old but I had the same problem yesterday and want to point out a "fix" for newbies like me (I'm using HwSim for a school project): I was testing my .hdl files in linux (debian12) and after fixing a line of code it kept giving me the "CHIP missing keyword" error.
After a few try, I figured out linux was converting the .hdl in .txt (not like Windows, which kept .hdl even after modifing the code), so it ended up not loading.
I fixed by switching back to windows, rewriting the right script in .hdl and going back to linux for the test.
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

AngryKurd
Are you sure you are clicking load script rather than load chip when choosing your test script?. I get this error when I try to load the script using the chip button on the top left. So press file > load script. and load your script, to load your hdl file file > load chip.
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

WBahn
Administrator
In reply to this post by tortellinigratis
tortellinigratis wrote
I know this is 10 years old but I had the same problem yesterday and want to point out a "fix" for newbies like me (I'm using HwSim for a school project): I was testing my .hdl files in linux (debian12) and after fixing a line of code it kept giving me the "CHIP missing keyword" error.
After a few try, I figured out linux was converting the .hdl in .txt (not like Windows, which kept .hdl even after modifing the code), so it ended up not loading.
I fixed by switching back to windows, rewriting the right script in .hdl and going back to linux for the test.
You didn't say how you were editing your .hdl file in linux, but you should be able to control the extension it is saved with and, if nothing else, rename the file. You shouldn't need to move files back and forth between two operating systems.
Reply | Threaded
Open this post in threaded view
|

Re: Hardware Simulator Won't Load Chip

varshneydevansh
In reply to this post by tortellinigratis
Even I faced the same problem yesterday with the Mux.hdl file. I was editing it in the gedit and while doing so it saved the file as text format instead of the C source code (text/x-csrc).

What I did is I opened the file with the vs-code and did save-as to the file there I selected the C source code as the desired extension and it worked.