From 928b02aa1fd3929919542564b3648e4b79d8d421 Mon Sep 17 00:00:00 2001 From: Bastian Koppelmann Date: Wed, 11 Dec 2019 10:37:17 +0100 Subject: [PATCH] gdsMill: Fix reader/writer ignoring the 'DATATYPE' of 'PATH' records most readers (like KLayout/Calibre) will not open gds files omiting the DATATYPE. Signed-off-by: Bastian Koppelmann --- compiler/gdsMill/gdsMill/gds2reader.py | 5 +++++ compiler/gdsMill/gdsMill/gds2writer.py | 4 ++++ compiler/gdsMill/gdsMill/gdsPrimitives.py | 1 + 3 files changed, 10 insertions(+) diff --git a/compiler/gdsMill/gdsMill/gds2reader.py b/compiler/gdsMill/gdsMill/gds2reader.py index 7e519c36..56dc4bef 100644 --- a/compiler/gdsMill/gdsMill/gds2reader.py +++ b/compiler/gdsMill/gdsMill/gds2reader.py @@ -251,6 +251,11 @@ class Gds2reader: thisPath.pathType=pathType if(self.debugToTerminal==1): print("\t\t\tPath Type: "+str(pathType)) + elif(idBits==b'\x0E\x02'): #Data type + dataType = struct.unpack(">h",record[2:4])[0] + thisPath.dataType=dataType + if(self.debugToTerminal==1): + print("\t\t\tData Type: "+str(dataType)) elif(idBits==b'\x0F\x03'): #Path width pathWidth = struct.unpack(">i",record[2:6])[0] thisPath.pathWidth=pathWidth diff --git a/compiler/gdsMill/gdsMill/gds2writer.py b/compiler/gdsMill/gdsMill/gds2writer.py index 402416cd..059c156d 100644 --- a/compiler/gdsMill/gdsMill/gds2writer.py +++ b/compiler/gdsMill/gdsMill/gds2writer.py @@ -238,6 +238,10 @@ class Gds2writer: idBits=b'\x16\x02' #purpose layer purposeLayer = struct.pack(">h",thisPath.purposeLayer) self.writeRecord(idBits+purposeLayer) + if(thisPath.dataType is not None): + idBits=b'\x0E\x02' #Data type + dataType = struct.pack(">h",thisPath.dataType) + self.writeRecord(idBits+dataType) if(thisPath.pathType): idBits=b'\x21\x02' #Path type pathType = struct.pack(">h",thisPath.pathType) diff --git a/compiler/gdsMill/gdsMill/gdsPrimitives.py b/compiler/gdsMill/gdsMill/gdsPrimitives.py index dc43fea6..ef87cec8 100644 --- a/compiler/gdsMill/gdsMill/gdsPrimitives.py +++ b/compiler/gdsMill/gdsMill/gdsPrimitives.py @@ -33,6 +33,7 @@ class GdsPath: self.drawingLayer="" self.purposeLayer = None self.pathType="" + self.dataType=None self.pathWidth="" self.coordinates=""