├── .devcontainer ├── Dockerfile ├── copy_tt_support_tools.sh └── devcontainer.json ├── .github └── workflows │ ├── docs.yaml │ ├── fpga.yaml │ ├── gds.yaml │ └── test.yaml ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── LICENSE ├── README.md ├── docs └── info.md ├── info.yaml ├── src ├── config.json └── project.v └── test ├── Makefile ├── README.md ├── requirements.txt ├── tb.gtkw ├── tb.v └── test.py /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG VARIANT=ubuntu-22.04 2 | FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT} 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | ENV PDK_ROOT=/home/vscode/ttsetup/pdk 6 | ENV PDK=sky130A 7 | 8 | RUN apt update 9 | RUN apt install -y iverilog gtkwave python3 python3-pip python3-venv python3-tk python-is-python3 libcairo2 verilator libpng-dev libqhull-dev 10 | 11 | # Clone tt-support-tools 12 | RUN mkdir -p /ttsetup 13 | RUN git clone -b tt09 https://github.com/TinyTapeout/tt-support-tools /ttsetup/tt-support-tools 14 | 15 | COPY test/requirements.txt /ttsetup/test_requirements.txt 16 | COPY .devcontainer/copy_tt_support_tools.sh /ttsetup 17 | 18 | RUN pip3 install -r /ttsetup/test_requirements.txt -r /ttsetup/tt-support-tools/requirements.txt 19 | 20 | # Install verible (for formatting) 21 | RUN umask 022 && \ 22 | curl -L https://github.com/chipsalliance/verible/releases/download/v0.0-3795-gf4d72375/verible-v0.0-3795-gf4d72375-linux-static-x86_64.tar.gz | \ 23 | tar zxf - -C /usr/local --strip-components=1 && \ 24 | chmod 755 /usr/local/bin 25 | 26 | # Install openlane 27 | RUN pip3 install openlane==2.1.5 28 | -------------------------------------------------------------------------------- /.devcontainer/copy_tt_support_tools.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if [ ! -L tt ]; then 4 | cp -R /ttsetup/tt-support-tools tt 5 | cd tt && git pull && cd .. 6 | fi 7 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/ubuntu 3 | { 4 | "name": "Tiny Tapeout Dev Container", 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | "context": ".." 8 | }, 9 | "runArgs": [ 10 | "--memory=10GB" 11 | ], 12 | "customizations": { 13 | "vscode": { 14 | "settings": { 15 | "terminal.integrated.defaultProfile.linux": "bash" 16 | }, 17 | "extensions": ["mshr-h.veriloghdl", "surfer-project.surfer"] 18 | } 19 | }, 20 | "features": { 21 | "ghcr.io/devcontainers/features/docker-in-docker:2": { 22 | "moby": true, 23 | "azureDnsAutoDetection": true, 24 | "version": "latest", 25 | "dockerDashComposeVersion": "none" 26 | } 27 | }, 28 | "postStartCommand": "/ttsetup/copy_tt_support_tools.sh" 29 | } 30 | -------------------------------------------------------------------------------- /.github/workflows/docs.yaml: -------------------------------------------------------------------------------- 1 | name: docs 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | docs: 9 | runs-on: ubuntu-24.04 10 | steps: 11 | - name: Checkout repo 12 | uses: actions/checkout@v4 13 | with: 14 | submodules: recursive 15 | 16 | - name: Build docs 17 | uses: TinyTapeout/tt-gds-action/docs@tt09 18 | -------------------------------------------------------------------------------- /.github/workflows/fpga.yaml: -------------------------------------------------------------------------------- 1 | name: fpga 2 | 3 | on: 4 | push: 5 | # Comment out (or remove) the following line to run the FPGA workflow on every push: 6 | branches: none 7 | workflow_dispatch: 8 | 9 | jobs: 10 | fpga: 11 | runs-on: ubuntu-24.04 12 | steps: 13 | - name: checkout repo 14 | uses: actions/checkout@v4 15 | with: 16 | submodules: recursive 17 | 18 | - name: FPGA bitstream for TT ASIC Sim (ICE40UP5K) 19 | uses: TinyTapeout/tt-gds-action/fpga/ice40up5k@tt09 20 | -------------------------------------------------------------------------------- /.github/workflows/gds.yaml: -------------------------------------------------------------------------------- 1 | name: gds 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | gds: 9 | runs-on: ubuntu-24.04 10 | steps: 11 | - name: checkout repo 12 | uses: actions/checkout@v4 13 | with: 14 | submodules: recursive 15 | 16 | - name: Build GDS 17 | uses: TinyTapeout/tt-gds-action@tt09 18 | with: 19 | flow: openlane2 20 | 21 | precheck: 22 | needs: gds 23 | runs-on: ubuntu-24.04 24 | steps: 25 | - name: Run Tiny Tapeout Precheck 26 | uses: TinyTapeout/tt-gds-action/precheck@tt09 27 | 28 | gl_test: 29 | needs: gds 30 | runs-on: ubuntu-24.04 31 | steps: 32 | - name: checkout repo 33 | uses: actions/checkout@v4 34 | with: 35 | submodules: recursive 36 | 37 | - name: GL test 38 | uses: TinyTapeout/tt-gds-action/gl_test@tt09 39 | 40 | viewer: 41 | needs: gds 42 | runs-on: ubuntu-24.04 43 | permissions: 44 | pages: write # to deploy to Pages 45 | id-token: write # to verify the deployment originates from an appropriate source 46 | steps: 47 | - uses: TinyTapeout/tt-gds-action/viewer@tt09 48 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: test 2 | on: [push, workflow_dispatch] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-24.04 6 | steps: 7 | - name: Checkout repo 8 | uses: actions/checkout@v4 9 | with: 10 | submodules: recursive 11 | 12 | - name: Install iverilog 13 | shell: bash 14 | run: sudo apt-get update && sudo apt-get install -y iverilog 15 | 16 | # Set Python up and install cocotb 17 | - name: Setup python 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: '3.11' 21 | 22 | - name: Install Python packages 23 | shell: bash 24 | run: pip install -r test/requirements.txt 25 | 26 | - name: Run tests 27 | run: | 28 | cd test 29 | make clean 30 | make 31 | # make will return success even if the test fails, so check for failure in the results.xml 32 | ! grep failure results.xml 33 | 34 | - name: Test Summary 35 | uses: test-summary/action@v2.3 36 | with: 37 | paths: "test/results.xml" 38 | if: always() 39 | 40 | - name: upload vcd 41 | if: success() || failure() 42 | uses: actions/upload-artifact@v4 43 | with: 44 | name: test-vcd 45 | path: | 46 | test/tb.vcd 47 | test/results.xml 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | *.vcd 4 | runs 5 | tt_submission 6 | src/user_config.json 7 | src/config_merged.json 8 | test/sim_build 9 | test/__pycache__/ 10 | test/results.xml 11 | test/gate_level_netlist.v 12 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "mshr-h.veriloghdl", 4 | "surfer-project.surfer" 5 | ] 6 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "verilog.linting.linter": "verilator", 3 | "verilog.formatting.verilogHDL.formatter": "verible-verilog-format" 4 | } 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](../../workflows/gds/badge.svg) ![](../../workflows/docs/badge.svg) ![](../../workflows/test/badge.svg) ![](../../workflows/fpga/badge.svg) 2 | 3 | # ⚠️ This template is old and outdated ⚠️ 4 | 5 | Please use **[tt10-verilog-template](https://github.com/TinyTapeout/tt10-verilog-template)** for new projects. 6 | 7 | # Tiny Tapeout Verilog Project Template 8 | 9 | - [Read the documentation for project](docs/info.md) 10 | 11 | ## What is Tiny Tapeout? 12 | 13 | Tiny Tapeout is an educational project that aims to make it easier and cheaper than ever to get your digital and analog designs manufactured on a real chip. 14 | 15 | To learn more and get started, visit https://tinytapeout.com. 16 | 17 | ## Set up your Verilog project 18 | 19 | 1. Add your Verilog files to the `src` folder. 20 | 2. Edit the [info.yaml](info.yaml) and update information about your project, paying special attention to the `source_files` and `top_module` properties. If you are upgrading an existing Tiny Tapeout project, check out our [online info.yaml migration tool](https://tinytapeout.github.io/tt-yaml-upgrade-tool/). 21 | 3. Edit [docs/info.md](docs/info.md) and add a description of your project. 22 | 4. Adapt the testbench to your design. See [test/README.md](test/README.md) for more information. 23 | 24 | The GitHub action will automatically build the ASIC files using [OpenLane](https://www.zerotoasiccourse.com/terminology/openlane/). 25 | 26 | ## Enable GitHub actions to build the results page 27 | 28 | - [Enabling GitHub Pages](https://tinytapeout.com/faq/#my-github-action-is-failing-on-the-pages-part) 29 | 30 | ## Resources 31 | 32 | - [FAQ](https://tinytapeout.com/faq/) 33 | - [Digital design lessons](https://tinytapeout.com/digital_design/) 34 | - [Learn how semiconductors work](https://tinytapeout.com/siliwiz/) 35 | - [Join the community](https://tinytapeout.com/discord) 36 | - [Build your design locally](https://www.tinytapeout.com/guides/local-hardening/) 37 | 38 | ## What next? 39 | 40 | - [Submit your design to the next shuttle](https://app.tinytapeout.com/). 41 | - Edit [this README](README.md) and explain your design, how it works, and how to test it. 42 | - Share your project on your social network of choice: 43 | - LinkedIn [#tinytapeout](https://www.linkedin.com/search/results/content/?keywords=%23tinytapeout) [@TinyTapeout](https://www.linkedin.com/company/100708654/) 44 | - Mastodon [#tinytapeout](https://chaos.social/tags/tinytapeout) [@matthewvenn](https://chaos.social/@matthewvenn) 45 | - X (formerly Twitter) [#tinytapeout](https://twitter.com/hashtag/tinytapeout) [@tinytapeout](https://twitter.com/tinytapeout) 46 | -------------------------------------------------------------------------------- /docs/info.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | ## How it works 11 | 12 | Explain how your project works 13 | 14 | ## How to test 15 | 16 | Explain how to use your project 17 | 18 | ## External hardware 19 | 20 | List external hardware used in your project (e.g. PMOD, LED display, etc), if any 21 | -------------------------------------------------------------------------------- /info.yaml: -------------------------------------------------------------------------------- 1 | # Tiny Tapeout project information 2 | project: 3 | title: "" # Project title 4 | author: "" # Your name 5 | discord: "" # Your discord username, for communication and automatically assigning you a Tapeout role (optional) 6 | description: "" # One line description of what your project does 7 | language: "Verilog" # other examples include SystemVerilog, Amaranth, VHDL, etc 8 | clock_hz: 0 # Clock frequency in Hz (or 0 if not applicable) 9 | 10 | # How many tiles your design occupies? A single tile is about 167x108 uM. 11 | tiles: "1x1" # Valid values: 1x1, 1x2, 2x2, 3x2, 4x2, 6x2 or 8x2 12 | 13 | # Your top module name must start with "tt_um_". Make it unique by including your github username: 14 | top_module: "tt_um_example" 15 | 16 | # List your project's source files here. 17 | # Source files must be in ./src and you must list each source file separately, one per line. 18 | # Don't forget to also update `PROJECT_SOURCES` in test/Makefile. 19 | source_files: 20 | - "project.v" 21 | 22 | # The pinout of your project. Leave unused pins blank. DO NOT delete or add any pins. 23 | pinout: 24 | # Inputs 25 | ui[0]: "" 26 | ui[1]: "" 27 | ui[2]: "" 28 | ui[3]: "" 29 | ui[4]: "" 30 | ui[5]: "" 31 | ui[6]: "" 32 | ui[7]: "" 33 | 34 | # Outputs 35 | uo[0]: "" 36 | uo[1]: "" 37 | uo[2]: "" 38 | uo[3]: "" 39 | uo[4]: "" 40 | uo[5]: "" 41 | uo[6]: "" 42 | uo[7]: "" 43 | 44 | # Bidirectional pins 45 | uio[0]: "" 46 | uio[1]: "" 47 | uio[2]: "" 48 | uio[3]: "" 49 | uio[4]: "" 50 | uio[5]: "" 51 | uio[6]: "" 52 | uio[7]: "" 53 | 54 | # Do not change! 55 | yaml_version: 6 56 | -------------------------------------------------------------------------------- /src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "//": "DO NOT EDIT THIS FILE before reading the comments below:", 3 | 4 | "//": "This is the default configuration for Tiny Tapeout projects. It should fit most designs.", 5 | "//": "If you change it, please make sure you understand what you are doing. We are not responsible", 6 | "//": "if your project fails because of a bad configuration.", 7 | 8 | "//": "!!! DO NOT EDIT THIS FILE unless you know what you are doing !!!", 9 | 10 | "//": "If you get stuck with this config, please open an issue or get in touch via the discord.", 11 | 12 | "//": "Here are some of the variables you may want to change:", 13 | 14 | "//": "PL_TARGET_DENSITY_PCT - You can increase this if Global Placement fails with error GPL-0302.", 15 | "//": "Users have reported that values up to 80 worked well for them.", 16 | "PL_TARGET_DENSITY_PCT": 60, 17 | 18 | "//": "CLOCK_PERIOD - Increase this in case you are getting setup time violations.", 19 | "//": "The value is in nanoseconds, so 20ns == 50MHz.", 20 | "CLOCK_PERIOD": 20, 21 | 22 | "//": "Hold slack margin - Increase them in case you are getting hold violations.", 23 | "PL_RESIZER_HOLD_SLACK_MARGIN": 0.1, 24 | "GRT_RESIZER_HOLD_SLACK_MARGIN": 0.05, 25 | 26 | "//": "RUN_LINTER, LINTER_INCLUDE_PDK_MODELS - Disabling the linter is not recommended!", 27 | "RUN_LINTER": 1, 28 | "LINTER_INCLUDE_PDK_MODELS": 1, 29 | 30 | "//": "If you need a custom clock configuration, read the following documentation first:", 31 | "//": "https://tinytapeout.com/faq/#how-can-i-map-an-additional-external-clock-to-one-of-the-gpios", 32 | "CLOCK_PORT": "clk", 33 | 34 | "//": "Configuration docs: https://openlane.readthedocs.io/en/latest/reference/configuration.html", 35 | 36 | "//": "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 37 | "//": "!!! DO NOT CHANGE ANYTHING BELOW THIS POINT !!!", 38 | "//": "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 39 | 40 | "//": "Save some time", 41 | "RUN_KLAYOUT_XOR": 0, 42 | "RUN_KLAYOUT_DRC": 0, 43 | 44 | "//": "Don't put clock buffers on the outputs", 45 | "DESIGN_REPAIR_BUFFER_OUTPUT_PORTS": 0, 46 | 47 | "//": "Reduce wasted space", 48 | "TOP_MARGIN_MULT": 1, 49 | "BOTTOM_MARGIN_MULT": 1, 50 | "LEFT_MARGIN_MULT": 6, 51 | "RIGHT_MARGIN_MULT": 6, 52 | 53 | "//": "Absolute die size", 54 | "FP_SIZING": "absolute", 55 | 56 | "GRT_ALLOW_CONGESTION": 1, 57 | 58 | "FP_IO_HLENGTH": 2, 59 | "FP_IO_VLENGTH": 2, 60 | 61 | "FP_PDN_VPITCH": 38.87, 62 | 63 | "//": "Clock", 64 | "RUN_CTS": 1, 65 | 66 | "//": "Don't use power rings or met5 layer", 67 | "FP_PDN_MULTILAYER": 0, 68 | "RT_MAX_LAYER": "met4", 69 | 70 | "//": "MAGIC_DEF_LABELS may cause issues with LVS", 71 | "MAGIC_DEF_LABELS": 0, 72 | 73 | "//": "Only export pin area in LEF (without any connected nets)", 74 | "MAGIC_WRITE_LEF_PINONLY": 1 75 | } 76 | -------------------------------------------------------------------------------- /src/project.v: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Your Name 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | `default_nettype none 7 | 8 | module tt_um_example ( 9 | input wire [7:0] ui_in, // Dedicated inputs 10 | output wire [7:0] uo_out, // Dedicated outputs 11 | input wire [7:0] uio_in, // IOs: Input path 12 | output wire [7:0] uio_out, // IOs: Output path 13 | output wire [7:0] uio_oe, // IOs: Enable path (active high: 0=input, 1=output) 14 | input wire ena, // always 1 when the design is powered, so you can ignore it 15 | input wire clk, // clock 16 | input wire rst_n // reset_n - low to reset 17 | ); 18 | 19 | // All output pins must be assigned. If not used, assign to 0. 20 | assign uo_out = ui_in + uio_in; // Example: ou_out is the sum of ui_in and uio_in 21 | assign uio_out = 0; 22 | assign uio_oe = 0; 23 | 24 | // List all unused inputs to prevent warnings 25 | wire _unused = &{ena, clk, rst_n, 1'b0}; 26 | 27 | endmodule 28 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # See https://docs.cocotb.org/en/stable/quickstart.html for more info 3 | 4 | # defaults 5 | SIM ?= icarus 6 | TOPLEVEL_LANG ?= verilog 7 | SRC_DIR = $(PWD)/../src 8 | PROJECT_SOURCES = project.v 9 | 10 | ifneq ($(GATES),yes) 11 | 12 | # RTL simulation: 13 | SIM_BUILD = sim_build/rtl 14 | VERILOG_SOURCES += $(addprefix $(SRC_DIR)/,$(PROJECT_SOURCES)) 15 | COMPILE_ARGS += -I$(SRC_DIR) 16 | 17 | else 18 | 19 | # Gate level simulation: 20 | SIM_BUILD = sim_build/gl 21 | COMPILE_ARGS += -DGL_TEST 22 | COMPILE_ARGS += -DFUNCTIONAL 23 | COMPILE_ARGS += -DUSE_POWER_PINS 24 | COMPILE_ARGS += -DSIM 25 | COMPILE_ARGS += -DUNIT_DELAY=\#1 26 | VERILOG_SOURCES += $(PDK_ROOT)/sky130A/libs.ref/sky130_fd_sc_hd/verilog/primitives.v 27 | VERILOG_SOURCES += $(PDK_ROOT)/sky130A/libs.ref/sky130_fd_sc_hd/verilog/sky130_fd_sc_hd.v 28 | 29 | # this gets copied in by the GDS action workflow 30 | VERILOG_SOURCES += $(PWD)/gate_level_netlist.v 31 | 32 | endif 33 | 34 | # Include the testbench sources: 35 | VERILOG_SOURCES += $(PWD)/tb.v 36 | TOPLEVEL = tb 37 | 38 | # MODULE is the basename of the Python test file 39 | MODULE = test 40 | 41 | # include cocotb's make rules to take care of the simulator setup 42 | include $(shell cocotb-config --makefiles)/Makefile.sim 43 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | # Sample testbench for a Tiny Tapeout project 2 | 3 | This is a sample testbench for a Tiny Tapeout project. It uses [cocotb](https://docs.cocotb.org/en/stable/) to drive the DUT and check the outputs. 4 | See below to get started or for more information, check the [website](https://tinytapeout.com/hdl/testing/). 5 | 6 | ## Setting up 7 | 8 | 1. Edit [Makefile](Makefile) and modify `PROJECT_SOURCES` to point to your Verilog files. 9 | 2. Edit [tb.v](tb.v) and replace `tt_um_example` with your module name. 10 | 11 | ## How to run 12 | 13 | To run the RTL simulation: 14 | 15 | ```sh 16 | make -B 17 | ``` 18 | 19 | To run gatelevel simulation, first harden your project and copy `../runs/wokwi/results/final/verilog/gl/{your_module_name}.v` to `gate_level_netlist.v`. 20 | 21 | Then run: 22 | 23 | ```sh 24 | make -B GATES=yes 25 | ``` 26 | 27 | ## How to view the VCD file 28 | 29 | Using GTKWave 30 | ```sh 31 | gtkwave tb.vcd tb.gtkw 32 | ``` 33 | 34 | Using Surfer 35 | ```sh 36 | surfer tb.vcd 37 | ``` 38 | -------------------------------------------------------------------------------- /test/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest==8.2.2 2 | cocotb==1.9.1 3 | -------------------------------------------------------------------------------- /test/tb.gtkw: -------------------------------------------------------------------------------- 1 | [*] 2 | [*] GTKWave Analyzer v3.4.0 (w)1999-2022 BSI 3 | [*] Mon Nov 20 16:00:28 2023 4 | [*] 5 | [dumpfile] "/home/uri/p/tt-new-template-proto/test/tb.vcd" 6 | [dumpfile_mtime] "Mon Nov 20 15:58:34 2023" 7 | [dumpfile_size] 1110 8 | [savefile] "/home/uri/p/tt-new-template-proto/test/tb.gtkw" 9 | [timestart] 0 10 | [size] 1376 600 11 | [pos] -1 -1 12 | *-24.534533 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 | [treeopen] tb. 14 | [sst_width] 297 15 | [signals_width] 230 16 | [sst_expanded] 1 17 | [sst_vpaned_height] 158 18 | @28 19 | tb.user_project.ena 20 | @29 21 | tb.user_project.clk 22 | @28 23 | tb.user_project.rst_n 24 | @200 25 | -Inputs 26 | @22 27 | tb.user_project.ui_in[7:0] 28 | @200 29 | -Bidirectional Pins 30 | @22 31 | tb.user_project.uio_in[7:0] 32 | tb.user_project.uio_oe[7:0] 33 | tb.user_project.uio_out[7:0] 34 | @200 35 | -Output Pins 36 | @22 37 | tb.user_project.uo_out[7:0] 38 | [pattern_trace] 1 39 | [pattern_trace] 0 40 | -------------------------------------------------------------------------------- /test/tb.v: -------------------------------------------------------------------------------- 1 | `default_nettype none 2 | `timescale 1ns / 1ps 3 | 4 | /* This testbench just instantiates the module and makes some convenient wires 5 | that can be driven / tested by the cocotb test.py. 6 | */ 7 | module tb (); 8 | 9 | // Dump the signals to a VCD file. You can view it with gtkwave or surfer. 10 | initial begin 11 | $dumpfile("tb.vcd"); 12 | $dumpvars(0, tb); 13 | #1; 14 | end 15 | 16 | // Wire up the inputs and outputs: 17 | reg clk; 18 | reg rst_n; 19 | reg ena; 20 | reg [7:0] ui_in; 21 | reg [7:0] uio_in; 22 | wire [7:0] uo_out; 23 | wire [7:0] uio_out; 24 | wire [7:0] uio_oe; 25 | `ifdef GL_TEST 26 | wire VPWR = 1'b1; 27 | wire VGND = 1'b0; 28 | `endif 29 | 30 | // Replace tt_um_example with your module name: 31 | tt_um_example user_project ( 32 | 33 | // Include power ports for the Gate Level test: 34 | `ifdef GL_TEST 35 | .VPWR(VPWR), 36 | .VGND(VGND), 37 | `endif 38 | 39 | .ui_in (ui_in), // Dedicated inputs 40 | .uo_out (uo_out), // Dedicated outputs 41 | .uio_in (uio_in), // IOs: Input path 42 | .uio_out(uio_out), // IOs: Output path 43 | .uio_oe (uio_oe), // IOs: Enable path (active high: 0=input, 1=output) 44 | .ena (ena), // enable - goes high when design is selected 45 | .clk (clk), // clock 46 | .rst_n (rst_n) // not reset 47 | ); 48 | 49 | endmodule 50 | -------------------------------------------------------------------------------- /test/test.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2024 Tiny Tapeout 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import cocotb 5 | from cocotb.clock import Clock 6 | from cocotb.triggers import ClockCycles 7 | 8 | 9 | @cocotb.test() 10 | async def test_project(dut): 11 | dut._log.info("Start") 12 | 13 | # Set the clock period to 10 us (100 KHz) 14 | clock = Clock(dut.clk, 10, units="us") 15 | cocotb.start_soon(clock.start()) 16 | 17 | # Reset 18 | dut._log.info("Reset") 19 | dut.ena.value = 1 20 | dut.ui_in.value = 0 21 | dut.uio_in.value = 0 22 | dut.rst_n.value = 0 23 | await ClockCycles(dut.clk, 10) 24 | dut.rst_n.value = 1 25 | 26 | dut._log.info("Test project behavior") 27 | 28 | # Set the input values you want to test 29 | dut.ui_in.value = 20 30 | dut.uio_in.value = 30 31 | 32 | # Wait for one clock cycle to see the output values 33 | await ClockCycles(dut.clk, 1) 34 | 35 | # The following assersion is just an example of how to check the output values. 36 | # Change it to match the actual expected output of your module: 37 | assert dut.uo_out.value == 50 38 | 39 | # Keep testing the module by changing the input values, waiting for 40 | # one or more clock cycles, and asserting the expected output values. 41 | --------------------------------------------------------------------------------