Some more refactoring of DEF layer mapping

This commit is contained in:
Matthias Koefferlein 2020-04-19 20:14:12 +02:00
parent 71906a5681
commit c7de542070
6 changed files with 30 additions and 46 deletions

View File

@ -1398,7 +1398,7 @@ DEFImporter::do_read (db::Layout &layout)
} else { } 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) { if (dl.first) {
for (std::vector<db::Polygon>::const_iterator p = r->second.begin (); p != r->second.end (); ++p) { 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 (dl.second).insert (*p);
@ -1441,7 +1441,7 @@ DEFImporter::do_read (db::Layout &layout)
if (! regions.empty ()) { 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) { if (dl.first) {
for (std::map<std::string, std::vector<db::Polygon> >::const_iterator r = regions.begin (); r != regions.end (); ++r) { for (std::map<std::string, std::vector<db::Polygon> >::const_iterator r = regions.begin (); r != regions.end (); ++r) {

View File

@ -146,25 +146,15 @@ LEFDEFReaderOptions::format_name () const
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// LEFDEFLayerDelegate implementation // LEFDEFLayerDelegate implementation
static db::LayerProperties lp_from_string (const std::string &ld) LEFDEFReaderState::LEFDEFReaderState (const LEFDEFReaderOptions *tc, db::Layout &layout)
{
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)
: m_create_layers (true), m_has_explicit_layer_mapping (false), m_laynum (1), mp_tech_comp (tc) : m_create_layers (true), m_has_explicit_layer_mapping (false), m_laynum (1), mp_tech_comp (tc)
{ {
if (tc) { if (tc) {
m_layer_map = tc->layer_map (); m_layer_map = tc->layer_map ();
m_create_layers = tc->read_all_layers (); m_create_layers = tc->read_all_layers ();
} }
m_layer_map.prepare (layout);
} }
void void
@ -184,9 +174,10 @@ LEFDEFReaderState::set_explicit_layer_mapping (bool f)
} }
void 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_layers [std::make_pair (n, purpose)] = std::make_pair (true, layer);
m_layer_map.map (lp, layer);
} }
void 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"); 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") { } else if (w1 == "NAME") {
// converts a line like // converts a line like
@ -293,7 +292,7 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
db::DirectLayerMapping lm (&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) { 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) { if (purpose == Outline) {
produce = mp_tech_comp->produce_cell_outlines (); produce = mp_tech_comp->produce_cell_outlines ();
ld = mp_tech_comp->cell_outline_layer (); ld = mp_tech_comp->cell_outline_layer ();
} else if (purpose == Region) { } else if (purpose == Regions) {
produce = mp_tech_comp->produce_regions (); produce = mp_tech_comp->produce_regions ();
ld = mp_tech_comp->region_layer (); ld = mp_tech_comp->region_layer ();
} else { } else if (purpose == PlacementBlockage) {
produce = mp_tech_comp->produce_placement_blockages (); produce = mp_tech_comp->produce_placement_blockages ();
ld = mp_tech_comp->placement_blockage_layer (); 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 void
LEFDEFReaderState::finish (db::Layout &layout) LEFDEFReaderState::finish (db::Layout &layout)
{ {

View File

@ -586,7 +586,7 @@ enum LayerPurpose
Outline, // from LEF+DEF Outline, // from LEF+DEF
Blockage, // from DEF only Blockage, // from DEF only
PlacementBlockage, // from DEF only PlacementBlockage, // from DEF only
Region, // from DEF only Regions, // from DEF only
}; };
/** /**
@ -600,13 +600,13 @@ public:
/** /**
* @brief Constructor * @brief Constructor
*/ */
LEFDEFReaderState (const LEFDEFReaderOptions *tc); LEFDEFReaderState (const LEFDEFReaderOptions *tc, db::Layout &layout);
/** /**
* @brief Provides an explicit layer mapping * @brief Provides an explicit layer mapping
* This method is used when reading the layer map file. * 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 * @brief Provides an explicit layer mapping
@ -662,11 +662,6 @@ public:
*/ */
void register_layer (const std::string &l); 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 * @brief Finish, i.e. assign GDS layer numbers to the layers
*/ */

View File

@ -124,13 +124,12 @@ private:
lefdef_options = &default_options; lefdef_options = &default_options;
} }
db::LEFDEFReaderState state (lefdef_options); db::LEFDEFReaderState state (lefdef_options, layout);
if (lefdef_options->consider_map_file ()) { if (lefdef_options->consider_map_file ()) {
state.import_map_file_heuristics (m_stream.absolute_path (), layout); state.import_map_file_heuristics (m_stream.absolute_path (), layout);
} }
state.prepare (layout);
layout.dbu (lefdef_options->dbu ()); layout.dbu (lefdef_options->dbu ());
if (import_lef) { if (import_lef) {

View File

@ -140,8 +140,7 @@ public:
} }
} }
db::LEFDEFReaderState layers (&options); db::LEFDEFReaderState state (&options, *layout);
layers.prepare (*layout);
layout->dbu (options.dbu ()); layout->dbu (options.dbu ());
if (import_lef) { 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) { for (std::vector<std::string>::const_iterator l = options.begin_lef_files (); l != options.end_lef_files (); ++l) {
tl::InputStream lef_stream (*l); tl::InputStream lef_stream (*l);
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << *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; tl::log << tl::to_string (QObject::tr ("Reading")) << " " << data.file;
importer.read (stream, *layout, layers); importer.read (stream, *layout, state);
} else { } else {
@ -177,23 +176,23 @@ public:
if (fi.isAbsolute ()) { if (fi.isAbsolute ()) {
tl::InputStream lef_stream (*l); tl::InputStream lef_stream (*l);
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << *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 { } else {
std::string ex_l = tl::to_string (def_fi.absoluteDir ().absoluteFilePath (tl::to_qstring (*l))); std::string ex_l = tl::to_string (def_fi.absoluteDir ().absoluteFilePath (tl::to_qstring (*l)));
tl::InputStream lef_stream (ex_l); tl::InputStream lef_stream (ex_l);
tl::log << tl::to_string (QObject::tr ("Reading")) << " " << *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; 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 (); lay::LayoutView *view = lay::LayoutView::current ();
if (! view || data.mode == 1) { if (! view || data.mode == 1) {

View File

@ -56,14 +56,12 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file
fn_path += lef_dir; fn_path += lef_dir;
fn_path += "/"; fn_path += "/";
db::LEFDEFReaderState ld (&tc);
db::Manager m (false); db::Manager m (false);
db::Layout layout (&m), layout2 (&m), layout_au (&m); db::Layout layout (&m), layout2 (&m), layout_au (&m);
tl::Extractor ex (filename); tl::Extractor ex (filename);
ld.prepare (layout); db::LEFDEFReaderState ld (&tc, layout);
db::DEFImporter imp; db::DEFImporter imp;