mirror of https://github.com/KLayout/klayout.git
Some more refactoring of DEF layer mapping
This commit is contained in:
parent
71906a5681
commit
c7de542070
|
|
@ -1398,7 +1398,7 @@ DEFImporter::do_read (db::Layout &layout)
|
|||
|
||||
} else {
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Region);
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Regions);
|
||||
if (dl.first) {
|
||||
for (std::vector<db::Polygon>::const_iterator p = r->second.begin (); p != r->second.end (); ++p) {
|
||||
group_cell->shapes (dl.second).insert (*p);
|
||||
|
|
@ -1441,7 +1441,7 @@ DEFImporter::do_read (db::Layout &layout)
|
|||
|
||||
if (! regions.empty ()) {
|
||||
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Region);
|
||||
std::pair <bool, unsigned int> dl = open_layer (layout, std::string (), Regions);
|
||||
if (dl.first) {
|
||||
|
||||
for (std::map<std::string, std::vector<db::Polygon> >::const_iterator r = regions.begin (); r != regions.end (); ++r) {
|
||||
|
|
|
|||
|
|
@ -146,25 +146,15 @@ LEFDEFReaderOptions::format_name () const
|
|||
// -----------------------------------------------------------------------------------
|
||||
// LEFDEFLayerDelegate implementation
|
||||
|
||||
static db::LayerProperties lp_from_string (const std::string &ld)
|
||||
{
|
||||
db::LayerProperties lp;
|
||||
tl::Extractor ex (ld.c_str ());
|
||||
try {
|
||||
ex.read (lp);
|
||||
return lp;
|
||||
} catch (...) {
|
||||
return db::LayerProperties (0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
LEFDEFReaderState::LEFDEFReaderState (const LEFDEFReaderOptions *tc)
|
||||
LEFDEFReaderState::LEFDEFReaderState (const LEFDEFReaderOptions *tc, db::Layout &layout)
|
||||
: m_create_layers (true), m_has_explicit_layer_mapping (false), m_laynum (1), mp_tech_comp (tc)
|
||||
{
|
||||
if (tc) {
|
||||
m_layer_map = tc->layer_map ();
|
||||
m_create_layers = tc->read_all_layers ();
|
||||
}
|
||||
|
||||
m_layer_map.prepare (layout);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -184,9 +174,10 @@ LEFDEFReaderState::set_explicit_layer_mapping (bool f)
|
|||
}
|
||||
|
||||
void
|
||||
LEFDEFReaderState::map_layer_explicit (const std::string &n, LayerPurpose purpose, unsigned int layer)
|
||||
LEFDEFReaderState::map_layer_explicit (const std::string &n, LayerPurpose purpose, const db::LayerProperties &lp, unsigned int layer)
|
||||
{
|
||||
m_layers [std::make_pair (n, purpose)] = std::make_pair (true, layer);
|
||||
m_layer_map.map (lp, layer);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -229,6 +220,14 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
|
|||
|
||||
layer_map [std::make_pair (std::string (), Outline)] = db::LayerProperties (layer, datatype, "OUTLINE");
|
||||
|
||||
} else if (w1 == "REGIONS") {
|
||||
|
||||
layer_map [std::make_pair (std::string (), Regions)] = db::LayerProperties (layer, datatype, "REGIONS");
|
||||
|
||||
} else if (w1 == "BLOCKAGE") {
|
||||
|
||||
layer_map [std::make_pair (std::string (), PlacementBlockage)] = db::LayerProperties (layer, datatype, "PLACEMENT_BLK");
|
||||
|
||||
} else if (w1 == "NAME") {
|
||||
|
||||
// converts a line like
|
||||
|
|
@ -293,7 +292,7 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
|
|||
|
||||
db::DirectLayerMapping lm (&layout);
|
||||
for (std::map<std::pair<std::string, LayerPurpose>, db::LayerProperties>::const_iterator i = layer_map.begin (); i != layer_map.end (); ++i) {
|
||||
map_layer_explicit (i->first.first, i->first.second, lm.map_layer (i->second).second);
|
||||
map_layer_explicit (i->first.first, i->first.second, i->second, lm.map_layer (i->second).second);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -370,10 +369,10 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
if (purpose == Outline) {
|
||||
produce = mp_tech_comp->produce_cell_outlines ();
|
||||
ld = mp_tech_comp->cell_outline_layer ();
|
||||
} else if (purpose == Region) {
|
||||
} else if (purpose == Regions) {
|
||||
produce = mp_tech_comp->produce_regions ();
|
||||
ld = mp_tech_comp->region_layer ();
|
||||
} else {
|
||||
} else if (purpose == PlacementBlockage) {
|
||||
produce = mp_tech_comp->produce_placement_blockages ();
|
||||
ld = mp_tech_comp->placement_blockage_layer ();
|
||||
}
|
||||
|
|
@ -528,12 +527,6 @@ LEFDEFReaderState::open_layer_uncached (db::Layout &layout, const std::string &n
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
LEFDEFReaderState::prepare (db::Layout &layout)
|
||||
{
|
||||
m_layer_map.prepare (layout);
|
||||
}
|
||||
|
||||
void
|
||||
LEFDEFReaderState::finish (db::Layout &layout)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ enum LayerPurpose
|
|||
Outline, // from LEF+DEF
|
||||
Blockage, // from DEF only
|
||||
PlacementBlockage, // from DEF only
|
||||
Region, // from DEF only
|
||||
Regions, // from DEF only
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -600,13 +600,13 @@ public:
|
|||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
LEFDEFReaderState (const LEFDEFReaderOptions *tc);
|
||||
LEFDEFReaderState (const LEFDEFReaderOptions *tc, db::Layout &layout);
|
||||
|
||||
/**
|
||||
* @brief Provides an explicit layer mapping
|
||||
* This method is used when reading the layer map file.
|
||||
*/
|
||||
void map_layer_explicit (const std::string &n, LayerPurpose purpose, unsigned int layer);
|
||||
void map_layer_explicit (const std::string &n, LayerPurpose purpose, const LayerProperties &lp, unsigned int layer);
|
||||
|
||||
/**
|
||||
* @brief Provides an explicit layer mapping
|
||||
|
|
@ -662,11 +662,6 @@ public:
|
|||
*/
|
||||
void register_layer (const std::string &l);
|
||||
|
||||
/**
|
||||
* @brief Prepare, i.e. create layers required by the layer map
|
||||
*/
|
||||
void prepare (db::Layout &layout);
|
||||
|
||||
/**
|
||||
* @brief Finish, i.e. assign GDS layer numbers to the layers
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -124,13 +124,12 @@ private:
|
|||
lefdef_options = &default_options;
|
||||
}
|
||||
|
||||
db::LEFDEFReaderState state (lefdef_options);
|
||||
db::LEFDEFReaderState state (lefdef_options, layout);
|
||||
|
||||
if (lefdef_options->consider_map_file ()) {
|
||||
state.import_map_file_heuristics (m_stream.absolute_path (), layout);
|
||||
}
|
||||
|
||||
state.prepare (layout);
|
||||
layout.dbu (lefdef_options->dbu ());
|
||||
|
||||
if (import_lef) {
|
||||
|
|
|
|||
|
|
@ -140,8 +140,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
db::LEFDEFReaderState layers (&options);
|
||||
layers.prepare (*layout);
|
||||
db::LEFDEFReaderState state (&options, *layout);
|
||||
layout->dbu (options.dbu ());
|
||||
|
||||
if (import_lef) {
|
||||
|
|
@ -153,11 +152,11 @@ public:
|
|||
for (std::vector<std::string>::const_iterator l = options.begin_lef_files (); l != options.end_lef_files (); ++l) {
|
||||
tl::InputStream lef_stream (*l);
|
||||
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << *l;
|
||||
importer.read (lef_stream, *layout, layers);
|
||||
importer.read (lef_stream, *layout, state);
|
||||
}
|
||||
|
||||
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << data.file;
|
||||
importer.read (stream, *layout, layers);
|
||||
importer.read (stream, *layout, state);
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -177,23 +176,23 @@ public:
|
|||
if (fi.isAbsolute ()) {
|
||||
tl::InputStream lef_stream (*l);
|
||||
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << *l;
|
||||
importer.read_lef (lef_stream, *layout, layers);
|
||||
importer.read_lef (lef_stream, *layout, state);
|
||||
} else {
|
||||
std::string ex_l = tl::to_string (def_fi.absoluteDir ().absoluteFilePath (tl::to_qstring (*l)));
|
||||
tl::InputStream lef_stream (ex_l);
|
||||
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << *l;
|
||||
importer.read_lef (lef_stream, *layout, layers);
|
||||
importer.read_lef (lef_stream, *layout, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << data.file;
|
||||
|
||||
importer.read (stream, *layout, layers);
|
||||
importer.read (stream, *layout, state);
|
||||
|
||||
}
|
||||
|
||||
layers.finish (*layout);
|
||||
state.finish (*layout);
|
||||
|
||||
lay::LayoutView *view = lay::LayoutView::current ();
|
||||
if (! view || data.mode == 1) {
|
||||
|
|
|
|||
|
|
@ -56,14 +56,12 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file
|
|||
fn_path += lef_dir;
|
||||
fn_path += "/";
|
||||
|
||||
db::LEFDEFReaderState ld (&tc);
|
||||
|
||||
db::Manager m (false);
|
||||
db::Layout layout (&m), layout2 (&m), layout_au (&m);
|
||||
|
||||
tl::Extractor ex (filename);
|
||||
|
||||
ld.prepare (layout);
|
||||
db::LEFDEFReaderState ld (&tc, layout);
|
||||
|
||||
db::DEFImporter imp;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue