Code Style Guidelines
Author: Johannes Hofmann, Niklas Sirch, Gundolf Kiefer 2025
Naming Conventions
This section summarizes all naming and coding conventions. The list may be incomplete an be extended as the project grows.
Overview
Category |
Convention |
Example(s) |
Notes |
|---|---|---|---|
Classes |
|
|
Use |
Variables |
|
|
Start with lowercase, use snake_case. |
Methods/Functions |
|
|
Start with lowercase, use snake_case. |
Constants (Macros) |
|
|
All caps with underscores. |
SystemC modules, |
|
|
Prefix |
SystemC processes |
|
|
Use |
SystemC processes |
|
|
|
Enumerations (enum) |
Type: |
|
Enum values must have a prefix to avoid name collisions. |
Config Options |
|
|
See section on configuration parameters for details. |
Additional Rules
All symbols that may go into
PN_INSTALLED_DIRmust be prefixed byPN_orpn_. Legal exceptions are:purely internal symbols (e.g. internal modules of a Nucleus)
Makefile symbols that directly affect the build process and nothing else, e.g.: PREFIX, VERBOSE, DEBUG
All hardware modules must follow these rules, where
is the module name ( PN_MODULE_NAME):The entity name is
m_<modname>.Any sub-entities defined in the same module must be prefixed by
m_<modname>_. For example, the embedded memory inside the Membrana variantm_membrana_hwis namedm_membrana_emem.The containing directory is named
<modname>.
Formatting
The project uses clang-format to format the code. The configuration is in
.clang-format. It is highly recommended to follow these guidelines to ensure a
consistent code style.
You can use the VS-Code Extension xaver.clang-format or format with these
commands.
$ # For single files use
$ clang-format -i file.cpp
$ # For all project files use
$ git ls-files '*.[ch]' '*.[ch]pp' | xargs clang-format -i