A unified switching theory with applications to VLSI design