Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "Getting Started with an OpenTitan Hardware Design" |
| 3 | --- |
| 4 | |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 5 | This document aims to clarify how to get started with a hardware design within the OpenTitan project. |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 6 | Design in this context nominally refers to a new [Comportable Peripheral]({{< relref "../rm/comportability_specification" >}}) but can include high level constructs like device reset strategy, etc. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 7 | This is primarily aimed at creating a new design from scratch, but has sections on how to contribute to an existing design. |
| 8 | It is targeted to RTL designers to give clarity on the typical process for declaring features, finding others to review, etc. |
| 9 | We aim for a healthy balance between adding clarity while not over prescribing rules and process. |
| 10 | There are times when a more regimented approach is warranted, and those will be highlighted in this document. |
| 11 | Feedback and improvements are welcome. |
| 12 | |
| 13 | |
| 14 | ## Stages of a Design |
| 15 | |
Sam Elliott | 2061d8b | 2020-04-20 19:56:54 +0100 | [diff] [blame] | 16 | The life stages of a design within the OpenTitan are described in the [Hardware Development Stages]({{< relref "doc/project/development_stages.md" >}}) document. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 17 | This separates the life of the design into three broad stages: Specification, In Development, and Signed off. |
| 18 | This document attempts to give guidance on how to get going with the first stage and have a smooth transition into the Development stage. |
| 19 | They are not hard and fast rules but methods we have seen work well in the project. |
| 20 | |
| 21 | |
| 22 | ## Concept and RFC |
| 23 | |
| 24 | The concept of a design might come from a variety of inspirations: a known required module already slated for future product need; a new design needed for a proposed product feature; an inspiration worthy of being discussed more broadly; perhaps even a new approach to an existing design (higher performance; more secure; etc). |
| 25 | Regardless of the inspiration, the concept should be codified into a brief proposal with basic features. |
| 26 | This is as opposed to minor modification proposals to an existing design, which can be handled as a GitHub pull request or issue filing associated with the existing design. |
| 27 | This proposal should be in **Google Doc** medium for agile review capability. |
| 28 | Ideally this proposal document would be created in the Team Drive, but if the author does not have access to the team drive, they can share a privately-created document. |
| 29 | |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 30 | Design proposals should follow the recommended [RFC (Request for Comment)]({{< relref "../project/rfc_process.md" >}}) process, which handles all such proposals. |
Alex Bradbury | 80ff95f | 2019-11-04 17:00:37 +0000 | [diff] [blame] | 31 | If the RFC potentially contains information that could be certification-sensitive (guidance to be shared), send a note to security@opentitan.org first for feedback. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 32 | The OpenTitan Technical Committee may be able to suggest other collaborators to help with early stage review. |
| 33 | |
Scott Johnson | 8573fa2 | 2019-11-01 14:49:56 -0700 | [diff] [blame] | 34 | An example of a canonical RFC will be provided *here* (TODO). |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 35 | |
| 36 | |
| 37 | ## Detailed Specification |
| 38 | |
| 39 | Once past initial review of the feature set and high level description, as well as potential security review, the full detailed specification should be completed, still in Google Doc form. |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 40 | The content, form, and format are discussed in the [design methodology]({{< relref "design.md" >}}) and [documentation methodology]({{< relref "../rm/markdown_usage_style.md" >}}) guides. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 41 | The outcome of this process should be a specification that is ready for further detailed review by other project members. |
| 42 | The content and the status of the proposal can be shared with the team. |
| 43 | |
| 44 | An example of a canonical detailed specification is the pinmux specification which can be found in the TeamDrive under TechnicalSpecifications --> deprecated, for those that have access to that resource. |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 45 | (Google Docs that have been converted into Markdown on GitHub are archived here). |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 46 | |
| 47 | |
| 48 | ## Specification Publication |
| 49 | |
| 50 | Once the specification is published to the wider team, the author(s) need to address input, comments, questions, etc., continuing to hone the proposal. |
| 51 | Other team members should also feel empowered to help address these questions and feedback. |
| 52 | It is acceptable to keep an unanswered-questions section of the document and move forward where there is agreement. |
| 53 | |
| 54 | |
| 55 | ## Initial Skeleton Design |
| 56 | |
| 57 | In parallel with publication and review of the specification, the initial skeleton design can commence. |
| 58 | There are many ways to get past this "big bang" of necessary implementation and get it through eventual code review. |
| 59 | One recommended method is as follows: |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 60 | * Start with a skeleton that includes a complete or near-complete definition of the register content in Hjson format |
| 61 | * Combine with a basic Markdown including that file |
| 62 | * Combine with an IP-top-level Verilog module that instantiates the auto-generated register model (see the [register tool documentation]({{< relref "../rm/register_tool" >}})), includes all of the known IP-level IO, clocking and reset. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 63 | |
| 64 | This is not mandatory but allows the basics to come in first with one review, and the full custom details over time. |
| 65 | Regardless the first check-ins of course should be compilable, syntax error free, |
| 66 | [coding style guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md) |
Garret Kelly | 9eebde0 | 2019-10-22 15:36:49 -0400 | [diff] [blame] | 67 | friendly, [Comportability]({{< relref "../rm/comportability_specification" >}}) equivalent, etc., as indicated by the [design methodology user guide]({{< relref "design.md" >}}). |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 68 | |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 69 | A good example of an initial skeleton design can be seen in [Pull Request #166](https://github.com/lowRISC/opentitan/pull/166) for the AES module. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 70 | |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 71 | As part of the GitHub filing process, the Google Doc specification must be converted into a Markdown specification. |
| 72 | (Tip: there are Google Doc add-ons that can convert the specification into Markdown format). |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 73 | Once this is completed, any specifications on the Team Drive should be moved to the deprecated section of the drive, with a link at the top indicating that the document is for historical purposes only. |
| 74 | This applies only for those specifications that originated on the Drive. |
| 75 | |
| 76 | |
| 77 | ## Full Design |
| 78 | |
Sam Elliott | 2061d8b | 2020-04-20 19:56:54 +0100 | [diff] [blame] | 79 | As the design develops within the OpenTitan repository, it transitions into "D0", "D1", etc., [design stages]({{< relref "doc/project/development_stages.md" >}}) and will be eventually plugged into the top level. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 80 | Following the recommended best practices for digestible pull requests suggests that continuing to stage the design from the initial skeleton into the full featured design is a good way to make steady progress without over-burdening the reviewers. |
| 81 | |
| 82 | ## Top Level Inclusion |
| 83 | |
| 84 | Once an IP block is ready, it can be included in the top-level design. |
| 85 | To do so, follow the steps below. |
| 86 | |
| 87 | * Get an agreement on if and how the IP block should be integrated. |
| 88 | * Ensure that the IP block is of acceptable quality. |
Philipp Wagner | 09402b4 | 2019-11-21 10:09:21 +0000 | [diff] [blame] | 89 | * Ensure that the top level simulation is not adversely affected. |
Scott Johnson | eca0338 | 2019-10-22 14:47:45 -0700 | [diff] [blame] | 90 | * Open a Pull Request with the necessary code changes. |
| 91 | |
| 92 | If it is not clear on how to proceed, feel free to file an issue requesting assistance. |