A state-space modeling and simulation program applicable to any DC-DC converter is presented. From a circuit description, this program automatically generates state-space equations corresponding to each switching interval. The focus is on a methodology for yielding the state-space equations. The state-space program consists of two parts. In the first part, state-space functions derived from nodal analysis and the unit source approach are generated from circuit descriptions. The circuit is described by a set of element cards defining the circuit topology. By specifying the on and off conditions of the switches, a set of state-space equations for each topological mode can be obtained by solving the node equation of the corresponding circuit topology. In the second part, a piecewise-linear, discrete-time modeling technique is used to perform the DC-DC converter analysis. The time-domain simulation is performed in a time-efficient manner by using a state-transition matrix.