This commit is contained in:
Matthias Koefferlein 2020-12-15 18:42:43 +01:00
parent 1106a52688
commit 7852568284
1 changed files with 90 additions and 8 deletions

View File

@ -36,17 +36,23 @@ namespace gsi
static bool
lm_is_mapped (const db::LayerMap *layer_map, const db::LayerProperties &lp)
{
return layer_map->logical (lp).first;
return !layer_map->logical (lp).empty ();
}
static int
lm_logical (const db::LayerMap *layer_map, const db::LayerProperties &lp)
{
std::pair<bool, unsigned int> lm = layer_map->logical (lp);
return lm.first ? int (lm.second) : -1;
std::set<unsigned int> lm = layer_map->logical (lp);
return lm.empty () ? -1 : int (*lm.begin ());
}
static db::LayerProperties
static std::set<unsigned int>
lm_logicals (const db::LayerMap *layer_map, const db::LayerProperties &lp)
{
return layer_map->logical (lp);
}
static db::LayerProperties
lm_mapping (const db::LayerMap *layer_map, unsigned int l)
{
return layer_map->mapping (l);
@ -82,16 +88,44 @@ namespace gsi
layer_map->map_expr (s, l);
}
static void
lm_unmap (db::LayerMap *layer_map, const db::LayerProperties &lp)
{
layer_map->unmap (lp);
}
static void
lm_unmap_interval (db::LayerMap *layer_map, const db::LayerProperties &lp1, const db::LayerProperties &lp2)
{
layer_map->unmap (ldpair_from_lp (lp1), ldpair_from_lp (lp2));
}
static void
lm_unmap_string (db::LayerMap *layer_map, std::string &s)
{
layer_map->unmap_expr (s);
}
Class<db::LayerMap> decl_LayerMap ("db", "LayerMap",
gsi::method_ext ("is_mapped?", &lm_is_mapped, gsi::arg ("layer"),
"@brief Check, if a given physical layer is mapped\n"
"@param layer The physical layer specified with an \\LayerInfo object.\n"
"@return True, if the layer is mapped."
) +
gsi::method_ext ("logical", &lm_logical, gsi::arg ("layer"),
gsi::method_ext ("#logical", &lm_logical, gsi::arg ("layer"),
"@brief Returns the logical layer (the layer index in the layout object) for a given physical layer.n"
"@param layer The physical layer specified with an \\LayerInfo object.\n"
"@return The logical layer index or -1 if the layer is not mapped."
"\n"
"This method is deprecated with version 0.27 as in this version, layers can be mapped to multiple targets which "
"this method can't capture. Use \\logicals instead.\n"
) +
gsi::method_ext ("logicals", &lm_logicals, gsi::arg ("layer"),
"@brief Returns the logical layers for a given physical layer.n"
"@param layer The physical layer specified with an \\LayerInfo object.\n"
"@return This list of logical layers this physical layer as mapped to or empty if there is no mapping."
"\n"
"This method has been introduced in version 0.27.\n"
) +
gsi::method ("mapping_str", &db::LayerMap::mapping_str, gsi::arg ("log_layer"),
"@brief Returns the mapping string for a given logical layer\n"
@ -162,11 +196,39 @@ namespace gsi
"separated by a hyphen. Examples are: \"1/2\", \"1-5/0\", \"1,2,5/0\",\n"
"\"1/5;5/6\".\n"
"\n"
"A target layer can be specified with the \":<target>\" notation where "
"the target is a valid layer specification string (i.e. \"1/0\").\n"
"layer/datatype wildcards can be specified with \"*\". When \"*\" is used\n"
"for the upper limit, it is equivalent to \"all layer above\". When used\n"
"alone, it is equivalent to \"all layers\". Examples: \"1 / *\", \"* / 10-*\"\n"
"\n"
"Named layers are specified simply by specifying the name, if\n"
"necessary in single or double quotes (if the name begins with a digit or\n"
"contains non-word characters). layer/datatype and name descriptions can\n"
"be mixed, i.e. \"AA;1/5\" (meaning: name \"AA\" or layer 1/datatype 5).\n"
"\n"
"A target layer can be specified with the \":<target>\" notation, where\n"
"target is a valid string for a LayerProperties() object.\n"
"\n"
"A target can include relative layer/datatype specifications and wildcards.\n"
"For example, \"1-10/0: *+1/0\" will add 1 to the original layer number.\n"
"\"1-10/0-50: * / *\" will use the original layers.\n"
"\n"
"Target mapping has been added in version 0.20.\n"
) +
gsi::method_ext ("unmap", &lm_unmap, gsi::arg ("phys_layer"),
"@brief Unmaps the given layer\n"
"Unmapping will remove the specific layer from the mapping. This method allows generating "
"'mapping holes' by first mapping a range and then unmapping parts of it.\n"
"\n"
"This method has been introduced in version 0.27."
) +
gsi::method_ext ("unmap", &lm_unmap_interval, gsi::arg ("pl_start"), gsi::arg ("pl_stop"),
"@brief Unmaps the layers from the given interval\n"
"This method has been introduced in version 0.27."
) +
gsi::method_ext ("unmap", &lm_unmap_string, gsi::arg ("expr"),
"@brief Unmaps the layers from the given expression\n"
"This method has been introduced in version 0.27."
) +
gsi::method ("clear", &db::LayerMap::clear,
"@brief Clears the map\n"
) +
@ -221,7 +283,27 @@ namespace gsi
"ly.read(\"input.gds\", lo)\n"
"@/code\n"
"\n"
"The LayerMap class has been introduced in version 0.18."
"1:n mapping is possible: a physical layer can be mapped to multiple logical layers. For this, mapping acts additive. "
"The following example will map layer 1, datatypes 0 to 255 to logical layer 0, and layer 1, datatype 17 to logical layers "
"0 plus 1:"
"\n"
"@code"
"lm = RBA::LayerMap::new\n"
"lm.map(\"1/0-255\", 0)\n"
"lm.map(\"1/17\", 1)\n"
"@/code\n"
"\n"
"'unmapping' allows to remove a mapping. This allows creating 'holes' in mapping ranges. The followin example maps "
"layer 1, datatypes 0 to 16 and 18 to 255 to logical layer 0:"
"\n"
"@code"
"lm = RBA::LayerMap::new\n"
"lm.map(\"1/0-255\", 0)\n"
"lm.unmap(\"1/17\")\n"
"@/code\n"
"\n"
"The LayerMap class has been introduced in version 0.18. Target layer have been introduced in version 0.20. "
"1:n mapping and unmapping has been introduced in version 0.27."
);
// NOTE: the contribution comes from format specific extensions.