CPU.hdl: Comparison failure at line 29

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

CPU.hdl: Comparison failure at line 29

Chen Li
This post was updated on .
Here is my CPU.hdl:

//deleted




the /jmp/ logic is if left and right are both 1(/and/) in one case(/or/), then it should jump.  But it fails in line 29. I cannot figure out where goese wrong. Thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: CPU.hdl: Comparison failure at line 29

cadet1620
Administrator
Look at the the lines that are miscomparing:
     |time| inM  |  instruction   |reset| outM  |writeM |addre| pc  |DRegiste|
cmp: |14  | 11111|1110110111100000|  0  |*******|   0   | 1000|   16|     -1 |
out: |14  | 11111|1110110111100000|  0  |  -4639|   0   |28128|   16|     -1 |
The instruction that is failing is 1110110111100000. Look in CPU.tst to decode the instruction.
set instruction %B1110110111100000, // A=A+1
The previous instruction, @999, set A=999, so this instruction should set it to 1000.

The A register is being loaded with a value that appears to be unrelated to the ALU output.

Fix this one problem, and your CPU will pass.

Hint:
    // if this instruction is a-instruction
    Not(in=instruction[15], out=aInst);
    //if this instruction is c-instruction
    Not(in=aInst, out=cInst);
Making aInst and cInst is a very good idea. You should move this code to the beginning of PARTS: because it is very important.  Then you should use aInst and cInst throughout the remaining code instead if instruction[15]. This will make the code more understandable and help prevent errors like this one.

--Mark

Please edit your post to remove the HDL.
Reply | Threaded
Open this post in threaded view
|

Re: CPU.hdl: Comparison failure at line 29

Chen Li
Thanks! I think this typo is made by emacs's dabbrev-expand.