Simulation of a PWM signal and its average