CPU.hdl always fails at line 3

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

CPU.hdl always fails at line 3

A_Random_Person
   My CPU always fails at line 3 of the test script. Can someone help?
Reply | Threaded
Open this post in threaded view
|

Re: CPU.hdl always fails at line 3

xedover
I think this is line 3?
set instruction %B1110110000010000, // D=A   set the D-register equal to value in the A-register


The D register takes its input from the output of the ALU and should be controlled by the value of bit[4] and bit[15]

in this value %B1110110000010000, we see that bit[4] = 1 (for the D register), and bit[15] = 1 (a C instruction)

Double-check that your D-Register is connected properly, and that its getting the proper values at the proper time.
Reply | Threaded
Open this post in threaded view
|

Re: CPU.hdl always fails at line 3

A_Random_Person
I don't think it's the D register's problem. I found out that the PC never increments for some reason.
Reply | Threaded
Open this post in threaded view
|

Re: CPU.hdl always fails at line 3

xedover
Did your PC pass its tests back in project 3?

from dia 5.8 in chapter 5, the PC takes its input from the A-Register, but then what's not clear from that diagram, is that there are two control bits where only one is shown, load and inc

getting the Program Counter to work was the most difficult for me.

you have to think about when the CPU is suppose to jump to the address (load from A), or increment to the next address.

Once I determined the jump flag, the increment flag was "not" it. (it either jumps or increments, but not both)

remember, the jump bits are bit[2] (J1), bit[1] (J2), bit[0] (J3). Pay close attention to the Jump tables in chapter 4, notice that J1 is the same as neg, J2 is the same as equ/zero, and J3 is the same as pos

Create a logic table for Ng and Zr flags and combine with the J-flag table (fig 4.5)

I had to create an entire separate logic circuit for the Jump logic

...hope this helps.