We may need to recompile the hardware/software interface when compiling for TLM model as compared to the actual firmware.
Typically, differences are minor and can implemented in C preprocessor.
Device driver access to a UART device would be changed as follows:
#ifdef ACTUAL_FIRMWARE // For real system and lower-level models: // Store via processor bus to UART device register #define UART_WRITE(A, D) (*(uart_base+A*4)) = (D) #else // For high-level TLM modelling: // Make a direct subroutine call from the firmware to the UART model. #define UART_WRITE(A, D) uart.write(A, D) #endif
Alternatively, it is also possible to use the workstation VM system to trap calls from natively-compiled firmware to hardware: this requires the memory map of the embedded system to resemble that of the workstation.