ci: Create layout image with klayout
diff --git a/.github/workflows/user_project_ci.yml b/.github/workflows/user_project_ci.yml index feb6f2e..cd20cfd 100644 --- a/.github/workflows/user_project_ci.yml +++ b/.github/workflows/user_project_ci.yml
@@ -206,27 +206,15 @@ verilog/ openlane/tiny_user_project/runs/tiny_user_project/tmp/synthesis/post_techmap.dot key: ${{ runner.os }}-gds-${{ github.run_id }} - - name: create layout svg + - name: create layout png run: | - python -m pip install gdstk - python << EOF - import gdstk - library = gdstk.read_gds('gds/tiny_user_project.gds') - top_cells = library.top_level() - top_cells[0].write_svg('tiny_user_project_layout.svg') - EOF - - name: convert to png - run: | - python -m pip install cairosvg - python << EOF - import cairosvg - cairosvg.svg2png(url='tiny_user_project_layout.svg', write_to='tiny_user_project_layout.png') - EOF + klayout -l ${{ env.PDK_ROOT }}/${{ env.PDK }}/libs.tech/klayout/tech/gf180mcu.lyp gds/tiny_user_project.gds -z -r scripts/create_svg.py + - name: populate img cache uses: actions/cache@v3 with: path: | - tiny_user_project_layout.png + layout.png key: ${{ runner.os }}-img-${{ github.run_id }} pages: @@ -244,7 +232,7 @@ uses: actions/cache@v3 with: path: | - tiny_user_project_layout.png + layout.png key: ${{ runner.os }}-img-${{ github.run_id }} - name: setup pages uses: actions/configure-pages@v2 @@ -266,5 +254,5 @@ PAGE_URL=$(echo "$PAGE_URL" | sed -e 's/\/$//') cat << EOF >> $GITHUB_STEP_SUMMARY # layout -  +  EOF
diff --git a/scripts/create_svg.py b/scripts/create_svg.py deleted file mode 100644 index 0bac98b..0000000 --- a/scripts/create_svg.py +++ /dev/null
@@ -1,8 +0,0 @@ -import gdstk -import pathlib -gds = sorted(pathlib.Path('.').glob('gds/tiny_user_project.gds')) -library = gdstk.read_gds(gds[-1]) -top_cells = library.top_level() -top_cells[0].write_svg('gds_render.svg') -import cairosvg -cairosvg.svg2png(url='gds_render.svg', write_to='gds_render.png') \ No newline at end of file
diff --git a/scripts/klayout_save_image.py b/scripts/klayout_save_image.py new file mode 100644 index 0000000..9f68f15 --- /dev/null +++ b/scripts/klayout_save_image.py
@@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2022 Greg Davill +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +lv = pya.LayoutView.current() +ly = pya.CellView.active().layout() + +# top cell bounding box in micrometer units +bbox = ly.top_cell().dbbox() + +# compute an image size having the same aspect ratio than +# the bounding box +w = 1200 +h = int(0.5 + w * bbox.height() / bbox.width()) + +lv.save_image_with_options('layout.png', w, h, 0, 0, 0, bbox, False)