Skip to content

Support additional start/shutdown code in Bluesim models #1081

Description

@quark17

When BSC source was opened, we removed some special-purpose code that Bluespec Inc had inserted to support their emulation system (SceMi). There was a flag -scemi that would automatically insert additional objects into the build (.a libraries or .ba modules) as if they had been specified on the command-line, but it would also insert some hooks into generated Bluesim models. I looked at resurrecting the SceMi tools and the first part can be done manually by the user, by adding to the command-line, but the second part is more difficult. It would be useful if BSC had a generic feature for hooking into the start/stop routines of Bluesim.

How this worked before was that the user would have a file scemilink.h that defined scemi_setup() and scemi_shutdown(). When given the -scemi flag, BSC would insert the following into the model_<topModuleName>.cxx file (created by SimBlocksToC):

  • at the top: #include "scemilink.h"
  • at the end of the create_model() function: scemi_setup(sim_hdl)
  • at the end of the destroy_model() function: scemi_shutdown(sim_hdl)

The scemi_setup function took a handle, because it would do things like set a config register inside the model (to tell it what port number to use for the communication link, say).

It would be helpful if there was someway to tell BSC to insert code. Maybe BSC can hardcode what the create and destroy functions should be called and the user just specifies the name of the file to include (or even, BSC can hardcode what the name should be, if that's easier). So, for example, -sim-hooks scemilink.h could be specified and the functions in the file would need to be called bluesim_custom_setup() and bluesim_custom_destroy() (or bluesim_create_hook and bluesim_destroy_hook) or something like that. But maybe there's also a different better way to register additional functions -- that perhaps doesn't even require a flag to compilation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions