You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug VIARULE GENERATE in DEF to GDS conversion in ORFS using Klayout #1877
GDS file generated by KLayout shows mismatches with the DEF file, leading to DRC violations in VIA ARRAY Cells (VIA-METAL1 and VIA-METAL2).
both KLayout 0.28.8, 0.28.5 and 0.28.8 (From latest commit of ORFS).
Observations:
DEF file passes DRC checks, while the GDS file from KLayout has issues.
Layer mapping has been verified.
DBU is set to 0.001 DBU, and Tech LEF DATABASE MICROS is set to 1000.
Note: the numbers are not exactly what I'm using for NDA purposes. They were useful in illustrating the problem in my Slack Discussion
Minimal reproducible:
The TECH LEF Snippet that produces the problem (a shorter via overhangs on the right-most generated via) that cause DRC issues, I've added the edit the solves the problems by increasing the overhang (so the shorter version with the bug doesn't cause a DRC error.
I have observed that the conversion of signals names that are non-scalars on text layers (pin labels) have some issues, if the DEF name is addr[2] for example the text layer has net123 and not the actual name. Not sure if this an actual issue or if it is for compatibility reasons.
Could you please provide a minimal reproducible testcase ?
That would be a lef with at least 2 metal and one via layer and a def file with the VIA in question and a NET referencing this via.
The VIARULE's get interpreted by OpenRoad and the resulting VIA is written in the VIAS section of the def file.
Without data it's hard to tell whether this is an OpenRoad or an klayout issue.
Thank you for your swift reply. I admit sending a bug report without a minimum reproducible isn't the nicest thing and for that I apologize. Please refer to my openroad slack discussion link about why I think it's a def2gds/klayout issue, maybe I'm wrong. I may put together a minimum test case that I can share in the future, it's just I don't know how to do it right now.
I did read the slack discussion, it contains some more context, but not more data.
Since klayout/strm2oas just convert def to gds and the def via just contain rectangles, I don’t see how that can go wrong unless you are changing units, because there is no math involved.
Applying the via rules to generate the via needs some math in OpenRoad.
You claim other tools would convert the def correctly … which I find puzzling.
But here comes in a minimal testcase with just the via in question, it’s the reproducibility that matters.
lef/def are Text Formats and you can run klayout or it’s command line strm2gds buddy program to convert them to gds.
Creating a testcases is as easy as taking the def, start stripping away stuff you don’t need, rerun strm2oas to see whether it still runs, rinse and repeat. After a couple iterations, you will be able to reduce def and then lef to a few lines that are relevant.
The def header info (VERSION, DESIGN, DIEAREA), VIAS section with the one VIA in question and the NETS section with one “- netname .. + coordinates vianame ;” and finally ENDDESIGN.
Don’t worry about the proprietary nature of lef, the size of a via hole in certain technologies and its metal overhang are not exactly secrets. But with a couple of lines testcase, you can easily change layer/via names and the lef via size and still have your testcase fail.
Last but not least, you can get in touch with Matthias directly and not make testcase public.
@rr667 That's funny, because VIARULE is not considered at all from LEF. The workaround might be an indirect effect - e.g. a rounding issue. This is what @stefanottili also mentioned.
KLayout reads VIA definitions, but not VIARULE. AFAIK VIARULE should be read by the router to generate VIA statements. @stefanottili Please correct me if I am wrong.
A snippet from the DEF plus the corresponding VIA definition is needed.
A side note: version 0.28.5 (or 0.28.8) is somewhat outdated.
Yes, I have followed @stefanottili excellent instructions to make the reproducible, here's what I have done:
I have created a floorplan with some design to have the power stripes laid out. I exported the .def with write_def command in OR.
I continued to strip down the .def piece by piece while running def2gds script to make sure it compiles.
I ended up with the via-rule-generate cell connected to a net. The GDS has the DRC issue unfortunately.
I learnt more about LEF/DEF and created an isolated different example that I can share publicly. The problem persists with my example.
@stefanottili is right, Klayout operates on the DEF not the TECH LEF. OpenROAD is what produces the DEF according to the VIARULE GENERATE algorithm it has.
Here's the reproducible (there's a shell in there to run def2gds python script I copied from ORFS, the outputs are there in case you don't want to run it).
@stefanottili Thank you again for being patient, please let me know if something is incomplete. I couldn't read in the def back after modifying it and view it with OpenROAD, is this necessary?
Here's my observations:
The workaround works because there's something about how (KLayout?) interprets the DEF for some numbers, as @klayoutmatthias has pointed out, a possible rounding error. I could be wrong.
The issue is exactly on the right side of the via-rule-generate cell, the left side is fine. Increasing the overhangs by 0.001 adds extra 0.001 to the left side but the right side, that used to give DRC errors, is fixed!
VERSION 5.6 ;
BUSBITCHARS "[]" ;
DIVIDERCHAR "/" ;
UNITS
DATABASE MICRONS 1000 ;
END UNITS
MANUFACTURINGGRID 0.001 ;
# Original: (commented)
# DRC ERROR ON THE RIGHT SIDE OF VIA ARRAY
# VIARULE MYVIA1_ARRAY GENERATE
# LAYER METAL_1 ;
# ENCLOSURE 0.061 0.007 ;
# LAYER METAL_2 ;
# ENCLOSURE 0.061 0.007 ;
# LAYER VIA_1 ;
# RECT -0.123 -0.123 0.123 0.123 ;
# SPACING 0.463 BY 0.463 ;
# END MYVIA1_ARRAY
# Edit: Increased overhangs as a workaround
# Left side has 0.001 extra
# Right side is just right (no DRCs)
VIARULE MYVIA1_ARRAY GENERATE
LAYER METAL_1 ;
ENCLOSURE 0.062 0.007 ; # Inc. overhang1 by 0.001
LAYER METAL_2 ;
ENCLOSURE 0.061 0.008 ; # Inc. overhang2 by 0.001
LAYER VIA_1 ;
RECT -0.123 -0.123 0.123 0.123 ; # DEF CUTSIZE 246 246
SPACING 0.463 BY 0.463 ; # DEF CUTSPACING 231 231
END MYVIA1_ARRAY
# DEF ENCLOSURE 62 137 8 61
END LIBRARY
@rr667 Thanks for the test case, it pinpoints the issue.
If you make the following changes to your testcase lef/def, you can load it in openroad
lef: you have to define the 3 layers (2 routing, 1 via), the WIDTH only matters for default NETS, it's value is irrelevant here, but some tools need it to load lef.
LAYER METAL_1
TYPE ROUTING ;
DIRECTION HORIZONTAL ;
WIDTH 0.6 ;
END METAL_1
LAYER VIA_1
TYPE CUT ;
END VIA_1
LAYER METAL_2
TYPE ROUTING ;
DIRECTION VERTICAL ;
WIDTH 0.6 ;
END METAL_2
The def requires DIEAREA and your SPECIALNET VDD's connectivity section references a PIN VDD that you've not defined, just comment it out.
if you create a file called or_via_fix.or you can run
openroad -gui -or_via_fix.or
but you have to "zoom in" to see the via due to OR's size based draw filtering (OR feature/bug).
read_lef klayout_tech.lef
read_def or_via_fix.def
The following command will use klayout's buddy tool strm2oas to convert lef/def/map to oas.
Your def2gds.sh works too, but it maps the metal/via layer twice, I'll leave it to Matthias to explain that.
I prefer to use .map files instead of .lyt
strm2oas can do what def2stream.py does using klayout, except adding a possible sealring reference.
And now to the issue at hand: @klayoutmatthias I believe it's a klayout bug, because it create too small of an overhang.
But it's caused by ambiguity in the VIARULE, that leads to a rounding issue no matter what.
The via metal has to be centered, but the width is not even, this is ambiguous.
klayout currently calculates the metal left/right coordinates as -19585/2,+19585/2.
A fix would be to calculate the left coordinate as -19585/2 and then add 19585 to get the right coordinate.
But even that is ambiguous due to the left coordinate calculation dividing an uneven number by two.
The real fix is to have an even SPACING in the VIARULE. That way klayout would work "as is".
Even the comment in the lef acknowledges that 463 leads to an ambiguous 231(.5) ...
I think it is possible to change the rounding in a way the DRC constraints are not compromised. Still - as Stefan pointed out - the results are slightly arbitrary as the via's anchor point is not well defined.
I have changed the spacing value in the tech lef line SPACING 0.463 BY 0.463 ; from 0.463 to a higher even number: 0.464.
I reverted to the original extra overhang value.
Running ORFS with the updated tech lef:
The overhangs are just right (no DRC violations)
I noticed the CUTSPACING value is still 231 and not 232. (in the OR GUI and in the 6_final.def)
Checking the 6_final.gds in Klayout:
it has the old DRC violation. (0.001 shorter overhang on the right side of the via rule).
Editing the 6_final.def file:
changing the CUTSPACING from 231 to 232 and running make final to def2gds again.
Now, the GDS in Klayout does have the 0.232 via spacings and the DRC violation is gone.
I think it's an OpenROAD parse-techlef issue to write the CUTSPACING 231 and not 232. I have tried changing the RECT value to see if my change will have an effect and it does, but sadly not for the SPACING. Should we file an issue to OpenROAD as well?
Activity
stefanottili commentedon Sep 29, 2024
Could you please provide a minimal reproducible testcase ?
That would be a lef with at least 2 metal and one via layer and a def file with the VIA in question and a NET referencing this via.
stefanottili commentedon Sep 30, 2024
The VIARULE's get interpreted by OpenRoad and the resulting VIA is written in the VIAS section of the def file.
Without data it's hard to tell whether this is an OpenRoad or an klayout issue.
rr667 commentedon Sep 30, 2024
Thank you for your swift reply. I admit sending a bug report without a minimum reproducible isn't the nicest thing and for that I apologize. Please refer to my openroad slack discussion link about why I think it's a def2gds/klayout issue, maybe I'm wrong. I may put together a minimum test case that I can share in the future, it's just I don't know how to do it right now.
Best Regards,
stefanottili commentedon Sep 30, 2024
I did read the slack discussion, it contains some more context, but not more data.
Since klayout/strm2oas just convert def to gds and the def via just contain rectangles, I don’t see how that can go wrong unless you are changing units, because there is no math involved.
Applying the via rules to generate the via needs some math in OpenRoad.
You claim other tools would convert the def correctly … which I find puzzling.
But here comes in a minimal testcase with just the via in question, it’s the reproducibility that matters.
lef/def are Text Formats and you can run klayout or it’s command line strm2gds buddy program to convert them to gds.
Creating a testcases is as easy as taking the def, start stripping away stuff you don’t need, rerun strm2oas to see whether it still runs, rinse and repeat. After a couple iterations, you will be able to reduce def and then lef to a few lines that are relevant.
The def header info (VERSION, DESIGN, DIEAREA), VIAS section with the one VIA in question and the NETS section with one “- netname .. + coordinates vianame ;” and finally ENDDESIGN.
Don’t worry about the proprietary nature of lef, the size of a via hole in certain technologies and its metal overhang are not exactly secrets. But with a couple of lines testcase, you can easily change layer/via names and the lef via size and still have your testcase fail.
Last but not least, you can get in touch with Matthias directly and not make testcase public.
klayoutmatthias commentedon Sep 30, 2024
@rr667 That's funny, because VIARULE is not considered at all from LEF. The workaround might be an indirect effect - e.g. a rounding issue. This is what @stefanottili also mentioned.
KLayout reads VIA definitions, but not VIARULE. AFAIK VIARULE should be read by the router to generate VIA statements. @stefanottili Please correct me if I am wrong.
A snippet from the DEF plus the corresponding VIA definition is needed.
A side note: version 0.28.5 (or 0.28.8) is somewhat outdated.
Matthias
stefanottili commentedon Oct 11, 2024
I don’t see how this could be a klayout bug from your description.
Please provide a test case or close this issue.
klayoutmatthias commentedon Oct 11, 2024
Hi @rr667
Any updates?
Matthias
rr667 commentedon Oct 12, 2024
Hello @klayoutmatthias
Yes, I have followed @stefanottili excellent instructions to make the reproducible, here's what I have done:
I have created a floorplan with some design to have the power stripes laid out. I exported the
.defwithwrite_defcommand in OR.I continued to strip down the
.defpiece by piece while runningdef2gdsscript to make sure it compiles.I ended up with the via-rule-generate cell connected to a net. The GDS has the DRC issue unfortunately.
I learnt more about LEF/DEF and created an isolated different example that I can share publicly. The problem persists with my example.
@stefanottili is right, Klayout operates on the DEF not the TECH LEF. OpenROAD is what produces the DEF according to the VIARULE GENERATE algorithm it has.
Here's the reproducible (there's a shell in there to run def2gds python script I copied from ORFS, the outputs are there in case you don't want to run it).
via_issue_ob.tar.gz
@stefanottili Thank you again for being patient, please let me know if something is incomplete. I couldn't read in the def back after modifying it and view it with OpenROAD, is this necessary?
Here's my observations:
0.001adds extra0.001to the left side but the right side, that used to give DRC errors, is fixed!In OpenROAD (DEF viewer?) the right side is fine:
DEF
TECH LEF
stefanottili commentedon Oct 12, 2024
@rr667 Thanks for the test case, it pinpoints the issue.
If you make the following changes to your testcase lef/def, you can load it in openroad
lef: you have to define the 3 layers (2 routing, 1 via), the WIDTH only matters for default NETS, it's value is irrelevant here, but some tools need it to load lef.
The def requires DIEAREA and your SPECIALNET VDD's connectivity section references a PIN VDD that you've not defined, just comment it out.
if you create a file called or_via_fix.or you can run
openroad -gui -or_via_fix.or
but you have to "zoom in" to see the via due to OR's size based draw filtering (OR feature/bug).
The following command will use klayout's buddy tool strm2oas to convert lef/def/map to oas.
Your def2gds.sh works too, but it maps the metal/via layer twice, I'll leave it to Matthias to explain that.
I prefer to use .map files instead of .lyt
strm2oas can do what def2stream.py does using klayout, except adding a possible sealring reference.
or_via_fix.map
And now to the issue at hand:
@klayoutmatthias I believe it's a klayout bug, because it create too small of an overhang.
But it's caused by ambiguity in the VIARULE, that leads to a rounding issue no matter what.
CUTSIZE 246 246 + CUTSPACING 231 231 + ENCLOSURE 62 137 8 61 + ROWCOL 1 8
246*8 + 231*7 + 8*2 = 19585
The via metal has to be centered, but the width is not even, this is ambiguous.
klayout currently calculates the metal left/right coordinates as -19585/2,+19585/2.
A fix would be to calculate the left coordinate as -19585/2 and then add 19585 to get the right coordinate.
But even that is ambiguous due to the left coordinate calculation dividing an uneven number by two.
The real fix is to have an even SPACING in the VIARULE. That way klayout would work "as is".
Even the comment in the lef acknowledges that 463 leads to an ambiguous 231(.5) ...
rr667 commentedon Oct 12, 2024
You figured it out really quickly ⚡
Thank you for looking into this, I will try the OR read def later 👍
stefanottili commentedon Oct 12, 2024
Please change the tech lef SPACING to 0.464, redo your floorplan and let us know whether the drc goes away.
klayoutmatthias commentedon Oct 12, 2024
Perfect. I can reproduce the issue.
I think it is possible to change the rounding in a way the DRC constraints are not compromised. Still - as Stefan pointed out - the results are slightly arbitrary as the via's anchor point is not well defined.
Thanks for this great debugging effort!
Matthias
Fixed issue #1877 (rounding introduces DRC error in LEF/DEF via)
rr667 commentedon Oct 13, 2024
Hello @stefanottili @klayoutmatthias,
Thanks a lot for taking the time. 😄
SPACING 0.463 BY 0.463 ;from 0.463 to a higher even number: 0.464.6_final.def)6_final.gdsin Klayout:6_final.deffile:make finalto def2gds again.Embedding fix for issue #1892 which is closely related to #1877
stefanottili commentedon Oct 17, 2024
@rr667 > Should we file an issue to OpenROAD as well?
If you mean "we" as in "you" ...
Yes, you should file an issue with OpenROAD with a small testcase attached.
rr667 commentedon Oct 18, 2024
Yes. 😂
It's been a pleasure. I believe this is complete now.
Merge pull request #1889 from KLayout/issue-1877