In college I was left a project of the simulation of a CPU, it has to be basic and carry various functions, consult thought that you can lead me to develop it. These functions would be:
Fetch cycle of a CPU for example to show fetch cycle can follow a sequence similar to that seen with paper_processor classes, which was carrying instructions memory cells steps indicated instruction he executed, as increasing 1 a value in a register and repeat these steps to generate a stop condition in this cycle.
An addition operation of 8-digit binary numbers form positive (0 to +255) from two registers to a third register, in case of exceeding the sum should switch on the corresponding flag. The user can enter the values you want to add.
Operations and records landslides rotations, select 2 of all possible operating in conjunction with the CF flag
Show the complement operation 2 a 8-bit register. The user can enter the binary value to support, using the leftmost bit as the value of sign, 0 for positive and 1 for negative. They must show the 2 steps: a. invest digits, b. add 1 to the inverted sequence. If an overflow occurs should turn on the corresponding flag.
Here the operations to be able to show step by step the machine and must be executed by the same graphical or visible to the user are defined. For example, using sequences of lights to display binary data in a record (on = 1, off = 0), engines, parts animations provided by tools, LCDs, LED matrices, 7-segment LED, etc.
The CPU will work to develop a minimum size of 8 bits in their operations.
It must have at least the basic records: PC, IR, 4 general registers as A, B, C and D, basic flags as ZF, SF, CF and OF, all minimum size of 8 bits as indicated and flags a clear bit each. You can include other items for your CPU if required for the instructions you want to deploy. It is expected that the clock rate is slow, 1 Hz (1 cycle = 1 second) or slower, so that the user can observe the step by step or operation, the clock would be manually, each user manual key (a button for example) will be the next step. The machine can operate in ways it is not necessary that all operations are visible at once, enough to show an operation at a time, you must decide how to do it and how the user will move from one operation to another, etc.
The user must indicate which instruction or operation is being displayed at all times and should indicate when you start and when it ends for the user to understand the order of the sequence of steps.
First of all we need a LOT more information of what you are trying to do.
This is just a guess or an idea what you might want to do:
Your input is two integer numbers and you want to do an addition. On the screen you want to show how the CPU registers are loaded and how the result is stored in another register. And all of this has to be visualized.
OK, this was just an idea of what your project might look like.
Fui en America Central hace muchos anos. Fui tambien en Panajachel al lago Atitlan. Fui en Guatemala por dos semanas, solo yo y mi mochila. Me gustaba mucho. Saludos
I like speaking spanish, however, my spanish is not good enough to have a technical discussion.
Your english is more than sufficient to tell us what you want.
It will not be the words and grammar - it will be the structure of your thoughts that
will help us to understand your problem a litte bit better.
It's basically an on-paper simulation of a 2-bit CPU; it implements a very small set of instructions, and contains a total of three registers - a program counter (PC), a general purpose register, and a status register (for overflow).
If you can work this and understand it on paper - then you'll be well on your way to understanding how a larger CPU works - at least at the register and memory level (basically an "instruction set simulator" - see Instruction set simulator - Wikipedia).
You might also be interested in this modern day implementation of a "mechanical computer":
Which was inspired by this bit of educational kit from the 1960s:
...whose predecessor was this other kit:
An earlier simulated education "computer" was the Geniac:
Note - on these three machines from the 1950s and 60s - don't even bother trying to acquire one, unless you plan on being very patient, and spending more than a bit of money on vintage collectible computer stuff. Seriously, these one-time toys are very difficult and expensive to obtain today - you sometimes (rarely) see them go on Ebay - and when they do, they fetch quite a top dollar.
That said - they do show how it is possible to implement a computer using simple means. Do your research - look up "cpu simulation" and "cpu simulators" - you'll find tons of papers and other information about such. Keep in mind that you'll want to likely limit the scope of things to 8 bit machines and under, and likely at the beginning only implement 2 and 4 bit machines - at least as "instruction set simulations" (which are typically more than good enough to simulate a CPU - in fact, if you peel back the code underneath most classic computer emulators - you'll find at heart they are really nothing more than "instruction set simulations", with their "memory" being a very large single dimension array, or some other similar memory structure).
Once you understand how to create and operate on paper a simple CPU - see if you can expand it. Add extra registers, more instructions, maybe more memory (though note that as your address space increases, so will the amount of work you'll have to do by hand to make it "compute"). You'll hit a hard and fast limit of what you can really do by hand at around the 5-6 bit mark; you can do 7 bits if you are very patient.
At that point, though - you should have enough knowledge to begin implementing that CPU in actual code; then it become easy to expand.
At a certain point - you'll begin to wonder how all of this translates to actual circuitry. I can't explain it to you here (I don't have the space or time) - but just realize that those binary digits are represented by electrical signals. You can think of them as +V for HIGH (1) and 0V for LOW (0). There is something called a clock - it is a circuit that generates a series of high (1) and low (0) pulses. You have things called "flip-flops" - which can form memory (aka - registers) - they can also act as counters if hooked up right; they usually count in binary - so you feed a pulse in, you get binary 0001 - another pulse, you get 0010, another and you get 0011 - etc. Again - these represent electrical values. That counter is your "program counter" - and the number it spits out can represent an address in memory...
Technically - even Babbages Analytical Engine worked in the same manner (had it been realized) - just mechanically, and using base-10 instead of base-2.
Ok - even at this basic level I would go on for pages - but honestly, CPUs in their basic form are not really that complicated to understand. Seriously - you'll go "duh" when it clicks in your brain. One thing that I realized when it clicked for me was that a CPU was just a really fast player piano - RAM was the piano roll - the address was where this "piano" was on the roll, and the information for processing was the holes in the roll. Only this "roll" could be changed on the fly, and it was possible to "back up" the roll (branch) based on the state of a register or other value. Indeed, a player piano is a very apt concept - if you don't believe me, do some research on "reproducer pianos" - they were probably the closest thing to a CPU that a player piano came to.
I seriously could bore you to tears here - but I won't. I hope my links and information help you (or anyone else) in some manner to understand how a CPU works.
cr0sh, the first link, with the paper cpu.
Waayyyyyy bck when in Uni and had first micro classes (Z80), our lecturer (well versed in how to teach students) did a similar thing, but he had a large board made up with hooks and you placed plastic or cardboard labels on them.
Areas representing address and data registers and flags.
You would write a simple pseudo code then step it out on the board.
Only had one class session with it then onto the real electronic thing.
But it stayed in the room for each class to help any programming probs.
It must have saved him many many hours of instruction, and help sooo many of us with visualization of a somewhat new area of engineering.
Your I/O device to the real world is probably a big concern, you could use a PC running Processing to purely scan registers etc that you construct in the arduino controller. (like SCADA does in the industrial world)
A button to let you control the clock of your virtual CPU, eg. step, run(slow) so you can see your program running.
An interesting project, I like projects like this where they are producing an educational resource about the basics of electronics and computing.