blob: bf4ac1f8bc5d86e691de7893392cf0c67af0fb97 [file] [log] [blame] [view]
Garret Kelly9eebde02019-10-22 15:36:49 -04001---
2title: "Design Methodology within OpenTitan"
3---
4
lowRISC Contributors802543a2019-08-31 12:12:56 +01005The design methodology within OpenTitan combines the challenges of industry-strength design methodologies with open source ambitions.
6When in conflict, quality must win, and thus we aim to create a final design product that is equal to the quality required from a full production silicon chip tapeout.
7
8## Language and Tool Selection
9
Scott Johnsonaf513352019-10-09 16:46:22 -070010Starting with the language, the strategy is to use the SystemVerilog language, restricted to a feature set described by the lowRISC
lowRISC Contributors802543a2019-08-31 12:12:56 +010011[Verilog Style Guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md).
12All IP should be developed and delivered under the feature set described by this style guide.
13Inconsistencies or lack of clarity within the style guide should be solved by filing and helping close an issue on the style guide in the
14[lowrisc/style-guides GitHub repo](https://github.com/lowRISC/style-guides).
15
16For professional tooling, the team has chosen several industry-grade tools for its design signoff process.
17Wherever possible we attempt to remain tool-agnostic, but we must choose a selection of tools as our ground truth for our own confidence of signoff-level assurances.
Scott Johnsonaf513352019-10-09 16:46:22 -070018As a project we promote other open source methodologies and work towards a future where these are signoff-grade as well.
lowRISC Contributors802543a2019-08-31 12:12:56 +010019The discussions on how the design tools are used and which ones are chosen are given below in separate sections.
20
21## Comportability and the Importance of Architectural Conformity
22
23The OpenTitan program is adopting a design methodology aimed at unifying as much as possible the interfaces between individual designs and the rest of the SOC.
Garret Kelly9eebde02019-10-22 15:36:49 -040024These are detailed in the [Comportability Specification]({{< relref "doc/rm/comportability_specification" >}}).
lowRISC Contributors802543a2019-08-31 12:12:56 +010025This document details how peripheral IP interconnects with the embedded processor, the chip IO, other designs, and the security infrastructure within the SOC.
26Not all of the details are complete at this time, but will be tracked and finalized within that specification.
27
Scott Johnson8573fa22019-11-01 14:49:56 -070028TODO: briefly discuss key architectural decisions, and how we came to the conclusion, with pointers to more thorough documentation. Some candidates:
lowRISC Contributors802543a2019-08-31 12:12:56 +010029* Processor/RISC-V strategy
30* Bus strategy
31* Reset strategy
32
Scott Johnsonaf513352019-10-09 16:46:22 -070033## Defining Design Complete: stages and tracking
lowRISC Contributors802543a2019-08-31 12:12:56 +010034
35Designs within the OpenTitan project come in a variety of completion status levels.
Scott Johnsonaf513352019-10-09 16:46:22 -070036Some designs are "tapeout ready" while others are still a work in progress.
lowRISC Contributors802543a2019-08-31 12:12:56 +010037Understanding the status of a design is important to gauge the confidence in its advertised feature set.
Sam Elliott2061d8b2020-04-20 19:56:54 +010038To that end, we've designated a spectrum of design stages in the [OpenTitan Hardware Development Stages]({{< relref "doc/project/development_stages.md" >}}) document.
Scott Johnsonaf513352019-10-09 16:46:22 -070039This document defines the design stages and references where one can find the current status of each of the designs in the repository.
lowRISC Contributors802543a2019-08-31 12:12:56 +010040
41## Documentation
42
43Documentation is a critical part of any design methodology.
44Within the OpenTitan project there are two important tooling components to efficient and effective documentation.
Scott Johnsonaf513352019-10-09 16:46:22 -070045
Philipp Wagner14a3fee2019-11-21 10:07:02 +000046The first is the [Hugo](https://gohugo.io) tool, which converts an annotated Markdown file into a rendered HTML file (including this document).
Garret Kelly9eebde02019-10-22 15:36:49 -040047See the linked manual for information about the annotations and how to use it to create enhanced auto-generated additions to standard Markdown files.
Tobias Wölfelb4b624d2020-05-15 11:06:07 +020048To automate the process a script [build_docs.py]({{< relref "doc/ug/documentation" >}}) is provided for generating the documentation.
Scott Johnsonaf513352019-10-09 16:46:22 -070049
Garret Kelly9eebde02019-10-22 15:36:49 -040050The second is the [reggen]({{< relref "doc/rm/register_tool" >}}) register tool that helps define the methodology and description language for specifying hardware registers.
Tobias Wölfelb4b624d2020-05-15 11:06:07 +020051These descriptions are used by `build_docs.py` to ensure that the technical specifications for the IP are accurate and up to date with the hardware being built.
lowRISC Contributors802543a2019-08-31 12:12:56 +010052
Philipp Wagner14a3fee2019-11-21 10:07:02 +000053Underlying and critical to this tooling is the human-written content that goes into the source Markdown and register descriptions.
Scott Johnsonaf513352019-10-09 16:46:22 -070054Clarity and consistency is key.
Garret Kelly9eebde02019-10-22 15:36:49 -040055See the [Markdown Style Guide]({{< relref "doc/rm/markdown_usage_style.md" >}}) for details and guidelines on the description language.
lowRISC Contributors802543a2019-08-31 12:12:56 +010056
57## Usage of Register Tool
58
59One design element that is prime for consistent definitions and usages is in the area of register definitions.
Scott Johnsonaf513352019-10-09 16:46:22 -070060Registers are critical, being at the intersection of hardware and software, where uniformity can reduce confusion and increase re-usability.
Garret Kelly9eebde02019-10-22 15:36:49 -040061The [register tool]({{< relref "doc/rm/register_tool" >}}) used within OpenTitan is custom for the project's needs, but flexible to add new features as they arise.
lowRISC Contributors802543a2019-08-31 12:12:56 +010062It attempts to stay lightweight yet solve most of the needs in this space.
63The description language (using HJSON format) described within that specification also details other features described in the
Garret Kelly9eebde02019-10-22 15:36:49 -040064[Comportability Specification]({{< relref "doc/rm/comportability_specification" >}}).
lowRISC Contributors802543a2019-08-31 12:12:56 +010065
66## Linting Methodology
67
68Linting is a productivity tool for designers to quickly find typos and bugs at the time when the RTL is written.
69Capturing fast and efficient feedback on syntactic and semantic (as well as style) content early in the process proves to be useful for high quality as well as consistent usage of the language.
70Running lint is especially useful with SystemVerilog, a weakly-typed language, unlike more modern hardware description languages.
71Running lint is faster than running a simulation.
72
Michael Schaffner810cf832021-05-18 14:31:55 -070073### Semantic Linting using Verilator (Open Source)
lowRISC Contributors802543a2019-08-31 12:12:56 +010074
Michael Schaffner810cf832021-05-18 14:31:55 -070075The Verilator tool is open source, thus enabling all project contributors to conveniently download, install and run the tool locally as described [in the installation instructions]({{< relref "doc/ug/install_instructions/index.md#verilator" >}}), without the need for buying a lint tool license.
Michael Schaffner29553ae2020-04-17 15:44:56 -070076
Michael Schaffner810cf832021-05-18 14:31:55 -070077For developers of design IP, the recommendation is thus to set up the Verilator lint flow for their IP as described in the [Lint Flow README]({{< relref "hw/lint/doc/README.md" >}}).
78Developers should run their code through the Verilator lint tool before creating a design pull request.
Michael Schaffner620b8bf2020-03-17 20:10:15 -070079Linting errors and warnings can be closed by fixing the code in question (preferred), or waiving the error.
Michael Schaffner810cf832021-05-18 14:31:55 -070080These waivers have to be reviewed as part of the pull request review process.
Michael Schaffner620b8bf2020-03-17 20:10:15 -070081
Michael Schaffner810cf832021-05-18 14:31:55 -070082Note that a pull request cannot be merged if it is not lint-clean, since the continuous integration infrastructure will run Verilator lint on each pull request.
Michael Schaffner620b8bf2020-03-17 20:10:15 -070083
Michael Schaffner810cf832021-05-18 14:31:55 -070084### Style Linting using Verible (Open Source)
lowRISC Contributors802543a2019-08-31 12:12:56 +010085
Michael Schaffner810cf832021-05-18 14:31:55 -070086To complement the Verilator lint explained above, we also leverage the Verible style linter, which captures different aspects of the code and detects style elements that are in violation of our [Verilog Style Guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md).
Michael Schaffner29553ae2020-04-17 15:44:56 -070087
88The tool is open source and freely available on the [Verible GitHub page](https://github.com/google/verible/).
Michael Schaffner810cf832021-05-18 14:31:55 -070089Hence, we recommend IP designers install the tool as described [here]({{< relref "doc/ug/install_instructions/index.md#verible" >}}) and in the [Lint Flow README]({{< relref "hw/lint/doc/README.md" >}}), and use the flow locally to close the errors and warnings.
Michael Schaffner29553ae2020-04-17 15:44:56 -070090
Michael Schaffner810cf832021-05-18 14:31:55 -070091Developers should run their code through the Verible style lint tool before creating a design pull request.
92Linting errors and warnings can be closed by fixing the code in question (preferred), or waiving the error.
93These waivers have to be reviewed as part of the pull request review process.
Michael Schaffner29553ae2020-04-17 15:44:56 -070094
Michael Schaffner810cf832021-05-18 14:31:55 -070095Note that a pull request cannot be merged if it is not lint-clean, since the continuous integration infrastructure will run Verible lint on each pull request.
96
97### Semantic Linting using AscentLint (Sign-Off)
98
99The rule set and capabilities of commercial tools currently still go beyond what open-source tools can provide.
100Hence, we have standardized on the [AscentLint](https://www.realintent.com/rtl-linting-ascent-lint/) tool from RealIntent for sign-off.
101This tool exhibits fast run-times and a comprehensive set of rules that provide concise error and warning messages.
102
103The sign-off lint flow leverages a new lint rule policy named _"lowRISC Lint Rules"_ that has been tailored towards our [Verilog Style Guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md).
104The lint flow run scripts and waiver files are available in the GitHub repository of this project but, due to the proprietary nature of the lint rules and their configuration, the _"lowRISC Lint Rules"_ lint policy file can not be publicly provided.
105However, the _"lowRISC Lint Rules"_ are available as part of the default policies in AscentLint release 2019.A.p3 or newer (as `LRLR-v1.0.policy`).
106This allows designers with access to this tool to run the lint flow locally on their premises.
107
108If developers of design IP have access to AscentLint, we recommend to set up the AscentLint flow for their IP as described in the [Lint Flow README]({{< relref "hw/lint/doc/README.md" >}}), and use the flow locally to close the errors and warnings.
109Linting errors and warnings can be closed by fixing the code in question (preferred), or waiving the error.
110These waivers have to be reviewed as part of the pull request review process.
111
112Note that our continuous integration infrastructure does not currently run AscentLint on each pull request as it does with Verilator lint.
113However, all designs with enabled AscentLint targets on the master branch will be run through the tool in eight-hour intervals and the results are published as part of the tool dashboards on the [hardware IP overview page](https://docs.opentitan.org/hw), enabling designers to close the lint errors and warnings even if they cannot run the sign-off tool locally.
114
115Goals for sign-off linting closure per design milestone are given in the [OpenTitan Development Stages]({{< relref "doc/project/development_stages" >}}) document.
116
117Note that cases may occur where the open-source and the sign-off lint tools both output a warning/error that is difficult to fix in RTL in a way that satisfies both tools at the same time.
118In those cases, priority shall be given to the RTL fix that satisfies the sign-off lint tool, and the open-source tool message shall be waived.
Michael Schaffner29553ae2020-04-17 15:44:56 -0700119
lowRISC Contributors802543a2019-08-31 12:12:56 +0100120## Assertion Methodology
121
122The creation and maintenance of assertions within RTL design code is an essential way to get feedback if a design is being used improperly.
Scott Johnsonaf513352019-10-09 16:46:22 -0700123Common examples include asserting that a full FIFO should never be written to, a state machine doesn't receive an input while in a particular state, or two signals should remain mutually exclusive.
124Often these will eventually result in a downstream error (incorrect data, bus collisions, etc.), but early feedback at the first point of inconsistency gives designers and verifiers alike fast access to easier debug.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100125
126Within OpenTitan we attempt to maintain uniformity in assertion style and syntax using SystemVerilog Assertions and a list of common macros.
127An overview of the included macros and how to use them is given in this
Garret Kelly9eebde02019-10-22 15:36:49 -0400128[Design Assertion README file]({{< relref "hw/formal/README.md" >}}).
lowRISC Contributors802543a2019-08-31 12:12:56 +0100129This document also describes how to formally verify assertions using
130[JasperGold](https://www.cadence.com/content/cadence-www/global/en_US/home/tools/system-design-and-verification/formal-and-static-verification/jasper-gold-verification-platform/formal-property-verification-app.html)
131from the company Cadence.
132
133## CDC Methodology
134
135Logic designs that have signals that cross from one clock domain to another unrelated clock domain are notorious for introducing hard to debug problems.
Scott Johnsonaf513352019-10-09 16:46:22 -0700136The reason is that design verification, with its constant and idealized timing relationships on signals, does not represent the variability and uncertainty of real world systems.
137For this reason, maintaining a robust Clock Domain Crossing verification strategy ("CDC methodology") is critical to the success of any multi-clock design.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100138
139Our general strategy is threefold:
140maintain a list of proven domain crossing submodules;
141enforce the usage of these submodules;
142use a production-worthy tool to check all signals within the design conform to correct crossing rules.
Scott Johnsonaf513352019-10-09 16:46:22 -0700143The *CDC Methodology document* (TODO:Coming Soon) gives details on the submodules and explains more rationale for the designs chosen.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100144
Scott Johnsone3684012019-10-24 17:28:59 -0700145The tool chosen for this program is not finalized.
146We will choose a sign-off-grade CDC checking tool that provides the features needed for CDC assurance.
147It is understandable that not all partner members will have access to the tool.
148Once chosen, the project will use it as its sign-off tool, and results will be shared in some form (TODO: final decision).
lowRISC Contributors802543a2019-08-31 12:12:56 +0100149CDC checking errors can be closed by fixing the code in question (preferred), or waiving the error.
Michael Schaffner810cf832021-05-18 14:31:55 -0700150CDC waivers should be reviewed as part of the pull request review process.
Scott Johnsone3684012019-10-24 17:28:59 -0700151Details on how to run the tool will be provided once the decision has been finalized.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100152
Scott Johnsone3684012019-10-24 17:28:59 -0700153The team will standardize on a suite of clock-crossing modules that can be used for most multi-clock designs.
154Many of those will be documented in the `hw/ip/prim/doc` directory.
155
156Similar to the linting tool, due to the proprietary nature of the CDC tool, it is possible that not all content towards running the tool will be checked in in the open source repository.
157For those items, we will work with the tool provider to allow other partners to also use the tool.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100158When this methodology is finalized the details will be given here. (TODO)
159
160## DFT
161
162Design For Testability is another critical part of any design methodology.
163It is the preparation of a design for a successful manufacturing test regime.
164This includes, but is not limited to, the ability to use scan chains for testing digital logic;
165the optimization of design logic to allow maximum access of test logic for fault coverage;
166the ability to observe and control memory cells and other storage macros;
167the control of analog designs and other items that are often outside the reach of test logic;
168built in self test (BIST) insertion for logic and memories.
169In this context, our primary concern at this stage is what impact does this have on the RTL that makes up the IP in our library.
170
171DFT in OpenTitan is particularly interesting for two primary reasons:
172the RTL in the OpenTitan repository is targeted towards an FPGA implementation, but must be prepared for a silicon implementation
Scott Johnson8573fa22019-11-01 14:49:56 -0700173(see the FPGA vs Silicon discussion later in this document);
lowRISC Contributors802543a2019-08-31 12:12:56 +0100174the whole purpose of a DFT methodology is full and efficient access to all logic and storage content,
175while the whole purpose of a security microcontroller is restricting access to private secured information.
176In light of the latter dilemma, special care must be taken in a security design to ensure DFT has access at only the appropriate times, but not while in use in production.
177
178At this time the DFT methodology for OpenTitan is not finalized.
179The expectation is that the RTL collateral will undergo a DFT introduction -
180likely with the propagation of such signals as `testmode`, `scanmode`, `bistmode`, etc -
181at a stage before final project completion.
182At this point there are a few references to such signals but they are not yet built into a coherent whole.
183At that future time the DFT considerations will be fully documented and carried out throughout all IP.
184
185## Generated Code
186
187The OpenTitan project contains a lot of generated code through a variety of methods.
188Most modern SystemVerilog-based projects work around the weaknesses in the language in such a way.
189But our first goal is to take full advantage of the language as much as possible, and only resort to generated code where necessary.
190
191At the moment, all generated code is checked in with the source files.
Scott Johnsonfe79c4b2020-07-08 10:31:08 -0700192The pros and cons of this decision are still being discussed, and the decision may be reversed, to be replaced with an over-arching build-all script to prepare a final design as source files changed.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100193Until that time, all generated files (see for example the output files from the
Garret Kelly9eebde02019-10-22 15:36:49 -0400194[register generation tool]({{< relref "doc/rm/register_tool" >}}))
lowRISC Contributors802543a2019-08-31 12:12:56 +0100195are checked in.
Scott Johnsonfe79c4b2020-07-08 10:31:08 -0700196There is an over-arching build file in the repository under `hw/Makefile` that builds all of the `regtool` content.
Scott Johnsonaf513352019-10-09 16:46:22 -0700197This is used by an Azure Pipelines pre-submit check script to ensure that the source files produce a generated file that is identical to the one being submitted.
lowRISC Contributors802543a2019-08-31 12:12:56 +0100198
199## Getting Started with a Design
200
Scott Johnson8573fa22019-11-01 14:49:56 -0700201The process for getting started with a design involves many steps, including getting clarity on its purpose, its feature set, authorship, documentation, etc.
Garret Kelly9eebde02019-10-22 15:36:49 -0400202These are discussed in the [Getting Started with a Design]({{< relref "getting_started_design.md" >}}) document.
Scott Johnson8573fa22019-11-01 14:49:56 -0700203
204## FPGA vs Silicon
Scott Johnson19f8eca2020-01-27 13:12:13 -0800205
206One output of the OpenTitan project will be silicon instantiations of hardware functionality described in this open source repository.
207The RTL repository defines design functionality at a level satisfactory to prove the hardware and software functionality in an FPGA (see [user guides]({{< relref "doc/ug" >}})).
208That level is so-called "tapeout ready".
209Once the project reaches that milestone, the team will work with a vendor or vendors to ensure a trustworthy, industry-quality, fully functional OpenTitan chip is manufactured.
210
211It is important that any IP that *can* be open *is* open to ensure maximal trustworthiness and transparency of the final devices.
212
213To that end, OpenTitan will define compliance collateral that ensures correctness - that the FPGA and the eventual silicon work the same.
214Due to fundamental economic and technical limitations, there may, and likely will, be differences between these incarnations.
215Some examples include the following:
216
217* Silicon versions by definition use different technologies for fundamental vendor collateral, including memories, analog designs, pads, and standard cells.
218* Some of the silicon collateral is beyond the so-called "foundry boundry" and not available for open sourcing.
219
220Some IP blocks will undergo hardening of designs to protect them against physical attack to meet security and certification requirements.
221Some of this hardening, for instance in fuses, may be of necessity proprietary.
222These changes will not impact the functionality of the design, but are described in processes unique to an ASIC flow vs. the emulated flow of an FPGA.
223
224Even with these differences, the overriding objective is compliance equivalence between the FPGA and silicon versions.
225This may require instantiation-specific differences in the software implementation of the compliance suite.
226
227Consider the embedded flash macro.
228This design is highly dependent upon the silicon technology node.
229In the open source repository, the embedded flash macro is emulated by a model that approximates the timing one would typically find in silicon.
230It lacks the myriad timing knobs and configuration points required to control the final flash block.
231This necessitates that the compliance suite will have initialization sections for flash that differ between FPGA and silicon.
232
233We consider this demonstration of "security equivalence" to be an open, unsolved problem and committed to clearly delimiting any differences in the compliance suite implementation.