One thing that pops into my eyes is that in case of an A instruction bit 15 is 0. It appears that you are loading A when bit 15 is 1?!
Another observation: you are masking the ALU control bits in case of an A instruction. That is unnecessary since the output of the ALU will only be loaded into registers if the respective control bits are set. So the ALU output in case of an A instruction is meaningless and will just be ignored.
thank you for that.
I see less differences now but still exists. most of them is due to D register being zero,i dont understand why
D register value is not loading.
In order for the hardware simulator to recognise which register is your D register, you are supposed to use the internal part DRegister instead of your standard Register. Same goes for ARegister, however that is not necessary to pass the test since only the output address pins are compared, and not the A register itself. I believe that is mentioned in the book and the slides?
Please note that the online hardware simulator still seems to be sensitive to the order of the HDL instructions in some cases. You may want to check the old Java based tools to verify instead.