The purpose of the study is to develop a method for calculating the mathematical models of block diagrams in the form of equations in a state-space representation. The model is calculated through an iterative process. The initial condition of the mathematical model is taken as a model consisting of unconnected elements of the block diagram. The hierarchy of elements, in general, is not set and is arbitrary, but remains unchanged throughout the computation. The iterative process is composed of steps, each of which processes one connection. The connection bridges the output and input ports of the element(s) in the block diagram. It is helpful (for example, to obtain the matrix frequency response of the system) to implement an algorithm for calculating the current connection without excluding and without zeroing the rows and columns of the equation-of-state matrices corresponding to this connection. This corresponds to a derivation of an equivalent model of a block diagram with input ports accessible for signal input and output ports of all elements composing the block diagram being open for observation. In this case, the definition of indexes at all steps of the algorithm remains the same as at step zero. The paper demonstrates that if a linear dynamic system contains a solvable system of algebraic loops, the mathematical model of a said dynamic system can be obtained as equations of state. In this case, the condition is derived, under which the system of algebraic loops can be solvable, and then the mathematical model of the block diagram can be obtained. If this condition is not met, the block diagram is to be rebuilt. The paper provides an example of step-by-step construction of a control system model defined by a block diagram and a class diagram of a system defined by a block diagram.