Next: , Previous: Module Creation, Up: Extending simulation


5.3 Run-time Module Loading

With our built module, we can now load it into hacchpsim. One way is to pass libraries on the command line using the -l option and the -L option.

     $ hacchpsim -lbar chptest.haco-a
     loaded function: `alert_me'
     loaded function: `twiddle'
     chpsim> watchall-events
     chpsim> step 40

The alternative is to add library paths and load libraries after the simulator is launched.

     $ hacchpsim chptest.haco-a
     chpsim> dlopen bar
     loaded function: `alert_me'
     loaded function: `twiddle'
     chpsim> watchall-events
     chpsim> step 40

Loading libraries on the command-line and in the interpreter is allowed, and works as expected. chpsim can load arbitrarily many libraries (within the limits of the operating system), and as long as the registered function names don't conflict.