Home / Learn Verilog / Clocks and Clock Edges: Period, Frequency, Duty Cycle

Clocks and Clock Edges: Period, Frequency, Duty Cycle

The clock is the heartbeat of every synchronous circuit.

In shortThe clock is the heartbeat of every synchronous circuit.

What's actually going on

Clock waveformclkrising edgeperiod
Clock waveform

Definition

A clock is a square wave that tells registers when to capture data. The rising edge (posedge) goes from 0 to 1, the falling edge (negedge) from 1 to 0.

Why you need this

Almost every real design is synchronous: all registers share a clock and state changes only on its edge.

How it works

Period T is the time of one cycle. Frequency f = 1/T. Duty cycle is the high time divided by the period. In a testbench, generate a clock with always #(T/2) clk = ~clk;

Where you'll see this

  • FPGA designs
  • Processors
  • Interfaces

Generate clocks

Two clocks with different frequency and dutyVerilog: edit and run

Both clocks have period 10, so 10 rising edges in 100 units. The duty cycle (high time) differs.

TermMeaningExample
Periodtime of one cycle10 ns
Frequency1 / period100 MHz
Duty cyclehigh time / period50 %
posedge0 -> 1 transitionmost flip-flops use this
negedge1 -> 0 transitionused by some designs

Test what you just read

1. A 100 MHz clock has a period of...

2. posedge means...