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

Bikeshed: Packaging existing RTL code with nmigen wrapper #258

Closed
Fatsie opened this issue Oct 24, 2019 · 5 comments
Closed

Bikeshed: Packaging existing RTL code with nmigen wrapper #258

Fatsie opened this issue Oct 24, 2019 · 5 comments
Labels

Comments

@Fatsie
Copy link
Contributor

Fatsie commented Oct 24, 2019

I would like to make nmigen wrappers around existing RTL code and package them for distribution with pip, conda and similar tools. Target is also that a user can use the wrapper class as any other submodule without need to take care of the RTL source code files.

An example alpha implementation (without packaging support) can be seen in ao68000.py used in my latest SnowWhite test tape-out.

In order for the user to not have to add the RTL files herself you can see that the files are added to the platform during elaboration. Users could have more than one instantiation of the wrapper class in their circuit. So in order to avoid errors because the files get added twice I use an empty .ao68000_added file as stamp. Maybe this could be supported natively by platform for example by a add_files_tag() or add_files_uuid() method. Let me know what you think. I'll try to implement what is proposed here.

Second part of the bikeshedding is the packaging itself; this is not nmigen specific so ignore if deemed not appropriate here. What is good pythonic way of distributing the RTL files with the nmigen wrapper ? I have been thinking of copying the RTL files along with the python code and use the module path to load the files from there. Another solution is to convert the RTL files into a python file where the files are presented as strings. Any comments ?

@whitequark
Copy link
Contributor

Maybe this could be supported natively by platform for example by a add_files_tag() or add_files_uuid() method.

We could make it a no-op to add a file with the exact same name and content. After all, what's the harm of it? Also, I would say that you should (by convention0 place all of the files into a directory with the name of the current module; special variable __name__ contains it.

Second part of the bikeshedding is the packaging itself

I think you want to use pkg_resources.

@whitequark
Copy link
Contributor

As an aside, there's currently no support for setting include path and definitions. You're going to hit at least the latter, possibly the former too. Some infrastructure would have to be added to support that. Definitions are fairly easy, but include paths would have to be checked to ensure they're relative.

@Fatsie
Copy link
Contributor Author

Fatsie commented Oct 25, 2019

Maybe this could be supported natively by platform for example by a add_files_tag() or add_files_uuid() method.

We could make it a no-op to add a file with the exact same name and content. After all, what's the harm of it? Also, I would say that you should (by convention0 place all of the files into a directory with the name of the current module; special variable __name__ contains it.

OK, given that file names are typically named after modules found in the source file, you likely still have a problem if two files have the same name in different modules.

As an aside, there's currently no support for setting include path and definitions. You're going to hit at least the latter, possibly the former too. Some infrastructure would have to be added to support that. Definitions are fairly easy, but include paths would have to be checked to ensure they're relative.

I have been looking mainly at open source FPGA retrocomputing code. This is a lot of VHDL and simple structured verilog code. So likely I don't need this support at first.

Also I would not mind that source code would need to be patched in order to be distributed with a nmigen wrapper like a lot of program source code need to be patched to distribute as rpm or deb.

@whitequark
Copy link
Contributor

OK, given that file names are typically named after modules found in the source file, you likely still have a problem if two files have the same name in different modules.

That's true, but the purpose here is to make sure that, when looking at the build directory, it would be immediately clear where the Verilog/VHDL files come from.

@whitequark
Copy link
Contributor

Seems like we have an agreement, so closing this issue. Feel free to comment if you have more questions.

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

No branches or pull requests

2 participants