Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule for writing GDS files #169

Merged
merged 21 commits into from
Jul 14, 2023
Merged

Add rule for writing GDS files #169

merged 21 commits into from
Jul 14, 2023

Conversation

lpawelcz
Copy link
Collaborator

@lpawelcz lpawelcz commented Jun 16, 2023

Closes #20, closes #54.

This PR adds gds_write rule which allows writing GDS files. The rule have a set of inputs and dependencies which are:

  • Implemented RTL - the result of place_and_route target,
  • KLayout - delivered as Python module
  • Python script - for writing GDS files with KLayout module
  • KLayout technology file - XML file generated from KLayout GUI version, based on data from PDKs.
  • KLayout LEF file - technology LEF file of the PDK that includes all relevant information regarding metal layers, vias, and spacing requirements
  • Additional LEF files - List of hardened macro LEF view files.
  • Additional GDS files - List of platform GDS files
  • Fill config - JSON file with configuration for metal fill

Apart from the rules itself, PR:

  • adds KLayout python module into pip_requirements.txt
  • imports and modifies def2stream.py script from OpenROAD-flow-scripts
  • modifies place_and_route rule to also return SynthesisInfo provider which is convenient for accessing top module name for the GDS write script.
  • modifies StandardCellInfo provider to also store GDS files from PDKs
  • adds density_fill stage after detailed_routing

@lpawelcz
Copy link
Collaborator Author

Hi @QuantamHD and @proppy, please take a look at this PR

gds_write/build_defs.bzl Outdated Show resolved Hide resolved
gds_write/build_defs.bzl Outdated Show resolved Hide resolved
gds_write/build_defs.bzl Outdated Show resolved Hide resolved
gds_write/build_defs.bzl Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
parser.add_argument("-o", "--out", required=True, help="Path to output GDS file")
parser.add_argument("-g", "--additional-gds", required=False, help="Paths to additional input GDS files", default="", nargs="*")
parser.add_argument("-f", "--fill-config", required=False, help="Path to JSON rule file for metal fill during chip finishing", default="")
parser.add_argument("-s", "--seal", required=False, help="Path to seal GDS/OAS file", default="")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is seal for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to OpenROAD-flow-scripts those seal GDS files are used in GF12 platform. At first I wanted to keep this part in case it would be needed in the future but I will remove it so that the script will be cleaner.

gds_write/def2stream.py Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
print("[INFO] Checking for missing cell from GDS/OAS...")
missing_cell = False
regex = None
if 'GDS_ALLOW_EMPTY' in os.environ:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use a flag instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with --gds-allow-empty flag

gds_write/def2stream.py Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
gds_write/def2stream.py Outdated Show resolved Hide resolved
load("@rules_hdl_pip_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_binary")

py_binary(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have some py_test too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we test the rule that uses this py_binary. If that is not enough I can add py_test but I think it would not be much different compared to the linked test. Please let me know what do you think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let @QuantamHD comment about the general approach taken by bazel_rules_hdl, but I'd think it'd be nice to have unittest for the python code as well.

@@ -60,6 +60,7 @@ def _place_and_route_impl(ctx):

return [
DefaultInfo(files = depset(output_files)),
SynthesisInfo(top_module = ctx.attr.synthesized_rtl[SynthesisInfo].top_module),
Copy link
Collaborator

@proppy proppy Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why this is required? (it looks unrelated)

Copy link
Collaborator Author

@lpawelcz lpawelcz Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful if place_and_route rule would return SynthesisInfo provider with the name of the top_module from the synthesized design. This name is required in GDS write script, see e.g. here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just return the ctx.attr.synthesized_rtl[SynthesisInfo] directly there's really no harm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

klayout_lyt = "klayout.lyt",
klayout_lef = "klayout_tech.lef",
fill_config = "fill.json",
additional_lef = ["sky130_fd_sc_hd_merged.lef"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get those thru dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that if we place all those files under single dependencies attribute we would have problems with distinguishing which file is which as they will be stored on a list and we would have to rely on file extensions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. I was able to use PDK dependencies to pass down LEF and GDS files through StandardCellInfo provider. From now on there is no need to specify input_lef and input_gds attributes. However I've left those attributes - they might be useful in some custom cases.

Copy link
Collaborator

@proppy proppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay,

Looks very good! I made a first round of comments with nits and questions about the implementation.

@lpawelcz lpawelcz force-pushed the gds-write branch 3 times, most recently from e127957 to 7d08218 Compare June 28, 2023 10:40
@QuantamHD
Copy link
Collaborator

QuantamHD commented Jul 5, 2023

Sorry for the long poll in review time. I'm committed to get that down to 24 hours. I will be more responsive going forward.

Thank you for your contribution! You rock :)

Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
@lpawelcz lpawelcz force-pushed the gds-write branch 2 times, most recently from c059e37 to 66cae28 Compare July 11, 2023 05:31
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Check for possible orphans cells in new layout is redundant
because we create new layout and explicitly copy there only
the tree of the top cell so it is impossible to have there
cells without parents other than the top cell.

Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
@QuantamHD
Copy link
Collaborator

Thanks!

@QuantamHD QuantamHD merged commit e30c65c into hdl:main Jul 14, 2023
4 checks passed
@lpawelcz lpawelcz deleted the gds-write branch July 17, 2023 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support GDSII Output for Place and Route Rules Add KLayout
3 participants