Automatic Construction of Formal Models for Embedded Systems