Cant figure out the CPU.HDL

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

Cant figure out the CPU.HDL

ammarr
i read the 5th chapter and and re read chapter 2 and 4 to try to understand the CPU.HDL but i still cant figure it out

i always get error in the 3rd line
set instruction %B1110110000010000, // D=A

Comparison failure at line 3

i am trying to do it similar to figure 5.9,

and i understand C-instruction and A-instruction from figures 4.3 ,4.4 & 4.5

but i still cant figure out how to handle a C-instruction and A-instruction in the cpu.hdl

any hint will be great
thanks
Reply | Threaded
Open this post in threaded view
|

Re: Cant figure out the CPU.HDL

ybakos
What is the value of the most significant bit of an A instruction and a C instruction?
Reply | Threaded
Open this post in threaded view
|

Re: Cant figure out the CPU.HDL

ammarr
Thanks  ybakos

i just realized that i was counting from right to left instead from left to right

i mean for the C instruction
i started the top most as 0 until and ended j3 = 15

now i fixed this, so my top most is 15

this is how i start my code
Mux16(a=instruction,b=Backin,sel=instruction[15],out=AorD);

and it worked but now am facing another problem

comparison failure at line 8 // D=D-A


Reply | Threaded
Open this post in threaded view
|

Re: Cant figure out the CPU.HDL

cadet1620
Administrator
ammarr wrote
... but now am facing another problem

comparison failure at line 8 // D=D-A
Hardware debugging involves collecting clues about the error and reasoning out plausible causes for it. There is a lot more information at the failure point than just the line number.

The CPU is executing a D=D-A instruction, so you need to look at the previous output line to see what the values of the D and A registers were, and the current line to see what the new, presumably wrong, value of D is and figure out what went wrong with the computation. The "Compare" line shows the expected value of D. Note that the A register shows up on addressM.

It's also possible that the new D value is correct and something else like the jump hardware went wrong.

It's sometimes easier to look at the .cmp and .out files in a text editor.

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

Re: Cant figure out the CPU.HDL

ammarr
hi

i think am mostly done

am just stuck with the Load of the PC ,still cant get the condition right

am trying to find the combination of j3,j2,j1,ng,zr

still struggling ......
Reply | Threaded
Open this post in threaded view
|

Re: Cant figure out the CPU.HDL

cadet1620
Administrator
A hint for the jump logic is to create a pos status flag from zr and ng. Then it's easy to test if any of the status flags and their corresponding instruction bits are set.

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

Re: Cant figure out the CPU.HDL

ammarr
Thanks alot

finally got it working

i spent nearly a week with the CPU with 4-5 hours daily,

but it always feels great to get things to work.

in the beginning i didn't understand what you meant by
cadet1620 wrote
 create a pos status flag from zr and ng. --Mark
i thought you meant Nand, where i get a 1 in all cases of ng  and zr

but then i realized that you meant a positive output of the ALU, that is a positive outM and not a positive state

so i used Xor with Not to get the po


any way to get the condition of the load of the PC i used

1 Xor
1 Not
14 And
1 Or8Way


is there a simpler way to optimize it.

Thanks for the course and great support......
Reply | Threaded
Open this post in threaded view
|

Re: Cant figure out the CPU.HDL

cadet1620
Administrator
Answered by e-mail.

--Mark