I'm unsure why this isn't loading in to the hardware simulator

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

I'm unsure why this isn't loading in to the hardware simulator

Ktesibios
I know that the program won't load into the hardware sim, if the program is wrong, however i can't see where I'm going wrong. This is the code that I have made for the CPU. I can't seem to find where I have gone wrong


CHIP CPU {

    IN  inM[16],         // M value input  (M = contents of RAM[A])
        instruction[16], // Instruction for execution
        reset;           // Signals whether to re-start the current
                         // program (reset==1) or continue executing
                         // the current program (reset==0).

    OUT outM[16],        // M value output
        writeM,          // Write to M?
        addressM[15],    // Address in data memory (of M)
        pc[15];          // address of next instruction

    PARTS:
    // Put your code here:
        Mux16(a=aregout, b=inM, sel=instruction[12], out=aluy);
        ALU(x=alux, y=aluy, zx=instruction[11], nx=instruction[10], zy=instruction[9], ny=instruction[8], f=instruction[7], no=instruction[6], out=outM, out=aluout, zr=zr, ng=ng);
        DRegister(in=aluout, load=instruction[4], out=alux);
        ARegister(in=ain, load=instruction[5], out=aregout, out=addressM);
        Mux16(a=instruction, b=aluout, sel=instruction[15], out=ain);
        And(a=instruction[2], b=ng, out=jlt);
        And(a=instruction[1], b=zr, out=jeq);
        Nand(a=zr, b=ng, out=gt);
        And(a=gt, b=instruction[0], out=jgt);
        Or(a=jgt, b=jlt, out=jm);
        Or(a=jr, b=jeq, out=pcl);
        PC(in=aregout, load=pcl, inc=true, reset=reset, out=pc);
        And(a=instruction[3], b=instruction[3], out=writeM);
}
Reply | Threaded
Open this post in threaded view
|

Re: I'm unsure why this isn't loading in to the hardware simulator

WBahn
Administrator
What does the error message at the bottom of the screen say? Those usually give you a pretty good job of at least pointing you in the right direction.

Looking at your code, I can see at least three errors.

Remember that busses and the ports they are connected to have to have the same width. The CPU has a mix of 16-bit and 15-bit busses, so you need to think about this carefully.

Also, if you have a signal named 'fred' connected to the input of a part, that signal must have a source driving it, either one of the chip inputs, or one of the outputs from another part within the chip.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unsure why this isn't loading in to the hardware simulator

Ktesibios
I can't see the bottom of the simulator in my screen. It doesn't show because my screen seems to be short than the height of the window. I will check the widths of the buses
Reply | Threaded
Open this post in threaded view
|

Re: I'm unsure why this isn't loading in to the hardware simulator

Ktesibios
I've managed to solve the problems. It's finally loaded (but test script failed so it's not fully correct). I can try to solve the c5 questions from here. Thanks for the help. I followed your advice about bus widths, and driving signals, which helped me find the source of the problem :-)