Skip to content

Commit

Permalink
DRC enhancements:
Browse files Browse the repository at this point in the history
- Shapes are added to existing categories rather than creating
  a new category with the same name
- The category name in "output" can be an array creating a
  hierarchy of categories.
  • Loading branch information
Matthias Koefferlein committed Apr 27, 2024
1 parent 4b967fc commit ed64d4a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/drc/drc/built-in-macros/_drc_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3226,7 +3226,23 @@ def _output(data, *args)
output_rdb = channel.rdb
output_cell = channel.cell

cat = output_rdb.create_category(args[0].to_s)
categories = args[0]
if !categories.is_a?(Array)
categories = [ categories.to_s ]
end

cat = nil
categories.each do |c|
ccat = nil
if cat
ccat = cat.each_sub_category.find { |i| i.name == c }
else
ccat = output_rdb.each_category.find { |i| i.name == c }
end
cat = ccat ? ccat : output_rdb.create_category(cat, c)
end
cat ||= output_rdb.create_category("default")

args[1] && cat.description = args[1]

cat.scan_collection(output_cell, RBA::CplxTrans::new(self.dbu), data)
Expand Down
6 changes: 5 additions & 1 deletion src/drc/drc/built-in-macros/_drc_layer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5111,7 +5111,11 @@ def nets(*args)
# This method will copy the content of the layer to the specified output.
#
# If a report database is selected for the output, the specification has to include a
# category name and optionally a category description.
# category name and optionally a category description. The category name can be an
# array of strings - in that case, a hierarchy of categories is created
# with the first array item being the top level category name.
# Shapes are added to an existing category, if a category with the given
# name already exists.
#
# If the layout is selected for the output, the specification can consist of
# one to three parameters: a layer number, a data type (optional, default is 0)
Expand Down
1 change: 1 addition & 0 deletions src/rdb/rdb/gsiDeclRdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ Class<rdb::Database> decl_ReportDatabase ("rdb", "ReportDatabase",
"@brief Creates a new sub-category\n"
"@param parent The category under which the category should be created\n"
"@param name The name of the category\n"
"Since version 0.29.1, 'parent' can be nil. In that case, a top-level category is created."
) +
gsi::method ("category_by_path", &rdb::Database::category_by_name, gsi::arg ("path"),
"@brief Gets a category by path\n"
Expand Down
4 changes: 4 additions & 0 deletions src/rdb/rdb/rdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,10 @@ Database::import_cells (const Cells &cells)
Category *
Database::create_category (Category *parent, const std::string &name)
{
if (! parent) {
return create_category (name);
}

set_modified ();

Category *cat = create_category (&parent->sub_categories (), name);
Expand Down

0 comments on commit ed64d4a

Please sign in to comment.