Jump logic

3 messages
Open this post in threaded view
|

Jump logic

 This post was updated on . It seems like comparing J bits with NG or ZR is needed. Also to my understanding ALU will never output ng=1 and zr=1 at the same time. My though process is like this. Lets say I need to check for Jump JEQ where j1,j2,j3 are: 0 1 0.  (case for alu output = 0) In such scenario ALU will output: ZR = 1 and NG = 0. I tried to AND: And j1 and ng - if ng is 0 I have a match it with j1 bit. And j2 and zr - if zr is 1 I have match for j2 bit. And j3 and ng - if zr is either 0 or 1 I have no match for j3 bit resulting 0. But in testing above was failing for >0 condition so i came up with below logic just for J3 bit: J3 zr ng truth table: 1 0 0 - 1 matches >0 so i solved for it 1 0 1 - 0 1 1 0 - 0 1 1 1 - 0 J3 + !ZR + !NG Above seems to be working but when ng and  zr are both 1 the output is 1 in some cases. But alu will never output 1 for both zr and ng so would above be acceptable Jump logic solution? I tried to improve above with below logic: <0 //j1 +!zr + ng =0 //J2 + zr  + !ng <0 //J3 +!zr !ng It works but it only fails in 2 cases when zr and ng are 1 which would never be a case so technically it would work. Those cases are for checking for NOT 0 and for unconditional jump. I wonder if both of these are acceptable or i need to improve it? Once this logic is correct i will add it to the CPU. I hope anyone here can help me and guide me into the right direction. thx Edit: I removed source code per posting guidelines.