Srikrishna Iyer | d04b08e | 2019-10-09 00:09:34 -0700 | [diff] [blame] | 1 | --- |
| 2 | title: "Directory Structure" |
| 3 | --- |
| 4 | |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 5 | This document provides an overview of the opentitan repository directory structure. |
Srikrishna Iyer | d04b08e | 2019-10-09 00:09:34 -0700 | [diff] [blame] | 6 | The hierarchy underneath the root is fairly self explanatory, containing the following: |
| 7 | * `doc`: High level documentatation, user guides and reference manuals |
| 8 | * `util`: Helper scripts and generator tools |
| 9 | * `hw`: Design and DV sources |
| 10 | * `sw`: All software sources used in the project |
| 11 | |
| 12 | We will focus on the directory structure underneath `hw` and `sw` below. |
| 13 | |
| 14 | ## Directory structure underneath `hw` |
| 15 | ``` |
| 16 | hw |
| 17 | ├──dv => Common / shared resources for SV/UVM as well as |
| 18 | │ Verilator based testbenches |
| 19 | │ |
| 20 | ├──formal => Scripts to build and run formal property verification |
| 21 | │ (FPV) for all applicable IPs to ensure protocol |
| 22 | │ compliance |
| 23 | │ |
| 24 | ├──ip => Standalone or generic / parameterized implementations |
| 25 | │ of comportable IPs designed towards building SoCs |
| 26 | │ |
| 27 | ├──lint => Scripts to run the `lint` tool on all RTL sources |
| 28 | │ |
| 29 | ├──top_earlgrey => An implementation of OpenTitan SoC built using above |
| 30 | │ IPs as well as third-party 'vendored' IPs |
| 31 | │ |
| 32 | ├──vendor => Vendored-in open source IPs from external repositories |
| 33 | ``` |
| 34 | |
| 35 | ### `hw/ip` |
| 36 | ``` |
| 37 | ip |
| 38 | ├──uart => UART IP root dir |
| 39 | │ │ |
| 40 | │ ├──data => Configuration data sources for design, DV and project |
| 41 | │ │ status tracking |
| 42 | │ │ |
| 43 | │ ├──doc => All documentation sources including design specification |
Rasmus Madsen | c0b7bd1 | 2020-12-09 17:58:10 +0100 | [diff] [blame] | 44 | │ │ and DV document |
Srikrishna Iyer | d04b08e | 2019-10-09 00:09:34 -0700 | [diff] [blame] | 45 | │ │ |
| 46 | │ ├──dv => SV/UVM testbench sources |
| 47 | │ │ |
| 48 | │ ├──fpv => Testbench sources used in FPV (if applicable) |
| 49 | │ │ |
| 50 | │ ├──model => Reference 'model' implementation in C (if applicable) |
| 51 | │ │ |
| 52 | │ ├──rtl => RTL design sources |
| 53 | │ │ |
| 54 | │ ├──util => IP-specfic automation scripts (if applicable) |
| 55 | │ │ |
| 56 | │ ├──... => Additional sub-directories could exist for specific IPs |
| 57 | │ based on need |
| 58 | │ |
| 59 | ├──... => More such Comportable IPs... |
| 60 | ``` |
| 61 | |
| 62 | ### `hw/top_earlgrey` |
| 63 | ``` |
| 64 | top_earlgrey => Chip root dir |
| 65 | │ |
| 66 | ├──data => Configuration data sources for design, DV and |
| 67 | │ project status tracking |
| 68 | │ |
| 69 | ├──doc => All documentation sources including chip |
Rasmus Madsen | c0b7bd1 | 2020-12-09 17:58:10 +0100 | [diff] [blame] | 70 | │ specification and DV document |
Srikrishna Iyer | d04b08e | 2019-10-09 00:09:34 -0700 | [diff] [blame] | 71 | │ |
| 72 | ├──dv => Chip level SV/UVM testbench sources |
| 73 | │ └──autogen => auto-generated chip DV sources |
| 74 | │ |
| 75 | ├──ip => IPs tailor-made for top_earlgrey |
| 76 | │ │ |
| 77 | │ ├──xbar => XBAR implementation for top_earlgrey |
| 78 | │ │ ├──dv => DV sources |
| 79 | │ │ │ └──autogen => auto-generated XBAR DV sources |
| 80 | │ │ └──rtl => RTL sources |
| 81 | │ │ └──autogen => Auto-generated XBAR RTL sources |
| 82 | │ │ |
| 83 | │ ├──... => More such IPs tailored for top_earlgrey... |
| 84 | │ |
| 85 | ├──rtl => Chip level RTL sources |
| 86 | │ └──autogen => auto-generated chip RTL sources |
| 87 | │ |
| 88 | ├──sw => Auto-generated chip-specific headers for SW |
| 89 | │ |
| 90 | └──util => Chip-specfic automation scripts |
| 91 | ``` |
| 92 | |
| 93 | ### Auto-generated sources: checked-in |
| 94 | In cases where we rely on automatic generation of RTL, DV, or software sources we currently check those files in to the repository. |
| 95 | This is primarily motivated by a desire to make it easy for engineers to rapidly test spot-fixes. |
| 96 | This is a decision that might be revisited in the future. |
| 97 | |
| 98 | #### Mitigating issues |
| 99 | Auto-generated sources can get out-of-sync if the underlying tools or templates are updated. |
| 100 | Also, users may accidently make modifications to those files by hand, which will cease to exist the next time the tools are run. |
| 101 | We employ the following methods to mitigate these risks: |
| 102 | * Add a CI check when a pull request is made to merge new changes to ensure that the checked-in file and the generator output are enquivalent and not out-of-sync |
| 103 | * Put auto-generated sources under a dedicated `autogen/` directory |
| 104 | * Add a warning message banner as a comment clearly indicating that the file has been auto-generated with the complete command |
| 105 | |
| 106 | ## Directory structure underneath `sw` |
| 107 | ``` |
| 108 | sw |
| 109 | ├──device => Sources compiled for the OpenTitan chip, |
| 110 | │ │ including tests run on FPGA and simulations |
| 111 | │ │ |
| 112 | │ ├──boot_rom => Sources for generating the primary boot image |
| 113 | │ │ loaded into ROM |
| 114 | │ │ |
| 115 | │ ├──benchmarks => Standard benchmarks and instructions for running |
| 116 | │ │ └──coremark them |
| 117 | │ │ |
| 118 | │ ├──doc => Documentation sources |
| 119 | │ │ |
| 120 | │ ├──examples => Example programs to demonstrate basic |
| 121 | │ │ ├──hello_world functionality |
| 122 | │ │ ├──... |
| 123 | │ │ |
| 124 | │ ├──exts => Sources that are specific to the intended target |
| 125 | │ │ │ (FPGA, Verilator, DV, firmware) |
| 126 | │ │ └──common => Common sources for all SW tests including the CRT |
| 127 | │ │ source and the linker script |
| 128 | │ │ |
| 129 | │ ├──lib => SW library of device interface functions (DIFs) |
| 130 | │ │ that provide APIs for controlling the hardware |
| 131 | │ │ |
| 132 | │ └──tests => SW tests implemented on FPGA/Verilator/DV targets |
| 133 | │ ├──flash_ctrl |
| 134 | │ ├──... |
| 135 | │ |
| 136 | ├──host => Sources compiled for the host communicating with |
| 137 | │ our OpenTitan chip |
| 138 | │ |
| 139 | └──vendor => Vendored-in open source software sources from |
| 140 | │ external repositories |
| 141 | └── cryptoc |
| 142 | ``` |