From 4561eebdc005a99b902584b05001205fd91d9b7c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 14 Jun 2026 21:33:41 +0200 Subject: [PATCH] Added missing files, added tests --- .../dbLayoutToNetlistReaderTests.cc | 21 +++++++ testdata/algo/l2n_reader_8.l2n | 55 +++++++++++++++++++ testdata/algo/l2n_reader_8s.l2n | 40 ++++++++++++++ testdata/algo/l2n_writer_au_4.txt | 55 +++++++++++++++++++ testdata/algo/l2n_writer_au_4s.txt | 40 ++++++++++++++ 5 files changed, 211 insertions(+) create mode 100644 testdata/algo/l2n_reader_8.l2n create mode 100644 testdata/algo/l2n_reader_8s.l2n create mode 100644 testdata/algo/l2n_writer_au_4.txt create mode 100644 testdata/algo/l2n_writer_au_4s.txt diff --git a/src/db/unit_tests/dbLayoutToNetlistReaderTests.cc b/src/db/unit_tests/dbLayoutToNetlistReaderTests.cc index 3fad59f11..07923a752 100644 --- a/src/db/unit_tests/dbLayoutToNetlistReaderTests.cc +++ b/src/db/unit_tests/dbLayoutToNetlistReaderTests.cc @@ -584,3 +584,24 @@ TEST(8_VariantDeviceParameters) "end;\n" ); } + +TEST(9_VariantDeviceParametersShort) +{ + db::LayoutToNetlist l2n; + + // build from: testdata/algo/l2n_reader_4.gds + + std::string in_path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "l2n_reader_8s.l2n"); + tl::InputStream is_in (in_path); + + db::LayoutToNetlistStandardReader reader (is_in); + reader.read (&l2n); + + tl_assert (l2n.netlist () != 0); + EXPECT_EQ (l2n.netlist ()->to_string (), + "circuit TOP ();\n" + " device DEVCLS dev (S=(null),G=(null),D=(null),B=(null)) (D=17.5,L=42,S=XYZ,B=true,N=nil);\n" + " device DEVCLS dev2 (S=(null),G=(null),D=(null),B=(null)) (D=0,L=0,S=,B=false,N=nil);\n" + "end;\n" + ); +} diff --git a/testdata/algo/l2n_reader_8.l2n b/testdata/algo/l2n_reader_8.l2n new file mode 100644 index 000000000..381730a7d --- /dev/null +++ b/testdata/algo/l2n_reader_8.l2n @@ -0,0 +1,55 @@ +#%l2n-klayout +top(TOP) +unit(0.001) + +# Layer section +# This section lists the mask layers (drawing or derived) and their connections. + +# Mask layers + +# Mask layer connectivity + +# Device class section +class(DEVCLS MOS4 1 + param(D 1 0) + param-int(L 1 0) + param-string(S 1 '') + param-var(B 1 'false') + param-nil(N 1) + terminal(S) + terminal(G) + terminal(D) + terminal(B) +) + +# Circuit section +# Circuits are the hierarchical building blocks of the netlist. +circuit(TOP + + # Devices and their connections + device(1 DEVCLS + name(dev) + param(D 17.5) + param-int(L 42) + param-string(S 'XYZ') + param-var(B 'true') + param-nil(N) + terminal(S) + terminal(G) + terminal(D) + terminal(B) + ) + device(2 DEVCLS + name(dev2) + param(D 0) + param-int(L 0) + param-string(S '') + param-var(B 'false') + param-nil(N) + terminal(S) + terminal(G) + terminal(D) + terminal(B) + ) + +) diff --git a/testdata/algo/l2n_reader_8s.l2n b/testdata/algo/l2n_reader_8s.l2n new file mode 100644 index 000000000..cea1aa20a --- /dev/null +++ b/testdata/algo/l2n_reader_8s.l2n @@ -0,0 +1,40 @@ +#%l2n-klayout +W(TOP) +U(0.001) +K(DEVCLS MOS4 1 + E(D 1 0) + EI(L 1 0) + ES(S 1 '') + EV(B 1 'false') + EN(N 1) + T(S) + T(G) + T(D) + T(B) +) +X(TOP + D(1 DEVCLS + I(dev) + E(D 17.5) + EI(L 42) + ES(S 'XYZ') + EV(B 'true') + EN(N) + T(S) + T(G) + T(D) + T(B) + ) + D(2 DEVCLS + I(dev2) + E(D 0) + EI(L 0) + ES(S '') + EV(B 'false') + EN(N) + T(S) + T(G) + T(D) + T(B) + ) +) diff --git a/testdata/algo/l2n_writer_au_4.txt b/testdata/algo/l2n_writer_au_4.txt new file mode 100644 index 000000000..381730a7d --- /dev/null +++ b/testdata/algo/l2n_writer_au_4.txt @@ -0,0 +1,55 @@ +#%l2n-klayout +top(TOP) +unit(0.001) + +# Layer section +# This section lists the mask layers (drawing or derived) and their connections. + +# Mask layers + +# Mask layer connectivity + +# Device class section +class(DEVCLS MOS4 1 + param(D 1 0) + param-int(L 1 0) + param-string(S 1 '') + param-var(B 1 'false') + param-nil(N 1) + terminal(S) + terminal(G) + terminal(D) + terminal(B) +) + +# Circuit section +# Circuits are the hierarchical building blocks of the netlist. +circuit(TOP + + # Devices and their connections + device(1 DEVCLS + name(dev) + param(D 17.5) + param-int(L 42) + param-string(S 'XYZ') + param-var(B 'true') + param-nil(N) + terminal(S) + terminal(G) + terminal(D) + terminal(B) + ) + device(2 DEVCLS + name(dev2) + param(D 0) + param-int(L 0) + param-string(S '') + param-var(B 'false') + param-nil(N) + terminal(S) + terminal(G) + terminal(D) + terminal(B) + ) + +) diff --git a/testdata/algo/l2n_writer_au_4s.txt b/testdata/algo/l2n_writer_au_4s.txt new file mode 100644 index 000000000..cea1aa20a --- /dev/null +++ b/testdata/algo/l2n_writer_au_4s.txt @@ -0,0 +1,40 @@ +#%l2n-klayout +W(TOP) +U(0.001) +K(DEVCLS MOS4 1 + E(D 1 0) + EI(L 1 0) + ES(S 1 '') + EV(B 1 'false') + EN(N 1) + T(S) + T(G) + T(D) + T(B) +) +X(TOP + D(1 DEVCLS + I(dev) + E(D 17.5) + EI(L 42) + ES(S 'XYZ') + EV(B 'true') + EN(N) + T(S) + T(G) + T(D) + T(B) + ) + D(2 DEVCLS + I(dev2) + E(D 0) + EI(L 0) + ES(S '') + EV(B 'false') + EN(N) + T(S) + T(G) + T(D) + T(B) + ) +)