mirror of https://github.com/KLayout/klayout.git
Merge branch 'lefdef'
This commit is contained in:
commit
cfe38aab42
|
|
@ -24,6 +24,8 @@
|
|||
#include "dbLoadLayoutOptions.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
#include "tlStream.h"
|
||||
|
||||
namespace bd
|
||||
{
|
||||
|
||||
|
|
@ -153,13 +155,44 @@ GenericReaderOptions::add_options (tl::CommandLineOptions &cmd)
|
|||
"layer is specified, all source layers addressed with the source specification are "
|
||||
"combined into this target layer.\n"
|
||||
"\n"
|
||||
"For clarity, source and target specifications can be enclosed in round or square brackets. "
|
||||
"With square brackets, the default target is '*/*' which results in the expansion of a source "
|
||||
"layer range.\n"
|
||||
"\n"
|
||||
"To clone layers, add a mapping statement beginning with a '+' character. While other mapping statements "
|
||||
"redefine mappings established before, mapping statement starting with '+' will clone the layer (1:m mapping).\n"
|
||||
"\n"
|
||||
"You can cancel mappings established before by using an 'unmap' statement. Such a statement "
|
||||
"begins with a '-' and lists the layers whose mapping is to be removed. This is useful for creating "
|
||||
"'mapping holes' in sequences.\n"
|
||||
"\n"
|
||||
"If brackets are used, '+' (multi-mapping) and '-' (unmapping) needs to go before the brackets.\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
"\n"
|
||||
"* 1/0 2/0 3/0-255:17/0\n"
|
||||
" Selects 1/0, 2/0 and maps layer 3, datatype 0 to 255 to layer 17, datatype 0\n"
|
||||
" Selects 1/0, 2/0 and maps layer 3, datatype 0 to 255 to layer 17, datatype 0.\n"
|
||||
" If clarity, the mapping can also be written with brackets like this: '(1/0) (2/0) (3/0-255:17/0)'.\n"
|
||||
"\n"
|
||||
"* A:1/0 B:2/0\n"
|
||||
" Maps named layer A to 1/0 and named layer B to 2/0"
|
||||
" Maps named layer A to 1/0 and named layer B to 2/0.\n"
|
||||
" If clarity, the mapping can also be written with brackets like this: '(A:1/0) (B:2/0)'.\n"
|
||||
"\n"
|
||||
"* [*/*] +(10/*:1000)/*\n"
|
||||
" Includes all layers, but in addition copies all datatypes of layer 10 to 1000 while keeping the datatype.\n"
|
||||
" Note the square bracket which implies range expansion and how the brackets give a visual aid for the "
|
||||
" grouping of the mapping parts.\n"
|
||||
"\n"
|
||||
"* [*/*] -(10/*)\n"
|
||||
" Includes all layers, but drops all datatypes from layer 10 through 'unmapping'.\n"
|
||||
" Please note, that this specification requires -" + m_prefix + "s (skip unknown layers) because otherwise the "
|
||||
" unmapped layers are still created through the unknown layer fallback path.\n"
|
||||
)
|
||||
<< tl::arg (group +
|
||||
"--" + m_long_prefix + "layer-map-file=map", this, &GenericReaderOptions::set_layer_map_file, "Specifies the layer mapping for the input as a file",
|
||||
"This option specifies the layer selection or mapping like -" + m_prefix + "m, but takes the mapping from the given file. "
|
||||
"Each line in this file is read as one layer mapping expression. "
|
||||
"Empty lines or lines starting with a hash (#) character or with double slashes (//) are ignored."
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
@ -604,12 +637,19 @@ void GenericReaderOptions::set_layer_map (const std::string &lm)
|
|||
|
||||
int l = 0;
|
||||
while (! ex.at_end ()) {
|
||||
m_layer_map.map_expr (ex, l);
|
||||
m_layer_map.add_expr (ex, l);
|
||||
ex.test ("//");
|
||||
++l;
|
||||
}
|
||||
}
|
||||
|
||||
void GenericReaderOptions::set_layer_map_file (const std::string &lm)
|
||||
{
|
||||
tl::InputStream file (lm);
|
||||
tl::TextInputStream text (file);
|
||||
m_layer_map = db::LayerMap::from_string_file_format (text.read_all ());
|
||||
}
|
||||
|
||||
void GenericReaderOptions::set_read_named_layers (bool f)
|
||||
{
|
||||
m_keep_layer_names = f;
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ private:
|
|||
std::vector<std::string> m_magic_lib_path;
|
||||
|
||||
void set_layer_map (const std::string &lm);
|
||||
void set_layer_map_file (const std::string &lm);
|
||||
void set_dbu (double dbu);
|
||||
void set_read_named_layers (bool f);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace db
|
|||
static const size_t null_id = std::numeric_limits<size_t>::max ();
|
||||
|
||||
CommonReader::CommonReader ()
|
||||
: m_cc_resolution (AddToCell)
|
||||
: m_cc_resolution (AddToCell), m_create_layers (false)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -275,6 +275,46 @@ CommonReader::merge_cell_without_instances (db::Layout &layout, db::cell_index_t
|
|||
layout.delete_cell (src_cell.cell_index ());
|
||||
}
|
||||
|
||||
const db::LayerMap &
|
||||
CommonReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
||||
{
|
||||
init (options);
|
||||
|
||||
m_common_options.layer_map.prepare (layout);
|
||||
|
||||
layout.start_changes ();
|
||||
try {
|
||||
do_read (layout);
|
||||
finish (layout);
|
||||
layout.end_changes ();
|
||||
} catch (...) {
|
||||
layout.end_changes ();
|
||||
throw;
|
||||
}
|
||||
|
||||
return m_layer_map_out;
|
||||
}
|
||||
|
||||
const db::LayerMap &
|
||||
CommonReader::read (db::Layout &layout)
|
||||
{
|
||||
return read (layout, db::LoadLayoutOptions ());
|
||||
}
|
||||
|
||||
void
|
||||
CommonReader::init (const LoadLayoutOptions &options)
|
||||
{
|
||||
m_common_options = options.get_options<db::CommonReaderOptions> ();
|
||||
m_cc_resolution = m_common_options.cell_conflict_resolution;
|
||||
m_create_layers = m_common_options.create_other_layers;
|
||||
|
||||
m_layer_map_out.clear ();
|
||||
m_multi_mapping_placeholders.clear ();
|
||||
m_layer_cache.clear ();
|
||||
m_layers_created.clear ();
|
||||
m_layer_names.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
CommonReader::finish (db::Layout &layout)
|
||||
{
|
||||
|
|
@ -382,6 +422,120 @@ CommonReader::finish (db::Layout &layout)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// resolve layer multi-mapping
|
||||
|
||||
for (std::map<std::set<unsigned int>, unsigned int>::const_iterator i = m_multi_mapping_placeholders.begin (); i != m_multi_mapping_placeholders.end (); ++i) {
|
||||
|
||||
if (i->first.size () > 1) {
|
||||
|
||||
bool discard_layer = i->first.find (i->second) == i->first.end ();
|
||||
|
||||
for (std::set<unsigned int>::const_iterator l = i->first.begin (); l != i->first.end (); ++l) {
|
||||
|
||||
// last one? this one will get a "move"
|
||||
std::set<unsigned int>::const_iterator ll = l;
|
||||
if (discard_layer && ++ll == i->first.end ()) {
|
||||
layout.move_layer (i->second, *l);
|
||||
layout.delete_layer (i->second);
|
||||
} else {
|
||||
layout.copy_layer (i->second, *l);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// rename layers created before if required
|
||||
|
||||
for (std::set<unsigned int>::const_iterator i = m_layers_created.begin (); i != m_layers_created.end (); ++i) {
|
||||
|
||||
const db::LayerProperties &lp = layout.get_properties (*i);
|
||||
|
||||
const tl::interval_map <db::ld_type, std::string> *dtmap = layer_names ().mapped (lp.layer);
|
||||
const std::string *name = 0;
|
||||
if (dtmap) {
|
||||
name = dtmap->mapped (lp.datatype);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
// need to rename: add a new madding to m_layer_map_out and adjust the layout's layer properties
|
||||
db::LayerProperties lpp = lp;
|
||||
join_layer_names (lpp.name, *name);
|
||||
layout.set_properties (*i, lpp);
|
||||
m_layer_map_out.map (LDPair (lp.layer, lp.datatype), *i, lpp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
CommonReader::open_dl (db::Layout &layout, const LDPair &dl)
|
||||
{
|
||||
std::map<db::LDPair, std::pair <bool, unsigned int> >::const_iterator lc = m_layer_cache.find (dl);
|
||||
if (lc != m_layer_cache.end ()) {
|
||||
return lc->second;
|
||||
} else {
|
||||
std::pair <bool, unsigned int> res = open_dl_uncached (layout, dl);
|
||||
m_layer_cache.insert (std::make_pair (dl, res));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
CommonReader::open_dl_uncached (db::Layout &layout, const LDPair &dl)
|
||||
{
|
||||
const std::set<unsigned int> &li = common_options ().layer_map.logical (dl, layout);
|
||||
if (li.empty ()) {
|
||||
|
||||
if (! m_create_layers) {
|
||||
return std::make_pair (false, (unsigned int) 0);
|
||||
}
|
||||
|
||||
// and create the layer
|
||||
db::LayerProperties lp;
|
||||
lp.layer = dl.layer;
|
||||
lp.datatype = dl.datatype;
|
||||
|
||||
// resolve OASIS name if possible
|
||||
const tl::interval_map <db::ld_type, std::string> *names_dmap = m_layer_names.mapped (dl.layer);
|
||||
if (names_dmap != 0) {
|
||||
const std::string *name = names_dmap->mapped (dl.datatype);
|
||||
if (name != 0) {
|
||||
lp.name = *name;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int nl = layout.insert_layer (lp);
|
||||
m_layer_map_out.map (dl, nl, lp);
|
||||
|
||||
m_layers_created.insert (nl);
|
||||
|
||||
return std::make_pair (true, nl);
|
||||
|
||||
} else if (li.size () == 1) {
|
||||
|
||||
m_layer_map_out.map (dl, *li.begin (), layout.get_properties (*li.begin ()));
|
||||
|
||||
return std::make_pair (true, *li.begin ());
|
||||
|
||||
} else {
|
||||
|
||||
for (std::set<unsigned int>::const_iterator i = li.begin (); i != li.end (); ++i) {
|
||||
m_layer_map_out.mmap (dl, *i, layout.get_properties (*i));
|
||||
}
|
||||
|
||||
std::map<std::set<unsigned int>, unsigned int>::iterator mmp = m_multi_mapping_placeholders.find (li);
|
||||
if (mmp == m_multi_mapping_placeholders.end ()) {
|
||||
// create a placeholder layer
|
||||
mmp = m_multi_mapping_placeholders.insert (std::make_pair (li, layout.insert_layer ())).first;
|
||||
}
|
||||
|
||||
return std::make_pair (true, mmp->second);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -31,6 +31,104 @@
|
|||
namespace db
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The CellConflictResolution enum
|
||||
*/
|
||||
enum CellConflictResolution
|
||||
{
|
||||
AddToCell = 0,
|
||||
OverwriteCell = 1,
|
||||
SkipNewCell = 2,
|
||||
RenameCell = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Structure that holds the GDS2 and OASIS specific options for the reader
|
||||
*/
|
||||
class DB_PUBLIC CommonReaderOptions
|
||||
: public FormatSpecificReaderOptions
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
CommonReaderOptions ()
|
||||
: create_other_layers (true),
|
||||
enable_text_objects (true),
|
||||
enable_properties (true),
|
||||
cell_conflict_resolution (CellConflictResolution::AddToCell)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Specifies a layer mapping
|
||||
*
|
||||
* If a layer mapping is specified, only the given layers are read.
|
||||
* Otherwise, all layers are read.
|
||||
* Setting "create_other_layers" to true will make the reader
|
||||
* create other layers for all layers not given in the layer map.
|
||||
* Setting an empty layer map and create_other_layers to true effectively
|
||||
* enables all layers for reading.
|
||||
*/
|
||||
db::LayerMap layer_map;
|
||||
|
||||
/**
|
||||
* @brief A flag indicating that a new layers shall be created
|
||||
*
|
||||
* If this flag is set to true, layers not listed in the layer map a created
|
||||
* too.
|
||||
*/
|
||||
bool create_other_layers;
|
||||
|
||||
/**
|
||||
* @brief A flag indicating whether to read text objects
|
||||
*
|
||||
* If this flag is set to true, text objects are read. Otherwise they are ignored.
|
||||
*/
|
||||
bool enable_text_objects;
|
||||
|
||||
/**
|
||||
* @brief A flag indicating whether to read user properties
|
||||
*
|
||||
* If this flag is set to true, user properties are read. Otherwise they are ignored.
|
||||
*/
|
||||
bool enable_properties;
|
||||
|
||||
/**
|
||||
* @brief Specifies the cell merge behavior
|
||||
*
|
||||
* This enum controls how cells are read if a cell with the requested name already
|
||||
* exists.
|
||||
*
|
||||
* AddToCell In this mode, instances or shapes are added to any existing cell
|
||||
* OverwriteCell Overwrite existing cell. If the existing cell has children, those are removed unless used otherwise
|
||||
* SkipNewCell Ignore the new cell and it's children
|
||||
* RenameCell Rename the new cell
|
||||
*
|
||||
* If the existing opr the new cell is a ghost cell, AddToCell is applied always. In other words,
|
||||
* ghost cells are always merged.
|
||||
*/
|
||||
CellConflictResolution cell_conflict_resolution;
|
||||
|
||||
/**
|
||||
* @brief Implementation of FormatSpecificReaderOptions
|
||||
*/
|
||||
virtual FormatSpecificReaderOptions *clone () const
|
||||
{
|
||||
return new CommonReaderOptions (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Implementation of FormatSpecificReaderOptions
|
||||
*/
|
||||
virtual const std::string &format_name () const
|
||||
{
|
||||
static const std::string n ("Common");
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A common reader base for GDS2 and OASIS providing common services for both readers
|
||||
*/
|
||||
|
|
@ -38,38 +136,13 @@ class DB_PUBLIC CommonReader
|
|||
: public ReaderBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The CellConflictResolution enum
|
||||
*/
|
||||
enum CellConflictResolution
|
||||
{
|
||||
AddToCell = 0,
|
||||
OverwriteCell = 1,
|
||||
SkipNewCell = 2,
|
||||
RenameCell = 3
|
||||
};
|
||||
typedef tl::interval_map <db::ld_type, tl::interval_map <db::ld_type, std::string> > layer_name_map;
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
CommonReader ();
|
||||
|
||||
/**
|
||||
* @brief Sets the cell name conflict resolution mode
|
||||
*/
|
||||
void set_cell_conflict_resolution (CellConflictResolution cc_resolution)
|
||||
{
|
||||
m_cc_resolution = cc_resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the cell name conflict resolution mode
|
||||
*/
|
||||
CellConflictResolution cell_conflict_resolution () const
|
||||
{
|
||||
return m_cc_resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Make a cell from a name
|
||||
*/
|
||||
|
|
@ -132,9 +205,17 @@ public:
|
|||
*/
|
||||
void finish (db::Layout &layout);
|
||||
|
||||
// Reimplementation of the ReaderBase interace
|
||||
virtual const db::LayerMap &read (db::Layout &layout, const db::LoadLayoutOptions &options);
|
||||
virtual const db::LayerMap &read (db::Layout &layout);
|
||||
|
||||
protected:
|
||||
friend class CommonReaderLayerMapping;
|
||||
|
||||
virtual void common_reader_error (const std::string &msg) = 0;
|
||||
virtual void common_reader_warn (const std::string &msg) = 0;
|
||||
virtual void do_read (db::Layout &layout) = 0;
|
||||
virtual void init (const LoadLayoutOptions &options);
|
||||
|
||||
/**
|
||||
* @brief Merge (and delete) the src_cell into target_cell
|
||||
|
|
@ -146,98 +227,69 @@ protected:
|
|||
*/
|
||||
void merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the common options
|
||||
*/
|
||||
db::CommonReaderOptions &common_options ()
|
||||
{
|
||||
return m_common_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the layer name map
|
||||
*/
|
||||
layer_name_map &layer_names ()
|
||||
{
|
||||
return m_layer_names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enters the a layer with a given layer/datatype
|
||||
*/
|
||||
std::pair <bool, unsigned int> open_dl (db::Layout &layout, const LDPair &dl);
|
||||
|
||||
private:
|
||||
std::map<size_t, std::pair<std::string, db::cell_index_type> > m_id_map;
|
||||
std::map<std::string, std::pair<size_t, db::cell_index_type> > m_name_map;
|
||||
std::map<size_t, std::string> m_name_for_id;
|
||||
CellConflictResolution m_cc_resolution;
|
||||
bool m_create_layers;
|
||||
db::CommonReaderOptions m_common_options;
|
||||
db::LayerMap m_layer_map_out;
|
||||
tl::interval_map <db::ld_type, tl::interval_map <db::ld_type, std::string> > m_layer_names;
|
||||
std::map<db::LDPair, std::pair <bool, unsigned int> > m_layer_cache;
|
||||
std::map<std::set<unsigned int>, unsigned int> m_multi_mapping_placeholders;
|
||||
std::set<unsigned int> m_layers_created;
|
||||
|
||||
std::pair <bool, unsigned int> open_dl_uncached (db::Layout &layout, const LDPair &dl);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Structure that holds the GDS2 and OASIS specific options for the reader
|
||||
* @brief A utility class that maps the layers for the proxy cell recovery
|
||||
*/
|
||||
class DB_PUBLIC CommonReaderOptions
|
||||
: public FormatSpecificReaderOptions
|
||||
class CommonReaderLayerMapping
|
||||
: public db::ImportLayerMapping
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
CommonReaderOptions ()
|
||||
: create_other_layers (true),
|
||||
enable_text_objects (true),
|
||||
enable_properties (true),
|
||||
cell_conflict_resolution (CommonReader::AddToCell)
|
||||
CommonReaderLayerMapping (db::CommonReader *reader, db::Layout *layout)
|
||||
: mp_reader (reader), mp_layout (layout)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Specifies a layer mapping
|
||||
*
|
||||
* If a layer mapping is specified, only the given layers are read.
|
||||
* Otherwise, all layers are read.
|
||||
* Setting "create_other_layers" to true will make the reader
|
||||
* create other layers for all layers not given in the layer map.
|
||||
* Setting an empty layer map and create_other_layers to true effectively
|
||||
* enables all layers for reading.
|
||||
*/
|
||||
db::LayerMap layer_map;
|
||||
|
||||
/**
|
||||
* @brief A flag indicating that a new layers shall be created
|
||||
*
|
||||
* If this flag is set to true, layers not listed in the layer map a created
|
||||
* too.
|
||||
*/
|
||||
bool create_other_layers;
|
||||
|
||||
/**
|
||||
* @brief A flag indicating whether to read text objects
|
||||
*
|
||||
* If this flag is set to true, text objects are read. Otherwise they are ignored.
|
||||
*/
|
||||
bool enable_text_objects;
|
||||
|
||||
/**
|
||||
* @brief A flag indicating whether to read user properties
|
||||
*
|
||||
* If this flag is set to true, user properties are read. Otherwise they are ignored.
|
||||
*/
|
||||
bool enable_properties;
|
||||
|
||||
/**
|
||||
* @brief Specifies the cell merge behavior
|
||||
*
|
||||
* This enum controls how cells are read if a cell with the requested name already
|
||||
* exists.
|
||||
*
|
||||
* AddToCell In this mode, instances or shapes are added to any existing cell
|
||||
* OverwriteCell Overwrite existing cell. If the existing cell has children, those are removed unless used otherwise
|
||||
* SkipNewCell Ignore the new cell and it's children
|
||||
* RenameCell Rename the new cell
|
||||
*
|
||||
* If the existing opr the new cell is a ghost cell, AddToCell is applied always. In other words,
|
||||
* ghost cells are always merged.
|
||||
*/
|
||||
CommonReader::CellConflictResolution cell_conflict_resolution;
|
||||
|
||||
/**
|
||||
* @brief Implementation of FormatSpecificReaderOptions
|
||||
*/
|
||||
virtual FormatSpecificReaderOptions *clone () const
|
||||
std::pair<bool, unsigned int> map_layer (const db::LayerProperties &lprops)
|
||||
{
|
||||
return new CommonReaderOptions (*this);
|
||||
// named layers that are imported from a library are ignored
|
||||
if (lprops.is_named ()) {
|
||||
return std::make_pair (false, 0);
|
||||
} else {
|
||||
return mp_reader->open_dl (*mp_layout, LDPair (lprops.layer, lprops.datatype));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Implementation of FormatSpecificReaderOptions
|
||||
*/
|
||||
virtual const std::string &format_name () const
|
||||
{
|
||||
static const std::string n ("Common");
|
||||
return n;
|
||||
}
|
||||
private:
|
||||
db::CommonReader *mp_reader;
|
||||
db::Layout *mp_layout;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,9 +174,9 @@ TextGenerator::load_from_data (const char *data, size_t ndata, const std::string
|
|||
m_description = description;
|
||||
m_name = name;
|
||||
|
||||
std::pair<bool, unsigned int> l1 = map.logical (db::LDPair (1, 0));
|
||||
std::pair<bool, unsigned int> l2 = map.logical (db::LDPair (2, 0));
|
||||
std::pair<bool, unsigned int> l3 = map.logical (db::LDPair (3, 0));
|
||||
std::pair<bool, unsigned int> l1 = map.first_logical (db::LDPair (1, 0));
|
||||
std::pair<bool, unsigned int> l2 = map.first_logical (db::LDPair (2, 0));
|
||||
std::pair<bool, unsigned int> l3 = map.first_logical (db::LDPair (3, 0));
|
||||
|
||||
if (l1.first && l2.first) {
|
||||
read_from_layout (layout, l1.second, l2.second, l3.second);
|
||||
|
|
@ -193,9 +193,9 @@ TextGenerator::load_from_file (const std::string &filename)
|
|||
|
||||
m_description = filename;
|
||||
|
||||
std::pair<bool, unsigned int> l1 = map.logical (db::LDPair (1, 0));
|
||||
std::pair<bool, unsigned int> l2 = map.logical (db::LDPair (2, 0));
|
||||
std::pair<bool, unsigned int> l3 = map.logical (db::LDPair (3, 0));
|
||||
std::pair<bool, unsigned int> l1 = map.first_logical (db::LDPair (1, 0));
|
||||
std::pair<bool, unsigned int> l2 = map.first_logical (db::LDPair (2, 0));
|
||||
std::pair<bool, unsigned int> l3 = map.first_logical (db::LDPair (3, 0));
|
||||
|
||||
if (l1.first && l2.first) {
|
||||
read_from_layout (layout, l1.second, l2.second, l3.second);
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ public:
|
|||
{
|
||||
// get the layers which we have to look for
|
||||
for (db::Layout::layer_iterator l = layout->begin_layers (); l != layout->end_layers (); ++l) {
|
||||
if (layers.is_empty () || layers.logical (*(*l).second).first) {
|
||||
if (layers.is_empty () || layers.is_mapped (*(*l).second)) {
|
||||
m_layers.push_back ((*l).first);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,21 +122,38 @@ extract_ld (const char *s, int &l, int &d, std::string &n)
|
|||
|
||||
std::pair <bool, unsigned int>
|
||||
NamedLayerReader::open_layer (db::Layout &layout, const std::string &n)
|
||||
{
|
||||
return open_layer (layout, n, keep_layer_names (), create_layers ());
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
NamedLayerReader::open_layer (db::Layout &layout, const std::string &n, bool keep_layer_name, bool create_layer)
|
||||
{
|
||||
std::map<std::string, std::pair <bool, unsigned int> >::const_iterator lc = m_layer_cache.find (n);
|
||||
if (lc != m_layer_cache.end ()) {
|
||||
return lc->second;
|
||||
} else {
|
||||
std::pair <bool, unsigned int> res = open_layer_uncached (layout, n, keep_layer_name, create_layer);
|
||||
m_layer_cache.insert (std::make_pair (n, res));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
NamedLayerReader::open_layer_uncached (db::Layout &layout, const std::string &n, bool keep_layer_name, bool create_layer)
|
||||
{
|
||||
int l = -1, d = -1;
|
||||
std::string on;
|
||||
|
||||
std::pair<bool, unsigned int> ll (false, 0);
|
||||
|
||||
ll = m_layer_map.logical (n, layout);
|
||||
if (! ll.first && !m_keep_layer_names) {
|
||||
std::set<unsigned int> li = m_layer_map.logical (n, layout);
|
||||
if (li.empty () && ! keep_layer_name) {
|
||||
|
||||
if (extract_plain_layer (n.c_str (), l)) {
|
||||
|
||||
db::LayerProperties lp;
|
||||
lp.layer = l;
|
||||
lp.datatype = 0;
|
||||
ll = m_layer_map.logical (lp, layout);
|
||||
li = m_layer_map.logical (lp, layout);
|
||||
|
||||
} else if (extract_ld (n.c_str (), l, d, on)) {
|
||||
|
||||
|
|
@ -144,22 +161,35 @@ NamedLayerReader::open_layer (db::Layout &layout, const std::string &n)
|
|||
lp.layer = l;
|
||||
lp.datatype = d;
|
||||
lp.name = on;
|
||||
ll = m_layer_map.logical (lp, layout);
|
||||
li = m_layer_map.logical (lp, layout);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ll.first) {
|
||||
if (! li.empty ()) {
|
||||
|
||||
// create the layer if it is not part of the layout yet.
|
||||
if (! layout.is_valid_layer (ll.second)) {
|
||||
layout.insert_layer (ll.second, m_layer_map.mapping (ll.second));
|
||||
for (std::set<unsigned int>::const_iterator i = li.begin (); i != li.end (); ++i) {
|
||||
m_layer_map_out.mmap (n, *i, layout.get_properties (*i));
|
||||
}
|
||||
|
||||
return ll;
|
||||
if (li.size () == 1) {
|
||||
|
||||
} else if (! m_create_layers) {
|
||||
return std::make_pair (true, *li.begin ());
|
||||
|
||||
} else {
|
||||
|
||||
std::map<std::set<unsigned int>, unsigned int>::iterator mmp = m_multi_mapping_placeholders.find (li);
|
||||
if (mmp == m_multi_mapping_placeholders.end ()) {
|
||||
// create a placeholder layer for later
|
||||
mmp = m_multi_mapping_placeholders.insert (std::make_pair (li, layout.insert_layer ())).first;
|
||||
}
|
||||
|
||||
return std::make_pair (true, mmp->second);
|
||||
|
||||
}
|
||||
|
||||
} else if (! create_layer) {
|
||||
|
||||
return std::pair<bool, unsigned int> (false, 0);
|
||||
|
||||
|
|
@ -188,21 +218,53 @@ NamedLayerReader::open_layer (db::Layout &layout, const std::string &n)
|
|||
void
|
||||
NamedLayerReader::map_layer (const std::string &name, unsigned int layer)
|
||||
{
|
||||
m_layer_map.map (name, layer);
|
||||
m_layer_cache [name] = std::make_pair (true, layer);
|
||||
m_layer_map_out.map (name, layer);
|
||||
}
|
||||
|
||||
void
|
||||
NamedLayerReader::prepare_layers ()
|
||||
NamedLayerReader::prepare_layers (db::Layout &layout)
|
||||
{
|
||||
m_new_layers.clear ();
|
||||
m_next_layer_index = m_layer_map.next_index ();
|
||||
|
||||
m_layer_map_out.clear ();
|
||||
m_multi_mapping_placeholders.clear ();
|
||||
m_layer_cache.clear ();
|
||||
|
||||
m_layer_map.prepare (layout);
|
||||
}
|
||||
|
||||
void
|
||||
NamedLayerReader::finish_layers (db::Layout &layout)
|
||||
{
|
||||
// resolve layer multi-mapping
|
||||
|
||||
for (std::map<std::set<unsigned int>, unsigned int>::const_iterator i = m_multi_mapping_placeholders.begin (); i != m_multi_mapping_placeholders.end (); ++i) {
|
||||
|
||||
if (i->first.size () > 1) {
|
||||
|
||||
bool discard_layer = i->first.find (i->second) == i->first.end ();
|
||||
|
||||
for (std::set<unsigned int>::const_iterator l = i->first.begin (); l != i->first.end (); ++l) {
|
||||
|
||||
// last one? this one will get a "move"
|
||||
std::set<unsigned int>::const_iterator ll = l;
|
||||
if (discard_layer && ++ll == i->first.end ()) {
|
||||
layout.move_layer (i->second, *l);
|
||||
layout.delete_layer (i->second);
|
||||
} else {
|
||||
layout.copy_layer (i->second, *l);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// assign layer numbers to new layers
|
||||
if (! m_new_layers.empty () && !m_keep_layer_names) {
|
||||
if (! m_new_layers.empty () && ! m_keep_layer_names) {
|
||||
|
||||
std::set<std::pair<int, int> > used_ld;
|
||||
for (db::Layout::layer_iterator l = layout.begin_layers (); l != layout.end_layers (); ++l) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public:
|
|||
*/
|
||||
NamedLayerReader ();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Sets a value indicating whether to create new layers
|
||||
*/
|
||||
|
|
@ -73,13 +74,21 @@ public:
|
|||
void set_layer_map (const LayerMap &lm);
|
||||
|
||||
/**
|
||||
* @brief Gets the layer map
|
||||
* @brief Gets the input layer map
|
||||
*/
|
||||
const LayerMap &layer_map ()
|
||||
{
|
||||
return m_layer_map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the layer map
|
||||
*/
|
||||
const LayerMap &layer_map_out ()
|
||||
{
|
||||
return m_layer_map_out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a value indicating whether layer names are kept
|
||||
* If set to true, no name translation is performed and layers are
|
||||
|
|
@ -96,7 +105,6 @@ public:
|
|||
return m_keep_layer_names;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Opens a new layer
|
||||
* This method will create or locate a layer for a given name.
|
||||
|
|
@ -105,6 +113,14 @@ protected:
|
|||
*/
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Opens a new layer
|
||||
* This method will create or locate a layer for a given name.
|
||||
* The result's first attribute is true, if such a layer could be found
|
||||
* or created. In this case, the second attribute is the layer index.
|
||||
*/
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &name, bool keep_layer_name, bool create_layer);
|
||||
|
||||
/**
|
||||
* @brief Force mapping of a name to a layer index
|
||||
*/
|
||||
|
|
@ -121,7 +137,7 @@ protected:
|
|||
* @brief Prepares reading
|
||||
* This method must be called before the reading is done.
|
||||
*/
|
||||
void prepare_layers ();
|
||||
void prepare_layers (db::Layout &layout);
|
||||
|
||||
private:
|
||||
bool m_create_layers;
|
||||
|
|
@ -129,6 +145,11 @@ private:
|
|||
LayerMap m_layer_map;
|
||||
unsigned int m_next_layer_index;
|
||||
std::map <std::string, unsigned int> m_new_layers;
|
||||
db::LayerMap m_layer_map_out;
|
||||
std::map<std::string, std::pair <bool, unsigned int> > m_layer_cache;
|
||||
std::map<std::set<unsigned int>, unsigned int> m_multi_mapping_placeholders;
|
||||
|
||||
std::pair <bool, unsigned int> open_layer_uncached (db::Layout &layout, const std::string &name, bool keep_layer_name, bool create_layer);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,33 @@
|
|||
namespace db
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
DB_PUBLIC void
|
||||
join_layer_names (std::string &s, const std::string &n)
|
||||
{
|
||||
if (s == n) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! s.empty ()) {
|
||||
|
||||
size_t i = s.find (n);
|
||||
if (i != std::string::npos && (i == 0 || s.c_str ()[i - 1] == ';')) {
|
||||
char after = s.c_str ()[i + n.size ()];
|
||||
if (after == 0 || after == ';') {
|
||||
// n is already contained in s
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
s += ";";
|
||||
|
||||
}
|
||||
|
||||
s += n;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// ReaderBase implementation
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,14 @@ public:
|
|||
{ }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Joins layer names into a single, combined layer
|
||||
* @param s The first layer name and output
|
||||
* @param n The name to add
|
||||
*/
|
||||
DB_PUBLIC void
|
||||
join_layer_names (std::string &s, const std::string &n);
|
||||
|
||||
/**
|
||||
* @brief The generic reader base class
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,10 +40,9 @@ namespace db
|
|||
/// A helper class to join two datatype map members
|
||||
struct LmapJoinOp1
|
||||
{
|
||||
void operator() (unsigned int &a, unsigned int b)
|
||||
void operator() (std::set<unsigned int> &a, const std::set<unsigned int> &b)
|
||||
{
|
||||
// TODO: could also do?: throw an exception ..
|
||||
a = b;
|
||||
a.insert (b.begin (), b.end ());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -58,7 +57,27 @@ struct LmapJoinOp2
|
|||
}
|
||||
};
|
||||
|
||||
/// Utility typedefs for the expression parser
|
||||
/// A helper class to implement the unmap operation
|
||||
struct LmapEraseDatatypeInterval
|
||||
{
|
||||
LmapEraseDatatypeInterval (unsigned int dfrom, unsigned int dto)
|
||||
: m_dfrom (dfrom), m_dto (dto)
|
||||
{ }
|
||||
|
||||
void operator() (LayerMap::datatype_map &a, const LayerMap::datatype_map &)
|
||||
{
|
||||
if (is_static_ld (m_dfrom) && is_static_ld (m_dto)) {
|
||||
a.erase (m_dfrom, m_dto + 1);
|
||||
} else {
|
||||
a.clear ();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int m_dfrom, m_dto;
|
||||
};
|
||||
|
||||
/// Utility typedefs for the expression parser
|
||||
typedef std::pair<ld_type, ld_type> ld_interval;
|
||||
|
||||
/// Utility typedefs for the expression parser
|
||||
|
|
@ -71,70 +90,104 @@ LayerMap::LayerMap ()
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
bool
|
||||
LayerMap::is_mapped (const LDPair &p) const
|
||||
{
|
||||
const datatype_map *dm = m_ld_map.mapped (p.layer);
|
||||
if (!dm) {
|
||||
return false;
|
||||
}
|
||||
const std::set<unsigned int> *l = dm->mapped (p.datatype);
|
||||
return (l && ! l->empty ());
|
||||
}
|
||||
|
||||
bool
|
||||
LayerMap::is_mapped (const std::string &n) const
|
||||
{
|
||||
std::map<std::string, std::set<unsigned int> >::const_iterator m = m_name_map.find (n);
|
||||
return m != m_name_map.end () && ! m->second.empty ();
|
||||
}
|
||||
|
||||
bool
|
||||
LayerMap::is_mapped (const db::LayerProperties &p) const
|
||||
{
|
||||
std::set<unsigned int> m;
|
||||
if (p.layer >= 0 && p.datatype >= 0) {
|
||||
if (is_mapped (db::LDPair (p.layer, p.datatype))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (! p.name.empty ()) {
|
||||
return is_mapped (p.name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical (const LDPair &p) const
|
||||
{
|
||||
return logical_internal (p, false);
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical (const std::string &n) const
|
||||
{
|
||||
return logical_internal (n, false);
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical (const db::LayerProperties &p) const
|
||||
{
|
||||
return logical_internal (p, false);
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical_internal (const LDPair &p, bool allow_placeholder) const
|
||||
{
|
||||
const datatype_map *dm = m_ld_map.mapped (p.layer);
|
||||
if (dm) {
|
||||
const unsigned int *l = dm->mapped (p.datatype);
|
||||
const std::set<unsigned int> *l = dm->mapped (p.datatype);
|
||||
if (l && (allow_placeholder || ! is_placeholder (*l))) {
|
||||
return std::make_pair (true, *l);
|
||||
return *l;
|
||||
}
|
||||
}
|
||||
return std::make_pair (false, 0);
|
||||
return std::set<unsigned int> ();
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical_internal (const std::string &n, bool allow_placeholder) const
|
||||
{
|
||||
std::map<std::string, unsigned int>::const_iterator m = m_name_map.find (n);
|
||||
std::map<std::string, std::set<unsigned int> >::const_iterator m = m_name_map.find (n);
|
||||
if (m != m_name_map.end () && (allow_placeholder || ! is_placeholder (m->second))) {
|
||||
return std::make_pair (true, m->second);
|
||||
return m->second;
|
||||
} else {
|
||||
return std::make_pair (false, 0);
|
||||
return std::set<unsigned int> ();
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical_internal (const db::LayerProperties &p, bool allow_placeholder) const
|
||||
{
|
||||
std::set<unsigned int> m;
|
||||
if (p.layer >= 0 && p.datatype >= 0) {
|
||||
std::pair<bool, unsigned int> m = logical_internal (db::LDPair (p.layer, p.datatype), allow_placeholder);
|
||||
if (m.first) {
|
||||
return m;
|
||||
}
|
||||
m = logical_internal (db::LDPair (p.layer, p.datatype), allow_placeholder);
|
||||
}
|
||||
if (! p.name.empty ()) {
|
||||
std::pair<bool, unsigned int> m = logical_internal (p.name, allow_placeholder);
|
||||
if (m.first) {
|
||||
return m;
|
||||
}
|
||||
if (m.empty () && ! p.name.empty ()) {
|
||||
m = logical_internal (p.name, allow_placeholder);
|
||||
}
|
||||
return std::make_pair (false, 0);
|
||||
return m;
|
||||
}
|
||||
|
||||
bool
|
||||
LayerMap::is_placeholder (unsigned int l) const
|
||||
LayerMap::is_placeholder (const std::set<unsigned int> &m) const
|
||||
{
|
||||
return (m_placeholders.size () > std::numeric_limits<unsigned int>::max () - l);
|
||||
for (std::set<unsigned int>::const_iterator i = m.begin (); i != m.end (); ++i) {
|
||||
if (m_placeholders.size () > std::numeric_limits<unsigned int>::max () - *i) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const db::LayerProperties *
|
||||
|
|
@ -148,39 +201,52 @@ LayerMap::target (unsigned int l) const
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical (const db::LayerProperties &p, db::Layout &layout) const
|
||||
{
|
||||
std::pair<bool, unsigned int> l = logical_internal (p, true);
|
||||
if (l.first && is_placeholder (l.second)) {
|
||||
return const_cast<LayerMap *> (this)->substitute_placeholder (p, l.second, layout);
|
||||
std::set<unsigned int> l = logical_internal (p, true);
|
||||
if (is_placeholder (l)) {
|
||||
return const_cast<LayerMap *> (this)->substitute_placeholder (p, l, layout);
|
||||
} else {
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
std::set<unsigned int>
|
||||
LayerMap::logical (const db::LDPair &p, db::Layout &layout) const
|
||||
{
|
||||
std::pair<bool, unsigned int> l = logical_internal (p, true);
|
||||
if (l.first && is_placeholder (l.second)) {
|
||||
return const_cast<LayerMap *> (this)->substitute_placeholder (db::LayerProperties (p.layer, p.datatype), l.second, layout);
|
||||
std::set<unsigned int> l = logical_internal (p, true);
|
||||
if (is_placeholder (l)) {
|
||||
return const_cast<LayerMap *> (this)->substitute_placeholder (db::LayerProperties (p.layer, p.datatype), l, layout);
|
||||
} else {
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int>
|
||||
LayerMap::substitute_placeholder (const db::LayerProperties &p, unsigned int ph, db::Layout &layout)
|
||||
std::set<unsigned int>
|
||||
LayerMap::substitute_placeholder (const db::LayerProperties &p, const std::set<unsigned int> &m, db::Layout &layout)
|
||||
{
|
||||
const db::LayerProperties &lp_ph = m_placeholders [std::numeric_limits<unsigned int>::max () - ph];
|
||||
db::LayerProperties lp_new = p;
|
||||
lp_new.layer = db::ld_combine (p.layer, lp_ph.layer);
|
||||
lp_new.datatype = db::ld_combine (p.datatype, lp_ph.datatype);
|
||||
std::set<unsigned int> res;
|
||||
for (std::set<unsigned int>::const_iterator i = m.begin (); i != m.end (); ++i) {
|
||||
|
||||
unsigned int l_new = layout.insert_layer (lp_new);
|
||||
map (p, l_new, lp_new);
|
||||
return std::make_pair (true, l_new);
|
||||
if (m_placeholders.size () > std::numeric_limits<unsigned int>::max () - *i) {
|
||||
|
||||
const db::LayerProperties &lp_ph = m_placeholders [std::numeric_limits<unsigned int>::max () - *i];
|
||||
db::LayerProperties lp_new = p;
|
||||
lp_new.layer = db::ld_combine (p.layer, lp_ph.layer);
|
||||
lp_new.datatype = db::ld_combine (p.datatype, lp_ph.datatype);
|
||||
|
||||
unsigned int l_new = layout.insert_layer (lp_new);
|
||||
map (p, l_new, lp_new);
|
||||
res.insert (l_new);
|
||||
|
||||
} else {
|
||||
res.insert (*i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::string format_interval (ld_type l1, ld_type l2)
|
||||
|
|
@ -196,44 +262,93 @@ static std::string format_interval (ld_type l1, ld_type l2)
|
|||
}
|
||||
}
|
||||
|
||||
static std::vector<std::pair<ld_type, ld_type> >
|
||||
extract_dt_intervals (const LayerMap::datatype_map &dt_map, int ll, bool &has_others)
|
||||
{
|
||||
std::vector<std::pair<ld_type, ld_type> > res;
|
||||
|
||||
for (LayerMap::datatype_map::const_iterator d = dt_map.begin (); d != dt_map.end (); ) {
|
||||
|
||||
if (d->second.find (ll) != d->second.end ()) {
|
||||
|
||||
std::pair<ld_type, ld_type> dpi = d->first;
|
||||
|
||||
if (d->second.size () > 1) {
|
||||
has_others = true;
|
||||
}
|
||||
|
||||
LayerMap::datatype_map::const_iterator dd = d;
|
||||
++dd;
|
||||
while (dd != dt_map.end () && dd->first.first == dpi.second && dd->second.find (ll) != dd->second.end ()) {
|
||||
if (dd->second.size () > 1) {
|
||||
has_others = true;
|
||||
}
|
||||
dpi.second = dd->first.second;
|
||||
++dd;
|
||||
}
|
||||
|
||||
d = dd;
|
||||
|
||||
res.push_back (dpi);
|
||||
|
||||
} else {
|
||||
++d;
|
||||
}
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string
|
||||
LayerMap::mapping_str (unsigned int ll) const
|
||||
{
|
||||
std::string s;
|
||||
bool f1 = true;
|
||||
bool is_mmap = false;
|
||||
|
||||
for (ld_map::const_iterator l = m_ld_map.begin (); l != m_ld_map.end (); ++l) {
|
||||
for (ld_map::const_iterator l = m_ld_map.begin (); l != m_ld_map.end (); ) {
|
||||
|
||||
std::pair<ld_type, ld_type> lti = l->first;
|
||||
|
||||
std::vector<std::pair<ld_type, ld_type> > dti = extract_dt_intervals (l->second, ll, is_mmap);
|
||||
++l;
|
||||
while (l != m_ld_map.end () && lti.second == l->first.first && extract_dt_intervals (l->second, ll, is_mmap) == dti) {
|
||||
lti.second = l->first.second;
|
||||
++l;
|
||||
}
|
||||
|
||||
bool f2 = true;
|
||||
for (datatype_map::const_iterator d = l->second.begin (); d != l->second.end (); ++d) {
|
||||
if (d->second == ll) {
|
||||
for (std::vector<std::pair<ld_type, ld_type> >::const_iterator d = dti.begin (); d != dti.end (); ++d) {
|
||||
|
||||
// create a string representation
|
||||
if (!f2) {
|
||||
s += ",";
|
||||
} else {
|
||||
|
||||
if (!f1) {
|
||||
s += ";";
|
||||
}
|
||||
f1 = false;
|
||||
|
||||
s += format_interval (l->first.first, l->first.second);
|
||||
s += "/";
|
||||
// create a string representation
|
||||
if (!f2) {
|
||||
s += ",";
|
||||
} else {
|
||||
|
||||
if (!f1) {
|
||||
s += ";";
|
||||
}
|
||||
f2 = false;
|
||||
f1 = false;
|
||||
|
||||
s += format_interval (d->first.first, d->first.second);
|
||||
s += format_interval (lti.first, lti.second);
|
||||
s += "/";
|
||||
|
||||
}
|
||||
f2 = false;
|
||||
|
||||
s += format_interval (d->first, d->second);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (std::map <std::string, unsigned int>::const_iterator l = m_name_map.begin (); l != m_name_map.end (); ++l) {
|
||||
if (l->second == ll) {
|
||||
for (std::map <std::string, std::set<unsigned int> >::const_iterator l = m_name_map.begin (); l != m_name_map.end (); ++l) {
|
||||
|
||||
if (l->second.find (ll) != l->second.end ()) {
|
||||
|
||||
if (l->second.size () > 1) {
|
||||
is_mmap = true;
|
||||
}
|
||||
|
||||
if (!f1) {
|
||||
s += ";";
|
||||
|
|
@ -243,6 +358,7 @@ LayerMap::mapping_str (unsigned int ll) const
|
|||
s += tl::to_word_or_quoted_string (l->first);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::map<unsigned int, LayerProperties>::const_iterator t = m_target_layers.find (ll);
|
||||
|
|
@ -251,7 +367,11 @@ LayerMap::mapping_str (unsigned int ll) const
|
|||
s += t->second.to_string (true);
|
||||
}
|
||||
|
||||
return s;
|
||||
if (is_mmap) {
|
||||
return "+" + s;
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -300,11 +420,19 @@ LayerMap::prepare (db::Layout &layout)
|
|||
// Now remap the indexes
|
||||
for (ld_map::iterator l = m_ld_map.begin (); l != m_ld_map.end (); ++l) {
|
||||
for (datatype_map::iterator d = l->second.begin (); d != l->second.end (); ++d) {
|
||||
d->second = real_layers [d->second];
|
||||
std::set<unsigned int> dn;
|
||||
for (std::set<unsigned int>::const_iterator i = d->second.begin (); i != d->second.end (); ++i) {
|
||||
dn.insert (real_layers [*i]);
|
||||
}
|
||||
d->second = dn;
|
||||
}
|
||||
}
|
||||
for (std::map<std::string, unsigned int>::iterator n = m_name_map.begin (); n != m_name_map.end (); ++n) {
|
||||
n->second = real_layers [n->second];
|
||||
for (std::map<std::string, std::set<unsigned int> >::iterator n = m_name_map.begin (); n != m_name_map.end (); ++n) {
|
||||
std::set<unsigned int> dn;
|
||||
for (std::set<unsigned int>::const_iterator i = n->second.begin (); i != n->second.end (); ++i) {
|
||||
dn.insert (real_layers [*i]);
|
||||
}
|
||||
n->second = dn;
|
||||
}
|
||||
|
||||
std::map<unsigned int, LayerProperties> old_target_layers;
|
||||
|
|
@ -329,11 +457,11 @@ LayerMap::get_layers () const
|
|||
|
||||
for (ld_map::const_iterator l = m_ld_map.begin (); l != m_ld_map.end (); ++l) {
|
||||
for (datatype_map::const_iterator d = l->second.begin (); d != l->second.end (); ++d) {
|
||||
layers.insert (d->second);
|
||||
layers.insert (d->second.begin (), d->second.end ());
|
||||
}
|
||||
}
|
||||
for (const_iterator_names n = m_name_map.begin (); n != m_name_map.end (); ++n) {
|
||||
layers.insert(n->second);
|
||||
layers.insert(n->second.begin (), n->second.end ());
|
||||
}
|
||||
|
||||
return std::vector<unsigned int> (layers.begin (), layers.end ());
|
||||
|
|
@ -358,7 +486,7 @@ LayerMap::mapping (unsigned int ll) const
|
|||
// no mapping is given. Use the lowest layer and datatype
|
||||
for (ld_map::const_iterator l = m_ld_map.begin (); l != m_ld_map.end (); ++l) {
|
||||
for (datatype_map::const_iterator d = l->second.begin (); d != l->second.end (); ++d) {
|
||||
if (d->second == ll) {
|
||||
if (d->second.find (ll) != d->second.end ()) {
|
||||
p.layer = l->first.first;
|
||||
p.datatype = d->first.first;
|
||||
break;
|
||||
|
|
@ -373,7 +501,7 @@ LayerMap::mapping (unsigned int ll) const
|
|||
// no mapping is given. Use the lowest layer and datatype
|
||||
for (ld_map::const_iterator l = m_ld_map.begin (); l != m_ld_map.end (); ++l) {
|
||||
for (datatype_map::const_iterator d = l->second.begin (); d != l->second.end (); ++d) {
|
||||
if (d->second == ll) {
|
||||
if (d->second.find (ll) != d->second.end ()) {
|
||||
p.layer = l->first.first;
|
||||
p.datatype = d->first.first;
|
||||
break;
|
||||
|
|
@ -384,8 +512,8 @@ LayerMap::mapping (unsigned int ll) const
|
|||
}
|
||||
|
||||
if (p.name.empty ()) {
|
||||
for (std::map <std::string, unsigned int>::const_iterator l = m_name_map.begin (); l != m_name_map.end (); ++l) {
|
||||
if (l->second == ll) {
|
||||
for (std::map <std::string, std::set<unsigned int> >::const_iterator l = m_name_map.begin (); l != m_name_map.end (); ++l) {
|
||||
if (l->second.find (ll) != l->second.end ()) {
|
||||
p.name = l->first;
|
||||
break;
|
||||
}
|
||||
|
|
@ -397,59 +525,59 @@ LayerMap::mapping (unsigned int ll) const
|
|||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const LDPair &p, unsigned int l)
|
||||
LayerMap::mmap (const LDPair &p, unsigned int l)
|
||||
{
|
||||
insert (p, p, l, (const LayerProperties *) 0);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const std::string &name, unsigned int l)
|
||||
LayerMap::mmap (const std::string &name, unsigned int l)
|
||||
{
|
||||
insert (name, l, (const LayerProperties *) 0);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const LayerProperties &f, unsigned int l)
|
||||
LayerMap::mmap (const LayerProperties &f, unsigned int l)
|
||||
{
|
||||
if (f.name.empty () || is_static_ld (f.layer) || is_static_ld (f.datatype)) {
|
||||
map (db::LDPair (f.layer, f.datatype), l);
|
||||
mmap (db::LDPair (f.layer, f.datatype), l);
|
||||
}
|
||||
if (! f.name.empty ()) {
|
||||
map (f.name, l);
|
||||
mmap (f.name, l);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const LDPair &p, unsigned int l, const LayerProperties &t)
|
||||
LayerMap::mmap (const LDPair &p, unsigned int l, const LayerProperties &t)
|
||||
{
|
||||
insert (p, p, l, &t);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const std::string &name, unsigned int l, const LayerProperties &t)
|
||||
LayerMap::mmap (const std::string &name, unsigned int l, const LayerProperties &t)
|
||||
{
|
||||
insert (name, l, &t);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const LayerProperties &f, unsigned int l, const LayerProperties &t)
|
||||
LayerMap::mmap (const LayerProperties &f, unsigned int l, const LayerProperties &t)
|
||||
{
|
||||
if (f.name.empty () || is_static_ld (f.layer) || is_static_ld (f.datatype)) {
|
||||
map (db::LDPair (f.layer, f.datatype), l, t);
|
||||
mmap (db::LDPair (f.layer, f.datatype), l, t);
|
||||
}
|
||||
if (! f.name.empty ()) {
|
||||
map (f.name, l, t);
|
||||
mmap (f.name, l, t);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const LDPair &p1, const LDPair &p2, unsigned int l)
|
||||
LayerMap::mmap (const LDPair &p1, const LDPair &p2, unsigned int l)
|
||||
{
|
||||
insert (p1, p2, l, (const LayerProperties *) 0);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map (const LDPair &p1, const LDPair &p2, unsigned int l, const LayerProperties &lp)
|
||||
LayerMap::mmap (const LDPair &p1, const LDPair &p2, unsigned int l, const LayerProperties &lp)
|
||||
{
|
||||
insert (p1, p2, l, &lp);
|
||||
}
|
||||
|
|
@ -495,18 +623,25 @@ parse_intervals (tl::Extractor &ex, ld_interval_vector &v)
|
|||
}
|
||||
|
||||
void
|
||||
LayerMap::map_expr (const std::string &expr, unsigned int l)
|
||||
LayerMap::mmap_expr (const std::string &expr, unsigned int l)
|
||||
{
|
||||
tl::Extractor ex (expr.c_str ());
|
||||
map_expr (ex, l);
|
||||
mmap_expr (ex, l);
|
||||
ex.expect_end ();
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::map_expr (tl::Extractor &ex, unsigned int l)
|
||||
LayerMap::mmap_expr (tl::Extractor &ex, unsigned int l)
|
||||
{
|
||||
try {
|
||||
|
||||
bool round_bracket = false, square_bracket = false;
|
||||
if (ex.test ("(")) {
|
||||
round_bracket = true;
|
||||
} else if (ex.test ("[")) {
|
||||
square_bracket = true;
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
tl::Extractor ex_saved = ex;
|
||||
|
|
@ -515,7 +650,7 @@ LayerMap::map_expr (tl::Extractor &ex, unsigned int l)
|
|||
ld_type n;
|
||||
if (! ex.try_read (n) && ex.try_read_word_or_quoted (name)) {
|
||||
|
||||
m_name_map.insert (std::make_pair (name, l));
|
||||
m_name_map [name].insert (l);
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -533,7 +668,9 @@ LayerMap::map_expr (tl::Extractor &ex, unsigned int l)
|
|||
datatype_map dm;
|
||||
for (ld_interval_vector::const_iterator di = vd.begin (); di != vd.end (); ++di) {
|
||||
LmapJoinOp1 op1;
|
||||
dm.add (di->first, di->second + 1, l, op1);
|
||||
std::set<unsigned int> single;
|
||||
single.insert (l);
|
||||
dm.add (di->first, di->second + 1, single, op1);
|
||||
}
|
||||
for (ld_interval_vector::const_iterator li = vl.begin (); li != vl.end (); ++li) {
|
||||
LmapJoinOp2 op2;
|
||||
|
|
@ -548,7 +685,15 @@ LayerMap::map_expr (tl::Extractor &ex, unsigned int l)
|
|||
LayerProperties lp;
|
||||
lp.read (ex, true);
|
||||
m_target_layers[l] = lp;
|
||||
}
|
||||
} else if (square_bracket) {
|
||||
m_target_layers[l] = LayerProperties (db::any_ld (), db::any_ld ());
|
||||
}
|
||||
|
||||
if (round_bracket) {
|
||||
ex.expect (")");
|
||||
} else if (square_bracket) {
|
||||
ex.expect ("]");
|
||||
}
|
||||
|
||||
} catch (...) {
|
||||
throw LayerSpecFormatException (ex.skip ());
|
||||
|
|
@ -566,7 +711,7 @@ LayerMap::insert (const std::string &name, unsigned int l, const LayerProperties
|
|||
m_target_layers[l] = *target;
|
||||
}
|
||||
|
||||
m_name_map.insert (std::make_pair (name, l));
|
||||
m_name_map [name].insert (l);
|
||||
|
||||
if (l >= m_next_index) {
|
||||
m_next_index = l + 1;
|
||||
|
|
@ -580,13 +725,16 @@ LayerMap::insert (const LDPair &p1, const LDPair &p2, unsigned int l, const Laye
|
|||
m_target_layers[l] = *target;
|
||||
}
|
||||
|
||||
std::set<unsigned int> single;
|
||||
single.insert (l);
|
||||
|
||||
// create a single-interval list for the datatype range
|
||||
LayerMap::datatype_map dt;
|
||||
LmapJoinOp1 op1;
|
||||
if (db::is_static_ld (p1.datatype) && db::is_static_ld (p2.datatype)) {
|
||||
dt.add (p1.datatype, p2.datatype + 1, l, op1);
|
||||
dt.add (p1.datatype, p2.datatype + 1, single, op1);
|
||||
} else {
|
||||
dt.add (0, std::numeric_limits<ld_type>::max (), l, op1);
|
||||
dt.add (0, std::numeric_limits<ld_type>::max (), single, op1);
|
||||
}
|
||||
|
||||
// add this to the layers using the special join operator that
|
||||
|
|
@ -603,6 +751,117 @@ LayerMap::insert (const LDPair &p1, const LDPair &p2, unsigned int l, const Laye
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::unmap (const LDPair &f)
|
||||
{
|
||||
unmap (f, f);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::unmap (const std::string &name)
|
||||
{
|
||||
m_name_map.erase (name);
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::unmap (const LayerProperties &f)
|
||||
{
|
||||
if (f.name.empty () || is_static_ld (f.layer) || is_static_ld (f.datatype)) {
|
||||
unmap (db::LDPair (f.layer, f.datatype));
|
||||
}
|
||||
if (! f.name.empty ()) {
|
||||
unmap (f.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
LayerMap::unmap (const LDPair &p1, const LDPair &p2)
|
||||
{
|
||||
if (m_ld_map.begin () == m_ld_map.end ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LmapEraseDatatypeInterval op (p1.datatype, p2.datatype);
|
||||
if (db::is_static_ld (p1.layer) && db::is_static_ld (p2.layer)) {
|
||||
m_ld_map.add (p1.layer, p2.layer + 1, LayerMap::datatype_map (), op);
|
||||
} else {
|
||||
m_ld_map.add (m_ld_map.begin ()->first.first, m_ld_map.end ()->first.second, LayerMap::datatype_map (), op);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LayerMap::unmap_expr (const std::string &expr)
|
||||
{
|
||||
tl::Extractor ex (expr.c_str ());
|
||||
unmap_expr (ex);
|
||||
ex.expect_end ();
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::unmap_expr (tl::Extractor &ex)
|
||||
{
|
||||
try {
|
||||
|
||||
bool round_bracket = false, square_bracket = false;
|
||||
if (ex.test ("(")) {
|
||||
round_bracket = true;
|
||||
} else if (ex.test ("[")) {
|
||||
square_bracket = true;
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
tl::Extractor ex_saved = ex;
|
||||
|
||||
std::string name;
|
||||
ld_type n;
|
||||
if (! ex.try_read (n) && ex.try_read_word_or_quoted (name)) {
|
||||
|
||||
m_name_map.erase (name);
|
||||
|
||||
} else {
|
||||
|
||||
ex = ex_saved;
|
||||
ld_interval_vector vl, vd;
|
||||
|
||||
parse_intervals (ex, vl);
|
||||
|
||||
if (ex.test ("/")) {
|
||||
parse_intervals (ex, vd);
|
||||
} else {
|
||||
vd.push_back (ld_interval (0, 0));
|
||||
}
|
||||
|
||||
for (ld_interval_vector::const_iterator li = vl.begin (); li != vl.end (); ++li) {
|
||||
for (ld_interval_vector::const_iterator di = vd.begin (); di != vd.end (); ++di) {
|
||||
unmap (LDPair (li->first, di->first), LDPair (li->second, di->second));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} while (ex.test (";") || ex.test (","));
|
||||
|
||||
if (ex.test (":")) {
|
||||
// ignore target layers
|
||||
LayerProperties lp;
|
||||
lp.read (ex, true);
|
||||
}
|
||||
|
||||
if (round_bracket) {
|
||||
ex.expect (")");
|
||||
} else if (square_bracket) {
|
||||
ex.expect ("]");
|
||||
}
|
||||
|
||||
} catch (...) {
|
||||
throw LayerSpecFormatException (ex.skip ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::clear ()
|
||||
{
|
||||
|
|
@ -646,6 +905,26 @@ LayerMap::to_string_file_format () const
|
|||
return os.str ();
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::add_expr (const std::string &expr, unsigned int l)
|
||||
{
|
||||
tl::Extractor ex (expr.c_str ());
|
||||
add_expr (ex, l);
|
||||
ex.expect_end ();
|
||||
}
|
||||
|
||||
void
|
||||
LayerMap::add_expr (tl::Extractor &ex, unsigned int l)
|
||||
{
|
||||
if (ex.test ("+")) {
|
||||
mmap_expr (ex, l);
|
||||
} else if (ex.test ("-")) {
|
||||
unmap_expr (ex);
|
||||
} else {
|
||||
map_expr (ex, l);
|
||||
}
|
||||
}
|
||||
|
||||
db::LayerMap
|
||||
LayerMap::from_string_file_format (const std::string &s)
|
||||
{
|
||||
|
|
@ -668,7 +947,7 @@ LayerMap::from_string_file_format (const std::string &s)
|
|||
} else {
|
||||
|
||||
if (! ex.at_end ()) {
|
||||
lm.map_expr (ex, l);
|
||||
lm.add_expr (ex, l);
|
||||
if (ex.test ("#") || ex.test ("//")) {
|
||||
// ignore comments
|
||||
} else {
|
||||
|
|
@ -703,7 +982,7 @@ namespace tl
|
|||
while (! ex.test (")") && ! ex.at_end ()) {
|
||||
std::string m;
|
||||
ex.read_word_or_quoted (m);
|
||||
t.map_expr (m, l);
|
||||
t.add_expr (m, l);
|
||||
++l;
|
||||
ex.test (";");
|
||||
}
|
||||
|
|
@ -723,7 +1002,7 @@ namespace tl
|
|||
while (! ex.test (")") && ! ex.at_end ()) {
|
||||
std::string m;
|
||||
ex.read_word_or_quoted (m);
|
||||
t.map_expr (m, l);
|
||||
t.add_expr (m, l);
|
||||
++l;
|
||||
ex.test (";");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
|
@ -161,6 +162,15 @@ struct DB_PUBLIC LDPair
|
|||
* and effectively rename a layer or add layer name information to
|
||||
* a GDS layer/datatype layer.
|
||||
*
|
||||
* "Unmapping" can be used to create "holes" in ranges of layers.
|
||||
* For example, by first mapping layers 1 to 100, datatype 0 and then
|
||||
* unmapping layer 50, datatype 0, the layers 1 to 49 and 51 to 100, datatype 0
|
||||
* are mapped.
|
||||
*
|
||||
* The layer map supports multi-mapping. That is, one input layer is
|
||||
* mapped to multiple target layers. It also supports merging but
|
||||
* mapping different input layers to a single target layer.
|
||||
*
|
||||
* A layer map object can be used as a standalone object or in
|
||||
* conjunction with a layout object. As a standalone object, the
|
||||
* logical layers (indexes) are simply consecutive numbers.
|
||||
|
|
@ -178,24 +188,52 @@ class DB_PUBLIC LayerMap
|
|||
: public gsi::ObjectBase
|
||||
{
|
||||
public:
|
||||
typedef tl::interval_map<ld_type, unsigned int> datatype_map;
|
||||
typedef tl::interval_map<ld_type, std::set<unsigned int> > datatype_map;
|
||||
typedef tl::interval_map<ld_type, datatype_map> ld_map;
|
||||
typedef ld_map::const_iterator const_iterator_layers;
|
||||
typedef datatype_map::const_iterator const_iterator_datatypes;
|
||||
typedef std::map<std::string, unsigned int>::const_iterator const_iterator_names;
|
||||
typedef std::map<std::string, std::set<unsigned int> >::const_iterator const_iterator_names;
|
||||
|
||||
/**
|
||||
* @brief The constructor for an empty map
|
||||
*/
|
||||
LayerMap ();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Returns the first logical layer for a given layer specification
|
||||
*/
|
||||
template <class L>
|
||||
std::pair<bool, unsigned int> first_logical (const L &p) const
|
||||
{
|
||||
std::set<unsigned int> r = logical (p);
|
||||
if (r.empty ()) {
|
||||
return std::make_pair (false, 0);
|
||||
} else {
|
||||
return std::make_pair (true, *r.begin ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the first logical layer for a given layer specification
|
||||
*/
|
||||
template <class L>
|
||||
std::pair<bool, unsigned int> first_logical (const L &p, db::Layout &layout) const
|
||||
{
|
||||
std::set<unsigned int> r = logical (p, layout);
|
||||
if (r.empty ()) {
|
||||
return std::make_pair (false, 0);
|
||||
} else {
|
||||
return std::make_pair (true, *r.begin ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query a layer mapping
|
||||
*
|
||||
* @return A pair telling if the layer is mapped (first=true) and
|
||||
* the logical layer mapped (second) if this is the case.
|
||||
*/
|
||||
std::pair<bool, unsigned int> logical (const LDPair &p) const;
|
||||
std::set<unsigned int> logical (const LDPair &p) const;
|
||||
|
||||
/**
|
||||
* @brief Query a layer mapping from a name
|
||||
|
|
@ -203,7 +241,7 @@ public:
|
|||
* @return A pair telling if the layer is mapped (first=true) and
|
||||
* the logical layer mapped (second) if this is the case.
|
||||
*/
|
||||
std::pair<bool, unsigned int> logical (const std::string &name) const;
|
||||
std::set<unsigned int> logical (const std::string &name) const;
|
||||
|
||||
/**
|
||||
* @brief Query a layer mapping from a name or LDPair
|
||||
|
|
@ -213,7 +251,7 @@ public:
|
|||
*
|
||||
* @param p The layer that is looked for
|
||||
*/
|
||||
std::pair<bool, unsigned int> logical (const db::LayerProperties &p) const;
|
||||
std::set<unsigned int> logical (const db::LayerProperties &p) const;
|
||||
|
||||
/**
|
||||
* @brief A compatibility function for future enhancements
|
||||
|
|
@ -236,14 +274,29 @@ public:
|
|||
* the logical layers are placeholder values which will be replaced by
|
||||
* true layers during this method if a new layer is requested.
|
||||
*/
|
||||
std::pair<bool, unsigned int> logical (const db::LayerProperties &p, db::Layout &layout) const;
|
||||
std::set<unsigned int> logical (const db::LayerProperties &p, db::Layout &layout) const;
|
||||
|
||||
/**
|
||||
* @brief Query or install a layer mapping from a LDPair
|
||||
*
|
||||
* See the version for LayerProperties about details.
|
||||
*/
|
||||
std::pair<bool, unsigned int> logical (const db::LDPair &p, db::Layout &layout) const;
|
||||
std::set<unsigned int> logical (const db::LDPair &p, db::Layout &layout) const;
|
||||
|
||||
/**
|
||||
* @brief Returns a value indicating whether a layer (given by layer/datatype) is mapped
|
||||
*/
|
||||
bool is_mapped (const LDPair &p) const;
|
||||
|
||||
/**
|
||||
* @brief Returns a value indicating whether the given named layer is mapped
|
||||
*/
|
||||
bool is_mapped (const std::string &name) const;
|
||||
|
||||
/**
|
||||
* @brief Returns a value indicating whether a layer is mapped
|
||||
*/
|
||||
bool is_mapped (const db::LayerProperties &p) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the target layer for a given logical layer
|
||||
|
|
@ -279,17 +332,81 @@ public:
|
|||
std::vector<unsigned int> get_layers () const;
|
||||
|
||||
/**
|
||||
* @brief Map a ldpair to a logical layer
|
||||
* @brief Single-map a physical to a logical layer
|
||||
*
|
||||
* "Single-mapping" substitutes a layer mapping. "Multimapping" (mmap_..)
|
||||
* adds to a given mapping and allows generating 1:n mappings (m:n in fact).
|
||||
*/
|
||||
void map (const LDPair &p, unsigned int l);
|
||||
template <class S>
|
||||
void map (const S &p, unsigned int l)
|
||||
{
|
||||
unmap (p);
|
||||
mmap (p, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Map a name to a logical layer
|
||||
* @brief Single-map a physical to a logical layer with a target layer
|
||||
*/
|
||||
void map (const std::string &name, unsigned int l);
|
||||
template <class S>
|
||||
void map (const S &p, unsigned int l, const LayerProperties &t)
|
||||
{
|
||||
unmap (p);
|
||||
mmap (p, l, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Map a name or LDPair to a logical layer
|
||||
* @brief Single-map a physical layer interval with a target layer
|
||||
*/
|
||||
void map (const LDPair &p1, const LDPair &p2, unsigned int l)
|
||||
{
|
||||
unmap (p1, p2);
|
||||
mmap (p1, p2, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Single-map a physical layer interval with a target layer
|
||||
*/
|
||||
void map (const LDPair &p1, const LDPair &p2, unsigned int l, const LayerProperties &t)
|
||||
{
|
||||
unmap (p1, p2);
|
||||
mmap (p1, p2, l, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Single-map a physical layer interval (given by an expression)
|
||||
*/
|
||||
void map_expr (const std::string &expr, unsigned int l)
|
||||
{
|
||||
unmap_expr (expr);
|
||||
mmap_expr (expr, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Same a map_expr with a string argument but taking the expression for a tl::Extractor
|
||||
*/
|
||||
void map_expr (tl::Extractor &ex, unsigned int l)
|
||||
{
|
||||
tl::Extractor ex1 = ex;
|
||||
unmap_expr (ex1);
|
||||
mmap_expr (ex, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Multi-map a ldpair to a logical layer
|
||||
*
|
||||
* "Multimapping" will not substitute but add to the mapping.
|
||||
*/
|
||||
void mmap (const LDPair &p, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Multi-map a name to a logical layer
|
||||
*
|
||||
* "Multimapping" will not substitute but add to the mapping.
|
||||
*/
|
||||
void mmap (const std::string &name, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Multi-map a name or LDPair to a logical layer
|
||||
*
|
||||
* The algorithm chooses the LDPair from the LayerProperties structure and/or
|
||||
* the name if no LDPair is given. If the source LayerProperties structure does
|
||||
|
|
@ -298,26 +415,26 @@ public:
|
|||
* @param f The source (where to derive the match expression from)
|
||||
* @param l The logical layer to map to the match expression
|
||||
*/
|
||||
void map (const LayerProperties &f, unsigned int l);
|
||||
void mmap (const LayerProperties &f, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Map a ldpair to a logical layer with a target layer
|
||||
* @brief Multi-map a ldpair to a logical layer with a target layer
|
||||
*
|
||||
* The target layer specifies which layer to create for the
|
||||
* corresponding input.
|
||||
*/
|
||||
void map (const LDPair &p, unsigned int l, const LayerProperties &t);
|
||||
void mmap (const LDPair &p, unsigned int l, const LayerProperties &t);
|
||||
|
||||
/**
|
||||
* @brief Map a name to a logical layer with a target layer
|
||||
* @brief Multi-map a name to a logical layer with a target layer
|
||||
*
|
||||
* The target layer specifies which layer to create for the
|
||||
* corresponding input.
|
||||
*/
|
||||
void map (const std::string &name, unsigned int l, const LayerProperties &t);
|
||||
void mmap (const std::string &name, unsigned int l, const LayerProperties &t);
|
||||
|
||||
/**
|
||||
* @brief Map a name or LDPair to a logical layer with a target layer
|
||||
* @brief Multi-map a name or LDPair to a logical layer with a target layer
|
||||
*
|
||||
* The algorithm chooses the LDPair from the LayerProperties structure or
|
||||
* the name if no LDPair is given. If the source LayerProperties structure does
|
||||
|
|
@ -327,23 +444,23 @@ public:
|
|||
* @param l The logical layer to map to the match expression
|
||||
* @param t The target layer to use for the mapped layer
|
||||
*/
|
||||
void map (const LayerProperties &f, unsigned int l, const LayerProperties &t);
|
||||
void mmap (const LayerProperties &f, unsigned int l, const LayerProperties &t);
|
||||
|
||||
/**
|
||||
* @brief Map a range of ldpair's to a logical layer
|
||||
* @brief Multi-map a range of ldpair's to a logical layer
|
||||
*
|
||||
* The range is given by two pairs p1,p2. The layers
|
||||
* mapped are [p1.l,p2.l], the datatypes mapped are [p1.d,p2.d].
|
||||
*/
|
||||
void map (const LDPair &p1, const LDPair &p2, unsigned int l);
|
||||
void mmap (const LDPair &p1, const LDPair &p2, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Map a range of ldpair's to a logical layer with a target layer
|
||||
* @brief Multi-map a range of ldpair's to a logical layer with a target layer
|
||||
*
|
||||
* The range is given by two pairs p1,p2. The layers
|
||||
* mapped are [p1.l,p2.l], the datatypes mapped are [p1.d,p2.d].
|
||||
*/
|
||||
void map (const LDPair &p1, const LDPair &p2, unsigned int l, const LayerProperties &t);
|
||||
void mmap (const LDPair &p1, const LDPair &p2, unsigned int l, const LayerProperties &t);
|
||||
|
||||
/**
|
||||
* @brief Map a range given by a string expression to a logical layer
|
||||
|
|
@ -373,12 +490,61 @@ public:
|
|||
* This method will throw a LayerSpecFormatException if
|
||||
* something is wrong with the format string
|
||||
*/
|
||||
void map_expr (const std::string &expr, unsigned int l);
|
||||
void mmap_expr (const std::string &expr, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Same a map_expr with a string argument but taking the expression for a tl::Extractor
|
||||
*/
|
||||
void map_expr (tl::Extractor &ex, unsigned int l);
|
||||
void mmap_expr (tl::Extractor &ex, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Unmaps a LDPair
|
||||
*/
|
||||
void unmap (const LDPair &f);
|
||||
|
||||
/**
|
||||
* @brief Unmaps the layer with the given name
|
||||
*/
|
||||
void unmap (const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Unmaps a layer with the given layer properties
|
||||
*/
|
||||
void unmap (const LayerProperties &f);
|
||||
|
||||
/**
|
||||
* @brief Removes any mapping for a range of ldpair's
|
||||
*
|
||||
* The range is given by two pairs p1,p2. The layers
|
||||
* between [p1.l,p2.l] and with datatypes between [p1.d,p2.d] are unmapped.
|
||||
*/
|
||||
void unmap (const LDPair &p1, const LDPair &p2);
|
||||
|
||||
/**
|
||||
* @brief Removes any mapping for the layers given by the expression
|
||||
*/
|
||||
void unmap_expr (const std::string &expr);
|
||||
|
||||
/**
|
||||
* @brief Removes any mapping for the layers given by the expression
|
||||
*/
|
||||
void unmap_expr (tl::Extractor &ex);
|
||||
|
||||
/**
|
||||
* @brief Generic expression mapping
|
||||
*
|
||||
* This generic mapping function takes a mapping expression. If it starts with "+",
|
||||
* "mmap" is used, if it starts with "-", "unmap" is used. Otherwise, "map" is used.
|
||||
*/
|
||||
void add_expr (const std::string &expr, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Generic expression mapping
|
||||
*
|
||||
* This generic mapping function takes a mapping expression. If it starts with "+",
|
||||
* "mmap" is used, if it starts with "-", "unmap" is used. Otherwise, "map" is used.
|
||||
*/
|
||||
void add_expr (tl::Extractor &ex, unsigned int l);
|
||||
|
||||
/**
|
||||
* @brief Prepares a layer mapping object for reading
|
||||
|
|
@ -463,7 +629,7 @@ public:
|
|||
|
||||
private:
|
||||
ld_map m_ld_map;
|
||||
std::map<std::string, unsigned int> m_name_map;
|
||||
std::map<std::string, std::set<unsigned int> > m_name_map;
|
||||
std::map<unsigned int, LayerProperties> m_target_layers;
|
||||
std::vector<LayerProperties> m_placeholders;
|
||||
unsigned int m_next_index;
|
||||
|
|
@ -471,12 +637,12 @@ private:
|
|||
void insert (const LDPair &p1, const LDPair &p2, unsigned int l, const LayerProperties *t);
|
||||
void insert (const std::string &name, unsigned int l, const LayerProperties *t);
|
||||
|
||||
std::pair<bool, unsigned int> logical_internal (const LDPair &p, bool allow_placeholder) const;
|
||||
std::pair<bool, unsigned int> logical_internal (const std::string &name, bool allow_placeholder) const;
|
||||
std::pair<bool, unsigned int> logical_internal (const db::LayerProperties &p, bool allow_placeholder) const;
|
||||
std::set<unsigned int> logical_internal (const LDPair &p, bool allow_placeholder) const;
|
||||
std::set<unsigned int> logical_internal (const std::string &name, bool allow_placeholder) const;
|
||||
std::set<unsigned int> logical_internal (const db::LayerProperties &p, bool allow_placeholder) const;
|
||||
|
||||
std::pair<bool, unsigned int> substitute_placeholder (const db::LayerProperties &p, unsigned int ph, db::Layout &layout);
|
||||
bool is_placeholder (unsigned int l) const;
|
||||
std::set<unsigned int> substitute_placeholder (const db::LayerProperties &p, const std::set<unsigned int> &ph, db::Layout &layout);
|
||||
bool is_placeholder (const std::set<unsigned int> &l) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,12 +85,12 @@ static void set_properties_enabled (db::LoadLayoutOptions *options, bool l)
|
|||
options->get_options<db::CommonReaderOptions> ().enable_properties = l;
|
||||
}
|
||||
|
||||
static db::CommonReader::CellConflictResolution get_cell_conflict_resolution (const db::LoadLayoutOptions *options)
|
||||
static db::CellConflictResolution get_cell_conflict_resolution (const db::LoadLayoutOptions *options)
|
||||
{
|
||||
return options->get_options<db::CommonReaderOptions> ().cell_conflict_resolution;
|
||||
}
|
||||
|
||||
static void set_cell_conflict_resolution (db::LoadLayoutOptions *options, db::CommonReader::CellConflictResolution cc)
|
||||
static void set_cell_conflict_resolution (db::LoadLayoutOptions *options, db::CellConflictResolution cc)
|
||||
{
|
||||
options->get_options<db::CommonReaderOptions> ().cell_conflict_resolution = cc;
|
||||
}
|
||||
|
|
@ -188,18 +188,18 @@ gsi::ClassExt<db::LoadLayoutOptions> common_reader_options (
|
|||
);
|
||||
|
||||
|
||||
gsi::EnumIn<db::LoadLayoutOptions, db::CommonReader::CellConflictResolution> decl_dbCommonReader_CellConflictResolution ("db", "CellConflictResolution",
|
||||
gsi::enum_const ("AddToCell", db::CommonReader::AddToCell,
|
||||
gsi::EnumIn<db::LoadLayoutOptions, db::CellConflictResolution> decl_dbCommonReader_CellConflictResolution ("db", "CellConflictResolution",
|
||||
gsi::enum_const ("AddToCell", db::AddToCell,
|
||||
"@brief Add content to existing cell\n"
|
||||
"This is the mode use in before version 0.27. Content of new cells is simply added to existing cells with the same name."
|
||||
) +
|
||||
gsi::enum_const ("OverwriteCell", db::CommonReader::OverwriteCell,
|
||||
gsi::enum_const ("OverwriteCell", db::OverwriteCell,
|
||||
"@brief The old cell is overwritten entirely (including child cells which are not used otherwise)\n"
|
||||
) +
|
||||
gsi::enum_const ("SkipNewCell", db::CommonReader::SkipNewCell,
|
||||
gsi::enum_const ("SkipNewCell", db::SkipNewCell,
|
||||
"@brief The new cell is skipped entirely (including child cells which are not used otherwise)\n"
|
||||
) +
|
||||
gsi::enum_const ("RenameCell", db::CommonReader::RenameCell,
|
||||
gsi::enum_const ("RenameCell", db::RenameCell,
|
||||
"@brief The new cell will be renamed to become unique\n"
|
||||
),
|
||||
"@brief This enum specifies how cell conflicts are handled if a layout read into another layout and a cell name conflict arises. "
|
||||
|
|
|
|||
|
|
@ -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->is_mapped (lp);
|
||||
}
|
||||
|
||||
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,74 @@ namespace gsi
|
|||
layer_map->map_expr (s, l);
|
||||
}
|
||||
|
||||
static void
|
||||
lm_mmap (db::LayerMap *layer_map, const db::LayerProperties &lp, unsigned int l)
|
||||
{
|
||||
layer_map->mmap (lp, l);
|
||||
}
|
||||
|
||||
static void
|
||||
lm_mmap_with_target (db::LayerMap *layer_map, const db::LayerProperties &lp, unsigned int l, const db::LayerProperties &t)
|
||||
{
|
||||
layer_map->mmap (lp, l, t);
|
||||
}
|
||||
|
||||
static void
|
||||
lm_mmap_interval (db::LayerMap *layer_map, const db::LayerProperties &lp1, const db::LayerProperties &lp2, unsigned int l)
|
||||
{
|
||||
layer_map->mmap (ldpair_from_lp (lp1), ldpair_from_lp (lp2), l);
|
||||
}
|
||||
|
||||
static void
|
||||
lm_mmap_interval_with_target (db::LayerMap *layer_map, const db::LayerProperties &lp1, const db::LayerProperties &lp2, unsigned int l, const db::LayerProperties &t)
|
||||
{
|
||||
layer_map->mmap (ldpair_from_lp (lp1), ldpair_from_lp (lp2), l, t);
|
||||
}
|
||||
|
||||
static void
|
||||
lm_mmap_string (db::LayerMap *layer_map, std::string &s, unsigned int l)
|
||||
{
|
||||
layer_map->mmap_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 +226,84 @@ 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 ("mmap", &lm_mmap, gsi::arg ("phys_layer"), gsi::arg ("log_layer"),
|
||||
"@brief Maps a physical layer to a logical one and adds to existing mappings\n"
|
||||
"\n"
|
||||
"This method acts like the corresponding 'map' method, but adds the logical layer to the receivers of the "
|
||||
"given physical one. Hence this method implements 1:n mapping capabilities.\n"
|
||||
"For backward compatibility, 'map' still substitutes mapping.\n"
|
||||
"\n"
|
||||
"Multi-mapping has been added in version 0.27.\n"
|
||||
) +
|
||||
gsi::method_ext ("mmap", &lm_mmap_with_target, gsi::arg ("phys_layer"), gsi::arg ("log_layer"), gsi::arg ("target_layer"),
|
||||
"@brief Maps a physical layer to a logical one, adds to existing mappings and specifies a target layer\n"
|
||||
"\n"
|
||||
"This method acts like the corresponding 'map' method, but adds the logical layer to the receivers of the "
|
||||
"given physical one. Hence this method implements 1:n mapping capabilities.\n"
|
||||
"For backward compatibility, 'map' still substitutes mapping.\n"
|
||||
"\n"
|
||||
"Multi-mapping has been added in version 0.27.\n"
|
||||
) +
|
||||
gsi::method_ext ("mmap", &lm_mmap_interval, gsi::arg ("pl_start"), gsi::arg ("pl_stop"), gsi::arg ("log_layer"),
|
||||
"@brief Maps a physical layer from the given interval to a logical one and adds to existing mappings\n"
|
||||
"\n"
|
||||
"This method acts like the corresponding 'map' method, but adds the logical layer to the receivers of the "
|
||||
"given physical one. Hence this method implements 1:n mapping capabilities.\n"
|
||||
"For backward compatibility, 'map' still substitutes mapping.\n"
|
||||
"\n"
|
||||
"Multi-mapping has been added in version 0.27.\n"
|
||||
) +
|
||||
gsi::method_ext ("mmap", &lm_mmap_interval_with_target, gsi::arg ("pl_start"), gsi::arg ("pl_stop"), gsi::arg ("log_layer"), gsi::arg ("layer_properties"),
|
||||
"@brief Maps a physical layer from the given interval to a logical one, adds to existing mappings and specifies a target layer\n"
|
||||
"\n"
|
||||
"This method acts like the corresponding 'map' method, but adds the logical layer to the receivers of the "
|
||||
"given physical one. Hence this method implements 1:n mapping capabilities.\n"
|
||||
"For backward compatibility, 'map' still substitutes mapping.\n"
|
||||
"\n"
|
||||
"Multi-mapping has been added in version 0.27.\n"
|
||||
) +
|
||||
gsi::method_ext ("mmap", &lm_mmap_string, gsi::arg ("map_expr"), gsi::arg ("log_layer"),
|
||||
"@brief Maps a physical layer given by an expression to a logical one and adds to existing mappings\n"
|
||||
"\n"
|
||||
"This method acts like the corresponding 'map' method, but adds the logical layer to the receivers of the "
|
||||
"given physical one. Hence this method implements 1:n mapping capabilities.\n"
|
||||
"For backward compatibility, 'map' still substitutes mapping.\n"
|
||||
"\n"
|
||||
"Multi-mapping has been added in version 0.27.\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 +358,28 @@ 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 supported: a physical layer can be mapped to multiple logical layers using 'mmap' instead of 'map'. When using this variant, "
|
||||
"mapping acts additive.\n"
|
||||
"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) # (can be 'mmap' too)\n"
|
||||
"lm.mmap(\"1/17\", 1)\n"
|
||||
"@/code\n"
|
||||
"\n"
|
||||
"'unmapping' allows removing 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.
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ TEST(1)
|
|||
db::LayerMap lm;
|
||||
|
||||
lm.map (db::LDPair (1, 5), 17);
|
||||
EXPECT_EQ (lm.logical (db::LDPair (1, 6)).first, false);
|
||||
EXPECT_EQ (lm.logical (db::LDPair (1, 5)).first, true);
|
||||
EXPECT_EQ (lm.logical (db::LDPair (1, 5)).second, (unsigned int) 17);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair (1, 6)).first, false);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair (1, 5)).first, true);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair (1, 5)).second, (unsigned int) 17);
|
||||
|
||||
lm.map (db::LDPair (1, 0), db::LDPair (5,0), 18);
|
||||
EXPECT_EQ (lm.logical (db::LDPair (2, 0)).first, true);
|
||||
EXPECT_EQ (lm.logical (db::LDPair (2, 0)).second, (unsigned int) 18);
|
||||
EXPECT_EQ (lm.logical (db::LDPair (0, 0)).first, false);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair (2, 0)).first, true);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair (2, 0)).second, (unsigned int) 18);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair (0, 0)).first, false);
|
||||
|
||||
EXPECT_EQ (lm.mapping_str (18), "1/0;2-5/0");
|
||||
EXPECT_EQ (lm.mapping_str (18), "1-5/0");
|
||||
EXPECT_EQ (lm.mapping_str (17), "1/5");
|
||||
|
||||
lm.map (db::LDPair (2, 2), 18);
|
||||
|
|
@ -62,18 +62,37 @@ TEST(1)
|
|||
|
||||
lm.map_expr ("XP;10/7-8 : XN", 13);
|
||||
EXPECT_EQ (lm.mapping_str (13), "10/7-8;XP : XN");
|
||||
EXPECT_EQ (lm.logical ("XP").second, (unsigned int) 13);
|
||||
EXPECT_EQ (lm.logical ("XP").first, true);
|
||||
EXPECT_EQ (lm.logical (db::LDPair(10, 6)).first, false);
|
||||
EXPECT_EQ (lm.logical (db::LDPair(10, 7)).first, true);
|
||||
EXPECT_EQ (lm.logical (db::LDPair(10, 7)).second, (unsigned int) 13);
|
||||
EXPECT_EQ (lm.first_logical ("XP").second, (unsigned int) 13);
|
||||
EXPECT_EQ (lm.first_logical ("XP").first, true);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair(10, 6)).first, false);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair(10, 7)).first, true);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair(10, 7)).second, (unsigned int) 13);
|
||||
|
||||
EXPECT_EQ (lm.mapping (13).to_string (), "XN (10/7)");
|
||||
|
||||
lm.clear ();
|
||||
EXPECT_EQ (lm.logical (db::LDPair(10, 7)).first, false);
|
||||
EXPECT_EQ (lm.first_logical (db::LDPair(10, 7)).first, false);
|
||||
lm.map_expr ("'XP';10/7-8 : XN", 13);
|
||||
EXPECT_EQ (lm.mapping_str (13), "10/7-8;XP : XN");
|
||||
|
||||
// brackets, "add_expr"
|
||||
lm.clear ();
|
||||
lm.add_expr ("[1-10/*]", 1);
|
||||
EXPECT_EQ (lm.mapping_str (1), "1-10/* : */*");
|
||||
lm.add_expr ("-(5/*)", 0);
|
||||
EXPECT_EQ (lm.mapping_str (1), "1-4/*;6-10/* : */*");
|
||||
|
||||
lm.clear ();
|
||||
lm.add_expr ("[1/15]", 1);
|
||||
lm.add_expr ("+(1/5:1001/5)", 1);
|
||||
// NOTE: the target is taken from the second expression (the last one wins)
|
||||
EXPECT_EQ (lm.mapping_str (1), "1/5,15 : 1001/5");
|
||||
|
||||
lm.clear ();
|
||||
lm.add_expr ("+(1/5:1001/5)", 1);
|
||||
lm.add_expr ("[1/15]", 1);
|
||||
// NOTE: the target is taken from the second expression (the last one wins)
|
||||
EXPECT_EQ (lm.mapping_str (1), "1/5,15 : */*");
|
||||
}
|
||||
|
||||
TEST(2)
|
||||
|
|
@ -349,55 +368,55 @@ TEST(6)
|
|||
EXPECT_EQ (layers_to_string (ly), "1/0,3/10");
|
||||
|
||||
std::pair<bool, unsigned int> p;
|
||||
p = lm.logical (db::LayerProperties (1, 0));
|
||||
p = lm.first_logical (db::LayerProperties (1, 0));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 0);
|
||||
|
||||
p = lm.logical (db::LayerProperties (2, 0));
|
||||
p = lm.first_logical (db::LayerProperties (2, 0));
|
||||
EXPECT_EQ (p.first, false);
|
||||
|
||||
p = lm.logical (db::LayerProperties (3, 0));
|
||||
p = lm.first_logical (db::LayerProperties (3, 0));
|
||||
EXPECT_EQ (p.first, false);
|
||||
|
||||
p = lm.logical (db::LayerProperties (3, 10));
|
||||
p = lm.first_logical (db::LayerProperties (3, 10));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 1);
|
||||
|
||||
p = lm.logical (db::LayerProperties (3, 99));
|
||||
p = lm.first_logical (db::LayerProperties (3, 99));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 1);
|
||||
|
||||
EXPECT_EQ (layers_to_string (ly), "1/0,3/10");
|
||||
|
||||
// this will create layer 2/0 in the layout
|
||||
p = lm.logical (db::LayerProperties (2, 0), ly);
|
||||
p = lm.first_logical (db::LayerProperties (2, 0), ly);
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 2);
|
||||
|
||||
EXPECT_EQ (layers_to_string (ly), "1/0,3/10,2/0");
|
||||
|
||||
p = lm.logical (db::LayerProperties (2, 0));
|
||||
p = lm.first_logical (db::LayerProperties (2, 0));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 2);
|
||||
|
||||
p = lm.logical (db::LayerProperties (2, 0), ly);
|
||||
p = lm.first_logical (db::LayerProperties (2, 0), ly);
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 2);
|
||||
|
||||
EXPECT_EQ (layers_to_string (ly), "1/0,3/10,2/0");
|
||||
|
||||
// this will create layer 2/42 in the layout
|
||||
p = lm.logical (db::LayerProperties (2, 42), ly);
|
||||
p = lm.first_logical (db::LayerProperties (2, 42), ly);
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 3);
|
||||
|
||||
EXPECT_EQ (layers_to_string (ly), "1/0,3/10,2/0,2/42");
|
||||
|
||||
p = lm.logical (db::LayerProperties (2, 42));
|
||||
p = lm.first_logical (db::LayerProperties (2, 42));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 3);
|
||||
|
||||
p = lm.logical (db::LayerProperties (2, 42), ly);
|
||||
p = lm.first_logical (db::LayerProperties (2, 42), ly);
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 3);
|
||||
|
||||
|
|
@ -429,19 +448,132 @@ TEST(7)
|
|||
EXPECT_EQ (layers_to_string (ly), "85/0,185/0,,");
|
||||
|
||||
std::pair<bool, unsigned int> p;
|
||||
p = lm.logical (db::LayerProperties (85, 0));
|
||||
p = lm.first_logical (db::LayerProperties (85, 0));
|
||||
EXPECT_EQ (p.first, false);
|
||||
EXPECT_EQ (p.second, (unsigned int) 0);
|
||||
|
||||
p = lm.logical (db::LayerProperties (185, 0));
|
||||
p = lm.first_logical (db::LayerProperties (185, 0));
|
||||
EXPECT_EQ (p.first, false);
|
||||
EXPECT_EQ (p.second, (unsigned int) 0);
|
||||
|
||||
p = lm.logical (db::LayerProperties (10000, 0));
|
||||
p = lm.first_logical (db::LayerProperties (10000, 0));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 1);
|
||||
|
||||
p = lm.logical (db::LayerProperties (10001, 0));
|
||||
p = lm.first_logical (db::LayerProperties (10001, 0));
|
||||
EXPECT_EQ (p.first, true);
|
||||
EXPECT_EQ (p.second, (unsigned int) 0);
|
||||
}
|
||||
|
||||
static std::string set2string (const std::set<unsigned int> &set)
|
||||
{
|
||||
std::string s;
|
||||
for (std::set<unsigned int>::const_iterator i = set.begin (); i != set.end (); ++i) {
|
||||
if (i != set.begin ()) {
|
||||
s += ",";
|
||||
}
|
||||
s += tl::to_string (*i);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// multi-mapping, unmapping
|
||||
TEST(8)
|
||||
{
|
||||
db::LayerMap lm;
|
||||
|
||||
unsigned int n = 0;
|
||||
|
||||
// refinement
|
||||
// all
|
||||
lm.mmap_expr ("*/*", n++);
|
||||
EXPECT_EQ (lm.mapping_str (0), "*/*");
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('*/*')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
// some
|
||||
lm.mmap_expr ("*/1-10", n++);
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('+*/*';'+*/1-10')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
// others
|
||||
lm.mmap_expr ("*/5,15", n++);
|
||||
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('+*/*';'+*/1-10';'+*/5,15')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (0, 1000))), "0");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (1, 1000))), "0");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (0, 5))), "0,1,2");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (0, 15))), "0,2");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (0, 10))), "0,1");
|
||||
|
||||
// NOTE: the leading "+" indicates that the listed layers may go somewhere else, so we can't plainly map them
|
||||
EXPECT_EQ (lm.mapping_str (0), "+*/*");
|
||||
EXPECT_EQ (lm.mapping_str (1), "+*/1-10");
|
||||
EXPECT_EQ (lm.mapping_str (2), "+*/5,15");
|
||||
EXPECT_EQ (lm.mapping_str (3), "");
|
||||
|
||||
lm = db::LayerMap ();
|
||||
n = 0;
|
||||
|
||||
// refinement
|
||||
// all
|
||||
lm.mmap_expr ("*/*", n++);
|
||||
EXPECT_EQ (lm.mapping_str (0), "*/*");
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('*/*')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
// some
|
||||
lm.mmap_expr ("1-10/*", n++);
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('+*/*';'+1-10/*')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
// others
|
||||
lm.mmap_expr ("5,15/*", n++);
|
||||
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('+*/*';'+1-10/*';'+5/*;15/*')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (1000, 0))), "0");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (1000, 1))), "0");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (5, 0))), "0,1,2");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (15, 0))), "0,2");
|
||||
EXPECT_EQ (set2string (lm.logical (db::LDPair (10, 0))), "0,1");
|
||||
|
||||
// NOTE: the leading "+" indicates that the listed layers may go somewhere else, so we can't plainly map them
|
||||
EXPECT_EQ (lm.mapping_str (0), "+*/*");
|
||||
EXPECT_EQ (lm.mapping_str (1), "+1-10/*");
|
||||
EXPECT_EQ (lm.mapping_str (2), "+5/*;15/*");
|
||||
EXPECT_EQ (lm.mapping_str (3), "");
|
||||
|
||||
lm = db::LayerMap ();
|
||||
n = 0;
|
||||
|
||||
lm.mmap_expr ("*/*", n++);
|
||||
EXPECT_EQ (lm.mapping_str (0), "*/*");
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('*/*')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
|
||||
// some
|
||||
lm.mmap_expr ("1-10/0-20", n++);
|
||||
EXPECT_EQ (lm.to_string (),
|
||||
"layer_map('+*/*';'+1-10/0-20')"
|
||||
);
|
||||
EXPECT_EQ (db::LayerMap::from_string_file_format (lm.to_string_file_format ()).to_string (), lm.to_string ());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,5 +173,58 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Multi-mapping and unmapping</h2>
|
||||
|
||||
<p>
|
||||
Layer mapping table support an advanced feature which is to duplicate input layers to
|
||||
a number of output layers (1:n) mapping.
|
||||
The feature is enabled by prepending a "+" to the mapping statement. The following
|
||||
statement will first select layer 5/0 and additionally copy it to layer 1000/0:
|
||||
</p>
|
||||
|
||||
<pre>5/0
|
||||
+5/0: 1000/0
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Unmapping removes the mapping for a specific layer or range. It is specified by prepending "-"
|
||||
to the mapping expression. The following statement will map all datatypes of layer 5 to 0 except
|
||||
for datatype 10 which is not considered.
|
||||
</p>
|
||||
|
||||
<pre>5/*: 5/0
|
||||
-5/10
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Unmapping cancels the mappings specified previously, so the order of statements becomes important
|
||||
when using unmapping and multi-mapping.
|
||||
</p>
|
||||
|
||||
<h2>Brackets</h2>
|
||||
|
||||
<p>
|
||||
Square brackets can be used to imply mapping to the original layer. When putting square brackets
|
||||
around a mapping expression, the default target is "*/*", which means expansion to the original layer.
|
||||
Hence the following statements are identical:
|
||||
</p>
|
||||
|
||||
<pre>[1-10/*]
|
||||
1-10/* : */*
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
When combining this with "+" for multi-mapping, put "+" in front of the bracket.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You can put round brackets around mapping expressions for visual clarity, specifically when
|
||||
combining them with "-" (unmapping) or "+" (multi-mapping):
|
||||
</p>
|
||||
|
||||
<pre>-(1-10/*)
|
||||
+(17/0 : 1017/0)
|
||||
</pre>
|
||||
|
||||
</doc>
|
||||
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ SearchReplaceResults::export_layout (db::Layout &layout)
|
|||
std::map<unsigned int, db::LayerProperties>::const_iterator lm = m_lp_map.find (layer);
|
||||
if (lm != m_lp_map.end ()) {
|
||||
|
||||
std::pair<bool, unsigned int> ll = insert_lm.logical (lm->second);
|
||||
std::pair<bool, unsigned int> ll = insert_lm.first_logical (lm->second);
|
||||
if (! ll.first) {
|
||||
layer = layout.insert_layer (lm->second);
|
||||
insert_lm.map (lm->second, layer, lm->second);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>446</width>
|
||||
<height>205</height>
|
||||
<width>536</width>
|
||||
<height>290</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -29,6 +29,19 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="load_pb">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="help_label">
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -45,103 +58,114 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="load_pb">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" rowspan="6" colspan="2">
|
||||
<widget class="QListWidget" name="layer_lv">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QToolButton" name="add_pb">
|
||||
<property name="toolTip">
|
||||
<string>Add a new layer to the list</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../lay/layResources.qrc">
|
||||
<normaloff>:/add.png</normaloff>:/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QToolButton" name="delete_pb">
|
||||
<property name="toolTip">
|
||||
<string>Delete the selected layers from the list</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../lay/layResources.qrc">
|
||||
<normaloff>:/clear.png</normaloff>:/clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2" rowspan="3">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QToolButton" name="edit_pb">
|
||||
<property name="toolTip">
|
||||
<string>Edit the current layer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../lay/layResources.qrc">
|
||||
<normaloff>:/edit.png</normaloff>:/edit.png</iconset>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QTabWidget" name="tabs">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>List</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="4">
|
||||
<widget class="QListWidget" name="layer_lv">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="add_pb">
|
||||
<property name="toolTip">
|
||||
<string>Add a new layer to the list</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../lay/lay/layResources.qrc">
|
||||
<normaloff>:/add.png</normaloff>:/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="delete_pb">
|
||||
<property name="toolTip">
|
||||
<string>Delete the selected layers from the list</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../lay/lay/layResources.qrc">
|
||||
<normaloff>:/clear.png</normaloff>:/clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QToolButton" name="edit_pb">
|
||||
<property name="toolTip">
|
||||
<string>Edit the current layer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../lay/lay/layResources.qrc">
|
||||
<normaloff>:/edit.png</normaloff>:/edit.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Text</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPlainTextEdit" name="text_edit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../lay/layResources.qrc"/>
|
||||
<include location="../../lay/lay/layResources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ LayerMappingWidget::LayerMappingWidget (QWidget *parent)
|
|||
|
||||
mp_ui->layer_lv->viewport ()->acceptDrops ();
|
||||
|
||||
connect (mp_ui->tabs, SIGNAL (currentChanged (int)), this, SLOT (current_tab_changed (int)));
|
||||
|
||||
mp_layer_table_file_dialog = new lay::FileDialog (this,
|
||||
tl::to_string (QObject::tr ("Load Layer Table")),
|
||||
tl::to_string (QObject::tr ("Layer properties and text files (*.lyp *.txt);;Layer properties files (*.lyp);;Text files (*.txt);;All files (*)")));
|
||||
|
|
@ -72,6 +74,8 @@ LayerMappingWidget::set_layer_map (const db::LayerMap &lm)
|
|||
{
|
||||
std::vector<unsigned int> layer_ids = lm.get_layers ();
|
||||
|
||||
mp_ui->text_edit->setPlainText (tl::to_qstring (lm.to_string_file_format ()));
|
||||
|
||||
mp_ui->layer_lv->reset ();
|
||||
mp_ui->layer_lv->clear ();
|
||||
|
||||
|
|
@ -88,16 +92,31 @@ LayerMappingWidget::set_layer_map (const db::LayerMap &lm)
|
|||
|
||||
db::LayerMap
|
||||
LayerMappingWidget::get_layer_map () const
|
||||
{
|
||||
return get_layer_map_from_tab (mp_ui->tabs->currentIndex ());
|
||||
}
|
||||
|
||||
db::LayerMap
|
||||
LayerMappingWidget::get_layer_map_from_tab (int tab) const
|
||||
{
|
||||
db::LayerMap lm;
|
||||
for (int i = 0; i < mp_ui->layer_lv->count (); ++i) {
|
||||
std::string t = tl::to_string (mp_ui->layer_lv->item (i)->data (Qt::DisplayRole).toString ());
|
||||
try {
|
||||
lm.map_expr (t, (unsigned int) i);
|
||||
} catch (...) {
|
||||
mp_ui->layer_lv->setCurrentItem (mp_ui->layer_lv->item (i));
|
||||
throw;
|
||||
|
||||
if (tab == 0) {
|
||||
|
||||
for (int i = 0; i < mp_ui->layer_lv->count (); ++i) {
|
||||
std::string t = tl::to_string (mp_ui->layer_lv->item (i)->data (Qt::DisplayRole).toString ());
|
||||
try {
|
||||
lm.add_expr (t, (unsigned int) i);
|
||||
} catch (...) {
|
||||
mp_ui->layer_lv->setCurrentItem (mp_ui->layer_lv->item (i));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
lm = db::LayerMap::from_string_file_format (tl::to_string (mp_ui->text_edit->toPlainText ()));
|
||||
|
||||
}
|
||||
|
||||
return lm;
|
||||
|
|
@ -128,17 +147,19 @@ LayerMappingWidget::load_button_pressed ()
|
|||
mp_ui->layer_lv->reset ();
|
||||
mp_ui->layer_lv->clear ();
|
||||
|
||||
db::LayerMap lm;
|
||||
|
||||
// use those layers which have cellview index 0
|
||||
unsigned int n = 0;
|
||||
for (LayerPropertiesConstIterator lay_iter = props.begin_const_recursive (); ! lay_iter.at_end (); ++lay_iter) {
|
||||
if (! lay_iter->has_children () && lay_iter->source (true /*=real*/).cv_index () == 0) {
|
||||
db::LayerProperties db_lp = lay_iter->source (true /*=real*/).layer_props ();
|
||||
QListWidgetItem *item = new QListWidgetItem (mp_ui->layer_lv);
|
||||
item->setData (Qt::DisplayRole, tl::to_qstring (db_lp.to_string ()));
|
||||
item->setFlags (item->flags () | Qt::ItemIsEditable);
|
||||
mp_ui->layer_lv->addItem (item);
|
||||
lm.map (db_lp, (unsigned int) n++);
|
||||
}
|
||||
}
|
||||
|
||||
set_layer_map (lm);
|
||||
|
||||
// if successful, stop now.
|
||||
success = true;
|
||||
|
||||
|
|
@ -230,5 +251,11 @@ LayerMappingWidget::edit_button_pressed ()
|
|||
END_PROTECTED
|
||||
}
|
||||
|
||||
void
|
||||
LayerMappingWidget::current_tab_changed (int index)
|
||||
{
|
||||
set_layer_map (get_layer_map_from_tab (1 - index));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,11 +84,14 @@ private slots:
|
|||
void add_button_pressed ();
|
||||
void delete_button_pressed ();
|
||||
void edit_button_pressed ();
|
||||
void current_tab_changed (int tab);
|
||||
|
||||
private:
|
||||
lay::FileDialog *mp_layer_table_file_dialog;
|
||||
std::string m_layer_table_file;
|
||||
Ui::LayerMappingWidget *mp_ui;
|
||||
|
||||
db::LayerMap get_layer_map_from_tab (int tab) const;
|
||||
};
|
||||
|
||||
} // namespace lay
|
||||
|
|
|
|||
|
|
@ -59,22 +59,20 @@ CIFReader::~CIFReader ()
|
|||
const LayerMap &
|
||||
CIFReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
||||
{
|
||||
prepare_layers ();
|
||||
|
||||
const db::CIFReaderOptions &specific_options = options.get_options<db::CIFReaderOptions> ();
|
||||
m_wire_mode = specific_options.wire_mode;
|
||||
m_dbu = specific_options.dbu;
|
||||
|
||||
db::LayerMap lm = specific_options.layer_map;
|
||||
lm.prepare (layout);
|
||||
set_layer_map (lm);
|
||||
set_layer_map (specific_options.layer_map);
|
||||
set_create_layers (specific_options.create_other_layers);
|
||||
set_keep_layer_names (specific_options.keep_layer_names);
|
||||
|
||||
prepare_layers (layout);
|
||||
|
||||
do_read (layout);
|
||||
|
||||
finish_layers (layout);
|
||||
return layer_map ();
|
||||
return layer_map_out ();
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
|
|
|
|||
|
|
@ -39,13 +39,8 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
|
|||
unsigned int ln = 0;
|
||||
tl::Extractor ex (map);
|
||||
while (! ex.at_end ()) {
|
||||
std::string n;
|
||||
int l;
|
||||
ex.read_word_or_quoted (n);
|
||||
ex.test (":");
|
||||
ex.read (l);
|
||||
lm.add_expr (ex, ln++);
|
||||
ex.test (",");
|
||||
lm.map (n, ln++, db::LayerProperties (l, 0));
|
||||
}
|
||||
opt->layer_map = lm;
|
||||
opt->create_other_layers = true;
|
||||
|
|
@ -173,6 +168,11 @@ TEST(3b)
|
|||
run_test (_this, tl::testsrc_private (), "t3.cif.gz", "t3b_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26", 0.00012);
|
||||
}
|
||||
|
||||
TEST(3c)
|
||||
{
|
||||
run_test (_this, tl::testsrc_private (), "t3.cif.gz", "t3c_au.gds.gz", "(CPG:1/0) +(CPG:1000/0) (CCP:1/0) (CMF:2/0) +(CMF:1000/0) (CVA:3/0)", 0.00012);
|
||||
}
|
||||
|
||||
TEST(4)
|
||||
{
|
||||
run_test (_this, tl::testsrc_private (), "t4.cif.gz", "t4_au.gds.gz");
|
||||
|
|
|
|||
|
|
@ -318,9 +318,7 @@ DXFReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
|||
m_stream.reset ();
|
||||
m_initial = true;
|
||||
m_line_number = 0;
|
||||
db::LayerMap lm = specific_options.layer_map;
|
||||
lm.prepare (layout);
|
||||
set_layer_map (lm);
|
||||
set_layer_map (specific_options.layer_map);
|
||||
set_create_layers (specific_options.create_other_layers);
|
||||
set_keep_layer_names (specific_options.keep_layer_names);
|
||||
|
||||
|
|
@ -330,7 +328,7 @@ DXFReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
|||
do_read (layout, top);
|
||||
cleanup (layout, top);
|
||||
|
||||
return layer_map ();
|
||||
return layer_map_out ();
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
|
|
@ -366,43 +364,31 @@ DXFReader::warn (const std::string &msg)
|
|||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
DXFReader::open_layer (db::Layout &layout, const std::string &n)
|
||||
{
|
||||
if (n == zero_layer_name) {
|
||||
return std::make_pair (true, m_zero_layer);
|
||||
} else {
|
||||
return NamedLayerReader::open_layer (layout, n);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DXFReader::do_read (db::Layout &layout, db::cell_index_type top)
|
||||
{
|
||||
prepare_layers (layout);
|
||||
|
||||
// create the zero layer - this is not mapped to GDS but can be specified in the layer mapping as
|
||||
// a layer named "0".
|
||||
std::pair<bool, unsigned int> ll = layer_map ().logical (zero_layer_name, layout);
|
||||
if (ll.first) {
|
||||
|
||||
// create the layer if it is not part of the layout yet.
|
||||
if (! layout.is_valid_layer (ll.second)) {
|
||||
layout.insert_layer (ll.second, layer_map ().mapping (ll.second));
|
||||
}
|
||||
std::pair<bool, unsigned int> li = NamedLayerReader::open_layer (layout, zero_layer_name, true /*keep layer name*/, false /*don't create a new layer*/);
|
||||
if (li.first) {
|
||||
|
||||
m_zero_layer = ll.second;
|
||||
// we got one from the layer mapping
|
||||
m_zero_layer = li.second;
|
||||
|
||||
} else {
|
||||
|
||||
// or explicitly create the layer:
|
||||
m_zero_layer = layer_map ().next_index ();
|
||||
layout.insert_layer (m_zero_layer, db::LayerProperties (0, 0, zero_layer_name));
|
||||
// or we explicitly create the layer
|
||||
db::LayerProperties lp_zero (0, 0, zero_layer_name);
|
||||
m_zero_layer = layout.insert_layer (lp_zero);
|
||||
map_layer (zero_layer_name, m_zero_layer);
|
||||
|
||||
}
|
||||
|
||||
prepare_layers ();
|
||||
// Read sections
|
||||
|
||||
// Read sections
|
||||
int g;
|
||||
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,6 @@ private:
|
|||
|
||||
void do_read (db::Layout &layout, db::cell_index_type top);
|
||||
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &n);
|
||||
db::cell_index_type make_layer_variant (db::Layout &layout, const std::string &cellname, db::cell_index_type template_cell, unsigned int layer, double sx, double sy);
|
||||
void cleanup (db::Layout &layout, db::cell_index_type top);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ TARGET = dxf_tests
|
|||
include($$PWD/../../../../lib_ut.pri)
|
||||
|
||||
SOURCES = \
|
||||
dbDXFReader.cc \
|
||||
dbDXFReaderTests.cc
|
||||
|
||||
INCLUDEPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common
|
||||
DEPENDPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common
|
||||
|
|
|
|||
|
|
@ -51,23 +51,11 @@ GDS2ReaderText::~GDS2ReaderText()
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
GDS2ReaderText::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
||||
void
|
||||
GDS2ReaderText::init (const db::LoadLayoutOptions &options)
|
||||
{
|
||||
GDS2ReaderBase::init (options);
|
||||
storedRecId = 0;
|
||||
|
||||
// HINT: reuse the standard GDS2 reader options for the text reader.
|
||||
// However, the allow_big_records and allow_multi_xy_records options are ignored.
|
||||
db::GDS2ReaderOptions gds2_options = options.get_options<db::GDS2ReaderOptions> ();
|
||||
db::CommonReaderOptions common_options = options.get_options<db::CommonReaderOptions> ();
|
||||
|
||||
return basic_read (layout, common_options.layer_map, common_options.create_other_layers, common_options.enable_text_objects, common_options.enable_properties, false, gds2_options.box_mode, common_options.cell_conflict_resolution);
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
GDS2ReaderText::read (db::Layout &layout)
|
||||
{
|
||||
return read (layout, db::LoadLayoutOptions ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -64,43 +64,14 @@ public:
|
|||
*/
|
||||
~GDS2ReaderText();
|
||||
|
||||
/**
|
||||
* @brief The basic read method
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* It can be given a couple of options specified with the
|
||||
* LoadLayoutOptions object.
|
||||
* The returned map will contain all layers, the passed
|
||||
* ones and the newly created ones.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @param options The generic reader options
|
||||
* @return The LayerMap object that tells where which layer was loaded
|
||||
*/
|
||||
virtual const LayerMap &read (db::Layout &layout, const LoadLayoutOptions &options);
|
||||
|
||||
/**
|
||||
* @brief The basic read method (without mapping)
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* This version will read all input layers and return a map
|
||||
* which tells which GDS2 layer has been read into which logical
|
||||
* layer.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @return The LayerMap object
|
||||
*/
|
||||
virtual const LayerMap &read (db::Layout &layout);
|
||||
|
||||
/**
|
||||
* @brief Format
|
||||
*/
|
||||
const char *format () const { return "GDS2Text"; }
|
||||
|
||||
protected:
|
||||
virtual void init (const LoadLayoutOptions &options);
|
||||
|
||||
private:
|
||||
tl::TextInputStream sStream;
|
||||
std::string sExtractedValue;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ GDS2Reader::GDS2Reader (tl::InputStream &s)
|
|||
m_recptr (0),
|
||||
mp_rec_buf (0),
|
||||
m_stored_rec (0),
|
||||
m_allow_big_records (true),
|
||||
m_progress (tl::to_string (tr ("Reading GDS2 file")), 10000)
|
||||
{
|
||||
m_progress.set_format (tl::to_string (tr ("%.0f MB")));
|
||||
|
|
@ -54,23 +55,16 @@ GDS2Reader::~GDS2Reader ()
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
GDS2Reader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
||||
void
|
||||
GDS2Reader::init (const db::LoadLayoutOptions &options)
|
||||
{
|
||||
m_options = options.get_options<db::GDS2ReaderOptions> ();
|
||||
m_common_options = options.get_options<db::CommonReaderOptions> ();
|
||||
GDS2ReaderBase::init (options);
|
||||
|
||||
m_allow_big_records = options.get_options<db::GDS2ReaderOptions> ().allow_big_records;
|
||||
|
||||
m_recnum = 0;
|
||||
--m_recnum;
|
||||
m_reclen = 0;
|
||||
|
||||
return basic_read (layout, m_common_options.layer_map, m_common_options.create_other_layers, m_common_options.enable_text_objects, m_common_options.enable_properties, m_options.allow_multi_xy_records, m_options.box_mode, m_common_options.cell_conflict_resolution);
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
GDS2Reader::read (db::Layout &layout)
|
||||
{
|
||||
return read (layout, db::LoadLayoutOptions ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -108,7 +102,7 @@ GDS2Reader::get_record ()
|
|||
error (tl::to_string (tr ("Invalid record length (less than 4)")));
|
||||
}
|
||||
if (m_reclen >= 0x8000) {
|
||||
if (m_options.allow_big_records) {
|
||||
if (m_allow_big_records) {
|
||||
warn (tl::to_string (tr ("Record length larger than 0x8000 encountered: interpreting as unsigned")));
|
||||
} else {
|
||||
error (tl::to_string (tr ("Record length larger than 0x8000 encountered (reader is configured not to allow such records)")));
|
||||
|
|
|
|||
|
|
@ -72,43 +72,14 @@ public:
|
|||
*/
|
||||
~GDS2Reader ();
|
||||
|
||||
/**
|
||||
* @brief The basic read method
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* It can be given a couple of options specified with the
|
||||
* LoadLayoutOptions object.
|
||||
* The returned map will contain all layers, the passed
|
||||
* ones and the newly created ones.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @param options The generic reader options
|
||||
* @return The LayerMap object that tells where which layer was loaded
|
||||
*/
|
||||
virtual const LayerMap &read (db::Layout &layout, const LoadLayoutOptions &options);
|
||||
|
||||
/**
|
||||
* @brief The basic read method (without mapping)
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* This version will read all input layers and return a map
|
||||
* which tells which GDS2 layer has been read into which logical
|
||||
* layer.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @return The LayerMap object
|
||||
*/
|
||||
virtual const LayerMap &read (db::Layout &layout);
|
||||
|
||||
/**
|
||||
* @brief Format
|
||||
*/
|
||||
virtual const char *format () const { return "GDS2"; }
|
||||
|
||||
protected:
|
||||
virtual void init (const LoadLayoutOptions &options);
|
||||
|
||||
private:
|
||||
tl::InputStream &m_stream;
|
||||
size_t m_recnum;
|
||||
|
|
@ -117,8 +88,7 @@ private:
|
|||
unsigned char *mp_rec_buf;
|
||||
tl::string m_string_buf;
|
||||
short m_stored_rec;
|
||||
db::GDS2ReaderOptions m_options;
|
||||
db::CommonReaderOptions m_common_options;
|
||||
bool m_allow_big_records;
|
||||
tl::AbsoluteProgress m_progress;
|
||||
|
||||
virtual void error (const std::string &txt);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#include "dbGDS2ReaderBase.h"
|
||||
#include "dbGDS2Format.h"
|
||||
#include "dbGDS2.h"
|
||||
#include "dbArray.h"
|
||||
|
||||
|
|
@ -34,42 +35,12 @@ namespace db
|
|||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief A utility class that maps the layers for the proxy cell recovery
|
||||
*/
|
||||
class GDS2ReaderLayerMapping
|
||||
: public db::ImportLayerMapping
|
||||
{
|
||||
public:
|
||||
GDS2ReaderLayerMapping (db::GDS2ReaderBase *reader, db::Layout *layout, bool create)
|
||||
: mp_reader (reader), mp_layout (layout), m_create (create)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int> map_layer (const db::LayerProperties &lprops)
|
||||
{
|
||||
// named layers that are imported from a library are ignored
|
||||
if (lprops.is_named ()) {
|
||||
return std::make_pair (false, 0);
|
||||
} else {
|
||||
return mp_reader->open_dl (*mp_layout, LDPair (lprops.layer, lprops.datatype), m_create);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
db::GDS2ReaderBase *mp_reader;
|
||||
db::Layout *mp_layout;
|
||||
bool m_create;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// GDS2ReaderBase
|
||||
|
||||
GDS2ReaderBase::GDS2ReaderBase ()
|
||||
: m_dbu (0.001),
|
||||
m_dbuu (1.0),
|
||||
m_create_layers (true),
|
||||
m_read_texts (true),
|
||||
m_read_properties (true),
|
||||
m_allow_multi_xy_records (false),
|
||||
|
|
@ -83,31 +54,18 @@ GDS2ReaderBase::~GDS2ReaderBase ()
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
GDS2ReaderBase::basic_read (db::Layout &layout, const LayerMap &layer_map, bool create_other_layers, bool enable_text_objects, bool enable_properties, bool allow_multi_xy_records, unsigned int box_mode, db::CommonReader::CellConflictResolution cc_resolution)
|
||||
void
|
||||
GDS2ReaderBase::init (const db::LoadLayoutOptions &options)
|
||||
{
|
||||
m_layer_map = layer_map;
|
||||
m_layer_map.prepare (layout);
|
||||
m_read_texts = enable_text_objects;
|
||||
m_read_properties = enable_properties;
|
||||
CommonReader::init (options);
|
||||
|
||||
m_allow_multi_xy_records = allow_multi_xy_records;
|
||||
m_box_mode = box_mode;
|
||||
m_create_layers = create_other_layers;
|
||||
db::GDS2ReaderOptions gds2_options = options.get_options<db::GDS2ReaderOptions> ();
|
||||
|
||||
set_cell_conflict_resolution (cc_resolution);
|
||||
m_read_texts = common_options ().enable_text_objects;
|
||||
m_read_properties = common_options ().enable_properties;
|
||||
|
||||
layout.start_changes ();
|
||||
try {
|
||||
do_read (layout);
|
||||
finish (layout);
|
||||
layout.end_changes ();
|
||||
} catch (...) {
|
||||
layout.end_changes ();
|
||||
throw;
|
||||
}
|
||||
|
||||
return m_layer_map;
|
||||
m_allow_multi_xy_records = gds2_options.allow_multi_xy_records;
|
||||
m_box_mode = gds2_options.box_mode;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -181,34 +139,6 @@ GDS2ReaderBase::finish_element (db::PropertiesRepository &rep)
|
|||
}
|
||||
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
GDS2ReaderBase::open_dl (db::Layout &layout, const LDPair &dl, bool create)
|
||||
{
|
||||
std::pair<bool, unsigned int> ll = m_layer_map.logical (dl, layout);
|
||||
if (ll.first) {
|
||||
|
||||
return ll;
|
||||
|
||||
} else if (! create) {
|
||||
|
||||
// layer not mapped and no layer create is requested
|
||||
return ll;
|
||||
|
||||
} else {
|
||||
|
||||
// and create the layer
|
||||
db::LayerProperties lp;
|
||||
lp.layer = dl.layer;
|
||||
lp.datatype = dl.datatype;
|
||||
|
||||
unsigned int ll = layout.insert_layer (lp);
|
||||
m_layer_map.map (dl, ll, lp);
|
||||
|
||||
return std::make_pair (true, ll);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
inline db::Point
|
||||
pt_conv (const GDS2XY &p)
|
||||
{
|
||||
|
|
@ -361,7 +291,7 @@ GDS2ReaderBase::do_read (db::Layout &layout)
|
|||
bool ignore_cell = false;
|
||||
std::map <tl::string, std::vector <std::string> >::const_iterator ctx = m_context_info.find (m_cellname);
|
||||
if (ctx != m_context_info.end ()) {
|
||||
GDS2ReaderLayerMapping layer_mapping (this, &layout, m_create_layers);
|
||||
CommonReaderLayerMapping layer_mapping (this, &layout);
|
||||
if (layout.recover_proxy_as (cell_index, ctx->second.begin (), ctx->second.end (), &layer_mapping)) {
|
||||
// ignore everything in that cell since it is created by the import:
|
||||
ignore_cell = true;
|
||||
|
|
@ -557,7 +487,7 @@ GDS2ReaderBase::read_boundary (db::Layout &layout, db::Cell &cell, bool from_box
|
|||
unsigned int xy_length = 0;
|
||||
GDS2XY *xy_data = get_xy_data (xy_length);
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, ld, m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, ld);
|
||||
if (ll.first) {
|
||||
|
||||
// create a box object if possible
|
||||
|
|
@ -738,7 +668,7 @@ GDS2ReaderBase::read_path (db::Layout &layout, db::Cell &cell)
|
|||
unsigned int xy_length = 0;
|
||||
GDS2XY *xy_data = get_xy_data (xy_length);
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, ld, m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, ld);
|
||||
if (ll.first) {
|
||||
|
||||
// this will copy the path:
|
||||
|
|
@ -829,7 +759,7 @@ GDS2ReaderBase::read_text (db::Layout &layout, db::Cell &cell)
|
|||
std::pair<bool, unsigned int> ll (false, 0);
|
||||
|
||||
if (m_read_texts) {
|
||||
ll = open_dl (layout, ld, m_create_layers);
|
||||
ll = open_dl (layout, ld);
|
||||
}
|
||||
|
||||
rec_id = get_record ();
|
||||
|
|
@ -951,7 +881,7 @@ GDS2ReaderBase::read_box (db::Layout &layout, db::Cell &cell)
|
|||
}
|
||||
ld.datatype = get_ushort ();
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, ld, m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, ld);
|
||||
|
||||
if (get_record () != sXY) {
|
||||
error (tl::to_string (tr ("XY record expected")));
|
||||
|
|
|
|||
|
|
@ -69,42 +69,20 @@ public:
|
|||
const std::string &libname () const { return m_libname; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief The basic read method
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* It can be given a couple of options specified with the
|
||||
* LoadLayoutOptions object.
|
||||
* The returned map will contain all layers, the passed
|
||||
* ones and the newly created ones.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @param layer_map The layer mapping on input
|
||||
* @param create_other_layer A flag indicating whether to read all other layers
|
||||
* @param enable_text_objects A flag indicating whether to read text objects
|
||||
* @param enable_properties A flag indicating whether to read user properties
|
||||
* @param allow_multi_xy_records If true, tries to check for multiple XY records for BOUNDARY elements
|
||||
* @param box_mode How to treat BOX records (0: ignore, 1: as rectangles, 2: as boundaries, 3: error)
|
||||
* @param cc_resolution The cell name conflict resolution mode
|
||||
* @return The LayerMap object that tells where which layer was loaded
|
||||
*/
|
||||
const LayerMap &basic_read (db::Layout &layout, const LayerMap &layer_map, bool create_other_layers, bool enable_text_objects, bool enable_properties, bool allow_multi_xy_records, unsigned int box_mode, db::CommonReader::CellConflictResolution cc_resolution);
|
||||
|
||||
/**
|
||||
* @brief Accessor method to the current cellname
|
||||
*/
|
||||
const std::string &cellname () const { return m_cellname; }
|
||||
|
||||
virtual void do_read (db::Layout &layout);
|
||||
virtual void init (const LoadLayoutOptions &options);
|
||||
|
||||
private:
|
||||
friend class GDS2ReaderLayerMapping;
|
||||
|
||||
LayerMap m_layer_map;
|
||||
std::string m_cellname;
|
||||
std::string m_libname;
|
||||
double m_dbu, m_dbuu;
|
||||
bool m_create_layers;
|
||||
bool m_read_texts;
|
||||
bool m_read_properties;
|
||||
bool m_allow_multi_xy_records;
|
||||
|
|
@ -119,9 +97,6 @@ private:
|
|||
void read_box (db::Layout &layout, db::Cell &cell);
|
||||
void read_ref (db::Layout &layout, db::Cell &cell, bool array, tl::vector<db::CellInstArray> &instances, tl::vector<db::CellInstArrayWithProperties> &insts_wp);
|
||||
|
||||
void do_read (db::Layout &layout);
|
||||
|
||||
std::pair <bool, unsigned int> open_dl (db::Layout &layout, const LDPair &dl, bool create);
|
||||
std::pair <bool, db::properties_id_type> finish_element (db::PropertiesRepository &rep);
|
||||
void finish_element ();
|
||||
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ TEST(2)
|
|||
db::Layout layout_piece (&m);
|
||||
layout_piece = layout;
|
||||
|
||||
std::pair<bool, unsigned int> jj = map_full.logical (pairs[i]);
|
||||
std::pair<bool, unsigned int> jj = map_full.first_logical (pairs[i]);
|
||||
EXPECT_EQ (jj.first, true);
|
||||
|
||||
for (unsigned int j = 0; j < layout_piece.layers(); ++j) {
|
||||
|
|
@ -418,7 +418,7 @@ TEST(3_AdvancedMapping)
|
|||
|
||||
EXPECT_EQ (lm_read.to_string_file_format (),
|
||||
"1/10 : 1/0\n"
|
||||
"2/0-9,21-*\n"
|
||||
"2/0-1 : 2/0\n"
|
||||
"1/0 : 1/0\n"
|
||||
"1/1 : 1/1\n"
|
||||
"1/20 : 1/1020\n"
|
||||
|
|
@ -427,23 +427,103 @@ TEST(3_AdvancedMapping)
|
|||
"2/11 : 2/11\n"
|
||||
"42/42 : 142/42\n"
|
||||
"100/0 : 200/0\n"
|
||||
"2/12-20 : */*\n"
|
||||
"1/22-30 : 1/*+1000\n"
|
||||
"1/2-9,11-19,31-* : */*\n"
|
||||
"0/*;3-41/*;42/0-41,43-*;43-99/*;100/1-*;101-*/* : *+100/*\n"
|
||||
);
|
||||
|
||||
std::string fn_au (tl::testsrc () + "/testdata/gds/alm_au.gds");
|
||||
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
|
||||
}
|
||||
|
||||
TEST(3_MultiMapping)
|
||||
{
|
||||
db::Manager m (false);
|
||||
db::Layout layout (&m);
|
||||
|
||||
db::LoadLayoutOptions options;
|
||||
db::LayerMap lm, lm_read;
|
||||
|
||||
unsigned int n = 0;
|
||||
lm.map_expr ("*/*: */*", n++);
|
||||
lm.unmap_expr ("1-2/10");
|
||||
lm.mmap_expr ("1-2/10: *+100/*", n++);
|
||||
lm.mmap_expr ("1/10;2/10: 12/1010", n++);
|
||||
lm.mmap_expr ("1/0-1: */*+1000", n++);
|
||||
options.get_options<db::CommonReaderOptions> ().layer_map = lm;
|
||||
|
||||
{
|
||||
tl::InputStream file (tl::testsrc () + "/testdata/gds/alm.gds");
|
||||
db::Reader reader (file);
|
||||
lm_read = reader.read (layout, options);
|
||||
}
|
||||
|
||||
EXPECT_EQ (lm_read.to_string_file_format (),
|
||||
"+1-2/10 : 12/1010\n"
|
||||
"+1/0 : 1/1000\n"
|
||||
"+1/0 : 1/0\n"
|
||||
"+1/1 : 1/1001\n"
|
||||
"+1/1 : 1/1\n"
|
||||
"+1/10 : 101/10\n"
|
||||
"1/20 : 1/20\n"
|
||||
"1/21 : 1/21\n"
|
||||
"2/0 : 2/0\n"
|
||||
"2/1 : 2/1\n"
|
||||
"+2/10 : 102/10\n"
|
||||
"2/11 : 2/11\n"
|
||||
"42/42 : 42/42\n"
|
||||
"100/0 : 100/0\n"
|
||||
);
|
||||
|
||||
std::string fn_au (tl::testsrc () + "/testdata/gds/alm_au2.gds");
|
||||
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
|
||||
}
|
||||
|
||||
TEST(3_MultiMapping2)
|
||||
{
|
||||
db::Manager m (false);
|
||||
db::Layout layout (&m);
|
||||
|
||||
db::LoadLayoutOptions options;
|
||||
db::LayerMap lm, lm_read;
|
||||
|
||||
unsigned int n = 0;
|
||||
lm.add_expr ("(1/0:1/0)", n++);
|
||||
lm.add_expr ("+(1/0:1000/0)", n++);
|
||||
lm.add_expr ("(4/0:1/0)", n++);
|
||||
lm.add_expr ("(2/0:2/0)", n++);
|
||||
lm.add_expr ("+(2/0:1000/0)", n++);
|
||||
lm.add_expr ("(3/0:3/0)", n++);
|
||||
options.get_options<db::CommonReaderOptions> ().layer_map = lm;
|
||||
|
||||
{
|
||||
tl::InputStream file (tl::testsrc () + "/testdata/gds/t10.gds");
|
||||
db::Reader reader (file);
|
||||
lm_read = reader.read (layout, options);
|
||||
}
|
||||
|
||||
EXPECT_EQ (lm_read.to_string_file_format (),
|
||||
"+1/0;4/0 : 1/0\n"
|
||||
"+1-2/0 : 1000/0\n"
|
||||
"+2/0 : 2/0\n"
|
||||
"3/0 : 3/0\n"
|
||||
"6/0 : 6/0\n"
|
||||
"8/0 : 8/0\n"
|
||||
"5/0 : 5/0\n"
|
||||
"7/0 : 7/0\n"
|
||||
"3/1 : 3/1\n"
|
||||
"6/1 : 6/1\n"
|
||||
"8/1 : 8/1\n"
|
||||
);
|
||||
|
||||
std::string fn_au (tl::testsrc () + "/testdata/gds/alm_au3.gds");
|
||||
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
|
||||
}
|
||||
|
||||
TEST(4_CollectModeRename)
|
||||
{
|
||||
db::Manager m (false);
|
||||
db::Layout layout (&m);
|
||||
|
||||
db::LoadLayoutOptions options;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::CommonReader::RenameCell;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::RenameCell;
|
||||
|
||||
{
|
||||
tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic.gds");
|
||||
|
|
@ -467,7 +547,7 @@ TEST(4_CollectModeOverwrite)
|
|||
db::Layout layout (&m);
|
||||
|
||||
db::LoadLayoutOptions options;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::CommonReader::OverwriteCell;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::OverwriteCell;
|
||||
|
||||
{
|
||||
tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic.gds");
|
||||
|
|
@ -491,7 +571,7 @@ TEST(4_CollectModeSkip)
|
|||
db::Layout layout (&m);
|
||||
|
||||
db::LoadLayoutOptions options;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::CommonReader::SkipNewCell;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::SkipNewCell;
|
||||
|
||||
{
|
||||
tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic.gds");
|
||||
|
|
@ -515,7 +595,7 @@ TEST(4_CollectModeAdd)
|
|||
db::Layout layout (&m);
|
||||
|
||||
db::LoadLayoutOptions options;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::CommonReader::AddToCell;
|
||||
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::AddToCell;
|
||||
|
||||
{
|
||||
tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic.gds");
|
||||
|
|
|
|||
|
|
@ -157,14 +157,14 @@ DEFImporter::read_diearea (db::Layout &layout, db::Cell &design, double scale)
|
|||
if (points.size () >= 2) {
|
||||
|
||||
// create outline shape
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Outline, 0);
|
||||
if (dl.first) {
|
||||
std::set<unsigned int> dl = open_layer (layout, std::string (), Outline, 0);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
if (points.size () == 2) {
|
||||
design.shapes (dl.second).insert (db::Box (points [0], points [1]));
|
||||
design.shapes (*l).insert (db::Box (points [0], points [1]));
|
||||
} else {
|
||||
db::Polygon p;
|
||||
p.assign_hull (points.begin (), points.end ());
|
||||
design.shapes (dl.second).insert (p);
|
||||
design.shapes (*l).insert (p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -305,9 +305,9 @@ DEFImporter::read_blockages (db::Layout &layout, db::Cell &design, double scale)
|
|||
db::Polygon p;
|
||||
read_polygon (p, scale);
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, layer, layer.empty () ? PlacementBlockage : Blockage, 0);
|
||||
if (dl.first) {
|
||||
design.shapes (dl.second).insert (p);
|
||||
std::set <unsigned int> dl = open_layer (layout, layer, layer.empty () ? PlacementBlockage : Blockage, 0);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
design.shapes (*l).insert (p);
|
||||
}
|
||||
|
||||
} else if (test ("RECT")) {
|
||||
|
|
@ -315,9 +315,9 @@ DEFImporter::read_blockages (db::Layout &layout, db::Cell &design, double scale)
|
|||
db::Polygon p;
|
||||
read_rect (p, scale);
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, layer, layer.empty () ? PlacementBlockage : Blockage, 0);
|
||||
if (dl.first) {
|
||||
design.shapes (dl.second).insert (p);
|
||||
std::set <unsigned int> dl = open_layer (layout, layer, layer.empty () ? PlacementBlockage : Blockage, 0);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
design.shapes (*l).insert (p);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -554,17 +554,19 @@ DEFImporter::read_single_net (std::string &nondefaultrule, Layout &layout, db::C
|
|||
|
||||
test (")");
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
if (dl.first) {
|
||||
std::set <unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
if (! dl.empty ()) {
|
||||
|
||||
db::Point p (x, y);
|
||||
db::Box rect (db::Point (db::DPoint ((x + x1) * scale, (y + y1) * scale)),
|
||||
db::Point (db::DPoint ((x + x2) * scale, (y + y2) * scale)));
|
||||
|
||||
if (prop_id != 0) {
|
||||
design.shapes (dl.second).insert (db::object_with_properties<db::Box> (rect, prop_id));
|
||||
} else {
|
||||
design.shapes (dl.second).insert (rect);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
if (prop_id != 0) {
|
||||
design.shapes (*l).insert (db::object_with_properties<db::Box> (rect, prop_id));
|
||||
} else {
|
||||
design.shapes (*l).insert (rect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -615,9 +617,9 @@ DEFImporter::read_single_net (std::string &nondefaultrule, Layout &layout, db::C
|
|||
}
|
||||
|
||||
if (pts.size () > 1) {
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
if (dl.first) {
|
||||
produce_routing_geometry (design, style, dl.second, prop_id, pts, ext, w);
|
||||
std::set <unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
produce_routing_geometry (design, style, *l, prop_id, pts, ext, w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -803,12 +805,12 @@ DEFImporter::read_nets (db::Layout &layout, db::Cell &design, double scale, bool
|
|||
db::Polygon p;
|
||||
read_polygon (p, scale);
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
if (dl.first) {
|
||||
std::set <unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
if (prop_id != 0) {
|
||||
design.shapes (dl.second).insert (db::object_with_properties<db::Polygon> (p, prop_id));
|
||||
design.shapes (*l).insert (db::object_with_properties<db::Polygon> (p, prop_id));
|
||||
} else {
|
||||
design.shapes (dl.second).insert (p);
|
||||
design.shapes (*l).insert (p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -821,12 +823,12 @@ DEFImporter::read_nets (db::Layout &layout, db::Cell &design, double scale, bool
|
|||
db::Polygon p;
|
||||
read_rect (p, scale);
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
if (dl.first) {
|
||||
std::set <unsigned int> dl = open_layer (layout, ln, specialnets ? SpecialRouting : Routing, mask);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
if (prop_id != 0) {
|
||||
design.shapes (dl.second).insert (db::object_with_properties<db::Polygon> (p, prop_id));
|
||||
design.shapes (*l).insert (db::object_with_properties<db::Polygon> (p, prop_id));
|
||||
} else {
|
||||
design.shapes (dl.second).insert (p);
|
||||
design.shapes (*l).insert (p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1191,8 +1193,8 @@ DEFImporter::read_pins (db::Layout &layout, db::Cell &design, double scale)
|
|||
// Produce geometry collected so far
|
||||
for (std::map<std::pair<std::string, unsigned int>, std::vector<db::Polygon> >::const_iterator g = geometry.begin (); g != geometry.end (); ++g) {
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, g->first.first, Pins, g->first.second);
|
||||
if (dl.first) {
|
||||
std::set<unsigned int> dl = open_layer (layout, g->first.first, Pins, g->first.second);
|
||||
if (! dl.empty ()) {
|
||||
|
||||
db::properties_id_type prop_id = 0;
|
||||
if (produce_pin_props ()) {
|
||||
|
|
@ -1204,21 +1206,27 @@ DEFImporter::read_pins (db::Layout &layout, db::Cell &design, double scale)
|
|||
for (std::vector<db::Polygon>::const_iterator p = g->second.begin (); p != g->second.end (); ++p) {
|
||||
db::Polygon pt = p->transformed (trans);
|
||||
if (prop_id == 0) {
|
||||
design.shapes (dl.second).insert (pt);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
design.shapes (*l).insert (pt);
|
||||
}
|
||||
} else {
|
||||
design.shapes (dl.second).insert (db::PolygonWithProperties (pt, prop_id));
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
design.shapes (*l).insert (db::PolygonWithProperties (pt, prop_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dl = open_layer (layout, g->first.first, Label, 0);
|
||||
if (dl.first) {
|
||||
if (! dl.empty ()) {
|
||||
db::Box bbox;
|
||||
if (! g->second.empty ()) {
|
||||
bbox = g->second.back ().box ().transformed (trans);
|
||||
}
|
||||
design.shapes (dl.second).insert (db::Text (label.c_str (), db::Trans (db::Vector (bbox.center ()))));
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
design.shapes (*l).insert (db::Text (label.c_str (), db::Trans (db::Vector (bbox.center ()))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1554,10 +1562,10 @@ DEFImporter::do_read (db::Layout &layout)
|
|||
|
||||
} else {
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Regions, 0);
|
||||
if (dl.first) {
|
||||
std::set<unsigned int> dl = open_layer (layout, std::string (), Regions, 0);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
for (std::vector<db::Polygon>::const_iterator p = r->second.begin (); p != r->second.end (); ++p) {
|
||||
group_cell->shapes (dl.second).insert (*p);
|
||||
group_cell->shapes (*l).insert (*p);
|
||||
}
|
||||
}
|
||||
regions.erase (r);
|
||||
|
|
@ -1597,12 +1605,12 @@ DEFImporter::do_read (db::Layout &layout)
|
|||
|
||||
if (! regions.empty ()) {
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Regions, 0);
|
||||
if (dl.first) {
|
||||
std::set<unsigned int> dl = open_layer (layout, std::string (), Regions, 0);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
|
||||
for (std::map<std::string, std::vector<db::Polygon> >::const_iterator r = regions.begin (); r != regions.end (); ++r) {
|
||||
for (std::vector<db::Polygon>::const_iterator p = r->second.begin (); p != r->second.end (); ++p) {
|
||||
others_cell->shapes (dl.second).insert (*p);
|
||||
others_cell->shapes (*l).insert (*p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,16 +142,16 @@ RuleBasedViaGenerator::create_cell (LEFDEFReaderState &reader, Layout &layout, d
|
|||
db::Vector vs ((m_cutsize.x () * m_columns + m_cutspacing.x () * (m_columns - 1)) / 2, (m_cutsize.y () * m_rows + m_cutspacing.y () * (m_rows - 1)) / 2);
|
||||
db::Box via_box (m_offset - vs, m_offset + vs);
|
||||
|
||||
std::pair <bool, unsigned int> dl (false, 0);
|
||||
std::set <unsigned int> dl;
|
||||
|
||||
dl = reader.open_layer (layout, m_bottom_layer, ViaGeometry, mask_bottom);
|
||||
if (dl.first) {
|
||||
cell.shapes (dl.second).insert (db::Polygon (via_box.enlarged (m_be).moved (m_bo)));
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
cell.shapes (*l).insert (db::Polygon (via_box.enlarged (m_be).moved (m_bo)));
|
||||
}
|
||||
|
||||
dl = reader.open_layer (layout, m_top_layer, ViaGeometry, mask_top);
|
||||
if (dl.first) {
|
||||
cell.shapes (dl.second).insert (db::Polygon (via_box.enlarged (m_te).moved (m_bo)));
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
cell.shapes (*l).insert (db::Polygon (via_box.enlarged (m_te).moved (m_bo)));
|
||||
}
|
||||
|
||||
const char *p = m_pattern.c_str ();
|
||||
|
|
@ -249,8 +249,8 @@ RuleBasedViaGenerator::create_cell (LEFDEFReaderState &reader, Layout &layout, d
|
|||
}
|
||||
|
||||
dl = reader.open_layer (layout, m_cut_layer, ViaGeometry, cm);
|
||||
if (dl.first) {
|
||||
cell.shapes (dl.second).insert (db::Polygon (vb));
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
cell.shapes (*l).insert (db::Polygon (vb));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -318,9 +318,9 @@ GeometryBasedLayoutGenerator::create_cell (LEFDEFReaderState &reader, Layout &la
|
|||
unsigned int mshift = get_maskshift (g->first.first, ext_msl, masks);
|
||||
unsigned int mask = mask_for (g->first.first, g->first.second.second, mshift, nm);
|
||||
|
||||
std::pair <bool, unsigned int> dl = reader.open_layer (layout, g->first.first, g->first.second.first, mask);
|
||||
if (dl.first) {
|
||||
cell.shapes (dl.second).insert (g->second);
|
||||
std::set <unsigned int> dl = reader.open_layer (layout, g->first.first, g->first.second.first, mask);
|
||||
for (std::set<unsigned int>::const_iterator l = dl.begin (); l != dl.end (); ++l) {
|
||||
cell.shapes (*l).insert (g->second);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -801,12 +801,24 @@ LEFDEFReaderState::register_layer (const std::string &ln)
|
|||
++m_laynum;
|
||||
}
|
||||
|
||||
void
|
||||
LEFDEFReaderState::map_layer_explicit (const std::string &n, LayerPurpose purpose, const db::LayerProperties &lp, unsigned int layer, unsigned int mask)
|
||||
static bool try_read_layers (tl::Extractor &ex, std::vector<int> &layers)
|
||||
{
|
||||
tl_assert (m_has_explicit_layer_mapping);
|
||||
m_layers [std::make_pair (n, std::make_pair (purpose, mask))] = std::make_pair (true, layer);
|
||||
m_layer_map.map (lp, layer);
|
||||
int l = 0;
|
||||
if (! ex.try_read (l)) {
|
||||
return false;
|
||||
}
|
||||
layers.push_back (l);
|
||||
|
||||
if (ex.test (",")) {
|
||||
do {
|
||||
if (! ex.try_read (l)) {
|
||||
return false;
|
||||
}
|
||||
layers.push_back (l);
|
||||
} while (ex.test (","));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -828,13 +840,14 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
|
|||
purpose_translation ["NET"] = Routing;
|
||||
purpose_translation ["VIA"] = ViaGeometry;
|
||||
purpose_translation ["BLOCKAGE"] = Blockage;
|
||||
purpose_translation ["ALL"] = All;
|
||||
|
||||
std::map<LayerPurpose, std::string> purpose_translation_rev;
|
||||
for (std::map<std::string, LayerPurpose>::const_iterator i = purpose_translation.begin (); i != purpose_translation.end (); ++i) {
|
||||
purpose_translation_rev.insert (std::make_pair (i->second, i->first));
|
||||
}
|
||||
|
||||
std::map<std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, db::LayerProperties> layer_map;
|
||||
std::map<std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::vector<db::LayerProperties> > layer_map;
|
||||
|
||||
while (! ts.at_end ()) {
|
||||
|
||||
|
|
@ -848,113 +861,173 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
|
|||
} else {
|
||||
|
||||
std::string w1, w2;
|
||||
int layer = 0, datatype = 0;
|
||||
std::vector<int> layers, datatypes;
|
||||
size_t max_purpose_str = 10;
|
||||
|
||||
if (ex.try_read_word (w1) && ex.try_read_word (w2, "._$,/:") && ex.try_read (layer) && ex.try_read (datatype)) {
|
||||
if (! ex.try_read_word (w1) || ! ex.try_read_word (w2, "._$,/:") || ! try_read_layers (ex, layers) || ! try_read_layers (ex, datatypes)) {
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("Reading layer map file %s, line %d not understood - skipped")), path, ts.line_number ());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (w1 == "DIEAREA") {
|
||||
if (w1 == "DIEAREA") {
|
||||
|
||||
layer_map [std::make_pair (std::string (), std::make_pair (Outline, (unsigned int) 0))] = db::LayerProperties (layer, datatype, "OUTLINE");
|
||||
for (std::vector<int>::const_iterator l = layers.begin (); l != layers.end (); ++l) {
|
||||
for (std::vector<int>::const_iterator d = datatypes.begin (); d != datatypes.end (); ++d) {
|
||||
layer_map [std::make_pair (std::string (), std::make_pair (Outline, (unsigned int) 0))].push_back (db::LayerProperties (*l, *d, "OUTLINE"));
|
||||
}
|
||||
}
|
||||
|
||||
} else if (w1 == "REGIONS") {
|
||||
} else if (w1 == "REGIONS") {
|
||||
|
||||
layer_map [std::make_pair (std::string (), std::make_pair (Regions, (unsigned int) 0))] = db::LayerProperties (layer, datatype, "REGIONS");
|
||||
for (std::vector<int>::const_iterator l = layers.begin (); l != layers.end (); ++l) {
|
||||
for (std::vector<int>::const_iterator d = datatypes.begin (); d != datatypes.end (); ++d) {
|
||||
layer_map [std::make_pair (std::string (), std::make_pair (Regions, (unsigned int) 0))].push_back (db::LayerProperties (*l, *d, "REGIONS"));
|
||||
}
|
||||
}
|
||||
|
||||
} else if (w1 == "BLOCKAGE") {
|
||||
} else if (w1 == "BLOCKAGE") {
|
||||
|
||||
layer_map [std::make_pair (std::string (), std::make_pair (PlacementBlockage, (unsigned int) 0))] = db::LayerProperties (layer, datatype, "PLACEMENT_BLK");
|
||||
for (std::vector<int>::const_iterator l = layers.begin (); l != layers.end (); ++l) {
|
||||
for (std::vector<int>::const_iterator d = datatypes.begin (); d != datatypes.end (); ++d) {
|
||||
layer_map [std::make_pair (std::string (), std::make_pair (PlacementBlockage, (unsigned int) 0))].push_back (db::LayerProperties (*l, *d, "PLACEMENT_BLK"));
|
||||
}
|
||||
}
|
||||
|
||||
} else if (w1 == "NAME") {
|
||||
} else if (w1 == "NAME") {
|
||||
|
||||
// converts a line like
|
||||
// "NAME M1/PINS,M2/PINS ..."
|
||||
// into a canonical name mapping like
|
||||
// "(M1/LABELS): M1.LABEL"
|
||||
// "(M2/LABELS): M2.LABEL"
|
||||
// converts a line like
|
||||
// "NAME M1/PINS,M2/PINS ..."
|
||||
// into a canonical name mapping like
|
||||
// "(M1/LABELS): M1.LABEL"
|
||||
// "(M2/LABELS): M2.LABEL"
|
||||
|
||||
std::vector<std::string> layer_names;
|
||||
std::vector<std::string> purposes = tl::split (w2, ",");
|
||||
for (std::vector<std::string>::const_iterator p = purposes.begin (); p != purposes.end (); ++p) {
|
||||
if (*p == "DIEAREA" || *p == "ALL" || *p == "COMP") {
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("Reading layer map file %s, line %d: NAME record ignored for entity: %s")), path, ts.line_number (), *p);
|
||||
} else {
|
||||
layer_names.push_back (tl::split (*p, "/").front ());
|
||||
}
|
||||
}
|
||||
|
||||
std::string final_name = tl::join (layer_names, "/") + ".LABEL";
|
||||
for (std::vector<std::string>::const_iterator ln = layer_names.begin (); ln != layer_names.end (); ++ln) {
|
||||
for (std::vector<int>::const_iterator l = layers.begin (); l != layers.end (); ++l) {
|
||||
for (std::vector<int>::const_iterator d = datatypes.begin (); d != datatypes.end (); ++d) {
|
||||
layer_map [std::make_pair (*ln, std::make_pair (Label, (unsigned int) 0))].push_back (db::LayerProperties (*l, *d, final_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (w1 == "COMP") {
|
||||
|
||||
// ignore "COMP (ALL) ..."
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("Reading layer map file %s, line %d: COMP entry ignored")), path, ts.line_number ());
|
||||
|
||||
} else {
|
||||
|
||||
// converts a line like
|
||||
// "M1 SPNET,NET,PINS,LEFPINS ..."
|
||||
// into a canonical name mapping like
|
||||
// "(M1,NET): M1.NET/PINS"
|
||||
// "(M1,PINS): M1.NET/PINS"
|
||||
// (separating, translating and recombing the purposes)
|
||||
|
||||
std::set<std::pair<LayerPurpose, unsigned int> > translated_purposes;
|
||||
|
||||
std::vector<std::string> purposes = tl::split (w2, ",");
|
||||
std::reverse (purposes.begin (), purposes.end ());
|
||||
|
||||
unsigned int mask = 0;
|
||||
|
||||
for (std::vector<std::string>::const_iterator p = purposes.begin (); p != purposes.end (); ++p) {
|
||||
|
||||
std::string p_uc = tl::to_upper_case (*p);
|
||||
tl::Extractor ex (p_uc.c_str ());
|
||||
|
||||
std::string ps;
|
||||
ex.read_word_or_quoted (ps);
|
||||
|
||||
std::map<std::string, LayerPurpose>::const_iterator i = purpose_translation.find (ps);
|
||||
if (i != purpose_translation.end ()) {
|
||||
|
||||
if (i->second == Routing) {
|
||||
|
||||
if (ex.test (":VOLTAGE:")) {
|
||||
double f = 0.0;
|
||||
ex.read (f);
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("Reading layer map file %s, line %d: NET voltage constraint ignored for layer %s")), path, ts.line_number (), w1);
|
||||
}
|
||||
|
||||
} else if (i->second == ViaGeometry) {
|
||||
|
||||
if (ex.test (":SIZE:")) {
|
||||
std::string sz;
|
||||
ex.read_word (sz);
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("Reading layer map file %s, line %d: VIA size constraint ignored for layer %s")), path, ts.line_number (), w1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::string> layers;
|
||||
std::vector<std::string> purposes = tl::split (w2, ",");
|
||||
for (std::vector<std::string>::const_iterator p = purposes.begin (); p != purposes.end (); ++p) {
|
||||
layers.push_back (tl::split (*p, "/").front ());
|
||||
}
|
||||
|
||||
std::string final_name = tl::join (layers, "/") + ".LABEL";
|
||||
for (std::vector<std::string>::const_iterator l = layers.begin (); l != layers.end (); ++l) {
|
||||
layer_map [std::make_pair (*l, std::make_pair (Label, (unsigned int) 0))] = db::LayerProperties (layer, datatype, final_name);
|
||||
if (ex.test (":MASK:")) {
|
||||
ex.read (mask);
|
||||
}
|
||||
|
||||
} else if (w1 == "COMP") {
|
||||
if (i == purpose_translation.end ()) {
|
||||
|
||||
// ignore "COMP (ALL) ..."
|
||||
tl::warn << tl::sprintf (tl::to_string (tr ("Reading layer map file %s, line %d: purpose %s ignored for layer %s")), path, ts.line_number (), ps, w1);
|
||||
|
||||
} else {
|
||||
} else if (i->second == All) {
|
||||
|
||||
// converts a line like
|
||||
// "M1 SPNET,NET,PINS,LEFPINS ..."
|
||||
// into a canonical name mapping like
|
||||
// "(M1,NET): M1.NET/PINS"
|
||||
// "(M1,PINS): M1.NET/PINS"
|
||||
// (separating, translating and recombing the purposes)
|
||||
|
||||
std::set<std::pair<LayerPurpose, unsigned int> > translated_purposes;
|
||||
|
||||
std::vector<std::string> purposes = tl::split (w2, ",");
|
||||
std::reverse (purposes.begin (), purposes.end ());
|
||||
|
||||
unsigned int mask = 0;
|
||||
|
||||
for (std::vector<std::string>::const_iterator p = purposes.begin (); p != purposes.end (); ++p) {
|
||||
|
||||
std::string p_uc = tl::to_upper_case (*p);
|
||||
tl::Extractor ex (p_uc.c_str ());
|
||||
|
||||
std::string ps;
|
||||
ex.read_word_or_quoted (ps);
|
||||
|
||||
if (ex.test (":")) {
|
||||
if (ex.test ("MASK") && ex.test (":")) {
|
||||
ex.read (mask);
|
||||
for (std::map<std::string, LayerPurpose>::const_iterator p = purpose_translation.begin (); p != purpose_translation.end (); ++p) {
|
||||
if (p->second != All) {
|
||||
translated_purposes.insert (std::make_pair (p->second, mask));
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, LayerPurpose>::const_iterator i = purpose_translation.find (ps);
|
||||
if (i != purpose_translation.end ()) {
|
||||
translated_purposes.insert (std::make_pair (i->second, mask));
|
||||
}
|
||||
} else {
|
||||
|
||||
translated_purposes.insert (std::make_pair (i->second, mask));
|
||||
|
||||
}
|
||||
|
||||
// create a visual description string for the combined purposes
|
||||
std::string purpose_str;
|
||||
}
|
||||
|
||||
for (std::set<std::pair<LayerPurpose, unsigned int> >::const_iterator p = translated_purposes.begin (); p != translated_purposes.end (); ++p) {
|
||||
// create a visual description string for the combined purposes
|
||||
std::string purpose_str;
|
||||
|
||||
if (p != translated_purposes.begin ()) {
|
||||
purpose_str += "/";
|
||||
}
|
||||
|
||||
std::string ps = purpose_translation_rev [p->first];
|
||||
if (p->second > 0) {
|
||||
ps += ":";
|
||||
ps += tl::to_string (p->second);
|
||||
}
|
||||
|
||||
if ((purpose_str + ps).size () > max_purpose_str) {
|
||||
purpose_str += "...";
|
||||
break;
|
||||
} else {
|
||||
purpose_str += ps;
|
||||
}
|
||||
for (std::set<std::pair<LayerPurpose, unsigned int> >::const_iterator p = translated_purposes.begin (); p != translated_purposes.end (); ++p) {
|
||||
|
||||
if (p != translated_purposes.begin ()) {
|
||||
purpose_str += "/";
|
||||
}
|
||||
|
||||
std::string final_name = w1 + "." + purpose_str;
|
||||
|
||||
for (std::set<std::pair<LayerPurpose, unsigned int> >::const_iterator p = translated_purposes.begin (); p != translated_purposes.end (); ++p) {
|
||||
layer_map [std::make_pair (w1, *p)] = db::LayerProperties (layer, datatype, final_name);
|
||||
std::string ps = purpose_translation_rev [p->first];
|
||||
if (p->second > 0) {
|
||||
ps += ":";
|
||||
ps += tl::to_string (p->second);
|
||||
}
|
||||
|
||||
if ((purpose_str + ps).size () > max_purpose_str) {
|
||||
purpose_str += "...";
|
||||
break;
|
||||
} else {
|
||||
purpose_str += ps;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string final_name = w1 + "." + purpose_str;
|
||||
|
||||
for (std::set<std::pair<LayerPurpose, unsigned int> >::const_iterator p = translated_purposes.begin (); p != translated_purposes.end (); ++p) {
|
||||
for (std::vector<int>::const_iterator l = layers.begin (); l != layers.end (); ++l) {
|
||||
for (std::vector<int>::const_iterator d = datatypes.begin (); d != datatypes.end (); ++d) {
|
||||
layer_map [std::make_pair (w1, *p)].push_back (db::LayerProperties (*l, *d, final_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -963,19 +1036,29 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
|
|||
|
||||
}
|
||||
|
||||
// build an explicit layer mapping now.
|
||||
|
||||
tl_assert (m_has_explicit_layer_mapping);
|
||||
m_layers.clear ();
|
||||
m_layer_map.clear ();
|
||||
|
||||
db::DirectLayerMapping lm (&layout);
|
||||
for (std::map<std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, db::LayerProperties>::const_iterator i = layer_map.begin (); i != layer_map.end (); ++i) {
|
||||
map_layer_explicit (i->first.first, i->first.second.first, i->second, lm.map_layer (i->second).second, i->first.second.second);
|
||||
for (std::map<std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::vector<db::LayerProperties> >::const_iterator i = layer_map.begin (); i != layer_map.end (); ++i) {
|
||||
for (std::vector<db::LayerProperties>::const_iterator j = i->second.begin (); j != i->second.end (); ++j) {
|
||||
unsigned int layer = lm.map_layer (*j).second;
|
||||
m_layers [i->first].insert (layer);
|
||||
m_layer_map.mmap (*j, layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
std::set <unsigned int>
|
||||
LEFDEFReaderState::open_layer (db::Layout &layout, const std::string &n, LayerPurpose purpose, unsigned int mask)
|
||||
{
|
||||
std::map <std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::pair<bool, unsigned int> >::const_iterator nl = m_layers.find (std::make_pair (n, std::make_pair (purpose, mask)));
|
||||
std::map <std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::set<unsigned int> >::const_iterator nl = m_layers.find (std::make_pair (n, std::make_pair (purpose, mask)));
|
||||
if (nl == m_layers.end ()) {
|
||||
|
||||
std::pair <bool, unsigned int> ll (false, 0);
|
||||
std::set <unsigned int> ll;
|
||||
|
||||
if (n.empty () || ! m_has_explicit_layer_mapping) {
|
||||
ll = open_layer_uncached (layout, n, purpose, mask);
|
||||
|
|
@ -989,14 +1072,84 @@ LEFDEFReaderState::open_layer (db::Layout &layout, const std::string &n, LayerPu
|
|||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n, LayerPurpose purpose, unsigned int mask)
|
||||
static std::string purpose_to_name (LayerPurpose purpose)
|
||||
{
|
||||
switch (purpose) {
|
||||
case Outline:
|
||||
return "OUTLINE";
|
||||
case Regions:
|
||||
return "REGION";
|
||||
case PlacementBlockage:
|
||||
return "BLOCKAGE";
|
||||
case Routing:
|
||||
return "NET";
|
||||
case SpecialRouting:
|
||||
return "SPNET";
|
||||
case ViaGeometry:
|
||||
return "VIA";
|
||||
case Label:
|
||||
return "LABEL";
|
||||
case Pins:
|
||||
return "PIN";
|
||||
case LEFPins:
|
||||
return "LEFPIN";
|
||||
case Obstructions:
|
||||
return "LEFOBS";
|
||||
case Blockage:
|
||||
return "BLK";
|
||||
case All:
|
||||
return "ALL";
|
||||
}
|
||||
|
||||
return std::string ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Implements implicit layer mapping
|
||||
*
|
||||
* This is how Implicit layer mapping works:
|
||||
*
|
||||
* 1. For named layers (e.g. routing, pin, etc.
|
||||
*
|
||||
* A decorated name is formed from the basic name and the purpose string (e.g. "M1" -> "M1.PIN").
|
||||
* With the example of "M1" and purpose Pin (decorated name "M1.PIN") and with a tech component datatype specification
|
||||
* of "5" for "Pin", the layer map entries have the following effect:
|
||||
*
|
||||
* Layer map Result
|
||||
*
|
||||
* (nothing) M1.PIN (default/5) (only if "create_all_layers" is ON, "default" is a default number assigned by the reader)
|
||||
* M1.PIN : 1/0 M1.PIN (1/0)
|
||||
* M1.PIN : 1/17 M1.PIN (1/17)
|
||||
* M1 : 1/0 M1.PIN (1/5)
|
||||
* M1 : 1/2 M1.PIN (1/7) (datatypes will add)
|
||||
* M1 M1.PIN (default/5)
|
||||
* M1 : METAL1 METAL1.PIN (default/5) (name is taken from layer map and decorated)
|
||||
* M1 : METAL1 (1/2) METAL1.PIN (1/7)
|
||||
* M1.PIN : METAL1_PIN METAL1_PIN (default/5) (specific name is used without decoration)
|
||||
* M1.PIN : METAL1_PIN (1/17) METAL1_PIN (1/17) (full and specific mapping)
|
||||
*
|
||||
* 2. For general layers (e.g. outline)
|
||||
*
|
||||
* By default, the name, layer and datatype are taken from the tech component's specification. The specification may
|
||||
* lack the layer and datatype and even the name. If the name is missing, it is generated from the purpose.
|
||||
*
|
||||
* Here are some examples for the mapping of "OUTLINE":
|
||||
*
|
||||
* Tech component Layer map Result
|
||||
*
|
||||
* (nothing) (nothing) OUTLINE (only if "create_all_layers" is ON)
|
||||
* OUTL (nothing) OUTL (default/0) ("default" is a default number assigned by the reader)
|
||||
* OUTL (4/17) (nothing) OUTL (4/17)
|
||||
* OUTL OUTL : 5/1 OUTL (5/1)
|
||||
* OUTL (4/17) OUTL : 4/11 OUTL 4/11
|
||||
* OUTL (4/17) 4/17 : 4/11 OUTL 4/11
|
||||
* 4/17 4/17 : 4/11 OUTLINE 4/11
|
||||
*/
|
||||
|
||||
std::set<unsigned int> LEFDEFReaderState::open_layer_uncached(db::Layout &layout, const std::string &n, LayerPurpose purpose, unsigned int mask)
|
||||
{
|
||||
if (n.empty ()) {
|
||||
|
||||
// NOTE: the canonical name is independent from the tech component's settings
|
||||
// as is "(name)". It's used for implementing the automatic map file import
|
||||
// feature.
|
||||
std::string ld;
|
||||
bool produce = false;
|
||||
|
||||
|
|
@ -1012,7 +1165,7 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
}
|
||||
|
||||
if (! produce) {
|
||||
return std::make_pair (false, 0);
|
||||
return std::set<unsigned int> ();
|
||||
}
|
||||
|
||||
db::LayerProperties lp;
|
||||
|
|
@ -1024,13 +1177,69 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
lp.datatype = 0;
|
||||
}
|
||||
|
||||
for (db::Layout::layer_iterator l = layout.begin_layers (); l != layout.end_layers (); ++l) {
|
||||
if ((*l).second->log_equal (lp)) {
|
||||
return std::make_pair (true, (*l).first);
|
||||
// if no name is given, derive one from the purpose
|
||||
if (lp.name.empty ()) {
|
||||
lp.name = purpose_to_name (purpose);
|
||||
}
|
||||
|
||||
if (lp.layer < 0) {
|
||||
std::map<std::string, int>::const_iterator ldef = m_default_number.find (lp.name);
|
||||
if (ldef != m_default_number.end ()) {
|
||||
lp.layer = ldef->second;
|
||||
lp.datatype = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair (true, layout.insert_layer (lp));
|
||||
// employ the layer map to find the target layer
|
||||
std::set<unsigned int> ll = m_layer_map.logical (lp, layout);
|
||||
if (ll.empty () && ! m_create_layers) {
|
||||
return std::set<unsigned int> ();
|
||||
}
|
||||
|
||||
std::set<unsigned int> res;
|
||||
|
||||
// map the layers to targets from the layout
|
||||
// (NOTE: the other readers will do this in advance, but LEF/DEF is too dynamic)
|
||||
|
||||
bool at_least_once = true;
|
||||
for (std::set<unsigned int>::const_iterator l = ll.begin (); l != ll.end () || at_least_once; ++l) {
|
||||
|
||||
at_least_once = false;
|
||||
|
||||
// If the layer map provides a target, use that one for the layer
|
||||
db::LayerProperties lp_new = lp;
|
||||
const db::LayerProperties *lpp = (l == ll.end () ? 0 : m_layer_map.target (*l));
|
||||
if (lpp) {
|
||||
if (! lpp->name.empty ()) {
|
||||
lp_new.name = lpp->name;
|
||||
}
|
||||
if (lpp->datatype >= 0) {
|
||||
lp_new.datatype = lpp->datatype;
|
||||
}
|
||||
if (lpp->layer >= 0) {
|
||||
lp_new.layer = lpp->layer;
|
||||
}
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (db::Layout::layer_iterator i = layout.begin_layers (); i != layout.end_layers () && ! found; ++i) {
|
||||
if ((*i).second->log_equal (lp_new)) {
|
||||
found = true;
|
||||
res.insert ((*i).first);
|
||||
}
|
||||
}
|
||||
|
||||
if (! found) {
|
||||
res.insert (layout.insert_layer (lp_new));
|
||||
}
|
||||
|
||||
if (l == ll.end ()) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -1064,12 +1273,10 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
break;
|
||||
}
|
||||
if (! produce) {
|
||||
return std::make_pair (false, 0);
|
||||
return std::set<unsigned int> ();
|
||||
}
|
||||
}
|
||||
|
||||
// Note: "name" is the decorated name as provided by the tech component's
|
||||
// x_suffix specifications.
|
||||
std::string name_suffix;
|
||||
int dt = 0;
|
||||
|
||||
|
|
@ -1111,8 +1318,10 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
}
|
||||
}
|
||||
|
||||
// "name" is the decorated name as provided by the tech component's x_suffix specifications.
|
||||
std::string name = n + name_suffix;
|
||||
|
||||
// Assign a layer number (a default one for now) and the datatype from the tech component's x_datatype specification.
|
||||
db::LayerProperties lp (name);
|
||||
lp.datatype = dt;
|
||||
std::map<std::string, int>::const_iterator ldef = m_default_number.find (n);
|
||||
|
|
@ -1120,37 +1329,71 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
lp.layer = ldef->second;
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int> ll = m_layer_map.logical (name, layout);
|
||||
if (! ll.first) {
|
||||
// Route the layer through the layer map, first the decorated name and if there is no mapping, the
|
||||
// undecorated one.
|
||||
std::set<unsigned int> ll = m_layer_map.logical (name, layout);
|
||||
bool generic_match = false;
|
||||
if (ll.empty ()) {
|
||||
ll = m_layer_map.logical (n, layout);
|
||||
generic_match = true;
|
||||
} else if (n == name) {
|
||||
// no suffix defined in tech component -> treat as generic match and combine datatypes
|
||||
generic_match = true;
|
||||
}
|
||||
|
||||
if (ll.first) {
|
||||
if (ll.empty () && ! m_create_layers) {
|
||||
return std::set<unsigned int> ();
|
||||
}
|
||||
|
||||
const db::LayerProperties *lpp = m_layer_map.target (ll.second);
|
||||
std::set<unsigned int> res;
|
||||
|
||||
bool at_least_once = true;
|
||||
for (std::set<unsigned int>::const_iterator l = ll.begin (); l != ll.end () || at_least_once; ++l) {
|
||||
|
||||
at_least_once = false;
|
||||
|
||||
// If the layer map provides a target, use that one for the layer
|
||||
db::LayerProperties lp_new = lp;
|
||||
const db::LayerProperties *lpp = (l == ll.end () ? 0 : m_layer_map.target (*l));
|
||||
if (lpp) {
|
||||
lp = *lpp;
|
||||
if (lp.datatype >= 0) {
|
||||
lp.datatype += dt;
|
||||
lp_new = *lpp;
|
||||
if (lp_new.datatype < 0) {
|
||||
lp_new.datatype = dt;
|
||||
} else if (generic_match) {
|
||||
lp_new.datatype += dt;
|
||||
}
|
||||
if (lp.name.empty ()) {
|
||||
lp.name = name;
|
||||
if (lp_new.name.empty ()) {
|
||||
lp_new.name = name;
|
||||
} else if (generic_match) {
|
||||
lp_new.name += name_suffix;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (! m_create_layers) {
|
||||
return std::make_pair (false, 0);
|
||||
}
|
||||
|
||||
if (lp.layer >= 0 && lp.datatype >= 0) {
|
||||
for (db::Layout::layer_iterator l = layout.begin_layers (); l != layout.end_layers (); ++l) {
|
||||
if ((*l).second->log_equal (lp)) {
|
||||
return std::make_pair (true, (*l).first);
|
||||
int lfound = -1;
|
||||
if (lp_new.layer >= 0 && lp_new.datatype >= 0) {
|
||||
for (db::Layout::layer_iterator i = layout.begin_layers (); i != layout.end_layers () && lfound < 0; ++i) {
|
||||
if ((*i).second->log_equal (lp_new)) {
|
||||
lfound = int ((*i).first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lfound < 0) {
|
||||
res.insert (layout.insert_layer (lp_new));
|
||||
} else {
|
||||
res.insert ((unsigned int) lfound);
|
||||
db::LayerProperties lp_org = layout.get_properties ((unsigned int) lfound);
|
||||
join_layer_names (lp_org.name, name);
|
||||
layout.set_properties ((unsigned int) lfound, lp_org);
|
||||
}
|
||||
|
||||
if (l == ll.end ()) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return std::make_pair (true, layout.insert_layer (lp));
|
||||
return res;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1177,78 +1420,13 @@ LEFDEFReaderState::finish (db::Layout &layout)
|
|||
|
||||
db::LayerMap lm;
|
||||
|
||||
for (std::map <std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::pair<bool, unsigned int> >::const_iterator l = m_layers.begin (); l != m_layers.end (); ++l) {
|
||||
for (std::map <std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::set<unsigned int> >::const_iterator l = m_layers.begin (); l != m_layers.end (); ++l) {
|
||||
|
||||
if (! l->second.first) {
|
||||
if (l->second.empty ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string ps;
|
||||
|
||||
switch (l->first.second.first) {
|
||||
case Outline:
|
||||
ps = "OUTLINE";
|
||||
break;
|
||||
case Regions:
|
||||
ps = "REGION";
|
||||
break;
|
||||
case PlacementBlockage:
|
||||
ps = "PLACEMENT_BLK";
|
||||
break;
|
||||
case Routing:
|
||||
default:
|
||||
ps = "NET";
|
||||
break;
|
||||
case SpecialRouting:
|
||||
ps = "SPNET";
|
||||
break;
|
||||
case ViaGeometry:
|
||||
ps = "VIA";
|
||||
break;
|
||||
case Label:
|
||||
ps = "LABEL";
|
||||
break;
|
||||
case Pins:
|
||||
ps = "PIN";
|
||||
break;
|
||||
case LEFPins:
|
||||
ps = "LEFPIN";
|
||||
break;
|
||||
case Obstructions:
|
||||
ps = "OBS";
|
||||
break;
|
||||
case Blockage:
|
||||
ps = "BLK";
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned int layer_index = l->second.second;
|
||||
db::LayerProperties lp = layout.get_properties (layer_index);
|
||||
|
||||
if (lp.layer < 0) {
|
||||
|
||||
std::map<std::string, int>::const_iterator n4n = number_for_name.end ();
|
||||
if (! l->first.first.empty ()) {
|
||||
n4n = number_for_name.find (l->first.first);
|
||||
}
|
||||
|
||||
if (n4n == number_for_name.end ()) {
|
||||
do {
|
||||
++lnum;
|
||||
} while (used_numbers.find (lnum) != used_numbers.end ());
|
||||
number_for_name.insert (std::make_pair (l->first.first, lnum));
|
||||
lp.layer = lnum;
|
||||
} else {
|
||||
lp.layer = n4n->second;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (lp.datatype < 0) {
|
||||
lp.datatype = 0;
|
||||
}
|
||||
|
||||
layout.set_properties (layer_index, lp);
|
||||
std::string ps = purpose_to_name (l->first.second.first);
|
||||
|
||||
std::string n = l->first.first;
|
||||
if (! n.empty ()) {
|
||||
|
|
@ -1261,11 +1439,43 @@ LEFDEFReaderState::finish (db::Layout &layout)
|
|||
n += tl::to_string (l->first.second.second);
|
||||
}
|
||||
|
||||
lm.map (db::LayerProperties (n), l->second.second, lp);
|
||||
for (std::set<unsigned int>::const_iterator li = l->second.begin (); li != l->second.end (); ++li) {
|
||||
|
||||
unsigned int layer_index = *li;
|
||||
db::LayerProperties lp = layout.get_properties (layer_index);
|
||||
|
||||
if (lp.layer < 0) {
|
||||
|
||||
std::map<std::string, int>::const_iterator n4n = number_for_name.end ();
|
||||
if (! l->first.first.empty ()) {
|
||||
n4n = number_for_name.find (l->first.first);
|
||||
}
|
||||
|
||||
if (n4n == number_for_name.end ()) {
|
||||
do {
|
||||
++lnum;
|
||||
} while (used_numbers.find (lnum) != used_numbers.end ());
|
||||
number_for_name.insert (std::make_pair (l->first.first, lnum));
|
||||
lp.layer = lnum;
|
||||
} else {
|
||||
lp.layer = n4n->second;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (lp.datatype < 0) {
|
||||
lp.datatype = 0;
|
||||
}
|
||||
|
||||
layout.set_properties (layer_index, lp);
|
||||
|
||||
lm.mmap (db::LayerProperties (n), layer_index, lp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// On return we deliver the "canonical" map
|
||||
// On return we deliver the "canonical" map which lists the decorated name vs. the real ones.
|
||||
m_layer_map = lm;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -775,7 +775,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Specify the LEF macro resolution strategy
|
||||
* @brief Specify the LEF macro resolution strategy when reading DEF files
|
||||
* Values are:
|
||||
* 0: propduce LEF geometry unless a FOREIGN cell is specified (default)
|
||||
* 1: produce LEF geometry always and ignore FOREIGN
|
||||
|
|
@ -884,6 +884,7 @@ enum LayerPurpose
|
|||
Blockage, // from DEF only
|
||||
PlacementBlockage, // from DEF only
|
||||
Regions, // from DEF only
|
||||
All // from DEF only
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1053,7 +1054,7 @@ public:
|
|||
/**
|
||||
* @brief Create a new layer or return the index of the given layer
|
||||
*/
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &name, LayerPurpose purpose, unsigned int mask);
|
||||
std::set<unsigned int> open_layer (db::Layout &layout, const std::string &name, LayerPurpose purpose, unsigned int mask);
|
||||
|
||||
/**
|
||||
* @brief Registers a layer (assign a new default layer number)
|
||||
|
|
@ -1187,7 +1188,7 @@ private:
|
|||
LEFDEFReaderState (const LEFDEFReaderState &);
|
||||
LEFDEFReaderState &operator= (const LEFDEFReaderState &);
|
||||
|
||||
std::map <std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::pair<bool, unsigned int> > m_layers;
|
||||
std::map <std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, std::set<unsigned int> > m_layers;
|
||||
db::LayerMap m_layer_map;
|
||||
bool m_create_layers;
|
||||
bool m_has_explicit_layer_mapping;
|
||||
|
|
@ -1200,8 +1201,7 @@ private:
|
|||
std::map<std::string, LEFDEFLayoutGenerator *> m_macro_generators;
|
||||
std::map<std::string, db::cell_index_type> m_foreign_cells;
|
||||
|
||||
std::pair <bool, unsigned int> open_layer_uncached (db::Layout &layout, const std::string &name, LayerPurpose purpose, unsigned int mask);
|
||||
void map_layer_explicit (const std::string &n, LayerPurpose purpose, const LayerProperties &lp, unsigned int layer, unsigned int mask);
|
||||
std::set<unsigned int> open_layer_uncached (db::Layout &layout, const std::string &name, LayerPurpose purpose, unsigned int mask);
|
||||
db::cell_index_type foreign_cell(Layout &layout, const std::string &name);
|
||||
};
|
||||
|
||||
|
|
@ -1363,7 +1363,7 @@ protected:
|
|||
/**
|
||||
* @brief Create a new layer or return the index of the given layer
|
||||
*/
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &name, LayerPurpose purpose, unsigned int mask)
|
||||
std::set<unsigned int> open_layer (db::Layout &layout, const std::string &name, LayerPurpose purpose, unsigned int mask)
|
||||
{
|
||||
return mp_reader_state->open_layer (layout, name, purpose, mask);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,22 +113,25 @@ private:
|
|||
const db::LayerMap &read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &options, bool import_lef)
|
||||
{
|
||||
const db::LEFDEFReaderOptions *lefdef_options = dynamic_cast<const db::LEFDEFReaderOptions *> (options.get_options (format ()));
|
||||
static db::LEFDEFReaderOptions default_options;
|
||||
if (! lefdef_options) {
|
||||
lefdef_options = &default_options;
|
||||
db::LEFDEFReaderOptions effective_options;
|
||||
if (lefdef_options) {
|
||||
effective_options = *lefdef_options;
|
||||
}
|
||||
|
||||
db::LEFDEFReaderState state (lefdef_options, layout, tl::dirname (m_stream.absolute_path ()));
|
||||
db::LEFDEFReaderState state (&effective_options, layout, tl::dirname (m_stream.absolute_path ()));
|
||||
|
||||
layout.dbu (lefdef_options->dbu ());
|
||||
layout.dbu (effective_options.dbu ());
|
||||
|
||||
if (import_lef) {
|
||||
|
||||
// Always produce LEF geometry when reading LEF
|
||||
effective_options.set_macro_resolution_mode (1);
|
||||
|
||||
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF file")));
|
||||
|
||||
db::LEFImporter importer;
|
||||
|
||||
for (std::vector<std::string>::const_iterator l = lefdef_options->begin_lef_files (); l != lefdef_options->end_lef_files (); ++l) {
|
||||
for (std::vector<std::string>::const_iterator l = effective_options.begin_lef_files (); l != effective_options.end_lef_files (); ++l) {
|
||||
|
||||
std::string lp = correct_path (*l, layout, tl::dirname (m_stream.absolute_path ()));
|
||||
|
||||
|
|
@ -149,7 +152,7 @@ private:
|
|||
|
||||
DEFImporter importer;
|
||||
|
||||
for (std::vector<std::string>::const_iterator l = lefdef_options->begin_lef_files (); l != lefdef_options->end_lef_files (); ++l) {
|
||||
for (std::vector<std::string>::const_iterator l = effective_options.begin_lef_files (); l != effective_options.end_lef_files (); ++l) {
|
||||
|
||||
std::string lp = correct_path (*l, layout, tl::dirname (m_stream.absolute_path ()));
|
||||
|
||||
|
|
@ -163,7 +166,7 @@ private:
|
|||
|
||||
// Additionally read all LEF files next to the DEF file
|
||||
|
||||
if (lefdef_options->read_lef_with_def ()) {
|
||||
if (effective_options.read_lef_with_def ()) {
|
||||
|
||||
std::string input_dir = tl::absolute_path (m_stream.absolute_path ());
|
||||
|
||||
|
|
@ -198,7 +201,7 @@ private:
|
|||
std::map<std::string, db::cell_index_type> foreign_cells = state.foreign_cells ();
|
||||
db::cell_index_type seen = std::numeric_limits<db::cell_index_type>::max ();
|
||||
|
||||
std::vector<db::Layout *> macro_layouts = lefdef_options->macro_layouts ();
|
||||
std::vector<db::Layout *> macro_layouts = effective_options.macro_layouts ();
|
||||
for (std::vector<db::Layout *>::const_iterator m = macro_layouts.begin (); m != macro_layouts.end (); ++m) {
|
||||
|
||||
std::vector<db::cell_index_type> target_cells, source_cells;
|
||||
|
|
|
|||
|
|
@ -937,6 +937,24 @@ LEFImporter::read_macro (Layout &layout)
|
|||
|
||||
expect ("END");
|
||||
|
||||
} else if (test ("DENSITY")) {
|
||||
|
||||
// read over DENSITY statements
|
||||
while (! test ("END")) {
|
||||
if (test ("LAYER")) {
|
||||
get ();
|
||||
expect (";");
|
||||
} else {
|
||||
expect ("RECT");
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
get_double ();
|
||||
}
|
||||
expect (";");
|
||||
}
|
||||
}
|
||||
|
||||
expect ("END");
|
||||
|
||||
} else if (test ("FIXEDMASK")) {
|
||||
|
||||
mg->set_fixedmask (true);
|
||||
|
|
|
|||
|
|
@ -770,8 +770,8 @@ gsi::Class<db::LEFDEFReaderOptions> decl_lefdef_config ("db", "LEFDEFReaderConfi
|
|||
"This property has been added in version 0.27.\n"
|
||||
) +
|
||||
gsi::method ("macro_resolution_mode", &db::LEFDEFReaderOptions::macro_resolution_mode,
|
||||
"@brief Gets the macro resolution mode.\n"
|
||||
"This property describes the way LEF macros are turned into GDS cells. There "
|
||||
"@brief Gets the macro resolution mode (LEF macros into DEF).\n"
|
||||
"This property describes the way LEF macros are turned into layout cells when reading DEF. There "
|
||||
"are three modes available:\n"
|
||||
"\n"
|
||||
"@ul\n"
|
||||
|
|
@ -786,7 +786,7 @@ gsi::Class<db::LEFDEFReaderOptions> decl_lefdef_config ("db", "LEFDEFReaderConfi
|
|||
"This property has been added in version 0.27.\n"
|
||||
) +
|
||||
gsi::method ("macro_resolution_mode=", &db::LEFDEFReaderOptions::set_macro_resolution_mode, gsi::arg ("mode"),
|
||||
"@brief Sets the macro resolution mode.\n"
|
||||
"@brief Sets the macro resolution mode (LEF macros into DEF).\n"
|
||||
"See \\macro_resolution_mode for details about this property.\n"
|
||||
"\n"
|
||||
"This property has been added in version 0.27.\n"
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@
|
|||
<item row="1" column="4">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>LEF import</string>
|
||||
<string>LEF import into DEF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -708,6 +708,8 @@
|
|||
<property name="text">
|
||||
<string>If a layer map file is given, pattern based rules are ignored.
|
||||
If used inside a technology, the file will be looked up relative to the technology's base path.
|
||||
Otherwise it's looked up relative to the LEF or DEF file.
|
||||
|
||||
(2*) Die area, Blockage and Region layers in map file will have priority over global production rules above.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
|
|
|
|||
|
|
@ -50,16 +50,13 @@ static db::LEFDEFReaderOptions default_options ()
|
|||
return tc;
|
||||
}
|
||||
|
||||
static db::LayerMap run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au, const db::LEFDEFReaderOptions &options, bool priv = true)
|
||||
static db::LayerMap read (db::Layout &layout, const char *lef_dir, const char *filename, const db::LEFDEFReaderOptions &options, bool priv = true)
|
||||
{
|
||||
std::string fn_path (priv ? tl::testsrc_private () : tl::testsrc ());
|
||||
fn_path += "/testdata/lefdef/";
|
||||
fn_path += lef_dir;
|
||||
fn_path += "/";
|
||||
|
||||
db::Manager m (false);
|
||||
db::Layout layout (&m), layout2 (&m), layout_au (&m);
|
||||
|
||||
tl::Extractor ex (filename);
|
||||
|
||||
db::LEFDEFReaderState ld (&options, layout, fn_path);
|
||||
|
|
@ -142,6 +139,16 @@ static db::LayerMap run_test (tl::TestBase *_this, const char *lef_dir, const ch
|
|||
|
||||
ld.finish (layout);
|
||||
|
||||
return ld.layer_map ();
|
||||
}
|
||||
|
||||
static db::LayerMap run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au, const db::LEFDEFReaderOptions &options, bool priv = true)
|
||||
{
|
||||
db::Manager m (false);
|
||||
db::Layout layout (&m), layout2 (&m), layout_au (&m);
|
||||
|
||||
db::LayerMap lm = read (layout, lef_dir, filename, options, priv);
|
||||
|
||||
// normalize the layout by writing to OASIS and reading from ..
|
||||
|
||||
// generate a "unique" name ...
|
||||
|
|
@ -200,7 +207,7 @@ static db::LayerMap run_test (tl::TestBase *_this, const char *lef_dir, const ch
|
|||
|
||||
}
|
||||
|
||||
return ld.layer_map ();
|
||||
return lm;
|
||||
}
|
||||
|
||||
TEST(1)
|
||||
|
|
@ -549,6 +556,202 @@ TEST(115_componentmaskshift)
|
|||
run_test (_this, "masks-2", "lef:in_tech.lef+lef:in.lef+def:in.def", "au.oas.gz", options, false);
|
||||
}
|
||||
|
||||
TEST(116_layer_mapping)
|
||||
{
|
||||
db::LEFDEFReaderOptions options = default_options ();
|
||||
db::LayerMap lm = db::LayerMap::from_string_file_format ("metal1: 1\nvia1: 2\nmetal2: 3\nOUTLINE: 42/17");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTLINE (42/17)';'metal1.VIA : metal1 (1/0)';'metal2.VIA : metal2 (3/0)';'via1.VIA : via1 (2/0)')"
|
||||
)
|
||||
}
|
||||
|
||||
options.set_layer_map (db::LayerMap ());
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTLINE (4/0)';'metal1.VIA : metal1 (1/0)';'metal2.VIA : metal2 (3/0)';'via1.VIA : via1 (2/0)')"
|
||||
)
|
||||
}
|
||||
|
||||
lm = db::LayerMap::from_string_file_format ("metal1: M1\nmetal1.V: M1_V\nvia1: V1\nmetal2: M2\nOUTLINE: OUTL");
|
||||
options.set_layer_map (lm);
|
||||
options.set_via_geometry_suffix ("V");
|
||||
options.set_via_geometry_datatype (42);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTL (4/0)';'metal1.VIA : M1V (1/42)';'metal2.VIA : M2V (3/42)';'via1.VIA : V1V (2/42)')"
|
||||
)
|
||||
}
|
||||
|
||||
lm = db::LayerMap::from_string_file_format ("metal1: M1\nmetal1.V: M1_V\nvia1: V1\nmetal2: M2");
|
||||
options.set_layer_map (lm);
|
||||
options.set_via_geometry_suffix ("V");
|
||||
options.set_via_geometry_datatype (42);
|
||||
options.set_read_all_layers (false);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('metal1.VIA : M1V (1/42)';'metal2.VIA : M2V (3/42)';'via1.VIA : V1V (2/42)')"
|
||||
)
|
||||
}
|
||||
|
||||
lm = db::LayerMap::from_string_file_format ("metal2: M2 (17/1)");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('metal2.VIA : M2V (17/43)')"
|
||||
)
|
||||
}
|
||||
|
||||
options.set_produce_via_geometry (false);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map()"
|
||||
)
|
||||
}
|
||||
|
||||
options.set_produce_via_geometry (true);
|
||||
options.set_via_geometry_suffix (".V");
|
||||
lm = db::LayerMap::from_string_file_format ("metal2.V: 17/1");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('metal2.VIA : metal2.V (17/1)')"
|
||||
)
|
||||
}
|
||||
|
||||
lm = db::LayerMap::from_string_file_format ("metal2.V: m2v (17/5)");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('metal2.VIA : m2v (17/5)')"
|
||||
)
|
||||
}
|
||||
|
||||
lm = db::LayerMap::from_string_file_format ("OUTLINE: OUTL");
|
||||
options.set_layer_map (lm);
|
||||
options.set_cell_outline_layer ("OUTLINE (42/17)");
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTL (42/17)')"
|
||||
)
|
||||
}
|
||||
|
||||
lm = db::LayerMap::from_string_file_format ("OUTLINE: OUTL (18/1)");
|
||||
options.set_layer_map (lm);
|
||||
options.set_cell_outline_layer ("OUTLINE (42/17)");
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTL (18/1)')"
|
||||
)
|
||||
}
|
||||
|
||||
options.set_cell_outline_layer ("OUTLINE (42/17)");
|
||||
lm = db::LayerMap::from_string_file_format ("42/17: OUTL (18/1)");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTL (18/1)')"
|
||||
)
|
||||
}
|
||||
|
||||
options.set_cell_outline_layer ("42/17");
|
||||
lm = db::LayerMap::from_string_file_format ("42/17: 18/1");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
{
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "via_properties", "lef:in.lef+def:in.def", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map('OUTLINE : OUTLINE (18/1)')"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(117_mapfile_all)
|
||||
{
|
||||
db::LEFDEFReaderOptions options = default_options ();
|
||||
|
||||
db::Layout layout;
|
||||
db::LayerMap lm_read = read (layout, "mapfile", "lef:in.lef+def:in.def+map:all.map", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map("
|
||||
"'OUTLINE : OUTLINE (1/0)';"
|
||||
"'+M1.LEFOBS;M1.LEFPIN;M1.NET;M1.PIN;M1.SPNET;M1.VIA : \\'M1.NET/PIN/...\\' (1/5)';"
|
||||
"'+M1.NET;M1.SPNET : \\'M1.NET/SPNET\\' (16/0)';"
|
||||
"'+M1.NET : M1.NET (18/0)';"
|
||||
"'+M1.BLK;M1.LEFOBS;M1.LEFPIN;M1.NET;M1.PIN;M1.SPNET;M1.VIA : \\'M1.NET/PIN/...\\' (22/2)';"
|
||||
"'+\\'M1.NET:1\\';\\'M1.PIN:1\\';\\'M1.SPNET:1\\';\\'M1.VIA:1\\' : \\'M1.NET:1/...\\' (6/0)';"
|
||||
"'+\\'M1.NET:1\\' : \\'M1.NET:1\\' (7/0)';"
|
||||
"'+M1.PIN : M1.PIN (3/0)';"
|
||||
"'+M1.PIN : M1.PIN (4/0)';"
|
||||
"'+M1.VIA : M1.VIA (20/0)';"
|
||||
"'+M1.VIA : M1.VIA (21/0)';"
|
||||
"'+M1.LABEL : M1.LABEL (26/0)';"
|
||||
"'+M1.LABEL : M1.LABEL (27/0)';"
|
||||
"'+M1.LABEL : M1.LABEL (28/1)';"
|
||||
"'+M1.BLK : M1.BLOCKAGE (13/0)';"
|
||||
"'M1_TEXT.LABEL : M1_TEXT.LABEL (29/0)'"
|
||||
")"
|
||||
)
|
||||
}
|
||||
|
||||
TEST(118_density)
|
||||
{
|
||||
run_test (_this, "density", "read:in.lef", "au.oas.gz", default_options (), false);
|
||||
}
|
||||
|
||||
TEST(119_multimapping)
|
||||
{
|
||||
db::LEFDEFReaderOptions options = default_options ();
|
||||
db::LayerMap lm = db::LayerMap::from_string_file_format ("(M1:1/0)\n(M2:3/0)\n+(M1:100/0)\n+(M2:100/0)\n(VIA1:2/0)");
|
||||
options.set_layer_map (lm);
|
||||
|
||||
db::LayerMap lm_read = run_test (_this, "multimap", "def:test.def", "au.oas.gz", options, false);
|
||||
EXPECT_EQ (lm_read.to_string (),
|
||||
"layer_map("
|
||||
"'OUTLINE : OUTLINE (4/0)';"
|
||||
"'+M1.VIA : M1 (1/0)';"
|
||||
"'+M1.VIA;M2.VIA : \\'M1;M2\\' (100/0)';"
|
||||
"'+M2.VIA : M2 (3/0)';"
|
||||
"'VIA1.VIA : VIA1 (2/0)'"
|
||||
")"
|
||||
)
|
||||
}
|
||||
|
||||
TEST(200_lefdef_plugin)
|
||||
{
|
||||
db::Layout ly;
|
||||
|
|
@ -594,3 +797,4 @@ TEST(201_lefdef_plugin_explicit_lef)
|
|||
|
||||
db::compare_layouts (_this, ly, fn_path + "au_plugin_alt_lef.oas.gz", db::WriteOAS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,9 +83,7 @@ MAGReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
|||
m_merge = specific_options.merge;
|
||||
mp_current_stream = 0;
|
||||
|
||||
db::LayerMap lm = specific_options.layer_map;
|
||||
lm.prepare (layout);
|
||||
set_layer_map (lm);
|
||||
set_layer_map (specific_options.layer_map);
|
||||
set_create_layers (specific_options.create_other_layers);
|
||||
set_keep_layer_names (specific_options.keep_layer_names);
|
||||
|
||||
|
|
@ -106,6 +104,8 @@ MAGReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
|||
m_dbu_trans_inv = db::CplxTrans (m_dbu).inverted ();
|
||||
m_tech.clear ();
|
||||
|
||||
prepare_layers (layout);
|
||||
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, "Reading MAGIC file tree");
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ MAGReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
|||
}
|
||||
|
||||
finish_layers (layout);
|
||||
return layer_map ();
|
||||
return layer_map_out ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -38,35 +38,6 @@ namespace db
|
|||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief A utility class that maps the layers for the proxy cell recovery
|
||||
*/
|
||||
class OASISReaderLayerMapping
|
||||
: public db::ImportLayerMapping
|
||||
{
|
||||
public:
|
||||
OASISReaderLayerMapping (db::OASISReader *reader, db::Layout *layout, bool create)
|
||||
: mp_reader (reader), mp_layout (layout), m_create (create)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned int> map_layer (const db::LayerProperties &lprops)
|
||||
{
|
||||
// named layers that are imported from a library are ignored
|
||||
if (lprops.is_named ()) {
|
||||
return std::make_pair (false, 0);
|
||||
} else {
|
||||
return mp_reader->open_dl (*mp_layout, LDPair (lprops.layer, lprops.datatype), m_create);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
db::OASISReader *mp_reader;
|
||||
db::Layout *mp_layout;
|
||||
bool m_create;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// OASISReader
|
||||
|
||||
|
|
@ -101,7 +72,6 @@ OASISReader::OASISReader (tl::InputStream &s)
|
|||
mm_last_property_name (this, "last-property-name"),
|
||||
mm_last_property_is_sprop (this, "last-property-is-stdprop"),
|
||||
mm_last_value_list(this, "last-value-list"),
|
||||
m_create_layers (false),
|
||||
m_read_texts (true),
|
||||
m_read_properties (true),
|
||||
m_read_all_properties (false),
|
||||
|
|
@ -129,40 +99,17 @@ OASISReader::~OASISReader ()
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
OASISReader::read (db::Layout &layout, const db::LoadLayoutOptions &options)
|
||||
void
|
||||
OASISReader::init (const db::LoadLayoutOptions &options)
|
||||
{
|
||||
db::OASISReaderOptions oasis_options = options.get_options<db::OASISReaderOptions> ();
|
||||
db::CommonReaderOptions common_options = options.get_options<db::CommonReaderOptions> ();
|
||||
CommonReader::init (options);
|
||||
|
||||
m_layer_map = common_options.layer_map;
|
||||
m_layer_map.prepare (layout);
|
||||
m_layers_created.clear ();
|
||||
m_read_texts = common_options.enable_text_objects;
|
||||
m_read_properties = common_options.enable_properties;
|
||||
m_create_layers = common_options.create_other_layers;
|
||||
m_read_texts = common_options ().enable_text_objects;
|
||||
m_read_properties = common_options ().enable_properties;
|
||||
|
||||
db::OASISReaderOptions oasis_options = options.get_options<db::OASISReaderOptions> ();
|
||||
m_read_all_properties = oasis_options.read_all_properties;
|
||||
m_expect_strict_mode = oasis_options.expect_strict_mode;
|
||||
|
||||
set_cell_conflict_resolution (common_options.cell_conflict_resolution);
|
||||
|
||||
layout.start_changes ();
|
||||
try {
|
||||
do_read (layout);
|
||||
finish (layout);
|
||||
layout.end_changes ();
|
||||
} catch (...) {
|
||||
layout.end_changes ();
|
||||
throw;
|
||||
}
|
||||
|
||||
return m_layer_map;
|
||||
}
|
||||
|
||||
const LayerMap &
|
||||
OASISReader::read (db::Layout &layout)
|
||||
{
|
||||
return read (layout, db::LoadLayoutOptions ());
|
||||
}
|
||||
|
||||
inline long long
|
||||
|
|
@ -554,44 +501,6 @@ OASISReader::warn (const std::string &msg)
|
|||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
OASISReader::open_dl (db::Layout &layout, const LDPair &dl, bool create)
|
||||
{
|
||||
std::pair<bool, unsigned int> ll = m_layer_map.logical (dl, layout);
|
||||
if (ll.first) {
|
||||
|
||||
return ll;
|
||||
|
||||
} else if (! create) {
|
||||
|
||||
return ll;
|
||||
|
||||
} else {
|
||||
|
||||
// and create the layer
|
||||
db::LayerProperties lp;
|
||||
lp.layer = dl.layer;
|
||||
lp.datatype = dl.datatype;
|
||||
|
||||
// resolve OASIS name if possible
|
||||
const tl::interval_map <db::ld_type, std::string> *names_dmap = m_layernames.mapped (dl.layer);
|
||||
if (names_dmap != 0) {
|
||||
const std::string *name = names_dmap->mapped (dl.datatype);
|
||||
if (name != 0) {
|
||||
lp.name = *name;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int ll = layout.insert_layer (lp);
|
||||
m_layer_map.map (dl, ll, lp);
|
||||
|
||||
m_layers_created.insert (ll);
|
||||
|
||||
return std::make_pair (true, ll);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper class to join two datatype layer name map members
|
||||
*/
|
||||
|
|
@ -599,12 +508,7 @@ struct LNameJoinOp1
|
|||
{
|
||||
void operator() (std::string &a, const std::string &b)
|
||||
{
|
||||
if (a != b) {
|
||||
if (! a.empty ()) {
|
||||
a += ";";
|
||||
}
|
||||
a += b;
|
||||
}
|
||||
join_layer_names (a, b);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -765,7 +669,6 @@ OASISReader::do_read (db::Layout &layout)
|
|||
m_textstrings.clear ();
|
||||
m_propstrings.clear ();
|
||||
m_propnames.clear ();
|
||||
m_layernames.clear ();
|
||||
|
||||
m_instances.clear ();
|
||||
m_instances_with_props.clear ();
|
||||
|
|
@ -1077,21 +980,8 @@ OASISReader::do_read (db::Layout &layout)
|
|||
LNameJoinOp1 op1;
|
||||
dt_map.add (dt1, dt2 + 1, name, op1);
|
||||
LNameJoinOp2 op2;
|
||||
m_layernames.add (l1, l2 + 1, dt_map, op2);
|
||||
layer_names ().add (l1, l2 + 1, dt_map, op2);
|
||||
|
||||
// rename layers created before if required
|
||||
for (std::set<unsigned int>::const_iterator i = m_layers_created.begin (); i != m_layers_created.end (); ++i) {
|
||||
const db::LayerProperties &lp = layout.get_properties (*i);
|
||||
if (lp.layer >= l1 && lp.layer <= l2 && lp.datatype >= dt1 && lp.datatype <= dt2 && lp.name != name) {
|
||||
// need to rename: add a new madding to m_layer_map and adjust the layout's layer properties
|
||||
db::LayerProperties lpp = lp;
|
||||
LNameJoinOp1 nj;
|
||||
nj (lpp.name, name);
|
||||
layout.set_properties (*i, lpp);
|
||||
m_layer_map.map (LDPair (lp.layer, lp.datatype), *i, lpp);
|
||||
}
|
||||
}
|
||||
|
||||
reset_modal_variables ();
|
||||
|
||||
// ignore properties attached to this name item
|
||||
|
|
@ -2038,7 +1928,7 @@ OASISReader::do_read_text (bool xy_absolute,
|
|||
|
||||
std::pair<bool, unsigned int> ll (false, 0);
|
||||
if (m_read_texts) {
|
||||
ll = open_dl (layout, LDPair (mm_textlayer.get (), mm_texttype.get ()), m_create_layers);
|
||||
ll = open_dl (layout, LDPair (mm_textlayer.get (), mm_texttype.get ()));
|
||||
}
|
||||
|
||||
if ((m & 0x4) && read_repetition ()) {
|
||||
|
|
@ -2180,7 +2070,7 @@ OASISReader::do_read_rectangle (bool xy_absolute,
|
|||
db::Box box (db::Point (mm_geometry_x.get (), mm_geometry_y.get ()),
|
||||
db::Point (mm_geometry_x.get () + mm_geometry_w.get (), mm_geometry_y.get () + mm_geometry_h.get ()));
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()));
|
||||
|
||||
if ((m & 0x4) && read_repetition ()) {
|
||||
|
||||
|
|
@ -2294,7 +2184,7 @@ OASISReader::do_read_polygon (bool xy_absolute, db::cell_index_type cell_index,
|
|||
|
||||
db::Vector pos (mm_geometry_x.get (), mm_geometry_y.get ());
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()));
|
||||
|
||||
if ((m & 0x4) && read_repetition ()) {
|
||||
|
||||
|
|
@ -2461,7 +2351,7 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db:
|
|||
|
||||
db::Vector pos (mm_geometry_x.get (), mm_geometry_y.get ());
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()));
|
||||
|
||||
if ((m & 0x4) && read_repetition ()) {
|
||||
|
||||
|
|
@ -2620,7 +2510,7 @@ OASISReader::do_read_trapezoid (unsigned char r, bool xy_absolute,db::cell_index
|
|||
|
||||
db::Vector pos (mm_geometry_x.get (), mm_geometry_y.get ());
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()));
|
||||
|
||||
db::Point pts [4];
|
||||
|
||||
|
|
@ -2775,7 +2665,7 @@ OASISReader::do_read_ctrapezoid (bool xy_absolute,db::cell_index_type cell_index
|
|||
|
||||
db::Vector pos (mm_geometry_x.get (), mm_geometry_y.get ());
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()));
|
||||
|
||||
db::Point pts [4];
|
||||
|
||||
|
|
@ -3126,7 +3016,7 @@ OASISReader::do_read_circle (bool xy_absolute, db::cell_index_type cell_index, d
|
|||
|
||||
db::Vector pos (mm_geometry_x.get (), mm_geometry_y.get ());
|
||||
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers);
|
||||
std::pair<bool, unsigned int> ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()));
|
||||
|
||||
// ignore this circle if the radius is zero
|
||||
if (mm_circle_radius.get () <= 0) {
|
||||
|
|
@ -3444,7 +3334,7 @@ OASISReader::do_read_cell (db::cell_index_type cell_index, db::Layout &layout)
|
|||
|
||||
// Restore proxy cell (link to PCell or Library)
|
||||
if (has_context) {
|
||||
OASISReaderLayerMapping layer_mapping (this, &layout, m_create_layers);
|
||||
CommonReaderLayerMapping layer_mapping (this, &layout);
|
||||
layout.recover_proxy_as (cell_index, context_strings.begin (), context_strings.end (), &layer_mapping);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,39 +81,6 @@ public:
|
|||
*/
|
||||
~OASISReader ();
|
||||
|
||||
/**
|
||||
* @brief The basic read method
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* A set of options can be specified with the LoadLayoutOptions
|
||||
* object.
|
||||
* The returned map will contain all layers, the passed
|
||||
* ones and the newly created ones.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @param map The LayerMap object
|
||||
* @param create true, if new layers should be created
|
||||
* @return The LayerMap object that tells where which layer was loaded
|
||||
*/
|
||||
virtual const LayerMap &read (db::Layout &layout, const LoadLayoutOptions &options);
|
||||
|
||||
/**
|
||||
* @brief The basic read method (without mapping)
|
||||
*
|
||||
* This method will read the stream data and translate this to
|
||||
* insert calls into the layout object. This will not do much
|
||||
* on the layout object beside inserting the objects.
|
||||
* This version will read all input layers and return a map
|
||||
* which tells which OASIS layer has been read into which logical
|
||||
* layer.
|
||||
*
|
||||
* @param layout The layout object to write to
|
||||
* @return The LayerMap object
|
||||
*/
|
||||
virtual const LayerMap &read (db::Layout &layout);
|
||||
|
||||
/**
|
||||
* @brief Format
|
||||
*/
|
||||
|
|
@ -136,6 +103,8 @@ protected:
|
|||
|
||||
virtual void common_reader_error (const std::string &msg) { error (msg); }
|
||||
virtual void common_reader_warn (const std::string &msg) { warn (msg); }
|
||||
virtual void init (const LoadLayoutOptions &options);
|
||||
virtual void do_read (db::Layout &layout);
|
||||
|
||||
private:
|
||||
friend class OASISReaderLayerMapping;
|
||||
|
|
@ -153,8 +122,6 @@ private:
|
|||
};
|
||||
|
||||
tl::InputStream &m_stream;
|
||||
LayerMap m_layer_map;
|
||||
std::set<unsigned int> m_layers_created;
|
||||
tl::AbsoluteProgress m_progress;
|
||||
std::string m_cellname;
|
||||
double m_dbu;
|
||||
|
|
@ -204,12 +171,10 @@ private:
|
|||
std::map <unsigned long, const db::StringRef *> m_text_forward_references;
|
||||
std::map <unsigned long, std::string> m_propstrings;
|
||||
std::map <unsigned long, std::string> m_propnames;
|
||||
tl::interval_map <db::ld_type, tl::interval_map <db::ld_type, std::string> > m_layernames;
|
||||
|
||||
tl::vector<db::CellInstArray> m_instances;
|
||||
tl::vector<db::CellInstArrayWithProperties> m_instances_with_props;
|
||||
|
||||
bool m_create_layers;
|
||||
bool m_read_texts;
|
||||
bool m_read_properties;
|
||||
bool m_read_all_properties;
|
||||
|
|
@ -219,7 +184,6 @@ private:
|
|||
db::property_names_id_type m_s_gds_property_name_id;
|
||||
db::property_names_id_type m_klayout_context_property_name_id;
|
||||
|
||||
void do_read (db::Layout &layout);
|
||||
void do_read_cell (db::cell_index_type cell_index, db::Layout &layout);
|
||||
|
||||
void do_read_placement (unsigned char r,
|
||||
|
|
@ -310,8 +274,6 @@ private:
|
|||
db::Coord get_coord (long grid = 1);
|
||||
db::Coord get_ucoord (unsigned long grid = 1);
|
||||
distance_type get_ucoord_as_distance (unsigned long grid = 1);
|
||||
|
||||
std::pair <bool, unsigned int> open_dl (db::Layout &layout, const LDPair &dl, bool create);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,28 @@
|
|||
LAYER M1
|
||||
TYPE ROUTING ;
|
||||
END M1
|
||||
LAYER VIA1
|
||||
TYPE CUT ;
|
||||
END VIA1
|
||||
|
||||
MACRO dense
|
||||
CLASS CORE ;
|
||||
ORIGIN 0.0 0.0 ;
|
||||
FOREIGN dense ;
|
||||
SIZE 0.7 BY 0.9 ;
|
||||
OBS
|
||||
LAYER M1 DESIGNRULEWIDTH 0.05 ;
|
||||
RECT 0.04 0.095 0.66 0.685 ;
|
||||
LAYER VIA1 ;
|
||||
RECT 0.285 0.31 0.415 0.36 ;
|
||||
RECT 0.285 0.18 0.415 0.23 ;
|
||||
END
|
||||
DENSITY
|
||||
LAYER M1 ;
|
||||
RECT 0.04 0.09 0.66 0.685 100.0 ;
|
||||
LAYER VIA1 ;
|
||||
RECT 0 0 100 100 45.5 ; #rect from (0,0) to (100,100), density of 45.5%
|
||||
RECT 100 0 200 100 42.2 ; #rect from (100,0) to (200, 100), density of 42.2%
|
||||
END
|
||||
END dense
|
||||
END LIBRARY
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
# some variations of map file entries
|
||||
DIEAREA ALL 1 0
|
||||
COMP ALL 2 0
|
||||
M1 PIN 3,4 0
|
||||
M1 LEFPIN,LEFOBS,PIN,NET,SPNET,VIA 1 5
|
||||
DOES NOT MEAN ANYTHING
|
||||
M1 NET,SPNET,PIN,VIA:MASK:1 6 0
|
||||
M1 NET:MASK:1 7 0
|
||||
M1 TEXT 8 0
|
||||
M1 FILLOPC 9 0
|
||||
M1 FILLOPC:MASK:1 10 0
|
||||
M1 FILLOPC:MASK:2 11 0
|
||||
M1 BLOCKAGEFILL 12 0
|
||||
M1 BLOCKAGE 13 0
|
||||
M1 FILL 14 0
|
||||
M1 VIAFILL,FILL 15 0
|
||||
M1 NET,SPNET,CUSTOM 16 0
|
||||
M1 VIAFILL:FLOATING,FILL:FLOATING 17 0
|
||||
M1 NET:VOLTAGE:0.8 18 0
|
||||
M1 VIAFILL 19 0
|
||||
M1 VIA:SIZE:0.05x0.05 20 0
|
||||
M1 VIA:SIZE:3x3 21 0
|
||||
M1 ALL 22 2
|
||||
NAME DIEAREA 23 0
|
||||
NAME ALL 24 0
|
||||
NAME COMP 25 0
|
||||
NAME M1/PIN 26 0
|
||||
NAME M1/NET 27 0
|
||||
NAME M1/SPNET 28 1
|
||||
NAME M1_TEXT 29 0
|
||||
Binary file not shown.
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
VERSION 5.8 ;
|
||||
DIVIDERCHAR "/" ;
|
||||
BUSBITCHARS "[]" ;
|
||||
DESIGN chip_top ;
|
||||
UNITS DISTANCE MICRONS 1000 ;
|
||||
DIEAREA ( 30000 3000 ) ( 10000000 4000 ) ;
|
||||
VIAS 1 ;
|
||||
- VIA1_dummy
|
||||
+ RECT M1 ( -200 -140 ) ( 200 140 )
|
||||
+ RECT VIA1 ( -100 -100 ) ( 100 100 )
|
||||
+ RECT M2 ( -300 -120 ) ( 300 120 ) ;
|
||||
END VIAS
|
||||
SPECIALNETS 1 ;
|
||||
- dummy
|
||||
+ ROUTED M1 150 + SHAPE IOWIRE ( 40000 3600 ) VIA1_dummy DO 16000 BY 1 STEP 700 0
|
||||
;
|
||||
END SPECIALNETS
|
||||
SCANCHAINS 77 ;
|
||||
- chain1_clock1
|
||||
+ PARTITION clock1
|
||||
+ START block1/bsr_reg_0 Q
|
||||
+ FLOATING
|
||||
block1/pgm_cgm_en_reg_reg ( IN SD ) ( OUT QZ )
|
||||
block1/start_reset_dd_reg ( IN SD ) ( OUT QZ )
|
||||
+ STOP block1/start_reset_d_reg SD ;
|
||||
END SCANCHAINS
|
||||
END DESIGN
|
||||
|
|
@ -30,7 +30,11 @@ class DBLayout_TestClass < TestBase
|
|||
lmap = RBA::LayerMap::new
|
||||
|
||||
lmap.map( "1/0", 0 )
|
||||
assert_equal(lmap.is_mapped(RBA::LayerInfo::new(1, 0)), true)
|
||||
assert_equal(lmap.is_mapped(RBA::LayerInfo::new(1, 1)), false)
|
||||
assert_equal(lmap.is_mapped(RBA::LayerInfo::new(2, 2)), false)
|
||||
lmap.map( "2/2", 0 )
|
||||
assert_equal(lmap.is_mapped(RBA::LayerInfo::new(2, 2)), true)
|
||||
lmap.map( "10/2", 0 )
|
||||
assert_equal( lmap.mapping_str(0), "1/0;2/2;10/2" )
|
||||
|
||||
|
|
@ -39,7 +43,7 @@ class DBLayout_TestClass < TestBase
|
|||
lmap.map( "4/2", 1 )
|
||||
lmap.map( "1/2", 1 )
|
||||
lmap.map( "0/0", 1 )
|
||||
assert_equal( lmap.mapping_str(1), "0/0;1/2;2-4/2" ) # could be "0/0;1-4/2" as well ...
|
||||
assert_equal( lmap.mapping_str(1), "0/0;1-4/2" ) # could be "0/0;1-4/2" as well ...
|
||||
|
||||
lmap.map( RBA::LayerInfo::new(2, 2), RBA::LayerInfo::new(4, 4), 2 )
|
||||
lmap.map( RBA::LayerInfo::new(0, 1), 2 )
|
||||
|
|
@ -85,6 +89,55 @@ class DBLayout_TestClass < TestBase
|
|||
assert_equal( lmap.mapping_str(0), "2/2 : 4/4" )
|
||||
assert_equal( lmap.mapping(0).to_s, "4/4" )
|
||||
assert_equal( lmap.mapping(2).to_s, "5/5" )
|
||||
|
||||
lmap = RBA::LayerMap::new
|
||||
|
||||
lmap.map("*/*", 0)
|
||||
lmap.unmap(RBA::LayerInfo::new(5, 10))
|
||||
assert_equal(lmap.mapping_str(0), "0-4/*;5/0-9,11-*;6-*/*")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.unmap(RBA::LayerInfo::new(5, 10), RBA::LayerInfo::new(16, 21))
|
||||
assert_equal(lmap.mapping_str(0), "0-4/*;5-16/0-9,22-*;17-*/*")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.unmap("5-16/10-21")
|
||||
assert_equal(lmap.mapping_str(0), "0-4/*;5-16/0-9,22-*;17-*/*")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.mmap(RBA::LayerInfo::new(5, 10), 1)
|
||||
assert_equal(lmap.mapping_str(0), "+*/*")
|
||||
assert_equal(lmap.mapping_str(1), "+5/10")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.mmap(RBA::LayerInfo::new(5, 10), 1, RBA::LayerInfo::new(100, 0))
|
||||
assert_equal(lmap.mapping_str(0), "+*/*")
|
||||
assert_equal(lmap.mapping_str(1), "+5/10 : 100/0")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.mmap(RBA::LayerInfo::new(5, 10), RBA::LayerInfo::new(16, 21), 1)
|
||||
assert_equal(lmap.mapping_str(0), "+*/*")
|
||||
assert_equal(lmap.mapping_str(1), "+5-16/10-21")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.mmap(RBA::LayerInfo::new(5, 10), RBA::LayerInfo::new(16, 21), 1, RBA::LayerInfo::new(100, 0))
|
||||
assert_equal(lmap.mapping_str(0), "+*/*")
|
||||
assert_equal(lmap.mapping_str(1), "+5-16/10-21 : 100/0")
|
||||
|
||||
lmap.clear
|
||||
lmap.map("*/*", 0)
|
||||
lmap.mmap("5-16/10-21", 1)
|
||||
assert_equal(lmap.mapping_str(0), "+*/*")
|
||||
assert_equal(lmap.mapping_str(1), "+5-16/10-21")
|
||||
|
||||
assert_equal(lmap.logicals(RBA::LayerInfo::new(5, 10)), [ 0, 1 ])
|
||||
assert_equal(lmap.logicals(RBA::LayerInfo::new(0, 10)), [ 0 ])
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue