Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imported VerilogModel wrappers won't dump *.verilator.vcd when vcd_file is set #135

Open
dmlockhart opened this issue May 4, 2015 · 0 comments

Comments

@dmlockhart
Copy link
Contributor

We typically enable VCD dumping in the following manner:

  model = MyModel( params )
  model.vcd_file = 'filename.vcd'
  model.elaborate()
  if translate_verilog:
    model = TranslationTool( model )
  sim = SimulationTool( model )
  sim.cycle()

The above should dump two vcd files post simulation if translate_verilog == True:

  • filename.vcd: VCD dump from the PyMTL interface wrapper (top-level)
  • filename.verilator.vcd: VCD dump from Verilator simulation (all levels)

VerilogModels act a bit differently in that they do not need to be passed into the TranslationTool explicitly for simulation (although they can) in order to make them behave more like a normal PyMTL model. This is made possible by invisibly performing translation/verilation as soon as the Model is instantiated using metaclasses.

However, at instantiation time in the above code vcd_file is not defined yet, so the generated verilator code will have VCD dumping disabled.

Even if we try to remedy this situation by calling TranslationTool explicitly, we have already imported the shared library using CFFI and CFFI has an issue where you if you import shared libraries with the same name twice, it will only use the first version it imported.

The workaround is to set vcd_file as a class rather than instance attribute, like so:

  MyModel.vcd_file = 'filename.vcd'   # set the class attribute!
  model = MyModel( params )
  model.elaborate()
  if translate_verilog:
    model = TranslationTool( model )
  sim = SimulationTool( model )
  sim.cycle()

This may not work when using parallel tests.

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

No branches or pull requests

1 participant