HOME       UP       PREV       NEXT (Forms of ESL Model)  

Using C Preprocessor to Adapt Firmware

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:


  // 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) 


  // 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)


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.

7: (C) 2008-11, DJ Greaves, University of Cambridge, Computer Laboratory.