m-labs / nmigen

A refreshed Python toolbox for building complex digital hardware. See https://gitlab.com/nmigen/nmigen
https://nmigen.org
Other
652 stars 55 forks source link

How to pass yosys_opts to LatticeICE40Platform? #314

Closed RobertBaruch closed 4 years ago

RobertBaruch commented 4 years ago

Specifically, I want to add -abc2 -relut to the yosys call in the generated top.ys file.

It's not clear from the comments or code how to do this. I see from the get_override() code in plat.py that you can get it from two places: an enviroment variable called NMIGEN_yosys_opts, or from kwargs, which doesn't seem to be defined:

https://github.com/m-labs/nmigen/blob/c42c3a096f89f8330f574ecd32700c2b9375e0be/nmigen/build/plat.py#L329

I'm probably missing some bit of Python knowledge, but I thought kwargs had to be passed in as an argument **kwargs.

In any case, I would much rather know how to pass yosys_opts programmatically, since environment variables aren't that great cross-platform-wise.

adamgreig commented 4 years ago

The kwargs are passed in to the function that get_override() is defined inside. If you're using LatticeICE40Platform you can pass in synth_opts when you call build(): https://github.com/m-labs/nmigen/blob/c42c3a096f89f8330f574ecd32700c2b9375e0be/nmigen/vendor/lattice_ice40.py#L27

RobertBaruch commented 4 years ago

Ah, I didn't notice that get_override() was defined in toolchain_prepare(). In any case, passing synth_opt="-relut -abc2" worked. Thanks!