Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #1482 (strict mode oasis should write the S_CELL_OFFSET i… #1501

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1338,30 +1338,34 @@ OASISWriter::write_cellname_table (size_t &cellnames_table_pos, const std::vecto
write ((unsigned long) *cell);
}

if (m_options.write_std_properties > 1) {
if (m_options.write_std_properties >= 1) {

reset_modal_variables ();

// write S_BOUNDING_BOX entries
if (m_options.write_std_properties > 1) {

std::vector<tl::Variant> values;
// write S_BOUNDING_BOX entries

// TODO: how to set the "depends on external cells" flag?
db::Box bbox = layout.cell (*cell).bbox ();
if (bbox.empty ()) {
// empty box
values.push_back (tl::Variant ((unsigned int) 0x2));
bbox = db::Box (0, 0, 0, 0);
} else {
values.push_back (tl::Variant ((unsigned int) 0x0));
}
std::vector<tl::Variant> values;

values.push_back (tl::Variant (bbox.left ()));
values.push_back (tl::Variant (bbox.bottom ()));
values.push_back (tl::Variant (bbox.width ()));
values.push_back (tl::Variant (bbox.height ()));
// TODO: how to set the "depends on external cells" flag?
db::Box bbox = layout.cell (*cell).bbox ();
if (bbox.empty ()) {
// empty box
values.push_back (tl::Variant ((unsigned int) 0x2));
bbox = db::Box (0, 0, 0, 0);
} else {
values.push_back (tl::Variant ((unsigned int) 0x0));
}

values.push_back (tl::Variant (bbox.left ()));
values.push_back (tl::Variant (bbox.bottom ()));
values.push_back (tl::Variant (bbox.width ()));
values.push_back (tl::Variant (bbox.height ()));

write_property_def (s_bounding_box_name, values, true);
write_property_def (s_bounding_box_name, values, true);

}

// PROPERTY record with S_CELL_OFFSET
if (cell_positions) {
Expand Down
59 changes: 59 additions & 0 deletions src/plugins/streamers/oasis/unit_tests/dbOASISWriterTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,65 @@ TEST(116)
EXPECT_EQ (std::string (os.string ()), std::string (expected))
}

{
std::string tmp_file = tl::TestBase::tmp_file ("tmp_dbOASISWriter116d2.gds");

{
tl::OutputStream out (tmp_file);
db::SaveLayoutOptions write_options;
write_options.set_format ("OASIS");
db::OASISWriterOptions oas_write_options;
oas_write_options.write_std_properties = 1;
oas_write_options.strict_mode = true;
oas_write_options.write_cblocks = false;
write_options.set_options (oas_write_options);
db::Writer writer (write_options);
writer.write (g, out);
}

tl::InputStream in (tmp_file);
db::OASISReaderOptions oas_options;
oas_options.read_all_properties = true;
oas_options.expect_strict_mode = 1;
db::LoadLayoutOptions options;
options.set_options (oas_options);
db::Reader reader (in);
db::Layout gg;
reader.set_warnings_as_errors (true);
reader.read (gg, options);

const char *expected =
"set props {\n"
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_TOP_CELL} {$2}}\n"
" {{S_TOP_CELL} {$1}}\n"
" {{name} {117}}\n"
" {17 {17value}}\n"
"}\n"
"begin_libp $props 0.001\n"
"set props {\n"
" {42 {42}}\n"
" {{S_CELL_OFFSET} {182}}\n"
"}\n"
"begin_cellp $props {$1}\n"
"path 1 0 0 0 0 {0 100} {1000 1200}\n"
"end_cell\n"
"set props {\n"
" {{S_CELL_OFFSET} {180}}\n"
"}\n"
"begin_cellp $props {$2}\n"
"end_cell\n"
"end_lib\n"
;

tl::OutputStringStream os;
tl::OutputStream stream (os);
db::TextWriter textwriter (stream);
textwriter.write (gg);
EXPECT_EQ (std::string (os.string ()), std::string (expected))
}

c1.insert (db::CellInstArray (c2.cell_index (), db::Trans ()));

{
Expand Down
Loading