How does CPU/MCU works

Discussion in 'General Electronics Chat' started by aamirali, Oct 17, 2013.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    If we go down , in the end MCP/CPU/MPU is made up of millions of transistors.

    When we write code like:

    ADD A,B
    MUL, A, R1

    So how does it come to know which is first instruction & what's its address or which address to go.
    Like at abstract level usually we say that when MCU first get turn on it checks at origin & then go to next instruction , fetch it & decode it & execute it & then fetch another & so on.
    But how it is working at transistor level.
    Like adder can be made by transistors & subtractor also. I don't understand how it actually works at core level & everything is synchronized, again at abstract level we says its clock. But how at core level millions of transistors are controlled by single clock?????
  2. WBahn


    Mar 31, 2012
    Here might be a project of interest to you:

  3. Veracohr

    Well-Known Member

    Jan 3, 2011
    Check out this transistor OR gate. A positive voltage ("1") on either input causes that input's transistor to conduct current, which forms a positive voltage across the bottom resistor, making the output a "1".


    To make it synchronous to a clock, imagine the resistor were replaced by another transistor; the transistors can't conduct current unless the new bottom transistor is on. If the clock is applied to the base of the transistor, it then turns on the transistor, enabling the OR gate, only when the clock is high.

    This probably isn't exactly how they work internally, but it gives an idea of how you can make synchronous gates. Add a bunch different gate types together, all enabled by the clock, and you get synchronized adders and any other higher-level function you want.

    As far as how the CPU knows how to execute "ADD A,B", that's what the compiler/assembler software does. You type in "ADD A,B" in the software and it's abstract, but when you tell the software to assemble it, it translates your simple command into a list of even simpler functions that accomplish it. Something like:

    1. Route register A to input 1 of adder
    2. Route register B to input 2 of adder
    3. Load temporary register from output of adder
    4. Load register A from temporary register

    But possibly broken down into even smaller functions.
  4. adam555

    Active Member

    Aug 17, 2013
    I recently saw a couple of videos that might help you:

    Making your own 4 bit computer from transistors

    See How the CPU Works In One Lesson