|
| 1 | +name: gds |
| 2 | +# either manually started, or on a schedule |
| 3 | +on: [ push, workflow_dispatch ] |
| 4 | +permissions: |
| 5 | + contents: write |
| 6 | + pages: write |
| 7 | + id-token: write |
| 8 | +jobs: |
| 9 | + gds: |
| 10 | + env: |
| 11 | + OPENLANE_TAG: 2022.07.02_01.38.08 |
| 12 | + OPENLANE_IMAGE_NAME: efabless/openlane:$(OPENLANE_TAG) |
| 13 | + OPENLANE_ROOT: /home/runner/openlane |
| 14 | + PDK_ROOT: /home/runner/pdk |
| 15 | + PDK: sky130B |
| 16 | + |
| 17 | + # ubuntu |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + # need the repo checked out |
| 21 | + - name: checkout repo |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + # build PDK and fetch OpenLane |
| 25 | + - name: pdk & caravel |
| 26 | + run: | |
| 27 | + cd $HOME |
| 28 | + git clone https://github.com/efabless/caravel_user_project.git -b mpw-7a |
| 29 | + cd caravel_user_project |
| 30 | + make setup |
| 31 | +
|
| 32 | + # need python |
| 33 | + - name: setup python |
| 34 | + uses: actions/setup-python@v2 |
| 35 | + with: |
| 36 | + python-version: '3.7.7' |
| 37 | + cache: 'pip' |
| 38 | + - run: pip install -r requirements.txt |
| 39 | + |
| 40 | + # fetch the Verilog from Wokwi API |
| 41 | + - name: fetch Verilog and build config |
| 42 | + run: ./setup.py --create-user-config |
| 43 | + |
| 44 | + # run the 'harden' rule in the Makefile to use OpenLane to build the GDS |
| 45 | + - name: make GDS |
| 46 | + run: make harden |
| 47 | + |
| 48 | + # for debugging, show all the files |
| 49 | + - name: show files |
| 50 | + run: find runs/wokwi/results |
| 51 | + |
| 52 | + - name: add summary |
| 53 | + run: | |
| 54 | + python << EOF >> $GITHUB_STEP_SUMMARY |
| 55 | + import csv |
| 56 | + with open('runs/wokwi/reports/final_summary_report.csv') as f: |
| 57 | + report = list(csv.DictReader(f))[0] |
| 58 | + keys = ['OpenDP_Util', 'cell_count', 'wire_length', 'AND', 'DFF', 'NAND', 'NOR', 'OR', 'XOR', 'XNOR', 'MUX'] |
| 59 | + print(f'| { "|".join(keys) } |') |
| 60 | + print(f'| { "|".join(["-----"] * len(keys)) } |') |
| 61 | + print(f'| { "|".join(report[k] for k in keys) } |') |
| 62 | + EOF |
| 63 | + |
| 64 | + - name: populate src cache |
| 65 | + uses: actions/cache@v2 |
| 66 | + with: |
| 67 | + path: src |
| 68 | + key: ${{ runner.os }}-src-${{ github.run_id }} |
| 69 | + |
| 70 | + - name: populate runs cache |
| 71 | + uses: actions/cache@v2 |
| 72 | + with: |
| 73 | + path: runs |
| 74 | + key: ${{ runner.os }}-runs-${{ github.run_id }} |
| 75 | + |
| 76 | + svg: |
| 77 | + needs: gds |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: checkout repo |
| 81 | + uses: actions/checkout@v2 |
| 82 | + |
| 83 | + - name: setup python |
| 84 | + uses: actions/setup-python@v4 |
| 85 | + with: |
| 86 | + python-version: '3.10' |
| 87 | + |
| 88 | + - name: restore runs cache |
| 89 | + uses: actions/cache@v2 |
| 90 | + with: |
| 91 | + path: runs |
| 92 | + key: ${{ runner.os }}-runs-${{ github.run_id }} |
| 93 | + |
| 94 | + - name: create svg |
| 95 | + run: | |
| 96 | + python -m pip install gdstk |
| 97 | + python << EOF |
| 98 | + import gdstk |
| 99 | + import pathlib |
| 100 | +
|
| 101 | + gds = sorted(pathlib.Path('runs').glob('wokwi/results/final/gds/*.gds')) |
| 102 | + library = gdstk.read_gds(gds[-1]) |
| 103 | + top_cells = library.top_level() |
| 104 | + top_cells[0].write_svg('gds_render.svg') |
| 105 | + EOF |
| 106 | +
|
| 107 | + - name: populate svg cache |
| 108 | + uses: actions/cache@v2 |
| 109 | + with: |
| 110 | + path: 'gds_render.svg' |
| 111 | + key: ${{ runner.os }}-svg-${{ github.run_id }} |
| 112 | + |
| 113 | + viewer: |
| 114 | + needs: gds |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - name: checkout GDS2glTF repo |
| 118 | + uses: actions/checkout@v2 |
| 119 | + with: |
| 120 | + repository: mbalestrini/GDS2glTF |
| 121 | + |
| 122 | + - name: checkout tinytapeout_gds_viewer repo |
| 123 | + uses: actions/checkout@v2 |
| 124 | + with: |
| 125 | + repository: mbalestrini/tinytapeout_gds_viewer |
| 126 | + path: viewer |
| 127 | + |
| 128 | + - name: setup python |
| 129 | + uses: actions/setup-python@v4 |
| 130 | + with: |
| 131 | + python-version: '3.10' |
| 132 | + |
| 133 | + - name: restore runs cache |
| 134 | + uses: actions/cache@v2 |
| 135 | + with: |
| 136 | + path: runs |
| 137 | + key: ${{ runner.os }}-runs-${{ github.run_id }} |
| 138 | + |
| 139 | + - name: gds2gltf |
| 140 | + run: | |
| 141 | + python -m pip install -r requirements.txt |
| 142 | + cp runs/wokwi/results/final/gds/*.gds tinytapeout.gds |
| 143 | + python3 gds2gltf.py tinytapeout.gds |
| 144 | + cp tinytapeout.gds.gltf viewer/ |
| 145 | +
|
| 146 | + - name: populate viewer cache |
| 147 | + uses: actions/cache@v2 |
| 148 | + with: |
| 149 | + path: viewer |
| 150 | + key: ${{ runner.os }}-viewer-${{ github.run_id }} |
| 151 | + |
| 152 | + artifact: |
| 153 | + needs: |
| 154 | + - gds |
| 155 | + runs-on: ubuntu-latest |
| 156 | + steps: |
| 157 | + - name: restore src cache |
| 158 | + uses: actions/cache@v2 |
| 159 | + with: |
| 160 | + path: src |
| 161 | + key: ${{ runner.os }}-src-${{ github.run_id }} |
| 162 | + |
| 163 | + - name: restore runs cache |
| 164 | + uses: actions/cache@v2 |
| 165 | + with: |
| 166 | + path: runs |
| 167 | + key: ${{ runner.os }}-runs-${{ github.run_id }} |
| 168 | + |
| 169 | + - name: upload artifact |
| 170 | + uses: actions/upload-artifact@v2 |
| 171 | + with: |
| 172 | + # path depends on the tag and the module name |
| 173 | + name: GDS |
| 174 | + path: | |
| 175 | + src/* |
| 176 | + runs/wokwi/results/final/* |
| 177 | + runs/wokwi/reports/final_summary_report.csv |
| 178 | +
|
| 179 | + pages: |
| 180 | + needs: |
| 181 | + - svg |
| 182 | + - viewer |
| 183 | + environment: |
| 184 | + name: github-pages |
| 185 | + url: ${{ steps.deployment.outputs.page_url }} |
| 186 | + outputs: |
| 187 | + page_url: ${{ steps.deployment.outputs.page_url }} |
| 188 | + runs-on: ubuntu-latest |
| 189 | + steps: |
| 190 | + - name: restore svg cache |
| 191 | + uses: actions/cache@v2 |
| 192 | + with: |
| 193 | + path: 'gds_render.svg' |
| 194 | + key: ${{ runner.os }}-svg-${{ github.run_id }} |
| 195 | + - name: restore viewer cache |
| 196 | + uses: actions/cache@v2 |
| 197 | + with: |
| 198 | + path: viewer |
| 199 | + key: ${{ runner.os }}-viewer-${{ github.run_id }} |
| 200 | + - name: Setup Pages |
| 201 | + uses: actions/configure-pages@v2 |
| 202 | + - name: Upload artifact |
| 203 | + uses: actions/upload-pages-artifact@v1 |
| 204 | + with: |
| 205 | + path: '.' |
| 206 | + - name: Deploy to GitHub Pages |
| 207 | + id: deployment |
| 208 | + uses: actions/deploy-pages@v1 |
| 209 | + |
| 210 | + preview: |
| 211 | + needs: pages |
| 212 | + runs-on: ubuntu-latest |
| 213 | + steps: |
| 214 | + - name: add gds preview |
| 215 | + run: | |
| 216 | + PAGE_URL=${{ needs.pages.outputs.page_url }} |
| 217 | + PAGE_URL=$(echo "$PAGE_URL" | sed -e 's/\/$//') |
| 218 | + cat << EOF >> $GITHUB_STEP_SUMMARY |
| 219 | + # layout |
| 220 | +  |
| 221 | + # viewer |
| 222 | + [open preview]($PAGE_URL/viewer/tinytapeout.html) |
| 223 | + EOF |
0 commit comments