Search code examples
cembeddeddriverdevice-drivervhdl

How to share register and bit field definitions between a device driver and the FPGA it controls


Are there any good, existing software tools available to assist in generating C header files with appropriate #defines for register offsets as well as bit definitions from VHDL? If any such tools do exist, what restrictions to they place on the VHDL and how are things that should be exported designated?

So far, I've found these tools but they aren't exactly what I'm looking for:

Based upon these tools I am also interested if the proper workflow is to generate both the C and the VHDL rather than trying to go directly from VHDL (perhaps with extra tags in the comments) to C.


Solution

  • I think that final though that was bugging you is sending you in the right direction. And I'd agree with RedGlyph in that you should consider changing your work flow a little.

    Have you thought about having one 'master document' for your control register information and generated everything automatically from this - RTL, testbench code, driver software headers and documentation?

    I've worked on projects where the control info was kept in one master spreadsheet and everything we needed generated from this. On one family of chips, I'd written a few Python scripts to generate this stuff from CSV files exported from the spreadsheet. On another project, the spreadsheet contained macros to generate the RTL files etc that we needed.

    Writing in-house scripts is all fine and good as you've total control over them and know how they work in detail. But remember that you have to spend time supporting these scripts and updating them to do new things. And consider what would happen if whoever wrote these scripts decided to go get a new job - would anyone else be familiar enough with the scripts to modify them? We're considering buying in a 3rd party tool for the reasons mentioned above.

    I've also worked on projects were the documentation and header files was back-ported from the RTL -it was a nightmare. Documentation usually lagged behind the design, and often control fields would 'go missing'. I'd rather not be involved in such a project again ;)