CPU project - How to check for correct values for each individual bytes

Thread Starter

tommyel

Joined Feb 19, 2021
1
This is just a part of a problem I'm given, but without I can't proceed further. I'm given set of instructions and set of addressing modes that can be used. In the first byte of Information Register is stored operation code of an instruction and in second byte is the addressing mode that that instruction uses.

I'm supposed to check if there's an error and if there is, it should activate an insterror (instruction error) signal. Error is considered one of the following:
  • Wrong operation code: OC in IR is not present in the list of available instructions
  • Wrong addressing mode: addressing mode is not in the list of the available ones
  • Wrong combination of OC and mode

I was thinking it should be done this way:
image3.png

I've recently started using components like gates etc. so I'm not quite familiar what should I exactly use to do this type of checking. I had a problem to find a way to, using only one signal, test only for first byte, then only for second byte, then for their combination.

I've tried this way: since addressing mode is only given for address instructions, I've made this:
image1.png
So, basically, if it's one of expected instructions and expected modes, then I'll activate adr2 signal (which is short for address instruction of 2B). Similarily I did for the rest of instructions. Then I had this:
image2.png

Here, ST * immed is the only wrong combination of OC and mode here (STORE * immediate).

So here, I say, if none of the expected types of instructions are activated (bezadr1, branch2 etc.), then they'll all have value 0 which I'll invert to 1 with NOT gate, which will then activate AND gate which will activate insterror signal.

But the problem is that this solution of mine doesn't solve in a way it's asked from me - since this only checks after 2nd byte of instruction is stored and then basically checks possible combinations, so it's essentially doing only 3rd error check (but used in a way to check 1st and 2nd error). I just can't progress any further with rest of an assignment until I'm completely done with this part (I'm having some issues I need to fix so I need to make this one work first, as it will have impact on the rest of the circuit I'm doing).
 

BobaMosfet

Joined Jul 1, 2009
1,767
Familiarize yourself with boolean logic, and using AND NOT OR NOR XOR gates to implement that logic. Use something like Excel to make a table of all your inputs and outputs and then you can choose the appropriate gates to implement the logic.

Remember, that the instruction you are evaluation (op-code and parameters), are just bits- each bit is a flag you're looking at. Don't make this more complex than it actually is. Good luck.
 
Top