Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 1 | .. raw:: html |
| 2 | |
| 3 | <!--- |
| 4 | # SPDX-FileCopyrightText: 2020 Efabless Corporation |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | --> |
| 20 | |
| 21 | Caravel User Project |
| 22 | ==================== |
| 23 | |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 24 | |License| |User CI| |Caravel Build| |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 25 | |
| 26 | Table of contents |
| 27 | ================= |
| 28 | |
| 29 | - `Overview <#overview>`__ |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 30 | - `Install Caravel <#install-caravel>`__ |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 31 | - `Caravel Integration <#caravel-integration>`__ |
| 32 | |
| 33 | - `Repo Integration <#repo-integration>`__ |
| 34 | - `Verilog Integration <#verilog-integration>`__ |
| 35 | |
| 36 | - `Running Full Chip Simulation <#running-full-chip-simulation>`__ |
| 37 | - `Hardening the User Project Macro using |
| 38 | Openlane <#hardening-the-user-project-macro-using-openlane>`__ |
| 39 | - `Checklist for Open-MPW |
| 40 | Submission <#checklist-for-open-mpw-submission>`__ |
| 41 | |
| 42 | Overview |
| 43 | ======== |
| 44 | |
| 45 | This repo contains a sample user project that utilizes the |
| 46 | `caravel <https://github.com/efabless/caravel.git>`__ chip user space. |
| 47 | The user project is a simple counter that showcases how to make use of |
| 48 | `caravel's <https://github.com/efabless/caravel.git>`__ user space |
| 49 | utilities like IO pads, logic analyzer probes, and wishbone port. The |
| 50 | repo also demonstrates the recommended structure for the open-mpw |
| 51 | shuttle projects. |
| 52 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 53 | Prerequisites |
| 54 | ============= |
| 55 | |
| 56 | - Docker |
| 57 | |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 58 | Install Caravel |
| 59 | =============== |
| 60 | |
| 61 | To setup caravel, run the following: |
| 62 | |
| 63 | .. code:: bash |
| 64 | |
matt venn | 77f3973 | 2021-05-04 13:31:13 +0200 | [diff] [blame] | 65 | # If unset, CARAVEL_ROOT will be set to $(pwd)/caravel |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 66 | # If you want to install caravel at a different location, run "export CARAVEL_ROOT=<caravel-path>" |
matt venn | 77f3973 | 2021-05-04 13:31:13 +0200 | [diff] [blame] | 67 | export CARAVEL_ROOT=$(pwd)/caravel |
| 68 | |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 69 | # Disable submodule installation if needed by, run "export SUBMODULE=0" |
Mohamed Kassem | 9ae1f07 | 2021-04-23 12:19:31 -0700 | [diff] [blame] | 70 | |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 71 | git clone https://github.com/efabless/caravel_user_project.git |
Mohamed Kassem | 9ae1f07 | 2021-04-23 12:19:31 -0700 | [diff] [blame] | 72 | cd caravel_user_project |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 73 | make install |
| 74 | |
| 75 | To update the installed caravel to the latest, run: |
| 76 | |
| 77 | .. code:: bash |
| 78 | |
| 79 | make update_caravel |
| 80 | |
| 81 | To remove caravel, run |
| 82 | |
| 83 | .. code:: bash |
| 84 | |
| 85 | make uninstall |
| 86 | |
| 87 | By default |
| 88 | `caravel-lite <https://github.com/efabless/caravel-lite.git>`__ is |
| 89 | installed. To install the full version of caravel, run this prior to |
| 90 | calling make install. |
| 91 | |
| 92 | .. code:: bash |
| 93 | |
| 94 | export CARAVEL_LITE=0 |
| 95 | |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 96 | Caravel Integration |
| 97 | =================== |
| 98 | |
| 99 | Repo Integration |
| 100 | ---------------- |
| 101 | |
| 102 | Caravel files are kept separate from the user project by having caravel |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 103 | as submodule. The submodule commit should point to the latest of |
| 104 | caravel/caravel-lite master. The following files should have a symbolic |
| 105 | link to `caravel's <https://github.com/efabless/caravel.git>`__ |
| 106 | corresponding files: |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 107 | |
| 108 | - `Openlane Makefile <openlane/Makefile>`__: This provides an easier |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 109 | way for running openlane to harden your macros. Refer to `Hardening |
| 110 | the User Project Macro using |
| 111 | Openlane <#hardening-the-user-project-macro-using-openlane>`__. Also, |
| 112 | the makefile retains the openlane summary reports under the signoff |
| 113 | directory. |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 114 | |
| 115 | - `Pin order <openlane/user_project_wrapper/pin_order.cfg>`__ file for |
| 116 | the user wrapper: The hardened user project wrapper macro must have |
| 117 | the same pin order specified in caravel's repo. Failing to adhere to |
| 118 | the same order will fail the gds integration of the macro with |
| 119 | caravel's back-end. |
| 120 | |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 121 | The symbolic links are automatically set when you run ``make install``. |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 122 | |
| 123 | Verilog Integration |
| 124 | ------------------- |
| 125 | |
| 126 | You need to create a wrapper around your macro that adheres to the |
| 127 | template at |
| 128 | `user\_project\_wrapper <caravel/verilog/rtl/__user_project_wrapper.v>`__. |
| 129 | The wrapper top module must be named ``user_project_wrapper`` and must |
| 130 | have the same input and output ports. The wrapper gives access to the |
| 131 | user space utilities provided by caravel like IO ports, logic analyzer |
| 132 | probes, and wishbone bus connection to the management SoC. |
| 133 | |
| 134 | For this sample project, the user macro makes use of: |
| 135 | |
| 136 | - The IO ports for displaying the count register values on the IO pads. |
| 137 | |
| 138 | - The LA probes for supplying an optional reset and clock signals and |
| 139 | for setting an initial value for the count register. |
| 140 | |
matt venn | 4acd8b7 | 2021-04-27 11:34:42 +0200 | [diff] [blame] | 141 | - The wishbone port for reading/writing the count value through the |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 142 | management SoC. |
| 143 | |
| 144 | Refer to `user\_project\_wrapper <verilog/rtl/user_project_wrapper.v>`__ |
| 145 | for more information. |
| 146 | |
| 147 | .. raw:: html |
| 148 | |
| 149 | <p align="center"> |
| 150 | <img src="./_static/counter_32.png" width="50%" height="50%"> |
| 151 | </p> |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 152 | |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 153 | .. raw:: html |
| 154 | |
| 155 | </p> |
| 156 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 157 | Building the PDK |
| 158 | ================ |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 159 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 160 | You have two options for building the pdk: |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 161 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 162 | - Build the pdk natively. |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 163 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 164 | Make sure you have `Magic VLSI Layout Tool <http://opencircuitdesign.com/magic/index.html>`__ installed on your machine before building the pdk. |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 165 | |
| 166 | .. code:: bash |
| 167 | |
| 168 | # set PDK_ROOT to the path you wish to use for the pdk |
| 169 | export PDK_ROOT=<pdk-installation-path> |
| 170 | |
| 171 | # you can optionally specify skywater-pdk and open-pdks commit used |
| 172 | # by setting and exporting SKYWATER_COMMIT and OPEN_PDKS_COMMIT |
| 173 | # if you do not set them, they default to the last verfied commits tested for this project |
| 174 | |
| 175 | make pdk |
| 176 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 177 | - Build the pdk using openlane's docker image which has magic installed. |
| 178 | |
| 179 | .. code:: bash |
| 180 | |
| 181 | # set PDK_ROOT to the path you wish to use for the pdk |
| 182 | export PDK_ROOT=<pdk-installation-path> |
| 183 | |
| 184 | # you can optionally specify skywater-pdk and open-pdks commit used |
| 185 | # by setting and exporting SKYWATER_COMMIT and OPEN_PDKS_COMMIT |
| 186 | # if you do not set them, they default to the last verfied commits tested for this project |
| 187 | |
| 188 | make pdk-nonnative |
| 189 | |
| 190 | Running Full Chip Simulation |
| 191 | ============================ |
| 192 | |
| 193 | First, you will need to install the simulation environment, by |
| 194 | |
| 195 | .. code:: bash |
| 196 | |
| 197 | make simenv |
| 198 | |
| 199 | This will pull a docker image with the needed tools installed. |
| 200 | |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 201 | Then, run the RTL and GL simulation by |
| 202 | |
| 203 | .. code:: bash |
| 204 | |
| 205 | export PDK_ROOT=<pdk-installation-path> |
| 206 | export CARAVEL_ROOT=$(pwd)/caravel |
| 207 | # specify simulation mode: RTL/GL |
| 208 | export SIM=RTL |
| 209 | # Run IO ports testbench, make verify-io_ports |
| 210 | make verify-<dv-pattern> |
| 211 | |
| 212 | The verilog test-benches are under this directory |
Manar | ffaf984 | 2021-04-30 22:55:37 +0200 | [diff] [blame] | 213 | `verilog/dv <https://github.com/efabless/caravel_user_project/tree/main/verilog/dv>`__. For more information on setting up the |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 214 | simulation environment and the available testbenches for this sample |
Manar | ffaf984 | 2021-04-30 22:55:37 +0200 | [diff] [blame] | 215 | project, refer to `README <https://github.com/efabless/caravel_user_project/blob/main/verilog/dv/README.md>`__. |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 216 | |
| 217 | Hardening the User Project Macro using Openlane |
| 218 | =============================================== |
| 219 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 220 | You will need to install openlane by running the following |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 221 | |
| 222 | .. code:: bash |
| 223 | |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 224 | export OPENLANE_ROOT=<openlane-installation-path> |
| 225 | export OPENLANE_TAG=<latest-openlane-tag> |
| 226 | make openlane |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 227 | |
| 228 | For detailed instructions on how to install openlane and the pdk refer |
| 229 | to |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 230 | `README <https://github.com/efabless/openlane/blob/master/README.md>`__. |
| 231 | |
| 232 | There are two options for hardening the user project macro using |
| 233 | openlane: |
| 234 | |
| 235 | 1. Hardening the user macro, then embedding it in the wrapper |
| 236 | 2. Flattening the user macro with the wrapper. |
| 237 | |
| 238 | For more details on this, refer to this |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 239 | `README <https://github.com/efabless/caravel/blob/master/openlane/README.rst>`__. |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 240 | |
| 241 | For this sample project, we went for the first option where the user |
| 242 | macro is hardened first, then it is inserted in the user project |
| 243 | wrapper. |
| 244 | |
| 245 | .. raw:: html |
| 246 | |
| 247 | <p align="center"> |
| 248 | <img src="./_static/wrapper.png" width="50%" height="50%"> |
| 249 | </p> |
| 250 | |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 251 | .. raw:: html |
| 252 | |
| 253 | </p> |
| 254 | |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 255 | To reproduce hardening this project, run the following: |
| 256 | |
| 257 | .. code:: bash |
| 258 | |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 259 | # Run openlane to harden user_proj_example |
| 260 | make user_proj_example |
| 261 | # Run openlane to harden user_project_wrapper |
| 262 | make user_project_wrapper |
| 263 | |
| 264 | |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 265 | Running Open-MPW Precheck Locally |
| 266 | ================================= |
| 267 | |
| 268 | You can install the precheck by running |
| 269 | |
| 270 | .. code:: bash |
| 271 | |
| 272 | # By default, this install the precheck in your home directory |
| 273 | # To change the installtion path, run "export PRECHECK_ROOT=<precheck installation path>" |
| 274 | make precheck |
| 275 | |
| 276 | This will clone the precheck repo and pull the latest precheck docker image. |
| 277 | |
| 278 | |
| 279 | Then, you can run the precheck by running |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 280 | Specify CARAVEL_ROOT before running any of the following, |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 281 | |
| 282 | .. code:: bash |
| 283 | |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 284 | # export CARAVEL_ROOT=$(pwd)/caravel |
| 285 | export CARAVEL_ROOT=<path-to-caravel> |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 286 | make run-precheck |
| 287 | |
| 288 | This will run all the precheck checks on your project and will produce the logs under the ``checks`` directory. |
| 289 | |
| 290 | |
| 291 | Other Miscellaneous Targets |
| 292 | ============================ |
| 293 | |
| 294 | The makefile provides a number of useful that targets that can run LVS, DRC, and XOR checks on your hardened design outside of openlane's flow. |
| 295 | |
| 296 | Run ```make help`` to display available targets. |
| 297 | |
| 298 | Specify CARAVEL_ROOT before running any of the following, |
| 299 | |
| 300 | .. code:: bash |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 301 | |
| 302 | # export CARAVEL_ROOT=$(pwd)/caravel |
manarabdelaty | 0218c0f | 2021-04-29 18:31:49 +0200 | [diff] [blame] | 303 | export CARAVEL_ROOT=<path-to-caravel> |
| 304 | |
| 305 | Run lvs on spice, |
| 306 | |
| 307 | .. code:: bash |
| 308 | |
| 309 | make lvs-<macro_name> |
| 310 | |
| 311 | Run lvs on the gds, |
| 312 | |
| 313 | .. code:: bash |
| 314 | |
| 315 | make lvs-gds-<macro_name> |
| 316 | |
| 317 | Run lvs on the maglef, |
| 318 | |
| 319 | .. code:: bash |
| 320 | |
| 321 | make lvs-maglef-<macro_name> |
| 322 | |
| 323 | Run drc using magic, |
| 324 | |
| 325 | .. code:: bash |
| 326 | |
| 327 | make drc-<macro_name> |
| 328 | |
| 329 | Run antenna check using magic, |
| 330 | |
| 331 | .. code:: bash |
| 332 | |
| 333 | make antenna-<macro_name> |
| 334 | |
| 335 | Run XOR check, |
| 336 | |
| 337 | .. code:: bash |
| 338 | |
| 339 | make xor-wrapper |
| 340 | |
Mohamed Kassem | 6f2fcd2 | 2021-04-19 10:14:19 -0700 | [diff] [blame] | 341 | |
| 342 | Checklist for Open-MPW Submission |
| 343 | ================================= |
| 344 | |
| 345 | - [x] The project repo adheres to the same directory structure in this |
| 346 | repo. |
| 347 | - [x] The project repo contain info.yaml at the project root. |
| 348 | - [x] Top level macro is named ``user_project_wrapper``. |
| 349 | - [x] Full Chip Simulation passes for RTL and GL (gate-level) |
| 350 | - [x] The hardened Macros are LVS and DRC clean |
| 351 | - [x] The hardened ``user_project_wrapper`` adheres to the same pin |
| 352 | order specified at |
| 353 | `pin\_order <https://github.com/efabless/caravel/blob/master/openlane/user_project_wrapper_empty/pin_order.cfg>`__ |
| 354 | - [x] XOR check passes with zero total difference. |
| 355 | - [x] Openlane summary reports are retained under ./signoff/ |
| 356 | |
| 357 | .. |License| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg |
| 358 | :target: https://opensource.org/licenses/Apache-2.0 |
manarabdelaty | d0e7afb | 2021-04-22 00:21:13 +0200 | [diff] [blame] | 359 | .. |User CI| image:: https://github.com/efabless/caravel_project_example/actions/workflows/user_project_ci.yml/badge.svg |
| 360 | :target: https://github.com/efabless/caravel_project_example/actions/workflows/user_project_ci.yml |
| 361 | .. |Caravel Build| image:: https://github.com/efabless/caravel_project_example/actions/workflows/caravel_build.yml/badge.svg |
Mohamed Kassem | 9ae1f07 | 2021-04-23 12:19:31 -0700 | [diff] [blame] | 362 | :target: https://github.com/efabless/caravel_project_example/actions/workflows/caravel_build.yml |