Implementation of Program Counter

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

Implementation of Program Counter

ashishrao7
This post was updated on .
I am trying to implement the load bit to the program counter of the CPU, my approach was as follows.

A jump happens only when the j1j2j3 bits are not 000 and they satisfy their respective condtions(checked by comparing with ng and zr bits form the ALU).This mean the load of the program counter becomes the jump controller bit.I drew a table to find the combination of 32 bits to get times when the load is 1(perform jump) and in the end got  a huge boolean function satisfying the same. Is my approach correct or is there a simpler approach? For some reason i feel that implementing the boolean function is pretty long. The images of what i am trying to do are given below.


 
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of Program Counter

cadet1620
Administrator
Your approach should get you there but it is a lot of work and will result in a fairly long implementation unless you optimize it using some technique like Karnaugh maps.

An easier approach is to think about when C-instructions should jump for the simplest conditions.
    JLT should jump if the 'ng' ALU status bit is set,
    JEQ should jump if the 'zr' ALU status bit is set.
    JGT should jump if the 'pos' ALU status bit is set.

What 'pos' ALU status bit?? There isn't one, but it is easy enough to make one in the CPU from the ALU 'zr' and 'ng' status bits.

All three of the above cases are just ANDing the appropriate 'j' bit in the instruction and the corresponding status bit, and the PC 'load' is just ORing them together.


How do the more complex cases work?   For example,
    JLE should jump if JLT should jump or JEQ should jump.

Do you see how this case is already handled by the 3 simple cases?

--Mark