I am trying to create a program counter with logic gates. I got the logic done but I'm not sure where I should connect the clock.
... where I should connect the clock.
This is because your circuit will not work:
Let's say "inc in" is true, "load in" is false and "reset in" is false.
Then the value of "out Out" is the output of the "inc16" element.
And the output of the "inc16" element is the value of "out Out" plus 1.
This means that the value of "out Out" is calculated as:
inc16 = out_Out + 1
out_Out = inc16
Or:
out_Out = out_Out + 1
This line has to be read like a mathematical equation, not like a variable assignment in a programming language:
And because the equation has no solution, the circuit won't work.
You have to introduce some delay element (a register made of flip-flops) into your circuit. This delay element will be controlled by the "Clock in" input:
Whenever there is a pulse at "Clock in", the input of the delay element will be copied to it's output.
The equations could then look like this (there are different possibilities):
inc16 = delay_Out + 1
out_Out = inc16
delay_In = out_Out
delay_Out = delay_In;
Or:
out_Out = out_Out + 1;
The first three lines are again read like mathematical equations; however, the two lines ending with a semi-colon (";
") are meant like a variable assignment in a programming language (such as C, C++ or Java) that takes place when there is a pulse from the "Clock in" input.
Here is EV3's solution (thanks for the edit):