Skip to content
BetterDL

Clock cycle

Also called: clock cycles, cycle count, clock tick

One period of the clock, from one active edge to the next. A multi-cycle CPU does one register-transfer step per clock cycle.

A clock cycle is one period of the clock: the time from one rising edge to the next. In a synchronous CPU, every register changes only at an edge, so the cycle is the basic unit of work.

In Tiny8, each cycle does one register-transfer step:

  • 3 cycles of fetch (F1, F2, F3);
  • 1 cycle of decode (D);
  • 1 or 2 cycles of execute (E1, E2).

So LOAD, STORE, ADD and SUB take 6 cycles; JMP, JZ and HALT take 5.

Counting cycles for a program run:

  1. Count how many times each kind of instruction actually executes, including every pass of a loop.
  2. Multiply by its cycle count and add.

The total feeds the CPI (cycles ÷ instructions) and the cpu execution time (cycles × clock period).

Worked example

Example

Cycles for a run

A Tiny8 run executes 4 LOADs, 3 SUBs, 2 STOREs, 3 JZs, 1 JMP and a HALT.

  1. 1.

    Memory instructions: 4 + 3 + 2 = 9, at 6 cycles each = 54.

  2. 2.

    JZ, JMP and HALT: 3 + 1 + 1 = 5, at 5 cycles each = 25.

  3. 3.

    Total: 54 + 25 = 79 cycles.

  4. 4.

    At 20 MHz (50 ns per cycle): 79 × 50 = 3950 ns.

Common mistakes

  • Counting a not-taken JZ as fewer than 5 cycles.

  • Forgetting the HALT's 5 cycles.

  • Treating a cycle count as a time without multiplying by the period.

Practice Clock cycle

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Clock cycle is taught in Basic CPU / Computer Architecture and Timing and Sequential Logic.