I'm currently a junior in highschool, and I've been interested in computer/electrical engineering, specifically microprocessor design. I've read [Code by Charles Petzold](https://bobcarp.files.wordpress.com/2014/07/code-charles-petzold.pdf), , and have begun reading the [Microprocessor Design Wikibook](https://en.wikibooks.org/wiki/Microprocessor_Design) (which seems to be incomplete.) Through reading *Code*, I understand the basic logic behind a CPU, and have begun building one in LogiSim. Chapter 17 in *Code* details the CPU I want to build, but the circuits lack key components -- clock signals, and instruction decoding. Some of the clock signals seem to be pretty obvious (the PC seems to need a steady clock signal) but others (like how to latch RAM values) I have had to think through and try to get working.

I can build a working accumulator (it can't be accurately called an ALU, I think, because it lacks the L part) that switches between addition and subtraction with a single input, and I understand this is all I need for the arithmetic part -- once I get jump opcodes working, I can implement multiplication and division in code. The part I'm struggling with is the instruction decoding. Through some google searches, I see that each opcode needs to be interpreted as multiple microinstructions, but I'm lost as to how I need this to work. Currently, my instruction decoder is just a combinational analysis circuit with a single binary output for each opcode -- 13 in all. 

The way the code works is it has one 8 bit code value (I only use the low-end byte), and then two separate 8 bit address values that I then combine to be the 16 bit address input to the RAM. In order to latch the values, I have a separate counter that counts up to 10b and then resets to 00b. It is the clock input for each latch in turn (for the three latches, there's a, b, and c. the second clocks have a be 1 while b & c are 0, then b is 1 and 1 & c are 0, then c is one and 1 & b are 0, then it resets). But on instructions such as ADD 000Ah, the PC jumps to 000AH...which is supposed to be added into the accumulator, but actually gets latched into the code latch, and is then interpreted as the next opcode, which makes the whole thing go crazy.

I feel like I'm missing some big information regarding instruction decoding and how I need to do clock signals...

Here are the LogiSim .circ files:
<https://dl.dropboxusercontent.com/u/61676438/PetzoldMk5/8BitAdder.circ>
<https://dl.dropboxusercontent.com/u/61676438/PetzoldMk5/8BitAdderSubtractor.circ>
<https://dl.dropboxusercontent.com/u/61676438/PetzoldMk5/8BitInverter.circ>
<https://dl.dropboxusercontent.com/u/61676438/PetzoldMk5/8BitLatch.circ>
<https://dl.dropboxusercontent.com/u/61676438/PetzoldMk5/ID.circ>
<https://dl.dropboxusercontent.com/u/61676438/PetzoldMk5/PetzoldMk5.circ>

PetzoldMk5 is the main CPU, relying on the other files to be imported as libraries.

Here's a list of opcodes (all binary):

```
Load                 0001
Add                  0010
Add w/ Carry         0011
Sub                  0100
Sub w/ Borrow        0101
Jump                 0110
Jump w/ Carry        0111
Jump W/ 0            1000
Jump w/o C           1001
Jump W/o 0           1010
Store                1011
Halt                 1100
Reset                1101

```