In general, a hardware-in-the-loop (HIL) building simulation has lower cost and fewer practical limitations (e.g., scheduling issues) than field tests in occupied buildings, while also overcoming limitations of simulations alone by capturing the full behavior of some physical systems, equipment, and components. However, the implementation of an HIL can be difficult due to the scarcity of appropriate tools. This paper presents an agent-based framework for HIL simulation. It can be used for investigation of controller performance via controller-in-the-loop simulations and also HIL for system synthesis. In the latter case, both controllers and major equipment participate in tests to ensure that dynamics of equipment operation are correctly captured in addition to controller performance. The HIL simulation framework presented allows such actual physical parts to be included in the framework while representing others for which behaviors are better known and modeled in simulation models. The mechanism implemented in the framework to synchronize simulations in software with real-time operation of physical equipment is described. As an example, use of the HIL simulation framework is illustrated through a brief study of speed control of the supply fan in the air handling unit of a variable-air-volume building heating, ventilating and air-conditioning system.