error in implementation of ALU status bits zr & ng

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

error in implementation of ALU status bits zr & ng

ajamil
after having successfully completed the ALU (without status bits), I was trying to add these status bits but I am getting this error 'can't connect the gate's output to chip part'
for negative output check, I am using a mux such that Mux(a=false, b=true, sel=out[15], out=ng);
have checked everything and can't get a clue. so asking here as last resort.

regards
Reply | Threaded
Open this post in threaded view
|

Re: error in implementation of ALU status bits zr & ng

cadet1620
Administrator
ajamil wrote
I am getting this error 'can't connect the gate's output to chip part'
What you are missing is that you can have multiple "out=" connections on a part.

Somewhere in your ALU you have
    Somepart(..., out=out);
That generates the main 'out' value that you want to further process. You want to add more connections to that part's 'out':
    Somepart(..., out=out, out[15]=ng, out[...]=..., out[...]=...);
where the last 2 'out' connections are used by circuitry that generates 'zr'.

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

Re: error in implementation of ALU status bits zr & ng

ajamil
This post was updated on .
(clever!)
 yes it could be implemented in this way but what's wrong in my approach considering the fact that we have previously manipulated all the bits wherever we want when we made 16-bit versions of our gates in project 1.

so basically what was wrong in my approach?

 what is the difference between writing sel = out[15] compared to the way you implemented it? in real world circuit, I can do it, I can connect last bit of ALU out to a mux and make it decide accordingly.
BTW. I have really enjoyed this set up (test files) and project.
regards
Reply | Threaded
Open this post in threaded view
|

Re: error in implementation of ALU status bits zr & ng

cadet1620
Administrator
In the Xxx16 chips you never had to connect a CHIP output (named in the OUTPUT line) to a PART input.

This loop is what is causing "Mux(..., sel=out[15]" to fail.  I don't know why this is disallowed by the HardwareSimulator, probably an internal design limitation.  The cleanest workaround is to use multiple out= connections.

Your code could be written as
    Somepart(..., out=out, out=w1);
    Mux(a=false, b=true, sel=w1, out=ng);

An alternative workaround (much uglier in my opinion) is to use another part to duplicate the internal output to the chip output
    Somepart(..., out=aluOut);
    And16(a=aluOut, b=true, out=out);
    Mux(a=false, b=true, sel=aluOut, out=ng);

--Mark