This paper describes a method for simulating SPICE models of secondary batteries, such as lithium-ion, lead-acid, and solid-state batteries, in real time in a hardware-in-the-loop simulation (HILS) environment. It details the process of deriving a state-space model from a SPICE equivalent circuit model and converting it into real-time executable difference equations. It then explains how to implement the model using an FPGA or microcontroller, converting it to fixed-point arithmetic, and ensuring real-time performance on the order of microseconds. It also touches on the design of a high-speed power output stage (power amplifier) for connecting to target devices such as battery management systems (BMS) and inverters, and techniques for accurately reproducing transient responses. Finally, it introduces existing battery HILS products from companies such as A&D and OPAL-RT, as well as similar examples from academic research, emphasizing the importance of development and verification in a safe and flexible environment.