What is meant by instruction cycle and clock cycle ?

Discussion in 'Embedded Systems and Microcontrollers' started by abhimanyu143, Jan 28, 2015.

  1. abhimanyu143

    Thread Starter Member

    Aug 25, 2014
    211
    1
    hello ,
    I need some help , I am confused on some terms.
    1. The instruction time ?
    2. instruction cycle ?
    3. clock cycle ?


    instruction cycle
    fetch-and-execute cycle, fetch-decode-execute cycle
    8051 runs on 12MHz

    What is meant by instruction cycle and clock cycle ?
    How is the 'clock cycle' of 8051 MCU related to the 'crystal' oscillator ?
     
  2. sevenfold4

    Member

    Jan 12, 2015
    80
    7
    The clock cycle is the period of the clock that you're feeding the to the micro (e.g. , a clock cycle takes 1us if the oscillator's frequency is 1MHz). The instruction cycle depends on the internal structure of the microcontroller or processor you use. E.g. , for a PIC an instruction cycle takes 4 clock cycles, for an 8051 it takes 12 cycles. This is because an instruction has multiple stages, like fetch, decode, execute and writeback.

    http://www.8051projects.net/plugins/forum/forum_viewtopic.php?41545.0#post_41554

    This page shows how Timer values are calculated, maybe it will serve you as an example.
     
    Last edited: Jan 28, 2015
    abhimanyu143 likes this.
  3. abhimanyu143

    Thread Starter Member

    Aug 25, 2014
    211
    1
    I am explaining with your example.
    Example: a clock cycle takes 1us if the oscillator's frequency is 1MHz
    fetch-and-execute cycle,
    explanations: 1 us for fetch cycle and 1 us for execute cycle. that means it take 2 us
    fetch-decode-execute cycle
    explanations: it take 3 us.
     
  4. sevenfold4

    Member

    Jan 12, 2015
    80
    7
    Your wording is weird
    Anyways
    1 Clock period = 1/frequency of the oscillator
    1 Machine cycle = 12 oscillator periods (In case of 8051, because of the inner structure)
    1 Instruction cycle = 1-4 machine cycles (Depending on the instruction given for 8051)
    So if 1 machine cycle would calculate to 1us, then 1 instruction would take 1us (Depending on the instruction)
    I think... In the past i just did the calculations and never really had to go too deep into it.
    Correct me if i am wrong
     
  5. abhimanyu143

    Thread Starter Member

    Aug 25, 2014
    211
    1
    actually I don't understand what do you mean, still I am confused on following terms.
    1. The instruction time ?
    2. instruction cycle ?
    3. clock cycle ?
     
  6. sevenfold4

    Member

    Jan 12, 2015
    80
    7
    1. I guess that would be the time it takes to run 1 cycle?
    2. Is the time to run the instructions.
    3. Is the speed of the clock depending of the crystal and structure of your mcu
     
  7. vikasbly44

    New Member

    Jan 19, 2015
    13
    1
    The instruction cycle is the time period during which one instruction is fetched from memory and executed when a computer is given an instruction to machine language.

    The clock cycle is the time between two adjacent pulses of the oscillator that sets the tempo of the computer processor.
     
Loading...