ALU Problem(It says comparison fail but i couldn't find the problem)

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

ALU Problem(It says comparison fail but i couldn't find the problem)

ChenYi
This is my out put:

And this is the comparison results:


I don't know what's wrong with it.
Here is my HDL code:
CHIP ALU {
    IN
        x[16], y[16],  // 16-bit inputs
        zx, // zero the x input?
        nx, // negate the x input?
        zy, // zero the y input?
        ny, // negate the y input?
        f,  // compute out = x + y (if 1) or x & y (if 0)
        no; // negate the out output?

    OUT
        out[16], // 16-bit output
        zr, // 1 if (out == 0), 0 otherwise
        ng; // 1 if (out < 0),  0 otherwise

    PARTS:
    // zx
    Mux16(a=x,b=false,sel=zx,out=out1);
    // nx
    Not16(in=out1,out=notout1);
    Mux16(a=out1,b=notout1,sel=nx,out=out2);
    // zy
    Mux16(a=y,b=false,sel=zy,out=out3);
    // ny
    Not16(in=out3,out=notout3);
    Mux16(a=out3,b=notout3,sel=ny,out=out4);
    // f
    Add16(a=out2,b=out4,out=xPlusy);
    And16(a=out2,b=out4,out=xAndy);
    Mux16(a=xAndy,b=xPlusy,sel=f,out=out5);
    // no
    Not16(in=out5,out=notout5);
    Mux16(a=out5,b=notout5,sel=no,out=final);
    Mux16(a=final,b=false,sel=false,out=out);

    // zr
    Or16Way(in=final, out=zrOut);
    Not(in=zrOut, out=zr);
    // zg
    IsNegative(in=final,out=zg);
}
CHIP IsNegative {
  IN in[16];
  OUT out;

  PARTS:
  Or(a=in[15],b=false,out=out);
}

If you find my problem, please let me know!!!
Thanks:-)
Reply | Threaded
Open this post in threaded view
|

Re: ALU Problem(It says comparison fail but i couldn't find the problem)

WBahn
Administrator
You aren't showing everything. There is also the zr and ng outputs. That's probably where your mistmatch it.