1 // *****************************************************************************
2 // *****************************************************************************
3 // Copyright 2012 - 2013, Cadence Design Systems
4 //
5 // This  file  is  part  of  the  Cadence  LEF/DEF  Open   Source
6 // Distribution,  Product Version 5.8.
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 //    you may not use this file except in compliance with the License.
10 //    You may obtain a copy of the License at
11 //
12 //        http://www.apache.org/licenses/LICENSE-2.0
13 //
14 //    Unless required by applicable law or agreed to in writing, software
15 //    distributed under the License is distributed on an "AS IS" BASIS,
16 //    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 //    implied. See the License for the specific language governing
18 //    permissions and limitations under the License.
19 //
20 // For updates, support, or to become part of the LEF/DEF Community,
21 // check www.openeda.org for details.
22 //
23 //  $Author: dell $
24 //  $Revision: #1 $
25 //  $Date: 2017/06/06 $
26 //  $State:  $
27 // *****************************************************************************
28 // *****************************************************************************
29 
30 #ifndef lefiVia_h
31 #define lefiVia_h
32 
33 #include <stdio.h>
34 #include "lefiKRDefs.hpp"
35 #include "lefiMisc.hpp"
36 
37 BEGIN_LEFDEF_PARSER_NAMESPACE
38 
39 class lefiViaLayer {
40 public:
41   lefiViaLayer();
42   void Init();
43 
44   LEF_COPY_CONSTRUCTOR_H(lefiViaLayer);
45   LEF_ASSIGN_OPERATOR_H(lefiViaLayer);
46 
47   void Destroy();
48   ~lefiViaLayer();
49 
50   void setName(const char* name);
51   void addRect(int mask,
52                double xl, double yl,
53                double xh, double yh);
54   void addPoly(int mask,
55                lefiGeometries* geom);
56 
57   lefiViaLayer* clone();
58 
59   int numRects();
60   char* name();
61   double xl(int index);
62   double yl(int index);
63   double xh(int index);
64   double yh(int index);
65   int rectColorMask(int index);
66   int polyColorMask(int index);
67 
68   int numPolygons();                                     // 5.6
69   lefiGeomPolygon* getPolygon(int index) const;   // 5.6
70 
71 protected:
72   char* name_;
73   int* rectColorMask_;
74   int* polyColorMask_;
75   int numRects_;
76   int rectsAllocated_;
77   double* xl_;
78   double* yl_;
79   double* xh_;
80   double* yh_;
81 
82   int numPolys_;
83   int polysAllocated_;
84   lefiGeomPolygon** polygons_;
85 
86 };
87 
88 class lefiVia {
89 public:
90   lefiVia();
91   void Init();
92 
93   LEF_COPY_CONSTRUCTOR_H(lefiVia);
94   void Destroy();
95   ~lefiVia();
96 
97   void clear();
98 
99   // setName calls clear to init
100   // deflt=0 no default specified
101   // deflt=1 default specified in lef file
102   void setName(const char* name, int viaType);
103 
104   void setResistance(double num);
105   void addProp(const char* name, const char* value, const char type);
106   void addNumProp(const char* name, double d, const char* value,
107                   const char type);
108 
109   // orient=-1 means no orient was specified.
110   void setForeign(const char* name, int hasPnt,
111      double x, double y, int orient);
112   void setTopOfStack();
113 
114   void addLayer(const char* name);
115   void addRectToLayer(int    mask,
116                       double xl, double yl,
117                       double xh, double yh);
118   void addPolyToLayer(int    mask,
119                       lefiGeometries* geom);
120   void bumpProps();
121 
122   void setViaRule(const char* viaRuleName, double xSize, double ySize,
123                   const char* botLayer, const char* cutLayer,
124                   const char* topLayer, double xCut, double yCut,
125                   double xBotEnc, double yBotEnc, double xTopEnc,
126                   double yTopEnc);                          // 5.6
127   void setRowCol(int numRows, int numCols);                 // 5.6
128   void setOrigin(double xOffset, double yOffset);           // 5.6
129   void setOffset(double xBot, double yBot, double xTop, double yTop);   // 5.6
130   void setPattern(const char* cutPattern);                  // 5.6
131 
132   // make a new one
133   lefiVia* clone();
134 
135   int hasDefault() const ;
136   int hasGenerated() const ; // 5.6, this no longer in 5.6, should be removed
137   int hasForeign() const ;
138   int hasForeignPnt() const ;
139   int hasForeignOrient() const ;
140   int hasProperties() const ;
141   int hasResistance() const ;
142   int hasTopOfStack() const ;
143 
144   int numLayers() const;
145   char* layerName(int layerNum) const;
146   int numRects(int layerNum) const;
147   double xl(int layerNum, int rectNum) const;
148   double yl(int layerNum, int rectNum) const;
149   double xh(int layerNum, int rectNum) const;
150   double yh(int layerNum, int rectNum) const;
151   int rectColorMask(int layerNum, int rectNum) const;
152   int polyColorMask(int layerNum, int polyNum) const;
153   int numPolygons(int layerNum) const;                                 // 5.6
154   lefiGeomPolygon getPolygon(int layerNum, int polyNum) const;  // 5.6
155 
156   char* name() const ;
157   double resistance() const ;
158 
159   // Given an index from 0 to numProperties()-1 return
160   // information about that property.
161   int numProperties() const ;
162   char* propName(int index) const;
163   char* propValue(int index) const;
164   double propNumber(int index) const;
165   char  propType(int index) const;
166   int propIsNumber(int index) const;
167   int propIsString(int index) const;
168   char* foreign() const;
169   double foreignX() const;
170   double foreignY() const;
171   int foreignOrient() const;
172   char* foreignOrientStr() const;
173 
174   // 5.6 VIARULE inside a VIA
175   int hasViaRule() const;
176   const char* viaRuleName() const;
177   double xCutSize() const;
178   double yCutSize() const;
179   const char* botMetalLayer() const;
180   const char* cutLayer() const;
181   const char* topMetalLayer() const;
182   double xCutSpacing() const;
183   double yCutSpacing() const;
184   double xBotEnc() const;
185   double yBotEnc() const;
186   double xTopEnc() const;
187   double yTopEnc() const;
188   int hasRowCol() const;
189   int numCutRows() const;
190   int numCutCols() const;
191   int hasOrigin() const;
192   double xOffset() const;
193   double yOffset() const;
194   int hasOffset() const;
195   double xBotOffset() const;
196   double yBotOffset() const;
197   double xTopOffset() const;
198   double yTopOffset() const;
199   int hasCutPattern() const;
200   const char* cutPattern() const;
201 
202   // Debug print
203   void print(FILE* f) const;
204 
205 protected:
206   char* name_;
207   int nameSize_;
208 
209   int hasDefault_;
210   int hasGenerated_;
211   int hasResistance_;
212   int hasForeignPnt_;
213   int hasTopOfStack_;
214 
215   int numProps_;
216   int propsAllocated_;
217   char** propName_;
218   // The prop value is stored in the propValue_ or the propDValue_.
219   // If it is a string it is in propValue_.  If it is a number,
220   // then propValue_ is NULL and it is stored in propDValue_;
221   char** propValue_;
222   double* propDValue_;
223   char*   propType_;
224 
225   int numLayers_;
226   int layersAllocated_;
227   lefiViaLayer** layers_;
228 
229   double resistance_;
230 
231   char* foreign_;
232   double foreignX_;
233   double foreignY_;
234   int foreignOrient_;
235 
236   char* viaRuleName_;          // 5.6
237   double xSize_;               // 5.6
238   double ySize_;               // 5.6
239   char* botLayer_;             // 5.6
240   char* cutLayer_;             // 5.6
241   char* topLayer_;             // 5.6
242   double xSpacing_;            // 5.6
243   double ySpacing_;            // 5.6
244   double xBotEnc_;             // 5.6
245   double yBotEnc_;             // 5.6
246   double xTopEnc_;             // 5.6
247   double yTopEnc_;             // 5.6
248   int numRows_;                // 5.6
249   int numCols_;                // 5.6
250   double xOffset_;             // 5.6
251   double yOffset_;             // 5.6
252   double xBotOs_;              // 5.6
253   double yBotOs_;              // 5.6
254   double xTopOs_;              // 5.6
255   double yTopOs_;              // 5.6
256   char* cutPattern_;           // 5.6
257 };
258 
259 END_LEFDEF_PARSER_NAMESPACE
260 
261 USE_LEFDEF_PARSER_NAMESPACE
262 
263 #endif
264