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

Support for module parameters #106

Open
7 of 8 tasks
alexforencich opened this issue Oct 18, 2020 · 18 comments
Open
7 of 8 tasks

Support for module parameters #106

alexforencich opened this issue Oct 18, 2020 · 18 comments

Comments

@alexforencich
Copy link
Contributor

alexforencich commented Oct 18, 2020

Support for setting module parameters should be added. Different simulators need module parameters passed through in different ways - different command line switches are used, and some require them in SIM_ARGS, some in COMPILE_ARGS.

Icarus verilog accepts module parameters in COMPILE_ARGS as -P toplevel.PARAM=value. Verilator accepts module parameters in COMPILE_ARGS as -GPARAM=value. No idea about other simulators.

Having a standardized way to support this in cocotb-test would be very convenient, perhaps via a module_params dict passed to Simulator.__init__().

Current simulator support:

  • Icarus Verilog
  • Questa
  • Ius
  • Xcelium
  • Vcs
  • Ghdl
  • Riviera
  • Verilator
@cmarqu
Copy link
Collaborator

cmarqu commented Oct 19, 2020

A complication is handling the quoting for string parameters, simulators differ a bit there.
It would be nice to abstract this away as well if possible.

@alexforencich
Copy link
Contributor Author

I forgot to mention I opened PR #108 for this. Each simulator would necessarily have its own get_parameter_commands method where this sort of thing could be implemented.

@alexforencich
Copy link
Contributor Author

Perhaps we should keep this open for now as a TODO for supporting this in other simulators

@themperek themperek reopened this Oct 19, 2020
@alexforencich
Copy link
Contributor Author

Added task list with current simulator support. Btw, does cocotb-test not support modelsim?

@themperek
Copy link
Owner

Btw, does cocotb-test not support modelsim?

It does need to add this ;-)

@alexforencich
Copy link
Contributor Author

Also might want to consider forcing sim_env to lowercase when reading the env var

@cmarqu
Copy link
Collaborator

cmarqu commented Oct 19, 2020

https://github.com/cocotb/cocotb/blob/master/examples/matrix_multiplier/tests/Makefile contains command line options for more simulators.

@alexforencich
Copy link
Contributor Author

Nice. I would be happy to write the code, but I do not have access to any of those simulators so I cannot test it.

@themperek
Copy link
Owner

I can test everything but Aldec.

@alexforencich
Copy link
Contributor Author

Also, what are your opinions on using f-strings?

@cmarqu
Copy link
Collaborator

cmarqu commented Oct 19, 2020

Also, what are your opinions on using f-strings?

Like them of course, but cocotb still wants to keep Python 3.5 compatibility for the 1.4 version(s) (release end of this year), because Ubuntu 16.04 ships with it by default and is supported until March/'April next year. So end of this year after the start of the 1.5 (or 2.0?) development cycle we will be able to use f-strings.

@themperek
Copy link
Owner

Also, what are your opinions on using f-strings?

cocotb still supports 3.5 but ...

@alexforencich
Copy link
Contributor Author

Ah, I see, they were introduced in 3.6 and so that could cause compatibility problems.

@alexforencich
Copy link
Contributor Author

Just opened #110, if you guys want to test that, it would be great.

@alexforencich
Copy link
Contributor Author

Related question: what's the best way to get some of these parameters to python before the simulation itself starts, specifically so they can be used when setting up TestFactory?

@alexforencich
Copy link
Contributor Author

Hmm, I basically did the same thing, except I prefixed the env vars with PARAM_ to try to avoid possible collisions with other stuff. I didn't use extra_env though, that's probably a good idea.

@gretzteam
Copy link
Contributor

I made a custom function that dumps the params and other tb/ip config to a yaml file in some kind of uniform way. The cocotb testbench can read it back.
It would be awesome to be able to directly pass stuff to the cocotb test but my understanding is this requires a cocotb change.
The issue with using files like this is when doing parallel run with pytest. It makes it harder to share sim_build directory and avoid collision with file names.... Not unsurmountable but shows its a bit hacky.

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

No branches or pull requests

4 participants