Use of "extern" methods in Verification IPs - a PySlint case study
As we prepare for Verification Futures 2023, Austin event, an enthusiastic user ran PySlint on a small SPI VIP and found the following violation (among others).
As expected, first reaction from the user was - what's the big deal?
Below is our attempt in rationalizing why this rule is important especially for VIP developers and users.
A quick recap - The extern keyword in SystemVerilog is an optional qualifier to class methods. As in C++, Java and other languages, this is a highly recommended coding style, some benefits include:
- Improves readability - By declaring the method prototype in one place
and the implementation in another, it can be easier to "read" the code for end users (not only the original developers) - to quickly glance the list of APIs/methods without scrolling 1000s of lines of code (if the implementation is mixed with declaration).
- To hide implementation details. If the method implementation is defined in a separate file, it can be hidden from users of the class. This can be useful for security reasons or to prevent users from modifying the implementation. Many-a-times VIP code is shipped as encrypted, yet users need to know the API definitions/signatures. SystemVerilog extern aids here perfectly.
- Enhances maintainability - Developers will know what is changing - the API signature or the "body".
- Distributed development - managers can distribute complex VIP code such as PCIe driver across few team members, as extern methods can be implemented in separate files.
- Allows for separate compilation. If the method is defined in a separate file, it can be compiled independently of the rest of the code. This can be very handy for large projects.
Comments
Post a Comment