Can I put in '0000000000000000' on a Mux16?

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

Can I put in '0000000000000000' on a Mux16?

eVh1955
My goal is to deactivate the chips beyond the A-register (except PC) like ALU and D-register whenever I encounter an A-instruction.  I tried this chip:

Mux16(a=false, b=instruction, sel=instruction[15], out=cinstruction);

but it returned an error.  It turned out that if in is an a-instruction, cinstruction = 0, not 16 bit zeroes.  In this case, ALU will not be reading this as a multiple bit but just a single zero.  

What I'm attempting to do now is to see if '0110000000000000' could be inserted into the Mux16 chip above.  Is this possible?  If not, what are the alternatives?  Thanks.  

CPU.hdl
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

WBahn
Administrator

As long as you don't write to anything other than the A register, does it matter what the ALU does?
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

eVh1955
Hi.  The problem is the ALU and the surrounding chips would accept an instruction from the in even when the latter is an a-instruction.  
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

WBahn
Administrator
Only if YOU design the instruction decode logic that way.

If you don't want to write to the D register or to the RAM or to perform a jump when the current instruction is an A-instruction, then put in the logic so that that doesn't happen.
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

eVh1955
Ahahaha.  Of course, sorry about that!

I'd like to clarify though, suppose we get the ALU output and the writeM is 1, does it also have the option of going to the D and A register as well or is it exclusively going to outM?  
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

WBahn
Administrator
There are three separate bits in the instruction that determine where the output of the ALU is written to and it can be any combination of M, D, and A, including all of them or none of them.
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

eVh1955
This post was updated on .
Thanks.  

Does Hack have an equivalent of a "Null" value?  The reason I asked is because in the test, outM is supposed to have a value of '*******' while mine was 0.  
Reply | Threaded
Open this post in threaded view
|

Re: Can I put in '0000000000000000' on a Mux16?

WBahn
Administrator
An asterisk in the compare file is a 'don't care' telling the comparison program to ignore the value in the other file. It is used when the value in the field depends on how the person wrote their program and, therefore, there's no single correct value for that line (but there are then other lines where there is a specific correct value, otherwise that field would likely have simply not been included in the output).