Licensing
=========

Re-distribution of the PeakRDL-rust code generator tool shall adhere to the
terms outlined by the GNU LGPL v2.1 or later license. For a copy of the license, see:
https://github.com/darsor/PeakRDL-rust/blob/main/LICENSE


Why LGPLv2.1+?
---------------
LGPLv2.1 or later was chosen because the intent is to promote a thriving ecosystem of free and
open source register automation tools. The license terms discourage this tool from
being bundled into some commercially sold closed-source software, as that would
be contrary to this project's philosophy.


What is covered by the LGPLv2.1+ license?
------------------------------------------
The LGPL license is intended for the code generator itself. This includes all
Python sources, Jinja template files, as well as testcase infrastructure not
explicitly mentioned in the exemptions below.


What is exempt from the LGPLv2.1+ license?
-------------------------------------------
Don't worry. Not everything that the PeakRDL-rust project touches is
considered LGPLv2.1+ code.

The following are exempt and are free to use with no restrictions:

*   Any Rust code that is generated using PeakRDL-rust is 100% yours. Since it
    was derived from your register block definition, it remains yours. You can
    distribute it freely, use it in proprietary software, sell it as part of an
    IP, whatever.
*   Any code snippets in this documentation can be freely copy/pasted. These are
    examples that are intended for this purpose.
*   The provided ``upds.rdl`` file can be downloaded and used freely.
*   The ``peakrdl-rust`` crate that the generated code uses is licensed
    under the dual MIT/Apache 2.0 license.
*   The ``peakrdl-rust-build`` build utility crate is licensed under the dual
    MIT/Apache 2.0 license.


Can I use this as part of my company's internally developed tools?
------------------------------------------------------------------
Absolutely!

Sometimes it may be necessary to integrate this into a larger toolchain at your
workplace. This is totally OK, as long as you don't start distributing it
outside your workplace in ways that violate the LGPLv2.1+ license.

That said, I'd encourage you to check out the `PeakRDL command line tool <https://peakrdl.readthedocs.io/>`_.
It might already do everything you need.


Generated Code License
----------------------
The Rust code generated by PeakRDL-rust is completely unrestricted and belongs
to you. This includes:

*   All register structure definitions
*   Field accessor methods and types
*   Enumeration definitions
*   Test code and validation functions
*   Any custom traits or implementations

You are free to:

*   Use the generated code in commercial products
*   Modify the generated code as needed
*   Distribute the generated code under any license
*   Include the generated code in proprietary software
*   Sell products containing the generated code
