PWM Controller
Medium · Sequential · SystemVerilog · VHDL
A premium problem. Subscribe to open it in the editor, run the testbench and see where your design lands.
Design a PWM controller for a half-bridge, with a high-side and a low-side output separated by a programmable dead time.
A half-bridge is two switches in series between the supply and ground, with its output taken from the point between them. The high-side switch pulls the output up and the low-side switch pulls it down; both on at once shorts the supply, which is called shoot-through. A switch takes time to turn off, so a controller leaves a dead time, a gap with both switches off, between one switch turning off and the other turning on.
The outputs repeat in periods of period cycles. A period in which duty + dead_time ≥ period is a fault: fault is high and both outputs are low throughout it. In any other period fault is low and, counting its cycles from 0, cycle k has pwm_h high when k < duty, pwm_l high when duty + dead_time ≤ k < period - dead_time, and both low otherwise.
Each period uses the period, duty and dead_time present two cycles before it begins. period is at least 1.
rst_n is a synchronous, active-low reset. The outputs are 0 while it is asserted and for the first two cycles after it is released, and the first period begins in the third.
- Clocks & timers