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
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.
| Term | Meaning | Example |
|---|---|---|
| Period | time of one cycle | 10 ns |
| Frequency | 1 / period | 100 MHz |
| Duty cycle | high time / period | 50 % |
| posedge | 0 -> 1 transition | most flip-flops use this |
| negedge | 1 -> 0 transition | used by some designs |
Test what you just read
1. A 100 MHz clock has a period of...
1 / 100 MHz = 10 ns.
2. posedge means...
Rising edge.