1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (c) 2019, Nefelus Inc
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 // * Redistributions of source code must retain the above copyright notice, this
11 //   list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above copyright notice,
14 //   this list of conditions and the following disclaimer in the documentation
15 //   and/or other materials provided with the distribution.
16 //
17 // * Neither the name of the copyright holder nor the names of its
18 //   contributors may be used to endorse or promote products derived from
19 //   this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 
33 #pragma once
34 
35 #include <list>
36 #include <map>
37 #include <set>
38 #include <string>
39 #include <vector>
40 
41 #include "ISdb.h"
42 #include "dbLogger.h"
43 #include "dbObject.h"
44 #include "dbSet.h"
45 #include "dbTypes.h"
46 #include "dbViaParams.h"
47 #include "geom.h"
48 #include "odb.h"
49 
50 #define ADS_MAX_CORNER 10
51 
52 namespace utl {
53 class Logger;
54 }
55 
56 namespace odb {
57 
58 class dbShape;
59 class lefout;
60 class dbViaParams;
61 class dbTransform;
62 
63 template <class T>
64 class dbId;
65 
66 // Forward declarations of all database objects
67 class dbDatabase;
68 class dbBox;
69 class dbJournalEntry;
70 
71 // Property objects
72 class dbProperty;
73 class dbBoolProperty;
74 class dbStringProperty;
75 class dbIntProperty;
76 class dbDoubleProperty;
77 
78 // Design objects
79 class dbChip;
80 class dbBlock;
81 class dbBTerm;
82 class dbNet;
83 class dbInst;
84 class dbITerm;
85 class dbVia;
86 class dbTrackGrid;
87 class dbObstruction;
88 class dbBlockage;
89 class dbWire;
90 class dbSWire;
91 class dbSBox;
92 class dbCapNode;
93 class dbRSeg;
94 class dbCCSeg;
95 class dbBlockSearch;
96 class dbRow;
97 class dbFill;
98 class dbTechAntennaPinModel;
99 class dbBlockCallBackObj;
100 class dbRegion;
101 class dbBPin;
102 
103 // Lib objects
104 class dbLib;
105 class dbSite;
106 class dbMaster;
107 class dbMTerm;
108 class dbMPin;
109 class dbTarget;
110 
111 // Tech objects
112 class dbTech;
113 class dbTechVia;
114 class dbTechViaRule;
115 class dbTechViaLayerRule;
116 class dbTechViaGenerateRule;
117 class dbTechNonDefaultRule;
118 class dbTechLayerRule;
119 class dbTechLayerSpacingRule;
120 class dbTechLayerAntennaRule;
121 class dbTechMinCutRule;
122 class dbTechMinEncRule;
123 class dbTechV55InfluenceEntry;
124 class dbTechSameNetRule;
125 class dbViaParams;
126 
127 // Generator Code Begin ClassDeclarations
128 class dbTechLayer;
129 class dbTechLayerSpacingEolRule;
130 class dbTechLayerMinStepRule;
131 class dbTechLayerCornerSpacingRule;
132 class dbTechLayerSpacingTablePrlRule;
133 class dbTechLayerEolKeepOutRule;
134 class dbTechLayerCutClassRule;
135 class dbTechLayerCutSpacingRule;
136 class dbTechLayerCutSpacingTableOrthRule;
137 class dbTechLayerCutSpacingTableDefRule;
138 class dbTechLayerCutEnclosureRule;
139 class dbTechLayerEolExtensionRule;
140 class dbModule;
141 class dbModInst;
142 class dbGroup;
143 class dbGCellGrid;
144 // Generator Code End ClassDeclarations
145 
146 // Extraction Objects
147 class dbExtControl;
148 
149 ///
150 /// dbProperty - Property base class.
151 ///
152 class dbProperty : public dbObject
153 {
154  public:
155   enum Type
156   {
157     // Do not change the order or the values of this enum.
158     STRING_PROP = 0,
159     BOOL_PROP = 1,
160     INT_PROP = 2,
161     DOUBLE_PROP = 3
162   };
163 
164   /// Get the type of this property.
165   Type getType();
166 
167   /// Get thetname of this property.
168   std::string getName();
169 
170   /// Get the owner of this property
171   dbObject* getPropOwner();
172 
173   /// Find the named property. Returns NULL if the property does not exist.
174   static dbProperty* find(dbObject* object, const char* name);
175 
176   /// Find the named property of the specified type. Returns NULL if the
177   /// property does not exist.
178   static dbProperty* find(dbObject* object, const char* name, Type type);
179 
180   /// Destroy a specific property
181   static void destroy(dbProperty* prop);
182   /// Destroy all properties of the specific object
183   static void destroyProperties(dbObject* obj);
184   static dbSet<dbProperty> getProperties(dbObject* object);
185   static dbSet<dbProperty>::iterator destroy(dbSet<dbProperty>::iterator itr);
186   // 5.8
187   static void writeProperties(dbObject* object, FILE* out);
188   static void writePropValue(dbProperty* prop, FILE* out);
189 };
190 
191 ///
192 /// dbProperty - Boolean property.
193 ///
194 class dbBoolProperty : public dbProperty
195 {
196  public:
197   /// Get the value of this property.
198   bool getValue();
199 
200   /// Set the value of this property.
201   void setValue(bool value);
202 
203   /// Create a bool property. Returns NULL if a property with the same name
204   /// already exists.
205   static dbBoolProperty* create(dbObject* object, const char* name, bool value);
206 
207   /// Find the named property of type bool. Returns NULL if the property does
208   /// not exist.
209   static dbBoolProperty* find(dbObject* object, const char* name);
210 };
211 
212 ///
213 /// dbProperty - String property.
214 ///
215 class dbStringProperty : public dbProperty
216 {
217  public:
218   /// Get the value of this property.
219   std::string getValue();
220 
221   /// Set the value of this property.
222   void setValue(const char* value);
223 
224   /// Create a string property. Returns NULL if a property with the same name
225   /// already exists.
226   static dbStringProperty* create(dbObject* object,
227                                   const char* name,
228                                   const char* value);
229 
230   /// Find the named property of type string. Returns NULL if the property does
231   /// not exist.
232   static dbStringProperty* find(dbObject* object, const char* name);
233 };
234 
235 ///
236 /// dbProperty - Int property.
237 ///
238 class dbIntProperty : public dbProperty
239 {
240  public:
241   /// Get the value of this property.
242   int getValue();
243 
244   /// Set the value of this property.
245   void setValue(int value);
246 
247   /// Create a int property. Returns NULL if a property with the same name
248   /// already exists.
249   static dbIntProperty* create(dbObject* object, const char* name, int value);
250 
251   /// Find the named property of type int. Returns NULL if the property does not
252   /// exist.
253   static dbIntProperty* find(dbObject* object, const char* name);
254 };
255 
256 ///
257 /// dbProperty - Double property.
258 ///
259 class dbDoubleProperty : public dbProperty
260 {
261  public:
262   /// Get the value of this property.
263   double getValue();
264 
265   /// Set the value of this property.
266   void setValue(double value);
267 
268   /// Create a double property. Returns NULL if a property with the same name
269   /// already exists.
270   static dbDoubleProperty* create(dbObject* object,
271                                   const char* name,
272                                   double value);
273 
274   /// Find the named property of type double. Returns NULL if the property does
275   /// not exist.
276   static dbDoubleProperty* find(dbObject* object, const char* name);
277 };
278 
279 ///////////////////////////////////////////////////////////////////////////////
280 ///
281 /// This class encapsulates a persitant ADS database.
282 /// You can open multiple databases, however, the number
283 /// of open databases is limited to the amount
284 /// of physical memory available.
285 ///
286 ///////////////////////////////////////////////////////////////////////////////
287 class dbDatabase : public dbObject
288 {
289  public:
290   ///
291   /// Return the libs contained in the database. A database can contain
292   /// multiple libs.
293   ///
294   dbSet<dbLib> getLibs();
295 
296   ///
297   /// Find a specific lib.
298   /// Returns NULL if no lib was found.
299   ///
300   dbLib* findLib(const char* name);
301 
302   ///
303   /// Find a specific master
304   /// Returns NULL if no master is found.
305   ///
306   dbMaster* findMaster(const char* name);
307 
308   ///
309   /// Get the chip of this database.
310   /// Returns NULL if no chip has been created.
311   ///
312   dbChip* getChip();
313 
314   ///
315   /// Get the technology of this database
316   /// Returns NULL if no chip has been created.
317   ///
318   dbTech* getTech();
319 
320   ////////////////////////
321   /// DEPRECIATED
322   ////////////////////////
323   /// Return the chips contained in the database. A database can contain
324   /// multiple chips.
325   ///
326   dbSet<dbChip> getChips();
327 
328   ///
329   /// Returns the number of masters
330   ///
331   uint getNumberOfMasters();
332 
333   ///
334   /// Translate a database-name to a database object.
335   ///
336   // dbObject * resolveDbName( const char * dbname );
337 
338   ///
339   /// Read a database from this stream.
340   /// WARNING: This function destroys the data currently in the database.
341   /// Throws ZIOError..
342   ///
343   void read(FILE* file);
344 
345   ///
346   /// Write a database to this stream.
347   /// Throws ZIOError..
348   ///
349   void write(FILE* file);
350 
351   /// Throws ZIOError..
352   void writeTech(FILE* file);
353   void writeLib(FILE* file, dbLib* lib);
354   void writeLibs(FILE* file);
355   void writeBlock(FILE* file, dbBlock* block);
356   void writeChip(FILE* file);
357   void writeWires(FILE* file, dbBlock* block);
358   void writeNets(FILE* file, dbBlock* block);
359   void writeParasitics(FILE* file, dbBlock* block);
360   void readTech(FILE* file);
361   void readLib(FILE* file, dbLib*);
362   void readLibs(FILE* file);
363   void readBlock(FILE* file, dbBlock* block);
364   void readWires(FILE* file, dbBlock* block);
365   void readNets(FILE* file, dbBlock* block);
366   void readParasitics(FILE* file, dbBlock* block);
367   void readChip(FILE* file);
368 
369   ///
370   /// ECO - The following methods implement a simple ECO mechanism for capturing
371   /// netlist changes. The intent of the ECO mechanism is to support delta
372   /// changes that occur in a "remote" node that must be applied back to the
373   /// "master" node. Being as such, the database on the "remote" must be an
374   /// exact copy of the "master" database, prior to changes. Furthermore, the
375   /// "master" database cannot change prior to commiting the eco to the block.
376   ///
377   /// WARNING: If these invariants does not hold then the results will be
378   ///          unpredictable.
379   ///
380 
381   ///
382   /// Begin collecting netlist changes on specified block.
383   ///
384   /// NOTE: Eco changes can not be nested at this time.
385   ///
386   static void beginEco(dbBlock* block);
387 
388   ///
389   /// End collecting netlist changes on specified block.
390   ///
391   static void endEco(dbBlock* block);
392 
393   ///
394   /// Returns true of the pending eco is empty
395   ///
396   static bool ecoEmpty(dbBlock* block);
397 
398   ///
399   /// Read the eco changes from the specified stream to be applied to the
400   /// specified block.
401   ///
402   static void readEco(dbBlock* block, const char* filename);
403 
404   ///
405   /// Write the eco netlist changes to the specified stream.
406   ///
407   static void writeEco(dbBlock* block, const char* filename);
408   static int checkEco(dbBlock* block);
409 
410   ///
411   /// Commit any pending netlist changes.
412   ///
413   static void commitEco(dbBlock* block);
414 
415   ///
416   /// links to utl::Logger
417   ///
418   void setLogger(utl::Logger* logger);
419 
420   ///
421   /// Initializes the database to nothing.
422   ///
423   void clear();
424 
425   ///
426   /// Create an instance of a database
427   ///
428   static dbDatabase* create();
429 
430   ///
431   /// Detroy an instance of a database
432   ///
433   static void destroy(dbDatabase* db);
434 
435   ///
436   /// Create a duplicate (IN-MEMORY) instance of a database.
437   ///
438   /// WARNING: This action may result in an out-of-memory condition if
439   ///          there is not enough memory (or swap space) to maintain
440   ///          multiple in-core databases.
441   ///
442   static dbDatabase* duplicate(dbDatabase* db);
443 
444   ///
445   /// diff the two databases
446   /// Returns true if differences were found.
447   ///
448   static bool diff(dbDatabase* db0,
449                    dbDatabase* db1,
450                    FILE* file,
451                    int indent_per_level);
452   ///
453   /// Translate a database-id back to a pointer.
454   ///
455   static dbDatabase* getDatabase(uint oid);
456 };
457 
458 ///////////////////////////////////////////////////////////////////////////////
459 ///
460 /// A box is the element used to represent layout shapes.
461 ///
462 ///////////////////////////////////////////////////////////////////////////////
463 class dbBox : public dbObject
464 {
465  public:
466   ///
467   /// Get the lower coordinate.
468   ///
469   int xMin();
470 
471   ///
472   /// Get the lower y coordinate.
473   ///
474   int yMin();
475 
476   ///
477   /// Get the high x coordinate.
478   ///
479   int xMax();
480 
481   ///
482   /// Get the high y coordinate.
483   ///
484   int yMax();
485 
486   ///
487   /// Returns true if this box represents a via
488   ///
489   bool isVia();
490 
491   ///
492   /// Get tech-via this box represents.
493   /// returns NULL if this box does not represent a tech-via
494   ///
495   dbTechVia* getTechVia();
496 
497   ///
498   /// Get block-via this box represents.
499   /// returns NULL if this box does not represent a block-via
500   ///
501   dbVia* getBlockVia();
502 
503   ///
504   /// Return the placed location of this via.
505   ///
506   void getViaXY(int& x, int& y);
507 
508   ///
509   /// Get the box bounding points.
510   ///
511   void getBox(Rect& rect);
512 
513   ///
514   /// Get the translated boxes of this via
515   ///
516   void getViaBoxes(std::vector<dbShape>& boxes);
517 
518   ///
519   /// Get the width (xMax-xMin) of the box.
520   ///
521   int getDir();
522 
523   ///
524   /// Get the width (xMax-xMin) of the box.
525   ///
526   uint getDX();
527 
528   int getDesignRuleWidth() const;
529 
530   void setDesignRuleWidth(int);
531 
532   ///
533   /// Get the height (yMax-yMin) of the box.
534   ///
535   uint getDY();
536   uint getWidth(uint dir = 1);
537   uint getLength(uint dir = 1);
538 
539   ///
540   /// Get GeomShape Interface
541   ///
542   GeomShape* getGeomShape();
543 
544   ///
545   /// Set temporary flag visited
546   ///
547   void setVisited(bool value);
548   bool isVisited();
549   void setMarked(bool value);
550   bool isMarked();
551 
552   ///
553   /// Get the owner of this box
554   ///
555   dbObject* getBoxOwner();
556 
557   ///
558   /// Get the owner type of this box
559   ///
560   dbBoxOwner getOwnerType();
561 
562   ///
563   /// Get the layer of this box.
564   /// Returns NULL if this shape is an object bbox.
565   /// These bboxes have no layer.
566   ///     dbBlock    - bbox has no layer
567   ///     dbInst     - bbox has no layer
568   ///     dbVia      - bbox has no layer
569   ///     dbTechVia  - bbox has no layer
570   ///
571   /// These bboxes have no layer.
572   ///    All dbBox(s) that represent VIA's.
573   ///
574   dbTechLayer* getTechLayer();
575 
576   ///
577   /// Add a physical pin to a dbBPin.
578   /// Returns NULL if this dbBPin already has a pin.
579   ///
580   static dbBox* create(dbBPin* bpin,
581                        dbTechLayer* layer,
582                        int x1,
583                        int y1,
584                        int x2,
585                        int y2);
586 
587   ///
588   /// Add a box to a block-via.
589   ///
590   static dbBox* create(dbVia* via,
591                        dbTechLayer* layer,
592                        int x1,
593                        int y1,
594                        int x2,
595                        int y2);
596 
597   ///
598   /// Add an obstruction to a master.
599   ///
600   static dbBox* create(dbMaster* master,
601                        dbTechLayer* layer,
602                        int x1,
603                        int y1,
604                        int x2,
605                        int y2);
606 
607   ///
608   /// Add a via obstrction to a master.
609   /// This function may fail and return NULL if this via has no shapes.
610   ///
611   static dbBox* create(dbMaster* master, dbTechVia* via, int x, int y);
612 
613   ///
614   /// Add a wire-shape to a master-pin.
615   ///
616   static dbBox* create(dbMPin* pin,
617                        dbTechLayer* layer,
618                        int x1,
619                        int y1,
620                        int x2,
621                        int y2);
622 
623   ///
624   /// Add a via obstrction to a master-pin.
625   /// This function may fail and return NULL if this via has no shapes.
626   ///
627   static dbBox* create(dbMPin* pin, dbTechVia* via, int x, int y);
628 
629   ///
630   /// Add a shape to a tech-via;
631   ///
632   static dbBox* create(dbTechVia* via,
633                        dbTechLayer* layer,
634                        int x1,
635                        int y1,
636                        int x2,
637                        int y2);
638 
639   ///
640   /// Add a boundary to a region
641   ///
642   static dbBox* create(dbRegion* region, int x1, int y1, int x2, int y2);
643 
644   ///
645   /// Create a halo on an instance.
646   ///
647   static dbBox* create(dbInst* inst, int x1, int y1, int x2, int y2);
648 
649   ///
650   /// Translate a database-id back to a pointer.
651   /// This function translates any dbBox which is part of a block.
652   ///
653   static dbBox* getBox(dbBlock* block, uint oid);
654 
655   /// Translate a database-id back to a pointer.
656   /// This function translates any dbBox which is part of a tech.
657   ///
658   static dbBox* getBox(dbTech* tech, uint oid);
659 
660   ///
661   /// Translate a database-id back to a pointer.
662   /// This function translates any dbBox whichs is part of a master.
663   ///
664   static dbBox* getBox(dbMaster* master, uint oid);
665 };
666 
667 ///////////////////////////////////////////////////////////////////////////////
668 ///
669 /// A sbox is the element used to represent special layout shapes.
670 ///
671 ///////////////////////////////////////////////////////////////////////////////
672 class dbSBox : public dbBox
673 {
674  public:
675   /// Direction of segment
676   enum Direction
677   {
678     UNDEFINED = 0,
679     HORIZONTAL = 1,
680     VERTICAL = 2,
681     OCTILINEAR = 3
682   };
683 
684   ///
685   /// Get the shape type of this wire.
686   ///
687   dbWireShapeType getWireShapeType();
688 
689   ///
690   /// Return the specified direction of this segment
691   ///
692   Direction getDirection();
693 
694   ///
695   /// Get the swire of this shape
696   ///
697   dbSWire* getSWire();
698 
699   ///
700   /// Get Oct Wire Shape
701   ///
702   Oct getOct();
703 
704   ///
705   /// Add a rect to a dbSWire.
706   ///
707   /// If direction == UNDEFINED
708   ///    |(x2-x1)| must be an even number or |(y2-y1)| must be an even number
709   ///
710   /// If direction == HORIZONTAL
711   ///    |(y2-y1)| must be an even number
712   ///
713   /// If direction == VERTICAL
714   ///    |(x2-x1)| must be an even number
715   ///
716   /// If the direction sementics are not met, this function will return NULL.
717   ///
718   /// These requirements are a result that the current DEF semantics (5.5) use
719   /// PATH statements to output these rectangles, the paths must have even
720   /// widths.
721   static dbSBox* create(dbSWire* swire,
722                         dbTechLayer* layer,
723                         int x1,
724                         int y1,
725                         int x2,
726                         int y2,
727                         dbWireShapeType type,
728                         Direction dir = UNDEFINED,
729                         int width = 0);
730 
731   ///
732   /// Add a block-via to a dbSWire
733   /// This function may fail and return NULL if this via has no shapes.
734   ///
735   static dbSBox* create(dbSWire* swire,
736                         dbVia* via,
737                         int x,
738                         int y,
739                         dbWireShapeType type);
740 
741   ///
742   /// Add a tech-via to a dbSWire.
743   /// This function may fail and return NULL if this via has no shapes.
744   ///
745   static dbSBox* create(dbSWire* swire,
746                         dbTechVia* via,
747                         int x,
748                         int y,
749                         dbWireShapeType type);
750 
751   ///
752   /// Translate a database-id back to a pointer.
753   /// This function translates any dbBox whichs is part of a block
754   ///
755   static dbSBox* getSBox(dbBlock* block, uint oid);
756 };
757 
758 ///////////////////////////////////////////////////////////////////////////////
759 ///
760 /// A Chip is the element the represents a VLSI/ASIC IC.
761 ///
762 ///////////////////////////////////////////////////////////////////////////////
763 class dbChip : public dbObject
764 {
765  public:
766   ///
767   /// Get the top-block of this chip.
768   /// Returns NULL if a top-block has NOT been created.
769   ///
770   dbBlock* getBlock();
771 
772   ///
773   /// Create a new chip.
774   /// Returns NULL if a chip already exists.
775   /// Returns NULL if there is no database technology.
776   ///
777   static dbChip* create(dbDatabase* db);
778 
779   ///
780   /// Translate a database-id back to a pointer.
781   ///
782   static dbChip* getChip(dbDatabase* db, uint oid);
783 
784   ///
785   /// Destroy a chip.
786   ///
787   static void destroy(dbChip* chip);
788 };
789 
790 ///////////////////////////////////////////////////////////////////////////////
791 ///
792 /// A Block is the element used to represent a layout-netlist.
793 /// A Block can have multiple children, however, currently only two-levels
794 /// of hierarchy is supported.
795 ///
796 ///////////////////////////////////////////////////////////////////////////////
797 class dbBlock : public dbObject
798 {
799  public:
800   ///
801   /// Get block chip name.
802   ///
803   std::string getName();
804 
805   ///
806   /// Get the block chip name.
807   ///
808   const char* getConstName();
809 
810   ///
811   /// Get the bounding box of this block.
812   ///
813   dbBox* getBBox();
814 
815   ///
816   /// Get the chip this block belongs too.
817   ///
818   dbChip* getChip();
819 
820   ///
821   /// Get the database this block belongs too.
822   ///
823   dbDatabase* getDataBase();
824 
825   ///
826   /// Get the parent block this block. Returns NULL if this block is the
827   /// top-block of the chip.
828   ///
829   dbBlock* getParent();
830 
831   ///
832   /// Returns the hierarchical parent of this block if it exists.
833   ///
834   dbInst* getParentInst();
835 
836   ///
837   /// Returns the top module of this block.
838   ///
839   dbModule* getTopModule();
840 
841   ///
842   /// Get the child blocks of this block.
843   ///
844   dbSet<dbBlock> getChildren();
845 
846   ///
847   /// Find a specific child-block of this block.
848   /// Returns NULL if the object was not found.
849   ///
850   dbBlock* findChild(const char* name);
851 
852   ///
853   /// Get all the block-terminals of this block.
854   ///
855   dbSet<dbBTerm> getBTerms();
856 
857   ///
858   /// Find a specific bterm of this block.
859   /// Returns NULL if the object was not found.
860   ///
861   dbBTerm* findBTerm(const char* name);
862 
863   ///
864   /// Get all the instance-terminals of this block.
865   ///
866   dbSet<dbITerm> getITerms();
867 
868   ///
869   /// Get the instances of this block.
870   ///
871   dbSet<dbInst> getInsts();
872 
873   ///
874   /// Get the modules of this block.
875   ///
876   dbSet<dbModule> getModules();
877 
878   ///
879   /// Get the modinsts of this block.
880   ///
881   dbSet<dbModInst> getModInsts();
882 
883   ///
884   /// Get the groups of this block.
885   ///
886   dbSet<dbGroup> getGroups();
887 
888   ///
889   /// Find a specific instance of this block.
890   /// Returns NULL if the object was not found.
891   ///
892   dbInst* findInst(const char* name);
893 
894   ///
895   /// Find a specific module in this block.
896   /// Returns NULL if the object was not found.
897   ///
898   dbModule* findModule(const char* name);
899 
900   ///
901   /// Find a specific modinst in this block. path is
902   /// master_module_name/modinst_name Returns NULL if the object was not found.
903   ///
904   dbModInst* findModInst(const char* path);
905 
906   ///
907   /// Find a specific group in this block.
908   /// Returns NULL if the object was not found.
909   ///
910   dbGroup* findGroup(const char* name);
911 
912   ///
913   /// Find a set of insts. Each name can be real name, or Ixxx, or xxx,
914   /// where xxx is the inst oid.
915   ///
916   bool findSomeInst(const char* names, std::vector<dbInst*>& insts);
917 
918   ///
919   /// Find a set of masters. Each name can be real name
920   ///
921   bool findSomeMaster(const char* names, std::vector<dbMaster*>& masters);
922 
923   ///
924   /// Find a specific iterm of this block.
925   ///
926   /// The iterm name must be of the form:
927   ///
928   ///     <instanceName><hierDelimeter><termName>
929   ///
930   /// For example:   inst0/A
931   ///
932   dbITerm* findITerm(const char* name);
933 
934   ///
935   /// Get the obstructions of this block
936   ///
937   dbSet<dbObstruction> getObstructions();
938 
939   ///
940   /// Get the blockages of this block
941   ///
942   dbSet<dbBlockage> getBlockages();
943 
944   ///
945   /// Get the nets of this block
946   ///
947   dbSet<dbNet> getNets();
948 
949   ///
950   /// Get the capNodes of this block
951   ///
952   dbSet<dbCapNode> getCapNodes();
953 
954   ///
955   /// Get the rsegs of this block
956   ///
957   dbSet<dbRSeg> getRSegs();
958 
959   ///
960   /// Find a specific net of this block.
961   /// Returns NULL if the object was not found.
962   ///
963   dbNet* findNet(const char* name);
964 
965   ///
966   /// Find a set of nets. Each name can be real name, or Nxxx, or xxx,
967   /// where xxx is the net oid.
968   ///
969   bool findSomeNet(const char* names, std::vector<dbNet*>& nets);
970 
971   //
972   // Utility to save_lef
973   //
974   // void dbBlock::saveLef(char *filename);
975   void saveLef(char* filename);
976 
977   //
978   // Utility to save_def
979   //
980   // void dbBlock::saveDef(char *filename, char *nets);
981   void saveDef(char* filename, char* nets);
982 
983   //
984   // Utility to write db file
985   //
986   // void dbBlock::writeDb(char *filename, int allNode=0);
987   void writeDb(char* filename, int allNode = 0);
988 
989   ///
990   /// Find a specific via of this block.
991   /// Returns NULL if the object was not found.
992   ///
993   dbVia* findVia(const char* name);
994 
995   ///
996   /// Get the vias of this block
997   ///
998   dbSet<dbVia> getVias();
999 
1000   ///
1001   /// Get the GCell grid of this block
1002   /// Returns NULL if no grid exists.
1003   ///
1004   dbGCellGrid* getGCellGrid();
1005 
1006   ///
1007   /// Get the DEF units of this technology.
1008   ///
1009   int getDefUnits();
1010 
1011   ///
1012   /// Set the DEF units of this technology.
1013   ///
1014   void setDefUnits(int units);
1015 
1016   ///
1017   /// Get the Database units per micron.
1018   ///
1019   int getDbUnitsPerMicron();
1020 
1021   ///
1022   /// Get the hierarchy delimeter.
1023   /// Returns (0) if the delimeter was not set.
1024   /// A hierarchy delimeter can only be set at the time
1025   /// a block is created.
1026   ///
1027   char getHierarchyDelimeter();
1028 
1029   ///
1030   /// Set the bus name delimeters
1031   ///
1032   void setBusDelimeters(char left, char right);
1033 
1034   ///
1035   /// Get the bus name delimeters
1036   /// Left and Right are set to "zero" if the bus delimeters
1037   /// were not set.
1038   ///
1039   void getBusDelimeters(char& left, char& right);
1040 
1041   ///
1042   /// Get extraction counters
1043   ///
1044   void getExtCount(int& numOfNet,
1045                    int& numOfRSeg,
1046                    int& numOfCapNode,
1047                    int& numOfCCSeg);
1048 
1049   ///
1050   /// Copy RC values from one extDb to another.
1051   ///
1052   void copyExtDb(uint fr,
1053                  uint to,
1054                  uint extDbCnt,
1055                  double resFactor,
1056                  double ccFactor,
1057                  double gndcFactor);
1058 
1059   ///
1060   /// Adjust RC values.
1061   ///
1062   void adjustRC(double resFactor, double ccFactor, double gndcFactor);
1063 
1064   ///
1065   /// add cc capacitance to gnd capacitance of capNodes of this block
1066   ///
1067   bool groundCC(float gndFactor);
1068 
1069   ///
1070   /// adjust CC's of nets
1071   ///
1072   bool adjustCC(float adjFactor,
1073                 double ccThreshHold,
1074                 std::vector<dbNet*>& nets,
1075                 std::vector<dbNet*>& halonets);
1076 
1077   ///
1078   /// undo adjusted CC
1079   ///
1080   void undoAdjustedCC(std::vector<dbNet*>& nets, std::vector<dbNet*>& halonets);
1081 
1082   ///
1083   /// Get the number of process corners.
1084   ///
1085   int getCornerCount();
1086 
1087   ///
1088   /// having independent extraction corners ?
1089   ///
1090   bool extCornersAreIndependent();
1091 
1092   ///
1093   /// Get the number of corners kept n this block
1094   ///
1095   int getCornersPerBlock();
1096 
1097   ///
1098   /// Get the number of ext dbs
1099   ///
1100   int getExtDbCount();
1101 
1102   ///
1103   /// Get ext corner name by the index in ext Db
1104   ///
1105   void getExtCornerName(int corner, char* cName);
1106 
1107   ///
1108   /// Get the index in ext Db by name
1109   ///
1110   int getExtCornerIndex(const char* cornerName);
1111 
1112   ///
1113   /// Set corner name list
1114   ///
1115   void setCornerNameList(char* name_list);
1116 
1117   ///
1118   /// Get corner name list
1119   ///
1120   char* getCornerNameList();
1121 
1122   ///
1123   /// Set the number of process corners. The maximum number of
1124   /// process corners is limited to 256. This method will
1125   /// delete all dbRCSeg, dbCCSeg, which depend on this value.
1126   ///
1127   void setCornerCount(int cornerCnt, int extDbCnt, const char* name_list);
1128   void setCornerCount(int cnt);
1129 
1130   ///
1131   /// Set the number of corners kept in this block
1132   ///
1133   void setCornersPerBlock(int cornersPerBlock);
1134 
1135   ///
1136   /// Initialize the parasitics value tables
1137   ///
1138   void initParasiticsValueTables();
1139 
1140   ///
1141   /// create child block for one extraction corner
1142   ///
1143   dbBlock* createExtCornerBlock(uint corner);
1144   ///
1145   /// find child block for one extraction corner
1146   ///
1147   dbBlock* findExtCornerBlock(uint corner);
1148   ///
1149   /// get extraction data block for one extraction corner
1150   ///
1151   dbBlock* getExtCornerBlock(uint corner);
1152 
1153   ///
1154   /// when stream out a hier. block it will not stream references to children
1155   ///
1156   void set_skip_hier_stream(bool value);
1157 
1158   ///
1159   /// Get the track-grids of this block.
1160   ///
1161   dbSet<dbTrackGrid> getTrackGrids();
1162 
1163   ///
1164   /// Find a specific track-grid.
1165   /// Returns NULL if a track-grid has not be defined for this layer.
1166   ///
1167   dbTrackGrid* findTrackGrid(dbTechLayer* layer);
1168 
1169   ///
1170   /// Get the rows of this block
1171   ///
1172   dbSet<dbRow> getRows();
1173 
1174   ///
1175   /// Get the fills in this block
1176   ///
1177   dbSet<dbFill> getFills();
1178 
1179   ///
1180   /// Get the list of masters used in this block.
1181   ///
1182   void getMasters(std::vector<dbMaster*>& masters);
1183 
1184   ///
1185   /// Set the die area. The die-area is considered a constant regardless
1186   /// of the geometric elements of the dbBlock. It is generally a constant
1187   /// declared in DEF.
1188   ///
1189   void setDieArea(const Rect& new_rect);
1190 
1191   ///
1192   /// Get the die area. The default die-area is (0,0,0,0).
1193   ///
1194   void getDieArea(Rect& rect);
1195 
1196   ///
1197   /// Get the core area. This computes the bbox of the rows
1198   /// and is O(#rows) in runtime.
1199   ///
1200   void getCoreArea(Rect& rect);
1201 
1202   void setPtFile(FILE* ptf);
1203   FILE* getPtFile();
1204   ///
1205   /// Set the extmain instance.
1206   ///
1207   void setExtmi(void* ext);
1208 
1209   ///
1210   /// Get the extmain instance.
1211   ///
1212   void* getExtmi();
1213 
1214   ///
1215   /// Get the extraction control settings
1216   ///
1217   dbExtControl* getExtControl();
1218 
1219   ///
1220   /// Get the extraction corner names
1221   ///
1222   void getExtCornerNames(std::list<std::string>& ecl);
1223 
1224   ///
1225   /// Get the capacitor-coupled segments.
1226   ///
1227   dbSet<dbCCSeg> getCCSegs();
1228 
1229   ///
1230   /// Allow bufferin of altered nes
1231   ///
1232   bool isBufferAltered();
1233 
1234   ///
1235   ///
1236   ///
1237   void setBufferAltered(bool value);
1238 
1239   ///
1240   /// Build search database for fast area searches for insts
1241   ///
1242   // uint makeInstSearchDB();
1243 
1244   ///
1245   /// Get search database object for fast area searches on physical objects
1246   ///
1247   dbBlockSearch* getSearchDb();
1248 
1249   ///
1250   /// reset _netSdb
1251   ///
1252   // void resetNetSdb();
1253 
1254   ///
1255   /// Get search database module for fast area searches on signal nets
1256   ///
1257   //    ZPtr<ISdb> getSignalNetSdb();
1258   ///
1259   /// Get search database module for fast area searches on signal nets
1260   /// Generate netSdb if it does not exist
1261   ///
1262   //    ZPtr<ISdb> getSignalNetSdb(ZContext & context, dbTech *tech);
1263 
1264   ///
1265   /// Get search database module for fast area searches on physical objects
1266   ///
1267   // ZPtr<ISdb> getNetSdb();
1268   ///
1269   /// Get search database module for fast area searches on physical objects
1270   /// Generate netSdb if it does not exist
1271   ///
1272   // ZPtr<ISdb> getNetSdb(ZContext & context, dbTech *tech);
1273   ///
1274   /// Remove search database
1275   ///
1276   // void removeSdb(std::vector<dbNet *> & nets);
1277   ///
1278   /// Put insts/nets/tracks on Search DB
1279   ///
1280   // dbBlockSearch *initSearchBlock(dbTech *tech, bool nets, bool insts,
1281   // ZContext & context, bool skipViaCuts=false);
1282 
1283   ///
1284   /// Get insts from Search DB given a bbox to do area search
1285   ///
1286   // uint getInsts(int x1, int y1, int x2, int y2, std::vector<dbInst *> &
1287   // result);
1288 
1289   void updateNetFlags(std::vector<dbNet*>& result);
1290 
1291   ///
1292   /// destroy coupling caps of nets
1293   ///
1294   void destroyCCs(std::vector<dbNet*>& nets);
1295 
1296   ///
1297   /// destroy RC segments of nets
1298   ///
1299   void destroyRSegs(std::vector<dbNet*>& nets);
1300 
1301   ///
1302   /// destroy capnodes of nets
1303   ///
1304   void destroyCNs(std::vector<dbNet*>& nets, bool cleanExtid);
1305 
1306   ///
1307   /// destroy parasitics of nets
1308   ///
1309   void destroyParasitics(std::vector<dbNet*>& nets);
1310   void destroyCornerParasitics(std::vector<dbNet*>& nets);
1311 
1312   ///
1313   /// get cc_halo_net's of input nets
1314   ///
1315   void getCcHaloNets(std::vector<dbNet*>& changedNets,
1316                      std::vector<dbNet*>& ccHaloNets);
1317 
1318   ///
1319   /// destroy old parasitics of nets
1320   ///
1321   void destroyOldParasitics(std::vector<dbNet*>& nets,
1322                             std::vector<uint>* capnn,
1323                             std::vector<uint>* rsegn);
1324   void destroyOldCornerParasitics(std::vector<dbNet*>& nets,
1325                                   std::vector<uint>& capnn,
1326                                   std::vector<uint>& rsegn);
1327 
1328   ///
1329   /// restore old parasitics of nets
1330   ///
1331   void restoreOldParasitics(std::vector<dbNet*>& nets,
1332                             bool coupled_rc,
1333                             std::vector<dbNet*>& ccHaloNets,
1334                             std::vector<uint>* capnn,
1335                             std::vector<uint>* rsegn);
1336   void restoreOldCornerParasitics(dbBlock* pBlock,
1337                                   std::vector<dbNet*>& nets,
1338                                   bool coupled_rc,
1339                                   std::vector<dbNet*>& ccHaloNets,
1340                                   std::vector<uint>& capnn,
1341                                   std::vector<uint>& rsegn);
1342 
1343   ///
1344   /// keep old parasitics of nets and replace by zeroRc's'
1345   ///
1346   void replaceOldParasitics(std::vector<dbNet*>& nets,
1347                             std::vector<uint>& capnn,
1348                             std::vector<uint>& rsegn);
1349 
1350   ///
1351   /// restore old parasitics
1352   ///
1353   void restoreOldParasitics(std::vector<dbNet*>& nets,
1354                             std::vector<uint>& capnn,
1355                             std::vector<uint>& rsegn);
1356 
1357   ///
1358   /// keep old parasitics of nets
1359   ///
1360   void keepOldParasitics(std::vector<dbNet*>& nets,
1361                          bool coupled_rc,
1362                          std::vector<dbNet*>& ccHaloNets,
1363                          std::vector<uint>* capnn,
1364                          std::vector<uint>* rsegn);
1365   void keepOldCornerParasitics(dbBlock* pBlock,
1366                                std::vector<dbNet*>& nets,
1367                                bool coupled_rc,
1368                                std::vector<dbNet*>& ccHaloNets,
1369                                std::vector<uint>& capnn,
1370                                std::vector<uint>& rsegn);
1371 
1372   ///
1373   /// merge rsegs before doing exttree
1374   ///
1375   void preExttreeMergeRC(double max_cap, uint corner);
1376 
1377   ///
1378   /// clear
1379   ///
1380   void clear();
1381 
1382   ///
1383   /// get wire_updated nets
1384   ///
1385   void getWireUpdatedNets(std::vector<dbNet*>& nets, Rect* bbox = NULL);
1386 
1387   ///
1388   /// return the regions of this design
1389   ///
1390   dbSet<dbRegion> getRegions();
1391 
1392   ///
1393   /// Find a specific region. Returns NULL if the region was not found.
1394   ///
1395   dbRegion* findRegion(const char* name);
1396 
1397   ///
1398   ///  Find the non-default-rule
1399   ///
1400   dbTechNonDefaultRule* findNonDefaultRule(const char* name);
1401 
1402   ///
1403   ///  Get the non-default-rules specific to this block.
1404   ///
1405   dbSet<dbTechNonDefaultRule> getNonDefaultRules();
1406 
1407   ///
1408   ///  Levelelize from set of insts
1409   ///
1410   uint levelize(std::vector<dbInst*>& startingInsts,
1411                 std::vector<dbInst*>& instsToBeLeveled);
1412 
1413   ///
1414   ///  Levelelize from Primary inputs or inout to sequential
1415   ///
1416   uint levelizeFromPrimaryInputs();
1417 
1418   ///
1419   ///  Levelelize from sequential
1420   ///
1421   uint levelizeFromSequential();
1422 
1423   ///
1424   ///  Mark inst backwards usinh user flag 2
1425   ///
1426   int markBackwardsUser2(dbInst* firstInst,
1427                          bool mark,
1428                          std::vector<dbInst*>& resultTable);
1429 
1430   ///
1431   ///  Mark inst backwards usinh user flag 2
1432   ///
1433   int markBackwardsUser2(std::vector<dbInst*>& startingInsts,
1434                          std::vector<dbInst*>& instsToBeLeveled,
1435                          bool mark,
1436                          std::vector<dbInst*>& resultTable);
1437 
1438   ///
1439   ///  Mark net backwards using user flag 2
1440   ///
1441   int markBackwardsUser2(dbNet* net,
1442                          bool mark,
1443                          std::vector<dbInst*>& resultTable);
1444 
1445   ///
1446   ///  Mark net backwards using user flag 2
1447   ///
1448   int markBackwardsUser2(dbNet* net,
1449                          std::vector<dbInst*>& instsToMark,
1450                          bool mark,
1451                          std::vector<dbInst*>& resultTable);
1452 
1453   ///
1454   ///  Mark masters as sequential based on mterms being of "use clock"; mark
1455   ///  iterms as clocked
1456   ///
1457   void markClockIterms();
1458 
1459   ///
1460   /// set First driving iterm on all signal nets; set 0 is none exists
1461   void setDrivingItermsforNets();
1462 
1463   void clearUserInstFlags();
1464 
1465  private:
1466   friend class ZDB;
1467 
1468   ///
1469   /// Build search database for fast area searches
1470   ///
1471   void makeSearchDB(bool nets, bool insts, ZContext& context);
1472 
1473  public:
1474   ///
1475   /// Get the Container class for Nets Search DB
1476   ///
1477   // ZPtr<ISdb> getSearchDbNets();
1478 
1479   ///
1480   /// Get the Container class for Insts Search DB
1481   ///
1482   // ZPtr<ISdb> getSearchDbInsts();
1483 
1484   ///
1485   /// This method copies the via-table from the src block to the destination
1486   /// block.
1487   ///
1488   /// WARNING: This method deletes any vias previously defined in the
1489   /// destination block.
1490   ///          If there are wire which reference these vias, the references will
1491   ///          be left dangling.
1492   ///
1493   static void copyViaTable(dbBlock* dst, dbBlock* src);
1494 
1495   ///
1496   /// Get the Read Only Container class for Nets Search DB
1497   ///
1498   // TODO ZPtr<ISdb_r> getSearchDbNets_r();
1499 
1500   ///
1501   /// Get the Read Only Container class for Insts Search DB
1502   ///
1503   // TODO ZPtr<ISdb_r> getSearchDbInsts_r();
1504 
1505   ///
1506   /// Create a chip's top-block. Returns NULL of a top-block already
1507   /// exists.
1508   ///
1509   static dbBlock* create(dbChip* chip,
1510                          const char* name,
1511                          char hier_delimeter = 0);
1512 
1513   ///
1514   /// Create a hierachical/child block. This block has no connectivity.
1515   /// Returns NULL if a block with the same name exists.
1516   ///
1517   static dbBlock* create(dbBlock* block,
1518                          const char* name,
1519                          char hier_delimeter = 0);
1520 
1521   ///
1522   /// duplicate - Make a duplicate of the specified "child" block. If name ==
1523   /// NULL, the name of the block is also duplicated. If the duplicated block
1524   /// does not have a unique name, then "findChild" may return an incorrect
1525   /// block. UNIQUE child-block-names are not enforced! (This should be fixed)!
1526   ///
1527   /// A top-block can not be duplicated. This methods returns NULL if the
1528   /// specified block has not parent.
1529   ///
1530   static dbBlock* duplicate(dbBlock* block, const char* name = NULL);
1531 
1532   ///
1533   /// Translate a database-id back to a pointer.
1534   ///
1535   static dbBlock* getBlock(dbChip* chip, uint oid);
1536 
1537   ///
1538   /// Translate a database-id back to a pointer.
1539   ///
1540   static dbBlock* getBlock(dbBlock* block, uint oid);
1541 
1542   ///
1543   /// Destroy a block.
1544   ///
1545   static void destroy(dbBlock* block);
1546 
1547   ///
1548   /// Delete the bterm from the block.
1549   ///
1550   static dbSet<dbBlock>::iterator destroy(dbSet<dbBlock>::iterator& itr);
1551 
1552   ///
1553   /// Show the netlist differences of these blocks
1554   /// Returns true if differences were found.
1555   ///
1556   static bool differences(dbBlock* block1,
1557                           dbBlock* block2,
1558                           FILE* out,
1559                           int indent_per_level = 4);
1560 
1561  private:
1562   void ComputeBBox();
1563 };
1564 
1565 ///////////////////////////////////////////////////////////////////////////////
1566 ///
1567 /// A block-terminal is the element used to represent connections in/out of
1568 /// a block.
1569 ///
1570 ///////////////////////////////////////////////////////////////////////////////
1571 class dbBTerm : public dbObject
1572 {
1573  public:
1574   ///
1575   /// Get the block-terminal name.
1576   ///
1577   std::string getName();
1578 
1579   ///
1580   /// Get the block-terminal name.
1581   ///
1582   const char* getConstName();
1583 
1584   ///
1585   /// Change the name of the bterm.
1586   /// Returns true if successful.
1587   /// Returns false if a bterm with the same name already exists.
1588   ///
1589   bool rename(const char* name);
1590 
1591   ///
1592   /// Get bbox of this term (ie the bbox of the bpins)
1593   ///
1594   Rect getBBox();
1595 
1596   ///
1597   /// Set the signal type of this block-terminal.
1598   ///
1599   void setSigType(dbSigType type);
1600 
1601   ///
1602   /// Get the signal type of this block-terminal.
1603   ///
1604   dbSigType getSigType();
1605 
1606   ///
1607   /// Set the IO direction of this block-terminal.
1608   ///
1609   void setIoType(dbIoType type);
1610 
1611   ///
1612   /// Get the IO direction of this block-terminal.
1613   ///
1614   dbIoType getIoType();
1615 
1616   ///
1617   /// Set spef mark of this block-terminal.
1618   ///
1619   void setSpefMark(uint v);
1620 
1621   ///
1622   /// get spef mark of this block-terminal.
1623   ///
1624   bool isSetSpefMark();
1625 
1626   ///
1627   /// Set mark of this block-terminal.
1628   ///
1629   void setMark(uint v);
1630 
1631   ///
1632   /// get mark of this block-terminal.
1633   ///
1634   bool isSetMark();
1635 
1636   ///
1637   /// set ext id of this block-terminal.
1638   ///
1639   void setExtId(uint v);
1640 
1641   ///
1642   /// get ext id of this block-terminal.
1643   ///
1644   uint getExtId();
1645 
1646   ///
1647   /// is this terminal SPECIAL (i.e. not for regular signal routing).
1648   ///
1649   bool isSpecial() const;
1650 
1651   ///
1652   /// set SPECIAL attribute -- expected to be done once by DEF parser.
1653   ///
1654   void setSpecial();
1655 
1656   /// Get the net of this block-terminal.
1657   ///
1658   dbNet* getNet();
1659 
1660   /// Disconnect the block-terminal from it's net.
1661   ///
1662   void disconnect();
1663 
1664   /// Connect the block-terminal to net.
1665   ///
1666   void connect(dbNet* net);
1667 
1668   ///
1669   /// Get the block of this block-terminal.
1670   ///
1671   dbBlock* getBlock();
1672 
1673   ///
1674   /// Get the hierarchical parent iterm of this bterm.
1675   ///
1676   /// Returns NULL if this bterm has no parent iterm.
1677   ///
1678   ///
1679   ///     (top-block)
1680   ///     +------------------------------------------------------------------+
1681   ///     |                                                                  |
1682   ///     |                                                                  |
1683   ///     |                                                                  |
1684   ///     |               (child-block / instance)                           |
1685   ///     |               +----------------------------------+               |
1686   ///     |               |                                  |               |
1687   ///     |B             I|B                                 |               |
1688   ///     |o.............o|o..........                       |               |
1689   ///     |  (net in      |  (net in child-block)            |               |
1690   ///     |   top-block)  |                                  |               |
1691   ///     |               |                                  |               |
1692   ///     |               |                                  |               |
1693   ///     |               |                                  |               |
1694   ///     |               |                                  |               |
1695   ///     |               +----------------------------------+               |
1696   ///     |                                                                  |
1697   ///     |                                                                  |
1698   ///     +------------------------------------------------------------------+
1699   ///
1700   ///
1701   /// B = dbBterm
1702   /// I = dbIterm
1703   ///
1704   dbITerm* getITerm();
1705 
1706   ///
1707   /// Get the bpins of this bterm.
1708   ///
1709   dbSet<dbBPin> getBPins();
1710 
1711   ///
1712   /// This method finds the first "placed" dbPin box.
1713   /// returns false if there are no placed bpins.
1714   ///
1715   bool getFirstPin(dbShape& shape);
1716 
1717   ///
1718   /// This method finds the location the first "placed" dbPin box.
1719   /// The location is the computed center of the bbox.
1720   /// returns false if there are no placed bpins. x and y are set to zero.
1721   //
1722   bool getFirstPinLocation(int& x, int& y);
1723 
1724   ///
1725   /// This method returns the placementstatus of the first dbBPin.
1726   /// Returns NONE if bterm has no dbPins.
1727   ///
1728   dbPlacementStatus getFirstPinPlacementStatus();
1729 
1730   ///
1731   /// Get the ground sensistivity pin (5.6 DEF)
1732   ///
1733   dbBTerm* getGroundPin();
1734 
1735   ///
1736   /// Set the ground sensistivity pin (5.6 DEF)
1737   ///
1738   void setGroundPin(dbBTerm* pin);
1739 
1740   ///
1741   /// Get the supply sensistivity pin (5.6 DEF)
1742   ///
1743   dbBTerm* getSupplyPin();
1744 
1745   ///
1746   /// Set the supply sensistivity pin (5.6 DEF)
1747   ///
1748   void setSupplyPin(dbBTerm* pin);
1749 
1750   ///
1751   /// Create a new block-terminal.
1752   /// Returns NULL if a bterm with this name already exists
1753   ///
1754   static dbBTerm* create(dbNet* net, const char* name);
1755 
1756   ///
1757   /// Delete the bterm from the block.
1758   ///
1759   static void destroy(dbBTerm* bterm);
1760 
1761   ///
1762   /// Delete the bterm from the block.
1763 
1764   static dbSet<dbBTerm>::iterator destroy(dbSet<dbBTerm>::iterator& itr);
1765 
1766   ///
1767   /// Translate a database-id back to a pointer.
1768   ///
1769   static dbBTerm* getBTerm(dbBlock* block, uint oid);
1770 
1771   uint32_t staVertexId();
1772   void staSetVertexId(uint32_t id);
1773 };
1774 
1775 ///////////////////////////////////////////////////////////////////////////////
1776 ///
1777 /// A BPIn is the element that represents a physical connection to a block
1778 /// terminal.
1779 ///
1780 ///////////////////////////////////////////////////////////////////////////////
1781 
1782 class dbBPin : public dbObject
1783 {
1784  public:
1785   ///
1786   /// Get the placement status of this block-terminal.
1787   ///
1788   dbPlacementStatus getPlacementStatus();
1789 
1790   ///
1791   /// Set the placement status of this block-terminal.
1792   ///
1793   void setPlacementStatus(dbPlacementStatus status);
1794 
1795   ///
1796   /// Get bterm of this pin.
1797   ///
1798   dbBTerm* getBTerm();
1799 
1800   ///
1801   /// Get boxes of this pin
1802   ///
1803   dbSet<dbBox> getBoxes();
1804 
1805   ///
1806   /// Get bbox of this pin (ie the bbox of getBoxes())
1807   ///
1808   Rect getBBox();
1809 
1810   ///
1811   /// Returns true if this bpin has an effective-width rule.
1812   ///
1813   bool hasEffectiveWidth();
1814 
1815   ///
1816   /// Set the effective width rule.
1817   ///
1818   void setEffectiveWidth(int w);
1819 
1820   ///
1821   /// Return the effective width rule.
1822   ///
1823   int getEffectiveWidth();
1824 
1825   ///
1826   /// Returns true if this bpin has an min-spacing rule.
1827   ///
1828   bool hasMinSpacing();
1829 
1830   ///
1831   /// Set the min spacing rule.
1832   ///
1833   void setMinSpacing(int w);
1834 
1835   ///
1836   /// Return the min spacing rule.
1837   ///
1838   int getMinSpacing();
1839 
1840   ///
1841   /// Create a new block-terminal-pin
1842   ///
1843   static dbBPin* create(dbBTerm* bterm);
1844 
1845   ///
1846   /// Delete the bpin from this bterm
1847   ///
1848   static void destroy(dbBPin* bpin);
1849 
1850   ///
1851   /// Delete the bterm from the bterm.
1852   static dbSet<dbBPin>::iterator destroy(dbSet<dbBPin>::iterator& itr);
1853 
1854   ///
1855   /// Translate a database-id back to a pointer.
1856   ///
1857   static dbBPin* getBPin(dbBlock* block, uint oid);
1858 };
1859 
1860 ///////////////////////////////////////////////////////////////////////////////
1861 ///
1862 /// A Net is the element that represents a "net" on a block.
1863 ///
1864 ///////////////////////////////////////////////////////////////////////////////
1865 class dbNet : public dbObject
1866 {
1867  public:
1868   ///
1869   /// Get the net name.
1870   ///
1871   std::string getName();
1872 
1873   ///
1874   /// Get the net name.
1875   ///
1876   const char* getConstName();
1877 
1878   ///
1879   /// Print net name with or without id and newline
1880   ///
1881   void printNetName(FILE* fp, bool idFlag = true, bool newLine = true);
1882 
1883   ///
1884   /// Change the name of the net.
1885   /// Returns true if successful.
1886   /// Returns false if a net with the same name already exists.
1887   ///
1888   bool rename(const char* name);
1889 
1890   ///
1891   /// RC netowork disconnect
1892   ///
1893   bool isRCDisconnected();
1894 
1895   ///
1896   ///
1897   ///
1898   void setRCDisconnected(bool value);
1899 
1900   ///
1901   /// Get the weight assigned to this net.
1902   /// (Default: 1)
1903   ///
1904   int getWeight();
1905 
1906   ///
1907   /// Set the weight assigned of this net.
1908   ///
1909   void setWeight(int weight);
1910 
1911   ///
1912   /// Get the source assigned to this net.
1913   ///
1914   dbSourceType getSourceType();
1915 
1916   ///
1917   /// Set the source assigned of this net.
1918   ///
1919   void setSourceType(dbSourceType type);
1920 
1921   ///
1922   /// Get the x-talk-class assigned to this net.
1923   /// (Default: 0)
1924   ///
1925   int getXTalkClass();
1926 
1927   ///
1928   /// Set the x-talk-class assigned of this net.
1929   ///
1930   void setXTalkClass(int value);
1931 
1932   ///
1933   /// Set the driving term id assigned of this net.
1934   ///
1935   void setDrivingITerm(int id);
1936 
1937   ///
1938   /// Returns driving term id assigned of this net. -1 if not set, 0 if non
1939   /// existent
1940   ///
1941   int getDrivingITerm();
1942 
1943   ///
1944   /// Returns true if a fixed-bump flag has been set.
1945   ///
1946   bool hasFixedBump();
1947 
1948   ///
1949   /// Set the value of the fixed-bump flag.
1950   ///
1951   void setFixedBump(bool value);
1952 
1953   ///
1954   /// Get the Regular Wiring of a net (TODO: per path)
1955   ///
1956   dbWireType getWireType();
1957 
1958   ///
1959   /// Set the Regular Wiring of a net (TODO: per path)
1960   ///
1961   void setWireType(dbWireType wire_type);
1962 
1963   ///
1964   /// Get the signal type of this block-net.
1965   ///
1966   dbSigType getSigType();
1967 
1968   ///
1969   /// Get the signal type of this block-net.
1970   ///
1971   void setSigType(dbSigType sig_type);
1972 
1973   ///
1974   /// Assuming no intersection, check if the net is in the bbox.
1975   ///
1976   bool isEnclosed(Rect* bbox);
1977 
1978   ///
1979   /// Returns the mark flag value. This flag specified that the
1980   /// net has been marked.
1981   ///
1982   bool isMarked();
1983 
1984   ///
1985   /// Returns the mark_1 flag value. This flag specified that the
1986   /// net has been mark_1ed.
1987   ///
1988   bool isMark_1ed();
1989 
1990   ///
1991   /// Set the mark flag to the specified value.
1992   ///
1993   void setMark(bool value);
1994 
1995   ///
1996   /// Set the mark_1 flag to the specified value.
1997   ///
1998   void setMark_1(bool value);
1999 
2000   ///
2001   /// Returns the select flag value. This flag specified that the
2002   /// net has been select.
2003   ///
2004   bool isSelect();
2005 
2006   /// Net
2007   /// Set the select flag to the specified value.
2008   ///
2009   void setSelect(bool value);
2010 
2011   ///
2012   /// check if wire of this net equals that of the target net
2013   /// return value = 0: equal
2014   ///                x: not equal
2015   ///                1x: wire seg after junction not equal
2016   ///
2017   uint wireEqual(dbNet* target);
2018 
2019   void wireMatch(dbNet* target);
2020   void printWire(int fid, int tid, char* type);
2021   void printWire();
2022   void printWire(char* type);
2023   ///
2024   /// Returns the wire-ordered flag value. This flag specified that the
2025   /// wires of this net have been ordered into a single dbWire.
2026   ///
2027   bool isWireOrdered();
2028 
2029   ///
2030   /// Set the wire-ordered flag to the specified value.
2031   /// Note: This flag is set to false any time a dbWire
2032   /// is created on this net.
2033   ///
2034   void setWireOrdered(bool value);
2035 
2036   ///
2037   /// Returns the buffered flag value. This flag specified that the
2038   /// net has been buffered.
2039   ///
2040   bool isBuffered();
2041 
2042   ///
2043   /// Set the buffered flag to the specified value.
2044   ///
2045   void setBuffered(bool value);
2046 
2047   ///
2048   /// Returns the disconnected flag value. This flag specified that the
2049   /// wire are connected to all the iterms of this net.
2050   ///
2051   bool isDisconnected();
2052 
2053   ///
2054   /// Set the disconnected flag to the specified value.
2055   /// Note: This flag is set to false any time a dbWire
2056   /// is created on this net.
2057   ///
2058   void setDisconnected(bool value);
2059 
2060   ///
2061   /// wire_update flag to be used at when the wire is replaced with a new wire
2062   /// NOTE: rcgraph, extracted, ordered, reduced all have to be reset
2063   ///
2064   void setWireAltered(bool value);
2065   bool isWireAltered();
2066 
2067   ///
2068   /// rc_graph flag set when Rseg and CapNodes were created
2069   ///
2070   void setRCgraph(bool value);
2071   bool isRCgraph();
2072 
2073   ///
2074   /// reduced flag set when Arnoldi modeling takes place
2075   ///
2076   void setReduced(bool value);
2077   bool isReduced();
2078 
2079   ///
2080   /// extracted flag set when net was extracted
2081   ///
2082   void setExtracted(bool value);
2083   bool isExtracted();
2084 
2085   ///
2086   /// Sinlge bit general purpose flag to be used at spef
2087   ///
2088   void setSpef(bool value);
2089   bool isSpef();
2090 
2091   ///
2092   /// Set/Reset the size-only flag
2093   ///
2094   void setSizeOnly(bool v);
2095 
2096   ///
2097   /// Returns true if the size-only flag is set.
2098   ///
2099   bool isSizeOnly();
2100 
2101   ///
2102   /// Set/Reset the don't-touch flag
2103   ///
2104   void setDoNotTouch(bool v);
2105 
2106   ///
2107   /// Returns true if the don't-touch flag is set.
2108   ///
2109   bool isDoNotTouch();
2110 
2111   ///
2112   /// Get the block of this block-terminal.
2113   ///
2114   dbBlock* getBlock();
2115 
2116   ///
2117   /// Get all the instance-terminals of this net.
2118   ///
2119   dbSet<dbITerm> getITerms();
2120 
2121   ///
2122   /// Get the 1st instance-terminal of this net.
2123   ///
2124   dbITerm* get1stITerm();
2125 
2126   ///
2127   /// Get the 1st inputSignal Iterm; can be
2128   ///
2129   dbITerm* get1stSignalInput(bool io);
2130 
2131   ///
2132   /// Get the 1st output Iterm; can be
2133   ///
2134   dbITerm* getFirstOutput();
2135 
2136   ///
2137   /// Get all the block-terminals of this net.
2138   ///
2139   dbSet<dbBTerm> getBTerms();
2140 
2141   ///
2142   /// Get the 1st block-terminal of this net.
2143   ///
2144   dbBTerm* get1stBTerm();
2145 
2146   ///
2147   /// Get the special-wires of this net.
2148   ///
2149   dbSet<dbSWire> getSWires();
2150 
2151   ///
2152   /// Get the wire of this net.
2153   /// Returns NULL if this net has no wire.
2154   ///
2155   dbWire* getWire();
2156 
2157   ///
2158   /// Get the first swire of this net.
2159   /// Returns NULL if this net has no swires.
2160   ///
2161   dbSWire* getFirstSWire();
2162   ///
2163   /// Move segements of the wire of this net to that of tnet
2164   ///
2165   void donateWire(dbNet* tnet, dbRSeg** new_rsegs);
2166 
2167   ///
2168   /// Get the global wire of thie net.
2169   /// Returns NULL if this net has no global wire.
2170   ///
2171   dbWire* getGlobalWire();
2172 
2173   ///
2174   /// Returns true if this dbNet is marked as special. Special nets/iterms are
2175   /// declared in the SPECIAL NETS section of a DEF file.
2176   ///
2177   bool isSpecial();
2178 
2179   ///
2180   /// Mark this dbNet as special.
2181   ///
2182   void setSpecial();
2183 
2184   ///
2185   /// Unmark this dbNet as special.
2186   ///
2187   void clearSpecial();
2188 
2189   ///
2190   /// Set the IO flag if there are any BTerms on net
2191   bool setIOflag();
2192 
2193   ///
2194   /// returns true if there are BTerms on net
2195   bool isIO();
2196 
2197   ///
2198   /// Returns true if this dbNet is was connected using a wild-card.
2199   ///
2200   bool isWildConnected();
2201 
2202   ///
2203   /// Mark this dbNet as wild-connected.
2204   ///
2205   void setWildConnected();
2206 
2207   ///
2208   /// Unmark this dbNet as wild-connected.
2209   ///
2210   void clearWildConnected();
2211 
2212   ///
2213   /// Get the gndc calibration factor of this net
2214   ///
2215   float getGndcCalibFactor();
2216 
2217   ///
2218   /// Set the gndc calibration factor of this net
2219   ///
2220   void setGndcCalibFactor(float gndcCalib);
2221 
2222   ///
2223   /// Calibrate the capacitance of this net
2224   ///
2225   void calibrateCapacitance();
2226 
2227   ///
2228   /// Calibrate the ground capacitance of this net
2229   ///
2230   void calibrateGndCap();
2231 
2232   ///
2233   /// Calibrate the coupling capacitance of this net
2234   ///
2235   void calibrateCouplingCap();
2236   void calibrateCouplingCap(int corner);
2237 
2238   ///
2239   /// Get the cc calibration factor of this net
2240   ///
2241   float getCcCalibFactor();
2242 
2243   ///
2244   /// Set the cc calibration factor of this net
2245   ///
2246   void setCcCalibFactor(float ccCalib);
2247 
2248   ///
2249   /// Adjust resistances of this net
2250   ///
2251   void adjustNetRes(float factor);
2252 
2253   ///
2254   /// Adjust resistances of this net for a corner
2255   ///
2256   void adjustNetRes(float factor, uint corner);
2257 
2258   ///
2259   /// Adjust ground cap of this net
2260   ///
2261   void adjustNetGndCap(float factor);
2262 
2263   ///
2264   /// Adjust ground cap of this net for a corner
2265   ///
2266   void adjustNetGndCap(uint corner, float factor);
2267 
2268   ///
2269   /// get ccAdjustFactor of this net
2270   ///
2271   float getCcAdjustFactor();
2272 
2273   ///
2274   /// set ccAdjustFactor of this net
2275   ///
2276   void setCcAdjustFactor(float factor);
2277 
2278   ///
2279   /// get ccAdjustOrder of this net
2280   ///
2281   uint getCcAdjustOrder();
2282 
2283   ///
2284   /// set ccAdjustOrder of this net
2285   ///
2286   void setCcAdjustOrder(uint order);
2287 
2288   ///
2289   /// adjust CC's of this net
2290   ///
2291   bool adjustCC(uint adjOrder,
2292                 float adjFactor,
2293                 double ccThreshHold,
2294                 std::vector<dbCCSeg*>& adjustedCC,
2295                 std::vector<dbNet*>& halonets);
2296 
2297   ///
2298   /// undo adjusted CC
2299   ///
2300   void undoAdjustedCC(std::vector<dbCCSeg*>& adjustedCC,
2301                       std::vector<dbNet*>& halonets);
2302 
2303   ///
2304   /// add cc capacitance to gnd capacitance of capNodes of this net
2305   ///
2306   bool groundCC(float gndFactor);
2307 
2308   ///
2309   /// Add to the dbCC of this net
2310   ///
2311   void addDbCc(float cap);
2312 
2313   ///
2314   /// Get dbCC of this net
2315   ///
2316   float getDbCc();
2317 
2318   ///
2319   /// Set dbCC of this net
2320   ///
2321   void setDbCc(float cap);
2322 
2323   ///
2324   /// Get refCC of this net
2325   ///
2326   float getRefCc();
2327 
2328   ///
2329   /// Set refCC of this net
2330   ///
2331   void setRefCc(float cap);
2332 
2333   ///
2334   /// get the CC match ratio against this net
2335   ///
2336   float getCcMatchRatio();
2337 
2338   ///
2339   /// set the CC match ratio against this net
2340   ///
2341   void setCcMatchRatio(float ratio);
2342 
2343   ///
2344   /// Get the gdn cap of this net to *gndcap, total cap to *totalcap
2345   ///
2346   void getGndTotalCap(double* gndcap, double* totalcap, double MillerMult);
2347 
2348   ///
2349   /// merge rsegs before doing exttree
2350   ///
2351   void preExttreeMergeRC(double max_cap, uint corner);
2352 
2353   ///
2354   /// Get Cap Node given a node_num
2355   ///
2356   dbCapNode* findCapNode(uint nodeId);
2357 
2358   ///
2359   /// Print the CapNodes of this net.
2360   ///
2361   void printCapN(char* type);
2362 
2363   ///
2364   /// donate parasitics
2365   ///
2366   void donateRC(dbITerm* donorterm,
2367                 dbITerm* rcvterm,
2368                 dbRSeg*& rtrseg,
2369                 dbRSeg*& lastrrseg,
2370                 dbCapNode*& lastrcapnd,
2371                 uint& ricapndCnt,
2372                 dbRSeg*& fstdrseg,
2373                 dbRSeg*& dtrseg,
2374                 dbCapNode*& fstdcapnd,
2375                 std::vector<dbCCSeg*>* gndcc,
2376                 dbRSeg*& bridgeRseg);
2377 
2378   ///
2379   /// reverse donate parasitics
2380   ///
2381   void unDonateRC(dbRSeg* rtrseg,
2382                   dbRSeg* lastrrseg,
2383                   dbITerm* it,
2384                   dbCapNode* lastrcapnd,
2385                   uint ricapndCnt,
2386                   dbRSeg* dtrseg,
2387                   dbRSeg* fstdrseg,
2388                   dbCapNode* fstdcapnd,
2389                   dbITerm* ot,
2390                   std::vector<dbCCSeg*>* gndcc);
2391 
2392   ///
2393   /// Get the Cap Nodes of this net.
2394   ///
2395   dbSet<dbCapNode> getCapNodes();
2396 
2397   ///
2398   /// delete the Cap Nodes of this net.
2399   ///
2400   void destroyCapNodes(bool cleanExtid);
2401 
2402   ///
2403   /// Reverse the rsegs seqence of this net.
2404   ///
2405   void reverseRSegs();
2406 
2407   ///
2408   /// create dummy zero rseg and capNodes
2409   ///
2410   void createZeroRc(bool foreign);
2411 
2412   ///
2413   /// Set the 1st R segment of this net.
2414   ///
2415   void set1stRSegId(uint rseg_id);
2416 
2417   ///
2418   /// Get the zeroth R segment of this net.
2419   ///
2420   dbRSeg* getZeroRSeg();
2421 
2422   ///
2423   /// Get the 1st R segment id of this net.
2424   ///
2425   uint get1stRSegId();
2426 
2427   ///
2428   /// find the rseg having srcn and tgtn
2429   ///
2430   dbRSeg* findRSeg(uint srcn, uint tgtn);
2431 
2432   ///
2433   /// Set the 1st Cap node of this net.
2434   ///
2435   void set1stCapNodeId(uint capn_id);
2436 
2437   ///
2438   /// Get the 1st Cap node of this net.
2439   ///
2440   uint get1stCapNodeId();
2441 
2442   ///
2443   /// Reset, or Set the extid of the bterms and iterms to the capnode id's
2444   ///
2445   void setTermExtIds(int capId);
2446 
2447   ///
2448   /// check if any of the RSegs has shape_id
2449   ///
2450   bool anchoredRSeg();
2451 
2452   ///
2453   /// Print the R segments of this net.
2454   ///
2455   void printRSeg(char* type);
2456 
2457   ///
2458   /// Print the Wire and Parasitics segments of this net.
2459   ///
2460   void printWnP(char* type);
2461 
2462   ///
2463   /// get rseg  count
2464   ///
2465   uint getRSegCount();
2466 
2467   ///
2468   /// Get the RSegs segments.
2469   ///
2470   dbSet<dbRSeg> getRSegs();
2471 
2472   ///
2473   /// compact internal capnode number'
2474   ///
2475   void collapseInternalCapNum(FILE* capNodeMap);
2476   ///
2477   /// find max number of cap nodes that are internal
2478   ///
2479   uint maxInternalCapNum();
2480 
2481   ///
2482   /// get capNode count
2483   ///
2484   uint getCapNodeCount();
2485 
2486   ///
2487   /// get CC seg count
2488   ///
2489   uint getCcCount();
2490 
2491   ///
2492   /// delete the R segments of this net.
2493   ///
2494   void destroyRSegs();
2495 
2496   ///
2497   /// reverse the link order of CCsegs of capNodes
2498   ///
2499   void reverseCCSegs();
2500 
2501   ///
2502   /// Get the source capacitor-coupled segments of this net..
2503   ///
2504   void getSrcCCSegs(std::vector<dbCCSeg*>& segs);
2505 
2506   ///
2507   /// Get the target capacitor-coupled segments of this net..
2508   ///
2509   void getTgtCCSegs(std::vector<dbCCSeg*>& segs);
2510 
2511   ///
2512   /// Get the nets having coupling caps with this net
2513   ///
2514   void getCouplingNets(uint corner,
2515                        double ccThreshold,
2516                        std::set<dbNet*>& cnets);
2517 
2518   ///
2519   /// delete the capacitor-coupled segments.
2520   ///
2521   void destroyCCSegs();
2522 
2523   ///
2524   /// destroy parasitics
2525   ///
2526   void destroyParasitics();
2527 
2528   ///
2529   /// Get total capacitance in FF
2530   ///
2531   double getTotalCapacitance(uint corner = 0, bool cc = false);
2532 
2533   ///
2534   /// Get total coupling capacitance in FF
2535   ///
2536   double getTotalCouplingCap(uint corner = 0);
2537 
2538   ///
2539   /// Get total resistance in mil ohms
2540   ///
2541   double getTotalResistance(uint corner = 0);
2542 
2543   ///
2544   /// Set the nondefault rule applied to this net for wiring.
2545   ///
2546   void setNonDefaultRule(dbTechNonDefaultRule* rule);
2547 
2548   ///
2549   /// Get the nondefault rule applied to this net for wiring.
2550   /// Returns NULLS if there is no nondefault rule.
2551   ///
2552   dbTechNonDefaultRule* getNonDefaultRule();
2553 
2554   ///
2555   /// Get stats of this net
2556   ///
2557   void getNetStats(uint& wireCnt,
2558                    uint& viaCnt,
2559                    uint& len,
2560                    uint& layerCnt,
2561                    uint* levelTable);
2562 
2563   ///
2564   /// Get wire counts of this net
2565   ///
2566   void getWireCount(uint& wireCnt, uint& viaCnt);
2567 
2568   ///
2569   /// Get wire counts of this signal net
2570   ///
2571   void getSignalWireCount(uint& wireCnt, uint& viaCnt);
2572 
2573   ///
2574   /// Get wire counts of this power net
2575   ///
2576   void getPowerWireCount(uint& wireCnt, uint& viaCnt);
2577 
2578   ///
2579   /// Get term counts of this net
2580   ///
2581   uint getTermCount();
2582 
2583   ///
2584   /// Get iterm counts of this signal net
2585   ///
2586   uint getITermCount();
2587 
2588   ///
2589   /// Get bterm counts of this signal net
2590   ///
2591   uint getBTermCount();
2592 
2593   ///
2594   /// Delete the swires of this net
2595   ///
2596   void destroySWires();
2597 
2598   ///
2599   /// Create a new net.
2600   /// Returns NULL if a net with this name already exists
2601   ///
2602   static dbNet* create(dbBlock* block,
2603                        const char* name,
2604                        bool skipExistingCheck = false);
2605 
2606   ///
2607   /// Delete this net from this block.
2608   ///
2609   static void destroy(dbNet* net);
2610 
2611   ///
2612   /// mark nets of a block.
2613   ///
2614   static void markNets(std::vector<dbNet*>& nets, dbBlock* block, bool mk);
2615 
2616   ///
2617   /// set level for fanout instances
2618   ///
2619   uint setLevelAtFanout(uint level,
2620                         bool fromPI,
2621                         std::vector<dbInst*>& instVector);
2622 
2623   ///
2624   /// Delete the net from the block.
2625   ///
2626   static dbSet<dbNet>::iterator destroy(dbSet<dbNet>::iterator& itr);
2627 
2628   ///
2629   /// Translate a database-id back to a pointer.
2630   ///
2631   static dbNet* getNet(dbBlock* block, uint oid);
2632 
2633   ///
2634   /// Translate a valid database-id back to a pointer.
2635   ///
2636   static dbNet* getValidNet(dbBlock* block, uint oid);
2637 };
2638 
2639 ///////////////////////////////////////////////////////////////////////////////
2640 ///
2641 /// A dbInstance is the element used to represent instances of master-cells in
2642 /// a block.
2643 ///
2644 ///////////////////////////////////////////////////////////////////////////////
2645 class dbInst : public dbObject
2646 {
2647  public:
2648   ///
2649   /// Get the instance name.
2650   ///
2651   std::string getName();
2652 
2653   ///
2654   /// Need a version that does not do strdup every time
2655   ///
2656   const char* getConstName();
2657 
2658   ///
2659   /// Compare, like !strcmp
2660   ///
2661   bool isNamed(const char* name);
2662 
2663   ///
2664   /// Change the name of the inst.
2665   /// Returns true if successful.
2666   /// Returns false if a inst with the same name already exists.
2667   ///
2668   bool rename(const char* name);
2669 
2670   /////////////////////////////////////////////////////////////////
2671   ///
2672   /// IMPORTANT -  INSTANCE PLACEMENT
2673   ///
2674   /// There are seven methods used to get/set the placement.
2675   ///
2676   ///     getOrigin           - Get the origin of this instance (Where the
2677   ///     master is setOrigin           - Set the origin of this instance
2678   ///     getOrient           - Get orient of this instance
2679   ///     setOrient           - Set orient of this instance
2680   ///     getLocation         - Get the lower-left corner of this instance
2681   ///     setLocation         - Set the lower-left corner of this instance
2682   ///     setLocationOrient   - Set the orient of this instance and maintain the
2683   ///     lower-left corner.
2684   ///
2685   /// The getLocation/setLocation are used to get and set the lower-left corner
2686   /// of the bounding box of the instance. These methods use the DEF semantics.
2687   ///
2688   ///
2689   ///  MASTER COORDINATE SYSTEM:
2690   ///
2691   ///                                              |
2692   ///                                            --o-- (0,0)
2693   ///                                              |
2694   ///
2695   ///
2696   ///   +----------------------+ (Master bbox after rotation applied)
2697   ///   |                      |
2698   ///   |                      |
2699   ///   |                      |
2700   ///   |                      |
2701   ///   |                      |
2702   ///   +----------------------+
2703   ///  Mx,My
2704   ///
2705   ///
2706   ///  BLOCK COORDINATE SYSTEM:
2707   ///
2708   ///                                              |
2709   ///                                            --o-- (x,y) (True origin
2710   ///                                            (getOrigin/setOrigin)
2711   ///                                              |
2712   ///
2713   ///
2714   ///   +----------------------+ (Master bbox after rotation applied)
2715   ///   |                      |
2716   ///   |                      |
2717   ///   |                      |
2718   ///   |                      |
2719   ///   |                      |
2720   ///   +----------------------+
2721   ///  Ix,Ix (Location getLocation/setLocation)
2722   ///
2723   ///
2724   /// getLocation returns:(Note Mx/My is the location of the bbox AFTER
2725   /// rotation)
2726   ///
2727   ///     Ix = x + Mx
2728   ///     Iy = y + My
2729   ///
2730   /// setLocation(x,y) is equivalent to:
2731   ///
2732   ///    dbMaster * master = inst->getMaster();
2733   ///    Rect bbox;
2734   ///    master->getBBox(bbox);
2735   ///    dbTransform t(getOrient());
2736   ///    t.apply(bbox);
2737   ///    inst->setOrigin(x - bbox.xMin(),y - bbox.yMin());
2738   ///
2739   /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2740   ///  WARNING:
2741   ///
2742   ///     If dbInst::setLocation() is called BEFORE dbInst::setOrient() is
2743   ///     called with the proper orient the "real" origin will be computed
2744   ///     incorrectly and the instance will be placed INCORRECTLY.
2745   ///
2746   ///     If you want to change the orient relative to the "location" use
2747   ///     setLocationOrient(). Otherwise the bounding box will be recomputed
2748   ///     incorrectly.
2749   ///
2750   ///     getLocation/setLocation are provided for backward compatibility and
2751   ///     there use should be avoided.
2752   ///
2753   /// TRANSFORMS:
2754   ///
2755   ///     When using dbTransform() to translate the shapes/pins of an instance,
2756   ///     use getOrigin() to correctly set up the transform:
2757   ///
2758   ///         int x, y;
2759   ///         inst->getOrigin(x,y);
2760   ///         dbTransform transform( inst->getOrient(), Point(x,y) );
2761   ///
2762   ///         for all shapes of inst:
2763   ///             transform.apply( shape )
2764   ///
2765   /////////////////////////////////////////////////////////////////////////////////////////////////////////////
2766 
2767   ///
2768   /// Get the "placed" origin of this instance.
2769   ///
2770   void getOrigin(int& x, int& y);
2771 
2772   ///
2773   /// Set the "placed" origin of this instance.
2774   ///
2775   void setOrigin(int x, int y);
2776 
2777   ///
2778   /// Get the orientation of this instance.
2779   ///
2780   dbOrientType getOrient();
2781 
2782   ///
2783   /// Set the orientation of this instance.
2784   ///
2785   void setOrient(dbOrientType orient);
2786 
2787   ///
2788   /// This method returns the lower-left corner
2789   /// of the bounding box of this instance.
2790   ///
2791   void getLocation(int& x, int& y) const;
2792 
2793   ///
2794   /// This method sets the lower-left corner
2795   /// of the bounding box of this instance.
2796   ///
2797   void setLocation(int x, int y);
2798 
2799   ///
2800   /// Set the orientation of this instance.
2801   /// This method holds the instance lower-left corner in place and
2802   /// rotates the instance relative to the lower-left corner.
2803   ///
2804   /// This method is equivalent to the following:
2805   ///
2806   ///     int x, y;
2807   ///     inst->getLocation();
2808   ///     inst->setOrient( orient );
2809   ///     inst->setLocation(x,y);
2810   ///
2811   ///
2812   void setLocationOrient(dbOrientType orient);
2813 
2814   ///
2815   /// Get the transform of this instance.
2816   /// Equivalent to getOrient() and getOrigin()
2817   ///
2818   void getTransform(dbTransform& t);
2819 
2820   ///
2821   /// Set the transform of this instance.
2822   /// Equivalent to setOrient() and setOrigin()
2823   ///
2824   void setTransform(dbTransform& t);
2825 
2826   ///
2827   /// Get the hierarchical transform of this instance.
2828   ///
2829   void getHierTransform(dbTransform& t);
2830 
2831   /////////////////////////////////////////////////////////////////
2832 
2833   ///
2834   /// This method returns the lower-left corner
2835   /// of the bounding box of this instance.
2836   ///
2837   dbBox* getBBox();
2838 
2839   ///
2840   /// Get the placement status of this instance.
2841   ///
2842   dbPlacementStatus getPlacementStatus();
2843 
2844   ///
2845   /// Is the placement status of this instance fixed
2846   ///
isFixed()2847   bool isFixed() { return getPlacementStatus().isFixed(); }
2848 
2849   ///
2850   /// Is the placement status of this instance placed
2851   ///
isPlaced()2852   bool isPlaced() { return getPlacementStatus().isPlaced(); }
2853 
2854   ///
2855   /// Set the placement status of this instance.
2856   ///
2857   void setPlacementStatus(dbPlacementStatus status);
2858 
2859   ///
2860   /// Get the eco state bits to be used when an ECO block is created
2861   ///
2862   bool getEcoCreate();
2863   bool getEcoDestroy();
2864   bool getEcoModify();
2865 
2866   ///
2867   /// Set the eco state bits to be used when an ECO block is created
2868   ///
2869   void setEcoCreate(bool v);
2870   void setEcoDestroy(bool v);
2871   void setEcoModify(bool v);
2872 
2873   ///
2874   /// Get the user-defined flag bit.
2875   ///
2876   bool getUserFlag1();
2877 
2878   ///
2879   /// Set the user-defined flag bit.
2880   ///
2881   void setUserFlag1();
2882 
2883   ///
2884   /// Clear the user-defined flag bit.
2885   ///
2886   void clearUserFlag1();
2887 
2888   ///
2889   /// Get the user-defined flag bit.
2890   ///
2891   bool getUserFlag2();
2892 
2893   ///
2894   /// Set the user-defined flag bit.
2895   ///
2896   void setUserFlag2();
2897 
2898   ///
2899   /// Clear the user-defined flag bit.
2900   ///
2901   void clearUserFlag2();
2902 
2903   ///
2904   /// Get the user-defined flag bit.
2905   ///
2906   bool getUserFlag3();
2907 
2908   ///
2909   /// Set the user-defined flag bit.
2910   ///
2911   void setUserFlag3();
2912 
2913   ///
2914   /// Clear the user-defined flag bit.
2915   ///
2916   void clearUserFlag3();
2917 
2918   ///
2919   /// Set/Reset the size-only flag
2920   ///
2921   void setSizeOnly(bool v);
2922 
2923   ///
2924   /// Returns true if the size-only flag is set.
2925   ///
2926   bool isSizeOnly();
2927 
2928   ///
2929   /// Set/Reset the don't-touch flag
2930   ///
2931   void setDoNotTouch(bool v);
2932 
2933   ///
2934   /// Returns true if the don't-touch flag is set.
2935   ///
2936   bool isDoNotTouch();
2937 
2938   ///
2939   /// Set/Reset the don't-size flag
2940   ///
2941   void setDoNotSize(bool v);
2942 
2943   ///
2944   /// Returns true if the don't-size flag is set.
2945   ///
2946   bool isDoNotSize();
2947 
2948   ///
2949   /// Get the block of this instance.
2950   ///
2951   dbBlock* getBlock();
2952 
2953   ///
2954   /// Get the Master of this instance.
2955   ///
2956   dbMaster* getMaster() const;
2957 
2958   ///
2959   /// Get the group of this instance.
2960   ///
2961   dbGroup* getGroup();
2962 
2963   ///
2964   /// Get the instance-terminals of this instance.
2965   ///
2966   dbSet<dbITerm> getITerms();
2967 
2968   ///
2969   /// Get the first output terminal of this instance.
2970   ///
2971   dbITerm* getFirstOutput();
2972 
2973   ///
2974   /// Get the region this instance belongs to. Returns NULL if instance has no
2975   /// assigned region.
2976   ///
2977   dbRegion* getRegion();
2978 
2979   ///
2980   /// Get the module this instance belongs to. Returns NULL if instance has no
2981   /// assigned module.
2982   ///
2983   dbModule* getModule();
2984 
2985   ///
2986   /// Find the iterm of the given terminal name.
2987   /// Returns NULL if no terminal was found.
2988   ///
2989   dbITerm* findITerm(const char* terminal_name);
2990 
2991   ///
2992   /// Find the iterm of the given terminal name given the master term order
2993   ///
2994   dbITerm* getITerm(uint mterm_order_id);
2995   dbITerm* getClockedTerm();
2996   dbITerm* getOutputTerm();
2997 
2998   ///
2999   /// Get the all the instances connected to the net of each iterm of this
3000   /// instance. Only traverse nets of the specified SigType. Default is
3001   /// dbSigType::SIGNAL.
3002   ///
3003   void getConnectivity(std::vector<dbInst*>& neighbors,
3004                        dbSigType::Value value = dbSigType::SIGNAL);
3005 
3006   ///
3007   /// Bind the hierarchical (child) block to this instance.
3008   ///
3009   /// This method creates connectivity across the hierarchy.
3010   ///
3011   ///     (block)
3012   ///     +------------------------------------------------------------------+
3013   ///     |                                                                  |
3014   ///     |                                                                  |
3015   ///     |                                                                  |
3016   ///     |               (child-block / instance)                           |
3017   ///     |               +----------------------------------+               |
3018   ///     |               |                                  |               |
3019   ///     |B             I|B                                 |               |
3020   ///     |o.............o|o..........                       |               |
3021   ///     |  (net in      |  (net in child-block)            |               |
3022   ///     |   top-block)  |                                  |               |
3023   ///     |               |                                  |               |
3024   ///     |               |                                  |               |
3025   ///     |               |                                  |               |
3026   ///     |               |                                  |               |
3027   ///     |               +----------------------------------+               |
3028   ///     |                                                                  |
3029   ///     |                                                                  |
3030   ///     +------------------------------------------------------------------+
3031   ///
3032   /// B = dbBterm
3033   /// I = dbIterm
3034   ///
3035   /// This method will return false under the following situations:
3036   ///
3037   ///    1) This instance is already bound to a block.
3038   ///    2) This block cannot already be bound to an instance.
3039   ///    2) The block must be a direct child of the instance block.
3040   ///    3) block bterms must map 1-to-1 (by name) to the master mterms.
3041   ///
3042   bool bindBlock(dbBlock* block, bool force = false);
3043 
3044   ///
3045   /// Unbind the hierarchical (child) block from this instance.
3046   /// Does nothing if this instance has no child block.
3047   ///
3048   void unbindBlock();
3049 
3050   //
3051   // reset _hierachy to 0; not fully understood and tested!!!
3052   //
3053   bool resetHierarchy(bool verbose);
3054   ///
3055   /// Get the hierarchical (child) block bound to this instance.
3056   /// Returns NULL if this instance has no child.
3057   ///
3058   dbBlock* getChild();
3059 
3060   ///
3061   /// Get the parent instance of this instance.
3062   /// Returns NULL if this instance has no parent.
3063   ///
3064   dbInst* getParent();
3065 
3066   ///
3067   /// Get the children of this instance.
3068   ///
3069   dbSet<dbInst> getChildren();
3070 
3071   ///
3072   /// Returns true if this instance has hierarchy.
3073   ///
3074   bool isHierarchical();
3075 
3076   ///
3077   /// Returns a halo assigned to this instance.
3078   /// Returns NULL if this instance has no halo.
3079   ///
3080   dbBox* getHalo();
3081 
3082   ///
3083   /// Get the weight assigned to this instance.
3084   /// (Default: 1)
3085   ///
3086   int getWeight();
3087 
3088   ///
3089   /// Set the weight assigned of this instance.
3090   ///
3091   void setWeight(int weight);
3092 
3093   ///
3094   /// Get the source assigned to this instance.
3095   ///
3096   dbSourceType getSourceType();
3097 
3098   ///
3099   /// Set the source assigned of this instance.
3100   ///
3101   void setSourceType(dbSourceType type);
3102 
3103   ///
3104   /// Get the iterm that represents this mterm
3105   ///
3106   dbITerm* getITerm(dbMTerm* mterm);
3107 
3108   ///
3109   /// Swap the master of this instance.
3110   ///
3111   /// Returns true if the operations succeeds.
3112   /// NOTE: If this instance is bound to a block hierarchy, the master cannot be
3113   /// swapped.
3114   ///
3115   /// This method invalidates any existing dbSet<dbITerm>::iterator.
3116   ///
3117   bool swapMaster(dbMaster* master);
3118 
3119   ///
3120   /// Level of instance; if negative belongs to Primary Input Logic cone, 0
3121   /// invalid.
3122   ///
3123   int getLevel();
3124 
3125   ///
3126   /// Set ;evel of instance; if fromPI true, logic cone is connected to Primiary
3127   /// inputs
3128   ///
3129   void setLevel(uint v, bool fromPI);
3130 
3131   ///
3132   /// Is the master's type BLOCK or any of its subtypes
3133   ///
3134   bool isBlock() const;
3135 
3136   ///
3137   /// Is the master's type CORE or any of its subtypes
3138   ///
3139   bool isCore() const;
3140 
3141   ///
3142   /// Is the master's type PAD or any of its subtypes
3143   ///
3144   bool isPad() const;
3145 
3146   ///
3147   /// Is the master's type ENDCAP or any of its subtypes
3148   ///
3149   bool isEndCap() const;
3150 
3151   ///
3152   /// Create a new instance.
3153   /// Returns NULL if an instance with this name already exists.
3154   /// Returns NULL if the master is not FROZEN.
3155   ///
3156   static dbInst* create(dbBlock* block, dbMaster* master, const char* name);
3157 
3158   ///
3159   /// Create a new instance within the specified region.
3160   /// Returns NULL if an instance with this name already exists.
3161   /// Returns NULL if the master is not FROZEN.
3162   ///
3163   static dbInst* create(dbBlock* block,
3164                         dbMaster* master,
3165                         const char* name,
3166                         dbRegion* region);
3167 
3168   ///
3169   /// Delete the instance from the block.
3170   ///
3171   static void destroy(dbInst* inst);
3172 
3173   ///
3174   /// Delete the net from the block.
3175   ///
3176   static dbSet<dbInst>::iterator destroy(dbSet<dbInst>::iterator& itr);
3177 
3178   ///
3179   /// Translate a database-id back to a pointer.
3180   ///
3181   static dbInst* getInst(dbBlock* block, uint oid);
3182 
3183   ///
3184   /// Translate a valid database-id back to a pointer.
3185   ///
3186   static dbInst* getValidInst(dbBlock* block, uint oid);
3187 };
3188 
3189 ///////////////////////////////////////////////////////////////////////////////
3190 ///
3191 /// A dbITerm (instance-terminal) is the element that represents a connection
3192 /// to a master-terminal of an instance.
3193 ///
3194 ///////////////////////////////////////////////////////////////////////////////
3195 class dbITerm : public dbObject
3196 {
3197  public:
3198   ///
3199   /// Get the instance of this instance-terminal.
3200   ///
3201   dbInst* getInst();
3202 
3203   ///
3204   /// Get the net of this instance-terminal.
3205   /// Returns NULL if this instance-terminal has NOT been connected
3206   /// to a net.
3207   ///
3208   dbNet* getNet();
3209 
3210   ///
3211   /// Get the master-terminal that this instance-terminal is representing.
3212   ///
3213   dbMTerm* getMTerm();
3214 
3215   ///
3216   /// Get bbox of this iterm (ie the transfromed bbox of the mterm)
3217   ///
3218   Rect getBBox();
3219 
3220   ///
3221   /// Get the block this instance-terminal belongs too.
3222   ///
3223   dbBlock* getBlock();
3224 
3225   ///
3226   /// Get the signal type of this instance-terminal.
3227   ///
3228   dbSigType getSigType();
3229 
3230   ///
3231   /// Get the IO direction of this instance-terminal.
3232   ///
3233   dbIoType getIoType();
3234 
3235   ///
3236   /// True is iterm is input of signal type; if io false INOUT is not considered
3237   /// iput
3238   ///
3239   bool isInputSignal(bool io = true);
3240 
3241   ///
3242   /// True is iterm is output of signal type; if io false INOUT is not
3243   /// considered iput
3244   ///
3245   bool isOutputSignal(bool io = true);
3246 
3247   ///
3248   /// Mark this dbITerm as spef. v should 1 or 0
3249   ///
3250   void setSpef(uint v);
3251 
3252   ///
3253   /// Return true if this dbITerm flag spef is set to 1
3254   ///
3255   bool isSpef();
3256 
3257   ///
3258   /// set ext id
3259   ///
3260   void setExtId(uint v);
3261 
3262   ///
3263   /// get ext id
3264   ///
3265   uint getExtId();
3266 
3267   ///
3268   /// Returns true if this dbITerm is marked as special. Special nets/iterms are
3269   /// declared in the SPECIAL NETS section of a DEF file.
3270   ///
3271   bool isSpecial();
3272 
3273   ///
3274   /// Mark this dbITerm as special.
3275   ///
3276   void setSpecial();
3277 
3278   ///
3279   /// Unmark this dbITerm as special.
3280   ///
3281   void clearSpecial();
3282 
3283   ///
3284   /// Set clocked of this instance-terminal.
3285   ///
3286   void setClocked(bool v);
3287 
3288   ///
3289   /// get clocked of this instance-terminal.
3290   ///
3291   bool isClocked();
3292 
3293   ///
3294   /// Set mark of this instance-terminal.
3295   ///
3296   void setMark(uint v);
3297 
3298   ///
3299   /// get mark of this instance-terminal.
3300   ///
3301   bool isSetMark();
3302 
3303   ///
3304   /// Returns true if this dbITerm has been marked as physically connected.
3305   ///
3306   bool isConnected();
3307 
3308   ///
3309   /// Mark this dbITerm as physically connected.
3310   ///
3311   void setConnected();
3312 
3313   ///
3314   /// Unmark this dbITerm as physically connected.
3315   ///
3316   void clearConnected();
3317 
3318   ///
3319   /// Get the hierarchical child bterm of this iterm.
3320   /// Returns NULL if there is no child bterm.
3321   ///
3322   ///
3323   ///     (top-block)
3324   ///     +------------------------------------------------------------------+
3325   ///     |                                                                  |
3326   ///     |                                                                  |
3327   ///     |                                                                  |
3328   ///     |               (child-block / instance)                           |
3329   ///     |               +----------------------------------+               |
3330   ///     |               |                                  |               |
3331   ///     |B             I|B                                 |               |
3332   ///     |o.............o|o..........                       |               |
3333   ///     |  (net in      |  (net in child-block)            |               |
3334   ///     |   top-block)  |                                  |               |
3335   ///     |               |                                  |               |
3336   ///     |               |                                  |               |
3337   ///     |               |                                  |               |
3338   ///     |               |                                  |               |
3339   ///     |               +----------------------------------+               |
3340   ///     |                                                                  |
3341   ///     |                                                                  |
3342   ///     +------------------------------------------------------------------+
3343   ///
3344   ///
3345   /// B = dbBterm
3346   /// I = dbIterm
3347   ///
3348   dbBTerm* getBTerm();
3349 
3350   ///
3351   /// Create a connection between a instance and a net using a specific
3352   /// master-terminal. The dbITerm representing the connection is returned.
3353   /// Returns NULL if that specific master-terminal of that instance is
3354   /// already connected to a net.
3355   ///
3356   static dbITerm* connect(dbInst* inst, dbNet* net, dbMTerm* terminal);
3357 
3358   ///
3359   /// Connect this iterm to this net.
3360   ///
3361   static void connect(dbITerm* iterm, dbNet* net);
3362 
3363   ///
3364   /// Disconnect this iterm from the net it is connected to.
3365   ///
3366   static void disconnect(dbITerm* iterm);
3367 
3368   ///
3369   /// Disconnect this iterm from the net it is connected to.
3370   ///
3371   static dbSet<dbITerm>::iterator disconnect(dbSet<dbITerm>::iterator& itr);
3372 
3373   ///
3374   /// Get the average of the centers for the iterm shapes
3375   /// Returns false if iterm has no shapes
3376   ///
3377   bool getAvgXY(int* x, int* y);
3378 
3379   ///
3380   /// Translate a database-id back to a pointer.
3381   ///
3382   static dbITerm* getITerm(dbBlock* block, uint oid);
3383 
3384   uint32_t staVertexId();
3385   void staSetVertexId(uint32_t id);
3386 };
3387 
3388 ///////////////////////////////////////////////////////////////////////////////
3389 ///
3390 /// A dbVia is the element that represents a block specific via definition.
3391 /// These vias are typically generated to be used in power routing.
3392 ///
3393 ///////////////////////////////////////////////////////////////////////////////
3394 class dbVia : public dbObject
3395 {
3396  public:
3397   ///
3398   /// Get the via name.
3399   ///
3400   std::string getName();
3401 
3402   ///
3403   /// Get the via name.
3404   ///
3405   const char* getConstName();
3406 
3407   ///
3408   /// Get the pattern value of this via.
3409   /// Returns and empty ("") string if a pattern has not been set.
3410   ///
3411   std::string getPattern();
3412 
3413   ///
3414   /// Set the pattern value of this via.
3415   /// The pattern is ignored if the pattern is already set on this via
3416   ///
3417   void setPattern(const char* pattern);
3418 
3419   ///
3420   /// Set generate rule that was used to genreate this via.
3421   ///
3422   void setViaGenerateRule(dbTechViaGenerateRule* rule);
3423 
3424   ///
3425   /// Get the generate rule that was used to genreate this via.
3426   ///
3427   dbTechViaGenerateRule* getViaGenerateRule();
3428 
3429   ///
3430   /// Returns true if this via has params.
3431   ///
3432   bool hasParams();
3433 
3434   ///
3435   /// Set via params to generate this via. This method will create the shapes
3436   /// of this via. All previous shapes are destroyed.
3437   ///
3438   void setViaParams(const dbViaParams& params);
3439 
3440   ///
3441   /// Get the via params used to generate this via.
3442   ///
3443   void getViaParams(dbViaParams& params_return);
3444 
3445   ///
3446   /// Get the block this via belongs too.
3447   ///
3448   dbBlock* getBlock();
3449 
3450   ///
3451   /// Get the bbox of this via
3452   /// Returns NULL if this via has no shapes.
3453   ///
3454   dbBox* getBBox();
3455 
3456   ///
3457   /// Get the boxes of this via.
3458   ///
3459   dbSet<dbBox> getBoxes();
3460 
3461   ///
3462   /// Get the upper-most layer of this via reaches
3463   /// Returns NULL if this via has no shapes.
3464   ///
3465   dbTechLayer* getTopLayer();
3466 
3467   ///
3468   /// Get the lower-most layer of this via reaches
3469   /// Returns NULL if this via has no shapes.
3470   ///
3471   dbTechLayer* getBottomLayer();
3472 
3473   ///
3474   /// Returns true if this via is a rotated version of a block or tech via.
3475   ///
3476   /// Vias in DEF can now be rotated.
3477   ///
3478   bool isViaRotated();
3479 
3480   ///
3481   /// Get the rotation of this via.
3482   ///
3483   dbOrientType getOrient();
3484 
3485   //
3486   // Get the tech-via that this roated via represents.
3487   /// Returns NULL if this via does not represent a tech via
3488   //
3489   dbTechVia* getTechVia();
3490 
3491   //
3492   // Get the block-via that this roated via represents.
3493   /// Returns NULL if this via does not represent a block via
3494   //
3495   dbVia* getBlockVia();
3496 
3497   ///
3498   /// Create a block specific via.
3499   /// Returns NULL if a via with this name already exists.
3500   ///
3501   static dbVia* create(dbBlock* block, const char* name);
3502 
3503   ///
3504   /// Created a rotated version of the specified block-via.
3505   /// Returns NULL if a via with this name already exists.
3506   ///
3507   static dbVia* create(dbBlock* block,
3508                        const char* name,
3509                        dbVia* via,
3510                        dbOrientType type);
3511 
3512   ///
3513   /// Created a rotated version of the specified tech-via.
3514   /// Returns NULL if a via with this name already exists.
3515   ///
3516   static dbVia* create(dbBlock* block,
3517                        const char* name,
3518                        dbTechVia* via,
3519                        dbOrientType type);
3520 
3521   /// Copy all the VIA's from the src-block to the dst-block.
3522   /// Returns false the copy failed.
3523   static bool copy(dbBlock* dst, dbBlock* src);
3524 
3525   /// Copy the VIA to the dst-block.
3526   static dbVia* copy(dbBlock* dst, dbVia* src);
3527 
3528   ///
3529   /// Translate a database-id back to a pointer.
3530   ///
3531   static dbVia* getVia(dbBlock* block, uint oid);
3532 };
3533 
3534 ///////////////////////////////////////////////////////////////////////////////
3535 ///
3536 ///  A dbWire is the element used to represent net wires. A wire object
3537 ///  represents a sequence of from-to paths, which may form either
3538 ///  a disjoint or non-disjoint set of paths. A wire is encoded using the
3539 ///  dbWireEncoder class, see "dbWireCodec.h". A wire is decoded using
3540 ///  the dbWireDecoder class.
3541 ///
3542 ///////////////////////////////////////////////////////////////////////////////
3543 class dbWire : public dbObject
3544 {
3545  public:
3546   ///
3547   /// Get the block this wire belongs too.
3548   ///
3549   dbBlock* getBlock();
3550 
3551   ///
3552   /// Get the net this wire is attached too.
3553   /// Returns NULL if this wire is not attached to a net.
3554   ///
3555   dbNet* getNet();
3556 
3557   ///
3558   /// Append the wire to this wire. This operation will fail if the wire
3559   /// is from another block and the wire contains bterms or iterms.
3560   ///
3561   void append(dbWire* wire, bool singleSegmentWire = false);
3562 
3563   ///
3564   /// Move segements of this wire to wires of other nets
3565   ///
3566   void shuffleWireSeg(dbNet** newNets, dbRSeg** new_rsegs);
3567 
3568   ///
3569   /// Get junction id associated with the term
3570   ///
3571   uint getTermJid(int termid);
3572 
3573   ///
3574   /// check if this wire equals the target wire
3575   /// return value = 0: equal
3576   ///                x: not equal
3577   ///                1x: wire seg after junction not equal
3578   ///
3579   uint equal(dbWire* target);
3580 
3581   // void match(dbWire *target);
3582 
3583   ///
3584   /// Get the shape of this shape-id.
3585   /// PRECONDITION: shape-id is a segment or via
3586   ///
3587   void getShape(int shape_id, dbShape& shape);
3588 
3589   ///
3590   /// Get the segment of this segment-id
3591   ///
3592   /// PRECONDITION: segment_id is a segment
3593   ///
3594   void getSegment(int segment_id, dbShape& shape);
3595 
3596   ///
3597   /// Get the segment of this segment-id, where layer is the layer of the
3598   /// segment
3599   ///
3600   /// PRECONDITION: segment_id is a segment
3601   ///
3602   void getSegment(int segment_id, dbTechLayer* layer, dbShape& shape);
3603 
3604   ///
3605   /// Get the previous via of this shape-id.
3606   /// returns false if the previous shape is not a via.
3607   ///
3608   bool getPrevVia(int shape_id, dbShape& shape);
3609 
3610   ///
3611   /// Get the via that follows of this shape-id.
3612   /// returns false if the next shape is not a via.
3613   ///
3614   bool getNextVia(int shape_id, dbShape& shape);
3615 
3616   ///
3617   /// Get the via boxes of this via_shape-id.
3618   ///
3619   /// returns false if this shape_id is not a via.
3620   ///
3621   bool getViaBoxes(int via_shape_id, std::vector<dbShape>& boxes);
3622 
3623   ///
3624   /// Returns true if this wire is a global-wire
3625   ///
3626   bool isGlobalWire();
3627 
3628   ///
3629   /// Get the bounding box of this wire
3630   ///
3631   bool getBBox(Rect& r);
3632 
3633   ///
3634   /// Get the total path length contained in this wire.
3635   ///
3636   uint64 getLength();
3637 
3638   ///
3639   /// Get the number of entries contained in this wire.
3640   ///
3641   uint length();
3642 
3643   ///
3644   /// Get the count of wire segments contained in this wire.
3645   ///
3646   uint count();
3647   ///
3648   /// Get junction coordinate.
3649   ///
3650   void getCoord(int jid, int& x, int& y);
3651 
3652   ///
3653   /// Get junction property
3654   ///
3655   bool getProperty(int jid, int& property);
3656 
3657   ///
3658   /// Set junction property
3659   ///
3660   bool setProperty(int jid, int property);
3661 
3662   ///
3663   /// Set one data entry
3664   ///
3665   int getData(int n);
3666 
3667   ///
3668   /// Set one opcode entry
3669   ///
3670   unsigned char getOpcode(int n);
3671 
3672   ///
3673   /// Print opcodes and data of this wire
3674   ///
3675   void printWire();
3676   void printWire(FILE* fp, int fid, int tid);
3677 
3678   ///
3679   /// Attach this wire to a net.
3680   ///   1) If the net is already attached to another wire, the other wire will
3681   ///      be destroyed.
3682   ///   2) If this wire is already attached to another net, thie wire will be
3683   ///   detachd from
3684   //       the other net.
3685   ///
3686   void attach(dbNet* net);
3687 
3688   ///
3689   /// Detach this wire from a net.
3690   ///
3691   void detach();
3692 
3693   ///
3694   /// Copy the src wire to the desintation wire.
3695   ///
3696   ///    removeITermBTerms - if true, then any iterms or bterms referenced in
3697   ///    the copied wire will be removed. copyVias - if true, then any reference
3698   ///    vias that do not exists in the dst-block are copied to the src-block.
3699   ///
3700   ///
3701   static void copy(dbWire* dst,
3702                    dbWire* src,
3703                    bool removeITermsBTerms = true,
3704                    bool copyVias = true);
3705 
3706   ///
3707   /// Copy the src wire to the desintation wire. Filter vias and segments that
3708   /// do not intersect bbox.
3709   ///
3710   ///    removeITermBTerms - if true, then any iterms or bterms referenced in
3711   ///    the copied wire will be removed. copyVias - if true, then any reference
3712   ///    vias that do not exists in the dst-block are copied to the src-block.
3713   ///
3714   ///
3715   static void copy(dbWire* dst,
3716                    dbWire* src,
3717                    const Rect& bbox,
3718                    bool removeITermsBTerms = true,
3719                    bool copyVias = true);
3720 
3721   ///
3722   /// Create a wire.
3723   /// Returns NULL if this net already has the specified wire dbWire.
3724   ///
3725   static dbWire* create(dbNet* net, bool global_wire = false);
3726 
3727   ///
3728   /// Create an unattached wire.
3729   ///
3730   static dbWire* create(dbBlock* block, bool global_wire = false);
3731 
3732   ///
3733   /// Translate a database-id back to a pointer.
3734   ///
3735   static dbWire* getWire(dbBlock* block, uint oid);
3736 
3737   ///
3738   /// Destroy a wire.
3739   ///
3740   static void destroy(dbWire* wire);
3741 
3742  private:
3743   void addOneSeg(unsigned char op,
3744                  int value,
3745                  uint jj,
3746                  int* did,
3747                  dbRSeg** new_rsegs);
3748   void addOneSeg(unsigned char op, int value);
3749   void donateWireSeg(dbWire* w1, dbRSeg** new_rsegs);
3750 
3751   friend class dbNet;
3752 };
3753 
3754 ///////////////////////////////////////////////////////////////////////////////
3755 ///
3756 ///  A dbSWire is the element used to represent special-net wires.
3757 ///
3758 ///////////////////////////////////////////////////////////////////////////////
3759 class dbSWire : public dbObject
3760 {
3761  public:
3762   ///
3763   /// Get the block this wire belongs too.
3764   ///
3765   dbBlock* getBlock();
3766 
3767   ///
3768   /// Get the net this wire is attached too.
3769   ///
3770   dbNet* getNet();
3771 
3772   ///
3773   /// Return the wire-type.
3774   ///
3775   dbWireType getWireType();
3776 
3777   ///
3778   /// Returns the shield net if the wire-type is dbWireType::SHIELD
3779   ///
3780   dbNet* getShield();
3781 
3782   ///
3783   /// Get the wires of this special wire.
3784   ///
3785   dbSet<dbSBox> getWires();
3786 
3787   ///
3788   /// Create a new special-wire.
3789   ///
3790   static dbSWire* create(dbNet* net, dbWireType type, dbNet* shield = NULL);
3791 
3792   ///
3793   /// Delete this wire
3794   ///
3795   static void destroy(dbSWire* swire);
3796 
3797   ///
3798   /// Delete this wire
3799   ///
3800   static dbSet<dbSWire>::iterator destroy(dbSet<dbSWire>::iterator& itr);
3801 
3802   ///
3803   /// Translate a database-id back to a pointer.
3804   ///
3805   static dbSWire* getSWire(dbBlock* block, uint oid);
3806 };
3807 
3808 ///////////////////////////////////////////////////////////////////////////////
3809 ///
3810 /// A dbGCellGrid is the element that represents a block specific grid
3811 /// definition.
3812 ///
3813 ///////////////////////////////////////////////////////////////////////////////
3814 
3815 ///////////////////////////////////////////////////////////////////////////////
3816 ///
3817 /// A dbTrackGrid is the element that represents a block tracks.
3818 ///
3819 ///////////////////////////////////////////////////////////////////////////////
3820 class dbTrackGrid : public dbObject
3821 {
3822  public:
3823   ///
3824   /// Get the layer for this track-grid.
3825   ///
3826   dbTechLayer* getTechLayer();
3827 
3828   ///
3829   /// Get the "X" track coordinates for a this tech-layer.
3830   ///
3831   void getGridX(std::vector<int>& x_grid);
3832 
3833   ///
3834   /// Get the "Y" track coordinates for a this tech-layer.
3835   ///
3836   void getGridY(std::vector<int>& y_grid);
3837 
3838   ///
3839   /// Get the block this grid belongs too.
3840   ///
3841   dbBlock* getBlock();
3842 
3843   ///
3844   /// Add a "X" grid pattern.
3845   ///
3846   void addGridPatternX(int origin_x, int line_count, int step);
3847 
3848   ///
3849   /// Add a "Y" grid pattern.
3850   ///
3851   void addGridPatternY(int origin_y, int line_count, int step);
3852 
3853   ///
3854   /// Get the number of "X" grid patterns.
3855   ///
3856   int getNumGridPatternsX();
3857 
3858   ///
3859   /// Get the number of "Y" grid patterns.
3860   ///
3861   int getNumGridPatternsY();
3862 
3863   ///
3864   /// Get the "ith" "X" grid pattern.
3865   ///
3866   void getGridPatternX(int i, int& origin_x, int& line_count, int& step);
3867 
3868   ///
3869   /// Get the "ith" "Y" grid pattern.
3870   ///
3871   void getGridPatternY(int i, int& origin_y, int& line_count, int& step);
3872   ///
3873   /// Create an empty Track grid.
3874   /// Returns NULL if a the grid for this layer already exists.
3875   ///
3876   static dbTrackGrid* create(dbBlock* block, dbTechLayer* layer);
3877 
3878   ///
3879   /// Translate a database-id back to a pointer.
3880   ///
3881   static dbTrackGrid* getTrackGrid(dbBlock* block, uint oid);
3882 
3883   ///
3884   /// destroy a grid
3885   ///
3886   static void destroy(dbTrackGrid* grid_);
3887 };
3888 
3889 ///////////////////////////////////////////////////////////////////////////////
3890 ///
3891 /// A dbObstruction is the element that represents a routing
3892 /// obstruction in a block.
3893 ///
3894 ///////////////////////////////////////////////////////////////////////////////
3895 class dbObstruction : public dbObject
3896 {
3897  public:
3898   ///
3899   /// Get the bbox of this obstruction.
3900   ///
3901   dbBox* getBBox();
3902 
3903   ///
3904   /// Get the instance associated with this obstruction.
3905   /// Returns NULL of no instance was associated with this obstruction
3906   ///
3907   dbInst* getInstance();
3908 
3909   ///
3910   /// Declare this obstruction to be a "slot" obstruction.
3911   ///
3912   void setSlotObstruction();
3913 
3914   ///
3915   /// Returns true if this obstruction is a "slot" obstruction.
3916   ///
3917   bool isSlotObstruction();
3918 
3919   ///
3920   /// Declare this obstruction to be a "fill" obstruction.
3921   ///
3922   void setFillObstruction();
3923 
3924   ///
3925   /// Returns true if this obstruction is a "fill" obstruction.
3926   ///
3927   bool isFillObstruction();
3928 
3929   ///
3930   /// Declare this obstruction to have been pushed into this block.
3931   ///
3932   void setPushedDown();
3933 
3934   ///
3935   /// Returns true if this obstruction was pushed into this block.
3936   ///
3937   bool isPushedDown();
3938   ///
3939   /// Returns true if this bpin has an effective-width rule.
3940   ///
3941   bool hasEffectiveWidth();
3942 
3943   ///
3944   /// Set the effective width rule.
3945   ///
3946   void setEffectiveWidth(int w);
3947 
3948   ///
3949   /// Return the effective width rule.
3950   ///
3951   int getEffectiveWidth();
3952 
3953   ///
3954   /// Returns true if this bpin has an min-spacing rule.
3955   ///
3956   bool hasMinSpacing();
3957 
3958   ///
3959   /// Set the min spacing rule.
3960   ///
3961   void setMinSpacing(int w);
3962 
3963   ///
3964   /// Return the min spacing rule.
3965   ///
3966   int getMinSpacing();
3967 
3968   ///
3969   /// Get the block this obstruction belongs too.
3970   ///
3971   dbBlock* getBlock();
3972 
3973   ///
3974   /// Delete this obstruction from this block.
3975   ///
3976   static void destroy(dbObstruction* obstruction);
3977 
3978   ///
3979   /// Create a routing obstruction.
3980   ///
3981   static dbObstruction* create(dbBlock* block,
3982                                dbTechLayer* layer,
3983                                int x1,
3984                                int y1,
3985                                int x2,
3986                                int y2,
3987                                dbInst* inst = NULL);
3988 
3989   ///
3990   /// Translate a database-id back to a pointer.
3991   ///
3992   static dbObstruction* getObstruction(dbBlock* block, uint oid);
3993 };
3994 
3995 ///////////////////////////////////////////////////////////////////////////////
3996 ///
3997 /// A dbBlockage is the element that represents a placement blockage in a block.
3998 ///
3999 ///////////////////////////////////////////////////////////////////////////////
4000 class dbBlockage : public dbObject
4001 {
4002  public:
4003   ///
4004   /// Get the bbox of this obstruction.
4005   ///
4006   dbBox* getBBox();
4007 
4008   ///
4009   /// Get the instance associated with this blockage.
4010   /// Returns NULL of no instance was associated with this blockage
4011   ///
4012   dbInst* getInstance();
4013 
4014   ///
4015   /// Declare this blockage to have been pushed into this block.
4016   ///
4017   void setPushedDown();
4018 
4019   ///
4020   /// Returns true if this blockage was pushed into this block.
4021   ///
4022   bool isPushedDown();
4023 
4024   ///
4025   /// Declare this blockage is soft.
4026   ///
4027   void setSoft();
4028 
4029   ///
4030   /// Returns true if this blockage is soft.
4031   ///
4032   bool isSoft();
4033 
4034   ///
4035   /// Set the max placement density percentage in [0,100]
4036   ///
4037   void setMaxDensity(float max_density);
4038 
4039   ///
4040   /// Returns the max placement density percentage
4041   ///
4042   float getMaxDensity();
4043 
4044   ///
4045   /// Get the block this obstruction belongs too.
4046   ///
4047   dbBlock* getBlock();
4048 
4049   ///
4050   /// Create a placement obstruction.
4051   ///
4052   static dbBlockage* create(dbBlock* block,
4053                             int x1,
4054                             int y1,
4055                             int x2,
4056                             int y2,
4057                             dbInst* inst = NULL);
4058 
4059   ///
4060   /// Translate a database-id back to a pointer.
4061   ///
4062   static dbBlockage* getBlockage(dbBlock* block, uint oid);
4063 };
4064 
4065 ///////////////////////////////////////////////////////////////////////////////
4066 ///
4067 /// A RCSeg is the element that represents an RC element in a RC network.
4068 ///
4069 /// The segment junction nodes are denoted "source" and "target". However,
4070 /// this namimg is just a convention and there is no implied directional
4071 /// meaning.
4072 ///
4073 ///////////////////////////////////////////////////////////////////////////////
4074 class dbCapNode : public dbObject
4075 {
4076  protected:
4077   friend class dbRSeg;
4078   friend class extMain;
4079   friend class extSpef;
4080   friend class te_tile;
4081   friend class tilext;
4082   friend class dbJournal;
4083 
4084   ///
4085   /// Get the capacitance of this capNode segment for this process corner.
4086   /// Returns value in femto-fards.
4087   ///
4088   void getCapTable(double* cap);
4089 
4090  public:
4091   ///
4092   /// Add the capacitances of other capnode to this capnode
4093   ///
4094   void addCapnCapacitance(dbCapNode* other);
4095 
4096   ///
4097   /// Add the gndCap of this capnode to *gndcap and *totalcap
4098   ///
4099   void addGndCap(double* gndcap, double* totalcap);
4100 
4101   /// Add the gndCap to *gndcap and *totalcap, ccCap to *totalcap
4102   ///
4103   void addGndTotalCap(double* gndcap, double* totalcap, double MillerMult);
4104 
4105   ///
4106   /// Get the gndCap of this capnode to *gndcap and *totalcap
4107   ///
4108   void getGndCap(double* gndcap, double* totalcap);
4109 
4110   ///
4111   /// Get the gndCap to *gndcap and *totalcap, ccCap to *totalcap
4112   ///
4113   void getGndTotalCap(double* gndcap, double* totalcap, double MillerMult);
4114 
4115   ///
4116   /// Add the caps of all corners of CC's from this capnode to *totalcap
4117   ///
4118   void accAllCcCap(double* totalcap, double MillerMult);
4119 
4120   ///
4121   /// Set the capacitance of this CapNode segment for this process corner. Value
4122   /// must be in femto-fards.
4123   ///
4124   void setCapacitance(double cap, int corner = 0);
4125 
4126   ///
4127   /// Add the capacitance of this CapNode segment for this process corner. Value
4128   /// must be in femto-fards.
4129   ///
4130   void addCapacitance(double cap, int corner = 0);
4131 
4132   ///
4133   /// add cc capacitance to gnd capacitance of this capNode
4134   ///
4135   bool groundCC(float gndFactor);
4136 
4137   ///
4138   ///  Adjust the capacitance of this capNode for this process corner
4139   ///
4140   void adjustCapacitance(float factor, uint corner);
4141 
4142   ///
4143   ///  Adjust the capacitance of this capNode
4144   ///
4145   void adjustCapacitance(float factor);
4146 
4147   ///
4148   /// check if having CC's with capacitnce greater than ccThreshHold
4149   ///
4150   bool needAdjustCC(double ccThreshHold);
4151 
4152   ///
4153   /// adjust CC's of this capNode
4154   ///
4155   void adjustCC(uint adjOrder,
4156                 float adjFactor,
4157                 std::vector<dbCCSeg*>& adjustedCC,
4158                 std::vector<dbNet*>& halonets);
4159 
4160   ///
4161   /// Get the capacitance of this capNode segment for this process corner.
4162   /// Returns value in femto-fards.
4163   ///
4164   double getCapacitance(uint corner = 0);
4165 
4166   ///
4167   /// Get the rc-network cap node.
4168   ///
4169   uint getNode();
4170 
4171   ///
4172   /// Get the shapeId of the cap node.
4173   ///
4174   uint getShapeId();
4175 
4176   ///
4177   /// Set the rc-network cap node.
4178   ///
4179   void setNode(uint nodeid);
4180 
4181   ///
4182   /// Get next cap node in same net
4183   ///
4184   //  dbCapNode *getNext(dbBlock *block_);
4185 
4186   ///
4187   ///  is this node iterm/bterm/internal/branch/dangling/foreign .
4188   ///
4189   bool isName();
4190   bool isITerm();
4191   bool isBTerm();
4192   bool isInternal();
4193   bool isBranch();
4194   bool isDangling();
4195   bool isForeign();
4196   bool isTreeNode();  // bterm, iterm, branch
4197   // bool isSourceNodeBterm();
4198   bool isSourceTerm(dbBlock* mblock = NULL);
4199   bool isInoutTerm(dbBlock* mblock = NULL);
4200 
4201   ///
4202   /// Returns the select flag value. This flag specified that the
4203   /// net has been select.
4204   ///
4205   bool isSelect();
4206 
4207   ///
4208   /// Set the select flag to the specified value.
4209   ///
4210   void setSelect(bool value);
4211 
4212   ///
4213   ///  increase children cnt; capNode is a branch of the rooted tree.
4214   ///
4215   uint incrChildrenCnt();
4216   uint getChildrenCnt();
4217   void setChildrenCnt(uint cnt);
4218 
4219   ///
4220   ///  set iterm/bterm/internal/branch/foreign flag of this cap node.
4221   ///
4222   void setNameFlag();
4223   void setBTermFlag();
4224   void setITermFlag();
4225   void setInternalFlag();
4226   void setBranchFlag();
4227   void setForeignFlag();
4228 
4229   ///
4230   ///  reset iterm/bterm/internal/branch/foreign flag of this cap node.
4231   ///
4232   void resetNameFlag();
4233   void resetBTermFlag();
4234   void resetITermFlag();
4235   void resetInternalFlag();
4236   void resetBranchFlag();
4237   void resetForeignFlag();
4238 
4239   ///
4240   /// Get the sort index of this node
4241   ///
4242   uint getSortIndex();
4243 
4244   ///
4245   /// Set the sort index of this node
4246   ///
4247   void setSortIndex(uint idx);
4248 
4249   ///
4250   /// Get the coordinates of this node if iterm or bterm
4251   ///
4252   bool getTermCoords(int& x, int& y, dbBlock* mblock = NULL);
4253 
4254   ///
4255   /// Get the iterm of this node
4256   ///
4257   dbITerm* getITerm(dbBlock* mblock = NULL);
4258 
4259   ///
4260   /// Get the bterm of this node
4261   ///
4262   dbBTerm* getBTerm(dbBlock* mblock = NULL);
4263 
4264   ///
4265   /// Set the _ycoord of this node
4266   ///
4267   /// void setCoordY(int y);
4268 
4269   ///
4270   /// Get the _ycoord of this node
4271   ///
4272   /// void getCoordY(int & y);
4273 
4274   ///
4275   /// print the ccsegs of the capn
4276   ///
4277   void printCC();
4278 
4279   ///
4280   /// check the ccsegs of the capn
4281   ///
4282   bool checkCC();
4283 
4284   ///
4285   /// Get the coupling caps bound to this node
4286   ///
4287   dbSet<dbCCSeg> getCCSegs();
4288 
4289   ///
4290   /// Net given the capNode id
4291   ///
4292   dbNet* getNet();
4293 
4294   ///
4295   /// set net
4296   ///
4297   void setNet(uint netid);
4298 
4299   ///
4300   /// set next
4301   ///
4302   void setNext(uint nextid);
4303 
4304   ///
4305   /// Create a new rc-segment
4306   /// The default values for each process corner is 0.0.
4307   ///
4308   static dbCapNode* create(dbNet* net, uint node, bool foreign);
4309 
4310   ///
4311   /// add a seg onto a net
4312   ///
4313   void addToNet();
4314 
4315   ///
4316   /// Destroy a rc-segment.
4317   ///
4318   static void destroy(dbCapNode* seg, bool destroyCC = true);
4319 
4320   ///
4321   /// Destroy a rc-segment.
4322   ///
4323   static dbSet<dbCapNode>::iterator destroy(dbSet<dbCapNode>::iterator& itr);
4324 
4325   ///
4326   /// Translate a database-id back to a pointer.
4327   ///
4328   static dbCapNode* getCapNode(dbBlock* block, uint oid);
4329 
4330   // friend void test_eco();
4331 };
4332 ///////////////////////////////////////////////////////////////////////////////
4333 ///
4334 /// A RSeg is the element that represents an Res element in a Res network.
4335 ///
4336 /// The segment junction nodes are denoted "source" and "target". However,
4337 /// this namimg is just a convention and there is no implied directional
4338 /// meaning.
4339 ///
4340 ///////////////////////////////////////////////////////////////////////////////
4341 class dbRSeg : public dbObject
4342 {
4343  public:
4344   ///
4345   /// Add the resistances of other rseg to this rseg
4346   ///
4347   void addRSegResistance(dbRSeg* other);
4348 
4349   ///
4350   /// Add the capacitances of other rseg to this rseg
4351   ///
4352   void addRSegCapacitance(dbRSeg* other);
4353 
4354   ///
4355   /// Get the resistance of this RC segment for this process corner. Returns
4356   /// value in ohms.
4357   ///
4358   double getResistance(int corner = 0);
4359 
4360   ///
4361   /// Get the resistance of this RC segment to *res
4362   ///
4363   void getAllRes(double* res);
4364 
4365   ///
4366   /// Add the resistance of this RC segment to *res
4367   ///
4368   void addAllRes(double* res);
4369 
4370   ///
4371   /// Get the gdn cap of this RC segment to *gndcap and *totalcap
4372   ///
4373   void getGndCap(double* gndcap, double* totalcap);
4374 
4375   ///
4376   /// Add the gdn cap of this RC segment to *gndcap and *totalcap
4377   ///
4378   void addGndCap(double* gndcap, double* totalcap);
4379 
4380   ///
4381   /// Get the gdn cap of this RC segment to *gndcap, total cap to *totalcap
4382   ///
4383   void getGndTotalCap(double* gndcap, double* totalcap, double MillerMult);
4384 
4385   ///
4386   /// Add the gdn cap of this RC segment to *gndcap, total cap to *totalcap
4387   ///
4388   void addGndTotalCap(double* gndcap, double* totalcap, double MillerMult);
4389 
4390   ///
4391   /// do merge rsegs
4392   ///
4393   void mergeRCs(std::vector<dbRSeg*>& mrsegs);
4394 
4395   ///
4396   /// Adjust the capacitance of this RC segment for this process corner.
4397   ///
4398   void adjustCapacitance(float factor, uint corner);
4399 
4400   ///
4401   /// Adjust the capacitance of the src capNode of this RC segment for the
4402   /// process corner.
4403   ///
4404   void adjustSourceCapacitance(float factor, uint corner);
4405 
4406   ///
4407   /// Adjust the capacitance of this RC segment.
4408   ///
4409   void adjustCapacitance(float factor);
4410 
4411   ///
4412   /// Set the capacitance of this RC segment for this process corner. Value must
4413   /// in FF.
4414   ///
4415   void setCapacitance(double cap, int corner = 0);
4416 
4417   ///
4418   /// Returns the _update_cap flag value. This flag specified that the
4419   /// rseg has been updated
4420   ///
4421   bool updatedCap();
4422 
4423   ///
4424   /// Get the capacitance of this RC segment for this process corner. Returns
4425   /// value in FF.
4426   ///
4427   double getCapacitance(int corner = 0);
4428 
4429   ///
4430   /// Get the capacitance of this RC segment for this process corner,
4431   /// plus coupling capacitance. Returns value in FF.
4432   ///
4433   double getSourceCapacitance(int corner = 0);
4434 
4435   ///
4436   /// Get the first capnode capacitance of this RC segment
4437   /// for this process corner, if foreign,
4438   /// plus coupling capacitance. Returns value in FF.
4439   ///
4440   double getCapacitance(int corner, double MillerMult);
4441 
4442   ///
4443   /// Get the CC segs of this RC segment,
4444   ///
4445   void getCcSegs(std::vector<dbCCSeg*>& ccsegs);
4446 
4447   ///
4448   /// print the CC segs of this RC segment,
4449   ///
4450   void printCcSegs();
4451   void printCC();
4452   bool checkCC();
4453 
4454   ///
4455   /// Get the capacitance table of this RC segment. value is in FF
4456   ///
4457   void getCapTable(double* cap);
4458 
4459   ///
4460   /// Set the resistance of this RC segment for this process corner. Value must
4461   /// be in ohms.
4462   ///
4463   void setResistance(double res, int corner = 0);
4464 
4465   ///
4466   ///  Adjust the resistance of this RC segment for this process corner
4467   ///
4468   void adjustResistance(float factor, int corner);
4469 
4470   ///
4471   ///  Adjust the resistance of this RC segment
4472   ///
4473   void adjustResistance(float factor);
4474 
4475   ///
4476   /// Set the next rseg
4477   ///
4478   void setNext(uint next_id);
4479 
4480   ///
4481   /// Get the rc-network source node of this segment,
4482   ///
4483   uint getSourceNode();
4484 
4485   ///
4486   /// Get the rc-network source node of this segment,
4487   ///
4488   dbCapNode* getSourceCapNode();
4489 
4490   ///
4491   /// Set the rc-network source node of this segment,
4492   ///
4493   void setSourceNode(uint nodeid);
4494 
4495   ///
4496   /// Get the rc-network target node of this segment,
4497   ///
4498   uint getTargetNode();
4499 
4500   ///
4501   /// Get the rc-network target node of this segment,
4502   ///
4503   dbCapNode* getTargetCapNode();
4504 
4505   ///
4506   /// Set the rc-network target node of this segment,
4507   ///
4508   void setTargetNode(uint nodeid);
4509 
4510   ///
4511   /// Get shape-id of this RC-segment.
4512   ///
4513   uint getShapeId();
4514 
4515   ///
4516   /// Set coordinates of this RC-segment.
4517   ///
4518   void setCoords(int x, int y);
4519 
4520   ///
4521   /// Get coordinates of this RC-segment.
4522   ///
4523   void getCoords(int& x, int& y);
4524 
4525   ///
4526   /// Set shape-id of this RC-segment, and the target capNode if internal.
4527   ///
4528   void updateShapeId(uint nsid);
4529 
4530   ///
4531   /// check path direction
4532   ///
4533   bool pathLowToHigh();
4534 
4535   ///
4536   /// check if cap allocated
4537   ///
4538   bool allocatedCap();
4539 
4540   ///
4541   /// returns length and width.
4542   ///
4543   uint getLengthWidth(uint& w);
4544 
4545   ///
4546   /// add a seg onto a net
4547   ///
4548   bool addToNet();
4549 
4550   ///
4551   /// Get the net of this RC-segment.
4552   ///
4553   dbNet* getNet();
4554 
4555   ///
4556   /// Create a new r-segment
4557   /// The default values for each process corner is 0.0.
4558   ///
4559   static dbRSeg* create(dbNet* net,
4560                         int x,
4561                         int y,
4562                         uint path_dir,
4563                         bool allocate_cap);
4564 
4565   ///
4566   /// Destroy a rc-segment.
4567   ///
4568   static void destroy(dbRSeg* seg);
4569   static void destroy(dbRSeg* seg, dbNet* net);
4570 
4571   ///
4572   /// simple destroy a disconnected rc-segment
4573   ///
4574   static void destroyS(dbRSeg* seg);
4575 
4576   ///
4577   /// Destroy a rc-segment.
4578   ///
4579   static dbSet<dbRSeg>::iterator destroy(dbSet<dbRSeg>::iterator& itr);
4580 
4581   ///
4582   /// Translate a database-id back to a pointer.
4583   ///
4584   static dbRSeg* getRSeg(dbBlock* block, uint oid);
4585 };
4586 
4587 ///////////////////////////////////////////////////////////////////////////////
4588 ///
4589 /// A CCSeg is the element that represents an coupling capacitance element
4590 /// in a RC network.
4591 ///
4592 /// The segment junction nodes are denoted "source" and "target". However,
4593 /// this namimg is just a convention and there is no implied directional
4594 /// meaning.
4595 ///
4596 ///////////////////////////////////////////////////////////////////////////////
4597 class dbCCSeg : public dbObject
4598 {
4599  public:
4600   ///
4601   /// Adjust the capacitance of this CC segment
4602   ///
4603   void adjustCapacitance(float factor);
4604 
4605   ///
4606   /// Adjust the capacitance of a corner this CC segment
4607   ///
4608   void adjustCapacitance(float factor, int corner);
4609 
4610   ///
4611   /// Get the capacitance of this CC segment for this process corner. Returns
4612   /// value in femto-fards.
4613   ///
4614   double getCapacitance(int corner = 0);
4615 
4616   ///
4617   /// Set the capacitance of this CC segment for this process corner. Value must
4618   /// be in femto-fards.
4619   ///
4620   void setCapacitance(double cap, int corner = 0);
4621 
4622   ///
4623   /// Add the capacitance of this CC segment for this process corner. Value must
4624   /// be in femto-fards.
4625   ///
4626   void addCapacitance(double cap, int corner = 0);
4627 
4628   ///
4629   /// Add the capacitance of all corners of this CC segment to *ttcap
4630   ///
4631   void accAllCcCap(double* ttcap, double MillerMult);
4632 
4633   ///
4634   /// Get the capacitance of all corners of this CC segment to *ttcap
4635   ///
4636   void getAllCcCap(double* ttcap);
4637 
4638   ///
4639   /// Set the capacitance of all corners of this CC segment by *ttcap
4640   ///
4641   void setAllCcCap(double* ttcap);
4642 
4643   dbCapNode* getSourceCapNode();
4644   dbCapNode* getTargetCapNode();
4645 
4646   ///
4647   /// Add capacitance of other CC segment to this CC segment
4648   ///
4649   void addCcCapacitance(dbCCSeg* other);
4650 
4651   ///
4652   /// Change this CC segement's capNode orig to capNode new
4653   ///
4654   void swapCapnode(dbCapNode* orig, dbCapNode* newn);
4655 
4656   ///
4657   /// Get the capNode of this CC segment, other than oneCap
4658   ///
4659   dbCapNode* getTheOtherCapn(dbCapNode* oneCap, uint& cid);
4660 
4661   /// Get the rc-network source node of this segment,
4662   ///
4663   uint getSourceNodeNum();
4664 
4665   ///
4666   /// Set the rc-network source node of this segment,
4667   ///
4668   // void setSourceNode( uint nodeid );
4669 
4670   ///
4671   /// Get the rc-network target node of this segment,
4672   ///
4673   uint getTargetNodeNum();
4674 
4675   ///
4676   /// Set the rc-network target node of this segment,
4677   ///
4678   // void setTargetNode( uint nodeid );
4679 
4680   ///
4681   /// Get the source net of this CC-segment.
4682   ///
4683   dbNet* getSourceNet();
4684 
4685   ///
4686   /// Get the target net of this CC-segment.
4687   ///
4688   dbNet* getTargetNet();
4689 
4690   ///
4691   /// Get the infile cnt of this CC-segment.
4692   ///
4693   uint getInfileCnt();
4694 
4695   ///
4696   /// Increment the infile cnt of this CC-segment.
4697   ///
4698   void incrInfileCnt();
4699 
4700   ///
4701   /// Returns the mark flag value. This flag specified that the
4702   /// CC seg has been marked.
4703   ///
4704   bool isMarked();
4705 
4706   ///
4707   /// Set the mark flag to the specified value.
4708   ///
4709   void setMark(bool value);
4710 
4711   ///
4712   /// print CC's of capn
4713   ///
4714   void printCapnCC(uint capn);
4715 
4716   ///
4717   /// check CC's of capn
4718   ///
4719   bool checkCapnCC(uint capn);
4720 
4721   ///
4722   /// unlink cc from capn
4723   ///
4724   void unLink_cc_seg(dbCapNode* capn);
4725 
4726   ///
4727   /// link cc to capn
4728   ///
4729   void Link_cc_seg(dbCapNode* capn, uint cseq);
4730 
4731   ///
4732   /// relink _cc_tgt_segs of a net
4733   /// Used in re-reading the CC part of a spef file.
4734   ///
4735 
4736   // static dbCCSeg * relinkTgtCC (dbNet *net_, dbCCSeg *pseg_, uint
4737   // src_cap_node, uint tgt_cap_node);
4738 
4739   ///
4740   /// Returns NULL if not found
4741   ///
4742   static dbCCSeg* findCC(dbCapNode* nodeA, dbCapNode* nodeB);
4743 
4744   ///
4745   /// Create a new cc-segment.
4746   /// The default values for each process corner is 0.0.
4747   ///
4748   static dbCCSeg* create(dbCapNode* nodeA,
4749                          dbCapNode* nodeB,
4750                          bool mergeParallel = false);
4751 
4752   ///
4753   /// Destroy a cc-segment.
4754   ///
4755   static void destroy(dbCCSeg* seg);
4756 
4757   ///
4758   /// simple destroy disconnected cc-segment
4759   ///
4760   static void destroyS(dbCCSeg* seg);
4761 
4762   ///
4763   /// Destroy a cc-segment.
4764   ///
4765   static dbSet<dbCCSeg>::iterator destroy(dbSet<dbCCSeg>::iterator& itr);
4766 
4767   ///
4768   /// Translate a database-id back to a pointer.
4769   ///
4770   static dbCCSeg* getCCSeg(dbBlock* block, uint oid);
4771 
4772   ///
4773   /// disconnect a cc-segment
4774   ///
4775   static void disconnect(dbCCSeg* tcc_);
4776 
4777   ///
4778   /// connect a cc-segment
4779   ///
4780   static void connect(dbCCSeg* tcc_);
4781 };
4782 
4783 ///////////////////////////////////////////////////////////////////////////////
4784 ///
4785 /// A Row is the element that represents placement sites.
4786 ///
4787 ///////////////////////////////////////////////////////////////////////////////
4788 class dbRow : public dbObject
4789 {
4790  public:
4791   ///
4792   /// Get the row name.
4793   ///
4794   std::string getName();
4795 
4796   ///
4797   /// Get the row name.
4798   ///
4799   const char* getConstName();
4800 
4801   ///
4802   /// Get the row site.
4803   ///
4804   dbSite* getSite();
4805 
4806   ///
4807   /// Get the origin of this row
4808   ///
4809   void getOrigin(int& x, int& y);
4810 
4811   ///
4812   /// Get the site-orientation of this row
4813   ///
4814   dbOrientType getOrient();
4815 
4816   ///
4817   /// Get the direction of this row
4818   ///
4819   dbRowDir getDirection();
4820 
4821   ///
4822   /// Get the number of sites in this row.
4823   ///
4824   int getSiteCount();
4825 
4826   ///
4827   /// Get the spacing between sites. The spacing is measured from the
4828   /// origin of each site.
4829   ///
4830   int getSpacing();
4831 
4832   ///
4833   /// Get the bounding box of this row
4834   ///
4835   void getBBox(Rect& bbox);
4836 
4837   ///
4838   /// Create a new row.
4839   ///
4840   static dbRow* create(dbBlock* block,
4841                        const char* name,
4842                        dbSite* site,
4843                        int origin_x,
4844                        int origin_y,
4845                        dbOrientType orient,
4846                        dbRowDir direction,
4847                        int num_sites,
4848                        int spacing);
4849 
4850   ///
4851   /// Destroy a row.
4852   ///
4853   static void destroy(dbRow* row);
4854 
4855   ///
4856   /// Destroy a row.
4857   ///
4858   static dbSet<dbRow>::iterator destroy(dbSet<dbRow>::iterator& itr);
4859 
4860   ///
4861   /// Translate a database-id back to a pointer.
4862   ///
4863   static dbRow* getRow(dbBlock* block, uint oid);
4864 };
4865 
4866 ///////////////////////////////////////////////////////////////////////////////
4867 ///
4868 /// A fill is the element that one metal fill shape
4869 ///
4870 ///////////////////////////////////////////////////////////////////////////////
4871 class dbFill : public dbObject
4872 {
4873  public:
4874   ///
4875   /// Get the fill bounding box.
4876   ///
4877   void getRect(Rect& rect);
4878 
4879   ///
4880   /// Returns true if this fill requires OPC (Optical proximity correction)
4881   ///
4882   bool needsOPC();
4883 
4884   ///
4885   /// Which mask is used for double or triple patterning.  Zero is returned for
4886   /// unassigned.  Values are typically in [1,3].
4887   ///
4888   uint maskNumber();
4889 
4890   ///
4891   /// Get the layer of this fill.
4892   ///
4893   dbTechLayer* getTechLayer();
4894 
4895   ///
4896   /// Create a new fill.
4897   ///
4898   static dbFill* create(dbBlock* block,
4899                         bool needs_opc,
4900                         uint mask_number,
4901                         dbTechLayer* layer,
4902                         int x1,
4903                         int y1,
4904                         int x2,
4905                         int y2);
4906 
4907   ///
4908   /// Destroy a fill.
4909   ///
4910   static void destroy(dbFill* fill);
4911 
4912   ///
4913   /// Destroy fills.
4914   ///
4915   static dbSet<dbFill>::iterator destroy(dbSet<dbFill>::iterator& itr);
4916 
4917   ///
4918   /// Translate a database-id back to a pointer.
4919   ///
4920   static dbFill* getFill(dbBlock* block, uint oid);
4921 };
4922 
4923 ///////////////////////////////////////////////////////////////////////////////
4924 ///
4925 /// A Region is the element that represents a placement region.
4926 ///
4927 ///////////////////////////////////////////////////////////////////////////////
4928 class dbRegion : public dbObject
4929 {
4930  public:
4931   ///
4932   /// Get the region name.
4933   ///
4934   std::string getName();
4935 
4936   ///
4937   /// Get the region type.
4938   ///
4939   dbRegionType getRegionType();
4940 
4941   ///
4942   /// Set the region type.
4943   ///
4944   void setRegionType(dbRegionType type);
4945 
4946   ///
4947   /// Get the instances of this region.
4948   ///
4949   dbSet<dbInst> getRegionInsts();
4950 
4951   ///
4952   // Set the value of the invalid flag.
4953   ///
4954   void setInvalid(bool v);
4955 
4956   ///
4957   /// Returns true if the invalid flag is set.
4958   ///
4959   bool isInvalid();
4960 
4961   ///
4962   /// Get the boundaries of this region.
4963   /// A region may have no boundaries. In this case, you may have to check the
4964   /// parents of this region. This case can occur when reading DEF GROUPS and
4965   /// REGIONS. The result is two levels of hierarchy with the boundaries on the
4966   /// parent.
4967   ///
4968   dbSet<dbBox> getBoundaries();
4969 
4970   ///
4971   /// Add this instance to the region
4972   ///
4973   void addInst(dbInst* inst);
4974 
4975   ///
4976   /// Remove this instance from the region
4977   ///
4978   void removeInst(dbInst* inst);
4979 
4980   ///
4981   /// Get the parent of this region. Returns null of this region has no parent.
4982   ///
4983   dbRegion* getParent();
4984 
4985   ///
4986   /// Get the children of this region.
4987   ///
4988   dbSet<dbRegion> getChildren();
4989 
4990   ///
4991   /// Add child region to this region.
4992   ///
4993   /// This method will do nothing if this child already has a parent.
4994   ///
4995   void addChild(dbRegion* region);
4996 
4997   ///
4998   /// Get the block of this region
4999   ///
5000   dbBlock* getBlock();
5001 
5002   ///
5003   /// Create a new region. Returns NULL if a region with this name already
5004   /// exists in the block.
5005   ///
5006   static dbRegion* create(dbBlock* block, const char* name);
5007 
5008   ///
5009   /// Create a new region. The region will become a child region of parent.
5010   /// Returns NULL if a region with this name already exists in the block.
5011   ///
5012   static dbRegion* create(dbRegion* parent, const char* name);
5013 
5014   ///
5015   /// Destroy a region.
5016   ///
5017   static void destroy(dbRegion* region);
5018 
5019   ///
5020   /// Destroy a region.
5021   ///
5022   static dbSet<dbRegion>::iterator destroy(dbSet<dbRegion>::iterator& itr);
5023 
5024   ///
5025   /// Translate a database-id back to a pointer.
5026   ///
5027   static dbRegion* getRegion(dbBlock* block, uint oid);
5028 };
5029 
5030 ///////////////////////////////////////////////////////////////////////////////
5031 ///
5032 /// A Library is the element that represents a collection of library-cells,
5033 /// called Masters.
5034 ///
5035 ///////////////////////////////////////////////////////////////////////////////
5036 class dbLib : public dbObject
5037 {
5038  public:
5039   ///
5040   /// Get the library name.
5041   ///
5042   std::string getName();
5043 
5044   ///
5045   /// Get the library name.
5046   ///
5047   const char* getConstName();
5048 
5049   ///
5050   /// Get the Database units per micron.
5051   ///
5052   int getDbUnitsPerMicron();
5053 
5054   ///
5055   /// Get the technology of this library
5056   ///
5057   dbTech* getTech();
5058 
5059   ///
5060   /// Get the master-cells of this library
5061   ///
5062   dbSet<dbMaster> getMasters();
5063 
5064   ///
5065   /// Finds a specific master-cell in the library
5066   /// Returns NULL if the object was not found.
5067   ///
5068   dbMaster* findMaster(const char* name);
5069 
5070   ///
5071   /// Get the sites of this library
5072   ///
5073   dbSet<dbSite> getSites();
5074 
5075   ///
5076   /// Finds a specific site in the library
5077   /// Returns NULL if the object was not found.
5078   ///
5079   dbSite* findSite(const char* name);
5080 
5081   ///
5082   /// Get the LEF units of this technology.
5083   ///
5084   int getLefUnits();
5085 
5086   ///
5087   /// Set the LEF units of this technology.
5088   ///
5089   void setLefUnits(int units);
5090 
5091   ///
5092   /// Get the HierarchyDelimeter.
5093   /// Returns (0) if the delimeter was not set.
5094   /// A hierarchy delimeter can only be set at the time
5095   /// a library is created.
5096   ///
5097   char getHierarchyDelimeter();
5098 
5099   ///
5100   /// Set the Bus name delimeters
5101   ///
5102   void setBusDelimeters(char left, char right);
5103 
5104   ///
5105   /// Get the Bus name delimeters
5106   /// Left and Right are set to "zero" if the bus delimeters
5107   /// were not set.
5108   ///
5109   void getBusDelimeters(char& left, char& right);
5110 
5111   ///
5112   /// Create a new library.
5113   ///
5114   static dbLib* create(dbDatabase* db,
5115                        const char* name,
5116                        char hierarchy_delimeter = 0);
5117 
5118   ///
5119   /// Translate a database-id back to a pointer.
5120   ///
5121   static dbLib* getLib(dbDatabase* db, uint oid);
5122 
5123   ///
5124   /// Destroy a library.
5125   ///
5126   static void destroy(dbLib* lib);
5127 };
5128 
5129 ///////////////////////////////////////////////////////////////////////////////
5130 ///
5131 /// A Site is the element that represents a placement site for cells in this
5132 /// library.
5133 ///
5134 ///////////////////////////////////////////////////////////////////////////////
5135 class dbSite : public dbObject
5136 {
5137  public:
5138   ///
5139   /// Get the site name.
5140   ///
5141   std::string getName();
5142 
5143   ///
5144   /// Get the site name.
5145   ///
5146   const char* getConstName();
5147 
5148   ///
5149   /// Get the width of this site
5150   ///
5151   uint getWidth();
5152 
5153   ///
5154   /// Set the width of this site
5155   ///
5156   void setWidth(uint width);
5157 
5158   ///
5159   /// Get the height of this site
5160   ///
5161   uint getHeight();
5162 
5163   ///
5164   /// Set the height of this site
5165   ///
5166   void setHeight(uint height);
5167 
5168   ///
5169   /// Get the class of this site.
5170   ///
5171   dbSiteClass getClass();
5172 
5173   ///
5174   /// Set the class of this site
5175   ///
5176   void setClass(dbSiteClass site_class);
5177 
5178   ///
5179   /// Mark that this site has X-Symmetry
5180   ///
5181   void setSymmetryX();
5182 
5183   ///
5184   /// Returns true if this site has X-Symmetry
5185   ///
5186   bool getSymmetryX();
5187 
5188   ///
5189   /// Mark that this site has Y-Symmetry
5190   ///
5191   void setSymmetryY();
5192 
5193   ///
5194   /// Returns true if this site has Y-Symmetry
5195   ///
5196   bool getSymmetryY();
5197 
5198   ///
5199   /// Mark that this site has R90-Symmetry
5200   ///
5201   void setSymmetryR90();
5202 
5203   ///
5204   /// Returns true if this site has R90-Symmetry
5205   ///
5206   bool getSymmetryR90();
5207 
5208   ///
5209   /// Get the library of this site.
5210   ///
5211   dbLib* getLib();
5212 
5213   ///
5214   /// Create a new site.
5215   /// Returns NULL if a site with this name already exists
5216   ///
5217   static dbSite* create(dbLib* lib, const char* name);
5218 
5219   ///
5220   /// Translate a database-id back to a pointer.
5221   ///
5222   static dbSite* getSite(dbLib* lib, uint oid);
5223 };
5224 
5225 ///////////////////////////////////////////////////////////////////////////////
5226 ///
5227 /// A Master is the element that represents a master-cell from the library.
5228 ///
5229 ///////////////////////////////////////////////////////////////////////////////
5230 class dbMaster : public dbObject
5231 {
5232  public:
5233   ///
5234   /// Get the master cell name.
5235   ///
5236   std::string getName();
5237 
5238   ///
5239   /// Get the master cell name.
5240   ///
5241   const char* getConstName();
5242 
5243   ///
5244   /// Get the x,y origin of this master
5245   ///
5246   void getOrigin(int& x, int& y);
5247 
5248   ///
5249   /// Set the x,y origin of this master, default is (0,0)
5250   ///
5251   void setOrigin(int x, int y);
5252 
5253   ///
5254   /// Get the width of this master cell.
5255   ///
5256   uint getWidth() const;
5257 
5258   ///
5259   /// Set the width of this master cell.
5260   ///
5261   void setWidth(uint width);
5262 
5263   ///
5264   /// Get the height of this master cell.
5265   ///
5266   uint getHeight() const;
5267 
5268   ///
5269   /// Set the height of this master cell.
5270   ///
5271   void setHeight(uint height);
5272 
5273   ///
5274   /// is filler cell
5275   ///
5276   bool isFiller();
5277 
5278   ///
5279   /// Get the type of this master cell
5280   ///
5281   dbMasterType getType() const;
5282 
5283   ///
5284   /// Is the type BLOCK or any of its subtypes
5285   ///
isBlock()5286   bool isBlock() const { return getType().isBlock(); }
5287 
5288   ///
5289   /// Is the type CORE or any of its subtypes
5290   ///
isCore()5291   bool isCore() const { return getType().isCore(); }
5292 
5293   ///
5294   /// Is the type PAD or any of its subtypes
5295   ///
isPad()5296   bool isPad() const { return getType().isPad(); }
5297 
5298   ///
5299   /// Is the type ENDCAP or any of its subtypes
5300   ///
isEndCap()5301   bool isEndCap() const { return getType().isEndCap(); }
5302 
5303   ///
5304   /// This master can be placed automatically in the core.
5305   /// Pad, ring, cover, and none are false.
5306   ///
5307   bool isCoreAutoPlaceable();
5308 
5309   ///
5310   /// Set the type of this master cell
5311   ///
5312   void setType(dbMasterType type);
5313 
5314   ///
5315   /// Get the Logical equivalent of this master
5316   /// Returns NULL if no equivalent was set.
5317   ///
5318   dbMaster* getLEQ();
5319 
5320   ///
5321   /// Set the Logical equivalent of this master
5322   /// NOTE: When setting the LEQ, the LEQ should be
5323   /// constructed to form a LEQ ring. The database
5324   /// does not enforce this. Typically, if the LEQ is
5325   /// set in the LEF file, than the LEQ's form a ring.
5326   ///
5327   void setLEQ(dbMaster* master);
5328 
5329   ///
5330   /// Get the Electical equivalent of this master
5331   /// Returns NULL if no equivalent was set.
5332   ///
5333   dbMaster* getEEQ();
5334 
5335   ///
5336   /// Set the Electical equivalent of this master
5337   /// NOTE: When setting the EEQ, the EEQ should be
5338   /// constructed to form a EEQ ring. The database
5339   /// does not enforce this. Typically, if the EEQ is
5340   /// set in the LEF file, than the EEQ's form a ring.
5341   ///
5342   void setEEQ(dbMaster* master);
5343 
5344   ///
5345   /// Mark that this site has X-Symmetry
5346   ///
5347   void setSymmetryX();
5348 
5349   ///
5350   /// Returns true if this site has X-Symmetry
5351   ///
5352   bool getSymmetryX();
5353 
5354   ///
5355   /// Mark that this site has Y-Symmetry
5356   ///
5357   void setSymmetryY();
5358 
5359   ///
5360   /// Returns true if this site has Y-Symmetry
5361   ///
5362   bool getSymmetryY();
5363 
5364   ///
5365   /// Mark that this site has R90-Symmetry
5366   ///
5367   void setSymmetryR90();
5368 
5369   ///
5370   /// Returns true if this site has R90-Symmetry
5371   ///
5372   bool getSymmetryR90();
5373 
5374   ///
5375   /// Get the terminals of this master.
5376   ///
5377   dbSet<dbMTerm> getMTerms();
5378 
5379   ///
5380   /// Find a specific master-terminal
5381   /// Returns NULL if the object was not found.
5382   ///
5383   dbMTerm* findMTerm(const char* name);
5384   dbMTerm* findMTerm(dbBlock* block, const char* name);
5385 
5386   ///
5387   /// Get the library of this master.
5388   ///
5389   dbLib* getLib();
5390 
5391   ///
5392   /// Get the obstructions of this master
5393   ///
5394   dbSet<dbBox> getObstructions();
5395 
5396   ///
5397   /// Get the placement bounding box of this master.
5398   ///
5399   void getPlacementBoundary(Rect& r);
5400 
5401   ///
5402   /// Apply the suppiled transform to the master obsutrctions and pin
5403   /// geometries.
5404   ///
5405   void transform(dbTransform& t);
5406 
5407   ///
5408   /// Freeze this master. dbMTerms cannot be added or delete from the master
5409   /// once it is frozen.
5410   ///
5411   void setFrozen();
5412 
5413   ///
5414   /// Returns true if the master is frozen
5415   ///
5416   bool isFrozen();
5417 
5418   int getOutputIndex();
5419   void setOutputIndex(int v);
5420   void setClockedIndex(int v);
5421   int getClockedIndex();
5422 
5423   ///
5424   /// Set _sequential of this master.
5425   ///
5426   void setSequential(uint v);
5427 
5428   ///
5429   /// Returns _sequential this master
5430   ///
5431   bool isSequential();
5432 
5433   ///
5434   /// Set _mark of this master.
5435   ///
5436   void setMark(uint mark);
5437 
5438   ///
5439   /// Returns _mark this master
5440   ///
5441   uint isMarked();
5442 
5443   bool isSpecialPower();
5444   void setSpecialPower(bool v);
5445 
5446   ///
5447   /// Returns the number of mterms of this master.
5448   ///
5449   int getMTermCount();
5450 
5451   ///
5452   /// Set the site of this master.
5453   /// h
5454   void setSite(dbSite* site);
5455 
5456   ///
5457   /// Set the site of this master.
5458   /// Returns NULL if no site has been set.
5459   ///
5460   dbSite* getSite();
5461 
5462   ///
5463   /// Returns a database unique id for this master.
5464   ///
5465   int getMasterId();
5466 
5467   ///
5468   /// Create a new master.
5469   /// Returns NULL if a master with this name already exists
5470   ///
5471   static dbMaster* create(dbLib* lib, const char* name);
5472 
5473   ///
5474   /// Translate a database-id back to a pointer.
5475   ///
5476   static dbMaster* getMaster(dbLib* lib, uint oid);
5477 
5478   void* staCell();
5479   void staSetCell(void* cell);
5480 };
5481 
5482 ///////////////////////////////////////////////////////////////////////////////
5483 ///
5484 /// A MTerm is the element that represents a terminal on a Master.
5485 ///
5486 ///////////////////////////////////////////////////////////////////////////////
5487 class dbMTerm : public dbObject
5488 {
5489  public:
5490   ///
5491   /// Get the master term name.
5492   ///
5493   std::string getName();
5494 
5495   ///
5496   /// Get the master term name.
5497   ///
5498   const char* getConstName();
5499 
5500   ///
5501   /// Get the master term name. Change lib_bus_del to blk_bus_del if needed
5502   ///
5503   char* getName(dbInst* inst, char* ttname);
5504   char* getName(dbBlock* block, dbMaster* master, char* ttname);
5505 
5506   ///
5507   /// Get the signal type of this master-terminal.
5508   ///
5509   dbSigType getSigType();
5510 
5511   ///
5512   /// Get the IO direction of this master-terminal.
5513   ///
5514   dbIoType getIoType();
5515 
5516   ///
5517   /// Set mark of this master-terminal.
5518   ///
5519   void setMark(uint v);
5520 
5521   ///
5522   /// get mark of this master-terminal.
5523   ///
5524   bool isSetMark();
5525 
5526   ///
5527   /// Get the master this master-terminal belongs too.
5528   ///
5529   dbMaster* getMaster();
5530 
5531   ///
5532   /// Get the physical pins of this terminal.
5533   ///
5534   dbSet<dbMPin> getMPins();
5535 
5536   ///
5537   /// Get bbox of this term (ie the bbox of the getMPins())
5538   ///
5539   Rect getBBox();
5540 
5541   ///
5542   /// Get the target points of this terminal.
5543   ///
5544   dbSet<dbTarget> getTargets();
5545 
5546   ///
5547   /// Add antenna info that is not specific to an oxide model.
5548   ///
5549   void addPartialMetalAreaEntry(double inval, dbTechLayer* refly = NULL);
5550   void addPartialMetalSideAreaEntry(double inval, dbTechLayer* refly = NULL);
5551   void addPartialCutAreaEntry(double inval, dbTechLayer* refly = NULL);
5552   void addDiffAreaEntry(double inval, dbTechLayer* refly = NULL);
5553 
5554   ///
5555   /// Antenna info that is specific to an oxide model.
5556   ///
5557   dbTechAntennaPinModel* createDefaultAntennaModel();
5558   dbTechAntennaPinModel* createOxide2AntennaModel();
5559 
5560   ///
5561   /// Access and write antenna rule models -- get functions will return NULL
5562   /// if model not created.
5563   ///
5564   bool hasDefaultAntennaModel() const;
5565   bool hasOxide2AntennaModel() const;
5566   dbTechAntennaPinModel* getDefaultAntennaModel() const;
5567   dbTechAntennaPinModel* getOxide2AntennaModel() const;
5568   void writeAntennaLef(lefout& writer) const;
5569 
5570   // From LEF's ANTENNADIFFAREA on the MACRO's PIN
5571   void getDiffArea(std::vector<std::pair<double, dbTechLayer*>>& data);
5572 
5573   void* staPort();
5574   void staSetPort(void* port);
5575 
5576   ///
5577   /// Return the index of this mterm on this master.
5578   /// PREQ: master must be frozen.
5579   ///
5580   int getIndex();
5581 
5582   ///
5583   /// Create a new master terminal.
5584   /// Returns NULL if a master terminal with this name already exists
5585   ///
5586   static dbMTerm* create(dbMaster* master,
5587                          const char* name,
5588                          dbIoType io_type = dbIoType(),
5589                          dbSigType sig_type = dbSigType());
5590 
5591   ///
5592   /// Translate a database-id back to a pointer.
5593   ///
5594   static dbMTerm* getMTerm(dbMaster* master, uint oid);
5595 };
5596 
5597 ///////////////////////////////////////////////////////////////////////////////
5598 ///
5599 /// A MPin is the element that represents a physical pin on a master-terminal.
5600 ///
5601 ///////////////////////////////////////////////////////////////////////////////
5602 class dbMPin : public dbObject
5603 {
5604  public:
5605   ///
5606   /// Get the master-terminal this pin belongs too.
5607   ///
5608   dbMTerm* getMTerm();
5609 
5610   ///
5611   /// Get the master this pin belongs too.
5612   ///
5613   dbMaster* getMaster();
5614 
5615   ///
5616   /// Get the geometry of this pin.
5617   ///
5618   dbSet<dbBox> getGeometry();
5619 
5620   ///
5621   /// Get bbox of this pin (ie the bbox of getGeometry())
5622   ///
5623   Rect getBBox();
5624 
5625   ///
5626   /// Create a new physical pin.
5627   ///
5628   static dbMPin* create(dbMTerm* mterm);
5629 
5630   ///
5631   /// Translate a database-id back to a pointer.
5632   ///
5633   static dbMPin* getMPin(dbMaster* master, uint oid);
5634 };
5635 
5636 ///////////////////////////////////////////////////////////////////////////////
5637 ///
5638 /// A Target is the element that represents a physical target point on a MTerm.
5639 ///
5640 ///////////////////////////////////////////////////////////////////////////////
5641 class dbTarget : public dbObject
5642 {
5643  public:
5644   ///
5645   /// Get the master this target belongs too.
5646   ///
5647   dbMaster* getMaster();
5648 
5649   ///
5650   /// Get the mterm this target
5651   ///
5652   dbMTerm* getMTerm();
5653 
5654   ///
5655   /// Get the tech-layer this target
5656   ///
5657   dbTechLayer* getTechLayer();
5658 
5659   ///
5660   /// Get the target point of this target.
5661   ///
5662   Point getPoint();
5663 
5664   ///
5665   /// Create a new master terminal.
5666   /// Returns NULL if a master terminal with this name already exists
5667   ///
5668   static dbTarget* create(dbMTerm* mterm, dbTechLayer* layer, Point point);
5669 
5670   ///
5671   /// Destroy a target
5672   ///
5673   static void destroy(dbTarget* t);
5674 
5675   ///
5676   /// Destroy a target
5677   ///
5678   static dbSet<dbTarget>::iterator destroy(dbSet<dbTarget>::iterator& itr);
5679 
5680   ///
5681   /// Translate a database-id back to a pointer.
5682   ///
5683   static dbTarget* getTarget(dbMaster* master, uint oid);
5684 };
5685 
5686 ///////////////////////////////////////////////////////////////////////////////
5687 ///
5688 /// A Tech is the element that represents technology specific data.
5689 ///
5690 ///////////////////////////////////////////////////////////////////////////////
5691 class dbTech : public dbObject
5692 {
5693  public:
5694   ///
5695   /// Set the Database distance units per micron.
5696   ///
5697   /// Legal values are 100, 200, 1000, 2000, 10000, 20000
5698   ///
5699   void setDbUnitsPerMicron(int value);
5700 
5701   ///
5702   /// Get the Database units per micron.
5703   ///
5704   int getDbUnitsPerMicron();
5705 
5706   ///
5707   /// Get the technolgy layers. The layers are ordered from the
5708   /// bottom mask number to the top mask number.
5709   ///
5710   dbSet<dbTechLayer> getLayers();
5711 
5712   ///
5713   /// Find the technology layer.
5714   /// Returns NULL if the object was not found.
5715   ///
5716   dbTechLayer* findLayer(const char* name);
5717 
5718   ///
5719   /// Find the technology layer.
5720   /// Returns NULL if the object was not found.
5721   ///
5722   dbTechLayer* findLayer(int layer_number);
5723 
5724   ///
5725   /// Find the technology routing layer.
5726   /// Returns NULL if the object was not found.
5727   ///
5728   dbTechLayer* findRoutingLayer(int level_number);
5729 
5730   ///
5731   /// Get the technolgy vias. This includes non-default-rule-vias.
5732   ///
5733   dbSet<dbTechVia> getVias();
5734 
5735   ///
5736   /// Find the technology via.
5737   /// Returns NULL if the object was not found.
5738   ///
5739   dbTechVia* findVia(const char* name);
5740 
5741   ///
5742   /// Get the LEF units of this technology.
5743   ///
5744   int getLefUnits();
5745 
5746   ///
5747   /// Set the LEF units of this technology.
5748   ///
5749   void setLefUnits(int units);
5750 
5751   ///
5752   /// Get the LEF version in this technology as a number or as a string.
5753   ///
5754   double getLefVersion() const;
5755   const char* getLefVersionStr() const;
5756 
5757   ///
5758   /// Set the LEF version of this technology, in both number and string form.
5759   ///
5760   void setLefVersion(double inver);
5761 
5762   ///
5763   ///  Get and set the NOWIREEXTENSIONATPIN construct
5764   ///
5765   bool hasNoWireExtAtPin() const;
5766   dbOnOffType getNoWireExtAtPin() const;
5767   void setNoWireExtAtPin(dbOnOffType intyp);
5768 
5769   ///
5770   ///  Get and set the NAMESCASESENSITIVE construct
5771   ///
5772   dbOnOffType getNamesCaseSensitive() const;
5773   void setNamesCaseSensitive(dbOnOffType intyp);
5774 
5775   ///
5776   /// Handle LEF CLEARANCEMEASURE construct
5777   ///
5778   bool hasClearanceMeasure() const;
5779   dbClMeasureType getClearanceMeasure() const;
5780   void setClearanceMeasure(dbClMeasureType inmeas);
5781 
5782   ///
5783   /// Handle LEF USEMINSPACING for pins and obstruction separately.
5784   ///
5785   bool hasUseMinSpacingObs() const;
5786   dbOnOffType getUseMinSpacingObs() const;
5787   void setUseMinSpacingObs(dbOnOffType inval);
5788 
5789   bool hasUseMinSpacingPin() const;
5790   dbOnOffType getUseMinSpacingPin() const;
5791   void setUseMinSpacingPin(dbOnOffType inval);
5792 
5793   ///
5794   ///  Handle MANUFACTURINGGRID construct
5795   ///  NOTE: Assumes conversion to internal DB units,
5796   ///  NOT microns or LEF/DEF units
5797   ///
5798   bool hasManufacturingGrid() const;
5799   int getManufacturingGrid() const;
5800   void setManufacturingGrid(int ingrd);
5801 
5802   ///
5803   /// Get the number of layers in this technology.
5804   ///
5805   int getLayerCount();
5806 
5807   ///
5808   /// Get the number of routing-layers in this technology.
5809   ///
5810   int getRoutingLayerCount();
5811 
5812   ///
5813   /// Get the number of vias in this technolgy.
5814   ///
5815   int getViaCount();
5816 
5817   ///
5818   /// Get the non-default rules
5819   ///
5820   dbSet<dbTechNonDefaultRule> getNonDefaultRules();
5821 
5822   ///
5823   /// Find a specific rule
5824   ///
5825   dbTechNonDefaultRule* findNonDefaultRule(const char* rulename);
5826 
5827   ///
5828   /// Find a specific rule
5829   /// Returns NULL if no rule exists.
5830   ///
5831   dbTechSameNetRule* findSameNetRule(dbTechLayer* l1, dbTechLayer* l2);
5832 
5833   ///
5834   /// Get the same-net rules of this non-default rule.
5835   ///
5836   void getSameNetRules(std::vector<dbTechSameNetRule*>& rules);
5837 
5838   ///
5839   ///
5840   ///
5841   dbSet<dbTechViaRule> getViaRules();
5842 
5843   ///
5844   ///
5845   ///
5846   dbSet<dbTechViaGenerateRule> getViaGenerateRules();
5847 
5848   ///
5849   ///
5850   ///
5851   dbTechViaRule* findViaRule(const char* name);
5852 
5853   ///
5854   ///
5855   ///
5856   dbTechViaGenerateRule* findViaGenerateRule(const char* name);
5857 
5858   ///
5859   ///
5860   ///
5861   void checkLayer(bool typeChk, bool widthChk, bool pitchChk, bool spacingChk);
5862 
5863   ///
5864   /// Create a new technology.
5865   /// Returns NULL if a database technology already exists
5866   ///
5867   static dbTech* create(dbDatabase* db, int dbu_per_micron = 1000);
5868 
5869   ///
5870   /// Translate a database-id back to a pointer.
5871   ///
5872   static dbTech* getTech(dbDatabase* db, uint oid);
5873 
5874   ///
5875   /// Destroy a technology.
5876   /// TODO: Define what happens to the libs and the chip.
5877   ///
5878   static void destroy(dbTech* tech);
5879 };
5880 
5881 ///////////////////////////////////////////////////////////////////////////////
5882 ///
5883 /// A TechVia is the element that represents a specific process VIA in
5884 /// a technolgy.
5885 ///
5886 ///////////////////////////////////////////////////////////////////////////////
5887 class dbTechVia : public dbObject
5888 {
5889  public:
5890   ///
5891   /// Get the via name.
5892   ///
5893   std::string getName();
5894 
5895   ///
5896   /// Get the via name.
5897   ///
5898   const char* getConstName();
5899 
5900   ///
5901   /// Returns true if this via is a default
5902   ///
5903   bool isDefault();
5904 
5905   ///
5906   /// Set the default flag to true.
5907   ///
5908   void setDefault();
5909 
5910   ///
5911   /// Returns true if this via is a top-of-stack
5912   ///
5913   bool isTopOfStack();
5914 
5915   ///
5916   /// Set the top-of-stack flag to true.
5917   ///
5918   void setTopOfStack();
5919 
5920   ///
5921   /// Get the resitance per square nm
5922   ///
5923   double getResistance();
5924 
5925   ///
5926   /// Set the resitance per square nm
5927   ///
5928   void setResistance(double res);
5929 
5930   ///
5931   /// Set the pattern value of this via.
5932   /// The pattern is ignored if the pattern is already set on this via
5933   ///
5934   void setPattern(const char* pattern);
5935 
5936   ///
5937   /// Get the pattern value of this via.
5938   /// Returns and empty ("") string if a pattern has not been set.
5939   ///
5940   std::string getPattern();
5941 
5942   ///
5943   /// Set generate rule that was used to genreate this via.
5944   ///
5945   void setViaGenerateRule(dbTechViaGenerateRule* rule);
5946 
5947   ///
5948   /// Get the generate rule that was used to genreate this via.
5949   ///
5950   dbTechViaGenerateRule* getViaGenerateRule();
5951 
5952   ///
5953   /// Returns true if this via has params.
5954   ///
5955   bool hasParams();
5956 
5957   ///
5958   /// Set via params to generate this via. This method will create the shapes
5959   /// of this via. All previous shapes are destroyed.
5960   ///
5961   void setViaParams(const dbViaParams& params);
5962 
5963   ///
5964   /// Get the via params used to generate this via.
5965   ///
5966   void getViaParams(dbViaParams& params_return);
5967 
5968   ///
5969   /// Get the technology this via belongs too.
5970   ///
5971   dbTech* getTech();
5972 
5973   ///
5974   /// Get the bbox of this via.
5975   /// Returns NULL if this via has no shapes.
5976   ///
5977   dbBox* getBBox();
5978 
5979   ///
5980   /// Get the boxes of this VIA
5981   ///
5982   dbSet<dbBox> getBoxes();
5983 
5984   ///
5985   /// Get the upper-most layer of this via reaches
5986   /// Returns NULL if this via has no shapes.
5987   ///
5988   dbTechLayer* getTopLayer();
5989 
5990   ///
5991   /// Get the lower-most layer of this via reaches
5992   /// Returns NULL if this via has no shapes.
5993   ///
5994   dbTechLayer* getBottomLayer();
5995 
5996   ///
5997   /// Returns the non-default rule this via belongs too.
5998   /// Returns NULL if this via is not part of a non-default rule.
5999   ///
6000   dbTechNonDefaultRule* getNonDefaultRule();
6001 
6002   ///
6003   /// Create a new via.
6004   /// Returns NULL if a via with this name already exists.
6005   ///
6006   static dbTechVia* create(dbTech* tech, const char* name);
6007 
6008   ///
6009   /// Create a new non-default-rule via.
6010   /// Returns NULL if a via with this name already exists.
6011   ///
6012   static dbTechVia* create(dbTechNonDefaultRule* rule, const char* name);
6013   ///
6014   /// Create a new non-default-rule via by cloning an existing via (not
6015   /// necessarily from the same non-default rule
6016   /// Returns NULL if a via with this name already exists.
6017   ///
6018   static dbTechVia* clone(dbTechNonDefaultRule* rule,
6019                           dbTechVia* invia_,
6020                           const char* new_name);
6021 
6022   ///
6023   /// Translate a database-id back to a pointer.
6024   ///
6025   static dbTechVia* getTechVia(dbTech* tech, uint oid);
6026 };
6027 
6028 ///////////////////////////////////////////////////////////////////////////////
6029 ///
6030 /// A TechViaRule is the element that represents a LEF VIARULE
6031 ///
6032 ///////////////////////////////////////////////////////////////////////////////
6033 class dbTechViaRule : public dbObject
6034 {
6035  public:
6036   ///
6037   /// Get the via-rule name.
6038   ///
6039   std::string getName();
6040 
6041   ///
6042   /// Add this via to this rule
6043   ///
6044   void addVia(dbTechVia* via);
6045 
6046   ///
6047   /// Get the number of vias assigned to this rule
6048   ///
6049   uint getViaCount();
6050 
6051   ///
6052   /// Return the via of this index. The index ranges from [0 ... (viaCount-1)]
6053   ///
6054   dbTechVia* getVia(uint indx);
6055 
6056   ///
6057   /// Get the number of layer-rules assigned to this rule
6058   ///
6059   uint getViaLayerRuleCount();
6060 
6061   ///
6062   /// Return the layer-rule of this index. The index ranges from [0 ...
6063   /// (viaCount-1)]
6064   ///
6065   dbTechViaLayerRule* getViaLayerRule(uint indx);
6066 
6067   ///
6068   /// Create a new via.
6069   /// Returns NULL if a via-rule with this name already exists.
6070   ///
6071   static dbTechViaRule* create(dbTech* tech, const char* name);
6072 
6073   ///
6074   /// Translate a database-id back to a pointer.
6075   ///
6076   static dbTechViaRule* getTechViaRule(dbTech* tech, uint oid);
6077 };
6078 
6079 ///////////////////////////////////////////////////////////////////////////////
6080 ///
6081 /// A TechViaLayerRule is the element that represents a LEF VIARULE LAYER
6082 ///
6083 ///////////////////////////////////////////////////////////////////////////////
6084 class dbTechViaLayerRule : public dbObject
6085 {
6086  public:
6087   ///
6088   /// Get the layer
6089   ///
6090   dbTechLayer* getLayer();
6091 
6092   ///
6093   /// Get the rule direction
6094   ///
6095   dbTechLayerDir getDirection();
6096 
6097   ///
6098   /// Set the rule direction
6099   ///
6100   void setDirection(dbTechLayerDir dir);
6101 
6102   ///
6103   /// Returns true if width rule is set
6104   ///
6105   bool hasWidth();
6106 
6107   ///
6108   /// Returns the width rule
6109   ///
6110   void getWidth(int& minWidth, int& maxWidth);
6111 
6112   ///
6113   /// Set the width rule
6114   ///
6115   void setWidth(int minWidth, int maxWidth);
6116 
6117   ///
6118   /// Returns true if the enclosure rule is set.
6119   ///
6120   bool hasEnclosure();
6121 
6122   ///
6123   /// Returns the enclosure rule
6124   ///
6125   void getEnclosure(int& overhang1, int& overhang2);
6126 
6127   ///
6128   /// Set the enclosure rule
6129   ///
6130   void setEnclosure(int overhang1, int overhang2);
6131 
6132   ///
6133   /// Returns true if the overhang rule is set.
6134   ///
6135   bool hasOverhang();
6136 
6137   ///
6138   /// Returns the overhang rule
6139   ///
6140   int getOverhang();
6141 
6142   ///
6143   /// Set the overhang rule
6144   ///
6145   void setOverhang(int overhang);
6146 
6147   ///
6148   /// Returns true if the metal-overhang rule is set.
6149   ///
6150   bool hasMetalOverhang();
6151 
6152   ///
6153   /// Returns the overhang rule
6154   ///
6155   int getMetalOverhang();
6156 
6157   ///
6158   /// Set the overhang rule
6159   ///
6160   void setMetalOverhang(int overhang);
6161 
6162   ///
6163   /// returns true if the rect rule is set
6164   ///
6165   bool hasRect();
6166 
6167   ///
6168   /// Get the rect rule
6169   ///
6170   void getRect(Rect& r);
6171 
6172   ///
6173   /// Set the rect rule
6174   ///
6175   void setRect(const Rect& r);
6176 
6177   ///
6178   /// returns true if the spacing rule is set
6179   ///
6180   bool hasSpacing();
6181 
6182   ///
6183   /// Get the spacing rule.
6184   ///
6185   void getSpacing(int& x_spacing, int& y_spacing);
6186 
6187   ///
6188   /// Set the spacing rule.
6189   ///
6190   void setSpacing(int x_spacing, int y_spacing);
6191 
6192   ///
6193   /// Returns true if the resistance rule is set.
6194   ///
6195   bool hasResistance();
6196 
6197   ///
6198   /// Set the resistance
6199   ///
6200   void setResistance(double r);
6201 
6202   ///
6203   /// Get the resistance
6204   ///
6205   double getResistance();
6206 
6207   ///
6208   /// Create a new via-layer_rule.
6209   ///
6210   static dbTechViaLayerRule* create(dbTech* tech,
6211                                     dbTechViaRule* rule,
6212                                     dbTechLayer* layer);
6213 
6214   ///
6215   /// Create a new via-layer_rule.
6216   ///
6217   static dbTechViaLayerRule* create(dbTech* tech,
6218                                     dbTechViaGenerateRule* rule,
6219                                     dbTechLayer* layer);
6220 
6221   ///
6222   /// Translate a database-id back to a pointer.
6223   ///
6224   static dbTechViaLayerRule* getTechViaLayerRule(dbTech* tech, uint oid);
6225 };
6226 
6227 ///////////////////////////////////////////////////////////////////////////////
6228 ///
6229 /// A TechViaGenerateRule is the element that represents a LEF VIARULE GENERATE
6230 ///
6231 ///////////////////////////////////////////////////////////////////////////////
6232 class dbTechViaGenerateRule : public dbObject
6233 {
6234  public:
6235   ///
6236   /// Get the via-rule name.
6237   ///
6238   std::string getName();
6239 
6240   ///
6241   /// Returns true if this is the default rule.
6242   ///
6243   bool isDefault();
6244 
6245   ///
6246   /// Get the number of layer-rules assigned to this rule
6247   ///
6248   uint getViaLayerRuleCount();
6249 
6250   ///
6251   /// Return the layer-rule of this index. The index ranges from [0 ...
6252   /// (viaCount-1)]
6253   ///
6254   dbTechViaLayerRule* getViaLayerRule(uint indx);
6255 
6256   ///
6257   /// Create a new via.
6258   /// Returns NULL if a via-rule with this name already exists.
6259   ///
6260   static dbTechViaGenerateRule* create(dbTech* tech,
6261                                        const char* name,
6262                                        bool is_default);
6263 
6264   ///
6265   /// Translate a database-id back to a pointer.
6266   ///
6267   static dbTechViaGenerateRule* getTechViaGenerateRule(dbTech* tech, uint oid);
6268 };
6269 
6270 ///////////////////////////////////////////////////////////////////////////////
6271 ///
6272 /// A TechLayerSpacingRule stores a design rule in LEF V5.4 format.
6273 /// These are bound to layers -- a layer may have several design rules to
6274 /// describe required spacing among different widths and parallel lengths.
6275 ///
6276 ///////////////////////////////////////////////////////////////////////////////
6277 
6278 class dbTechLayerSpacingRule : public dbObject
6279 {
6280  public:
6281   /// Combine data and predicates for elements of rule
6282   bool isUnconditional() const;
6283   uint getSpacing() const;
6284   bool getLengthThreshold(uint& threshold) const;
6285   bool getLengthThresholdRange(uint& rmin, uint& rmax) const;
6286   bool getRange(uint& rmin, uint& rmax) const;
6287   void setSpacingNotchLengthValid(bool val);
6288   void setSpacingEndOfNotchWidthValid(bool val);
6289   bool hasSpacingNotchLength() const;
6290   bool hasSpacingEndOfNotchWidth() const;
6291   bool hasRange() const;
6292   bool hasLengthThreshold() const;
6293   bool hasUseLengthThreshold() const;
6294   bool getInfluence(uint& influence) const;
6295   bool getInfluenceRange(uint& rmin, uint& rmax) const;
6296   bool getRangeRange(uint& rmin, uint& rmax) const;
6297   bool getAdjacentCuts(uint& numcuts,
6298                        uint& within,
6299                        uint& spacing,
6300                        bool& except_same_pgnet) const;
6301   bool getCutLayer4Spacing(dbTechLayer*& outly) const;
6302   bool getCutStacking() const;
6303   bool getCutCenterToCenter() const;
6304   bool getCutSameNet() const;
6305   bool getCutParallelOverlap() const;
6306   uint getCutArea() const;
6307   void writeLef(lefout& writer) const;
6308 
6309   void setSameNetPgOnly(bool pgonly);
6310   bool getSameNetPgOnly();
6311   void setLengthThreshold(uint threshold);
6312   void setSpacing(uint spacing);
6313   void setLengthThresholdRange(uint rmin, uint rmax);
6314   void setRange(uint rmin, uint rmax);
6315   void setUseLengthThreshold();
6316   void setInfluence(uint influence);
6317   void setInfluenceRange(uint rmin, uint rmax);
6318   void setRangeRange(uint rmin, uint rmax);
6319   void setAdjacentCuts(uint numcuts,
6320                        uint within,
6321                        uint spacing,
6322                        bool except_same_pgnet);
6323   void setCutLayer4Spacing(dbTechLayer* cutly);
6324   void setCutStacking(bool stacking);
6325   void setCutCenterToCenter(bool c2c);
6326   void setCutSameNet(bool same_net);
6327   void setCutParallelOverlap(bool overlap);
6328   void setCutArea(uint area);
6329   void setEol(uint width,
6330               uint within,
6331               bool parallelEdge,
6332               uint parallelSpace,
6333               uint parallelWithin,
6334               bool twoEdges);
6335   bool getEol(uint& width,
6336               uint& within,
6337               bool& parallelEdge,
6338               uint& parallelSpace,
6339               uint& parallelWithin,
6340               bool& twoEdges) const;
6341 
6342   ///
6343   /// Create a new layer spacing rule.
6344   /// Returns pointer to newly created object
6345   ///
6346   static dbTechLayerSpacingRule* create(dbTechLayer* inly);
6347   static dbTechLayerSpacingRule* getTechLayerSpacingRule(dbTechLayer* inly,
6348                                                          uint dbid);
6349 };
6350 
6351 ///////////////////////////////////////////////////////////////////////////////
6352 ///
6353 /// A dbTechMinCutRule stores rules for minimum cuts
6354 /// in LEF V5.5 format.
6355 /// These are bound to layers -- a layer may have several minimum cut rules to
6356 /// describe required cuts at intersections of  different widths and
6357 /// protrusion lengths.
6358 ///
6359 ///////////////////////////////////////////////////////////////////////////////
6360 
6361 class dbTechMinCutRule : public dbObject
6362 {
6363  public:
6364   bool getMinimumCuts(uint& numcuts, uint& width) const;
6365   void setMinimumCuts(uint numcuts,
6366                       uint width,
6367                       bool above_only,
6368                       bool below_only);
6369   bool getCutDistance(uint& cut_distance) const;
6370   void setCutDistance(uint cut_distance);
6371   bool getLengthForCuts(uint& length, uint& distance) const;
6372   void setLengthForCuts(uint length, uint distance);
6373   bool isAboveOnly() const;
6374   bool isBelowOnly() const;
6375   void writeLef(lefout& writer) const;
6376   static dbTechMinCutRule* create(dbTechLayer* inly);
6377   static dbTechMinCutRule* getMinCutRule(dbTechLayer* inly, uint dbid);
6378 };
6379 
6380 ///////////////////////////////////////////////////////////////////////////////
6381 ///
6382 /// A dbTechMinEncRule stores rules for minimum enclosure area
6383 /// in LEF V5.5 format.
6384 /// These are bound to layers -- a layer may have several minimum enclosure
6385 /// rules to describe connections to wires of different widths
6386 ///
6387 ///////////////////////////////////////////////////////////////////////////////
6388 
6389 class dbTechMinEncRule : public dbObject
6390 {
6391  public:
6392   bool getEnclosure(uint& area) const;
6393   void setEnclosure(uint area);
6394   bool getEnclosureWidth(uint& width) const;
6395   void setEnclosureWidth(uint width);
6396   void writeLef(lefout& writer) const;
6397 
6398   static dbTechMinEncRule* create(dbTechLayer* inly);
6399   static dbTechMinEncRule* getMinEncRule(dbTechLayer* inly, uint dbid);
6400 };
6401 
6402 ///////////////////////////////////////////////////////////////////////////////
6403 ///
6404 /// A dbTechV55InfluenceEntry stores an entry in the table for V5.5 format
6405 /// influence spacing rules.
6406 /// Influence spacing in V5.5 describes the required spacing (_spacing) for
6407 /// any wire within a distance (_within) a wire of width (_width).
6408 /// These are bound to layers.
6409 ///
6410 ///////////////////////////////////////////////////////////////////////////////
6411 
6412 class dbTechV55InfluenceEntry : public dbObject
6413 {
6414  public:
6415   bool getV55InfluenceEntry(uint& width, uint& within, uint& spacing) const;
6416   void setV55InfluenceEntry(const uint& width,
6417                             const uint& within,
6418                             const uint& spacing);
6419   void writeLef(lefout& writer) const;
6420 
6421   static dbTechV55InfluenceEntry* create(dbTechLayer* inly);
6422   static dbTechV55InfluenceEntry* getV55InfluenceEntry(dbTechLayer* inly,
6423                                                        uint dbid);
6424 };
6425 
6426 ///////////////////////////////////////////////////////////////////////////////
6427 ///
6428 /// A dbTechLayerAntennaRule expresses a single antenna rule for a given layer.
6429 ///
6430 ///////////////////////////////////////////////////////////////////////////////
6431 
6432 class dbTechLayerAntennaRule : public dbObject
6433 {
6434  public:
6435   bool isValid() const;
6436   void writeLef(lefout& writer) const;
6437 
6438   void setGatePlusDiffFactor(double factor);
6439   void setAreaMinusDiffFactor(double factor);
6440 
6441   void setAreaFactor(double factor, bool diffuse = false);
6442   void setSideAreaFactor(double factor, bool diffuse = false);
6443 
6444   bool hasAreaFactor() const;
6445   bool hasSideAreaFactor() const;
6446 
6447   double getAreaFactor() const;
6448   double getSideAreaFactor() const;
6449 
6450   bool isAreaFactorDiffUseOnly() const;
6451   bool isSideAreaFactorDiffUseOnly() const;
6452 
6453   bool hasAntennaCumRoutingPlusCut() const;
6454   void setAntennaCumRoutingPlusCut(bool value = true);
6455 
6456   // If return value is 0 then the value is unset
6457   double getPAR() const;
6458   double getCAR() const;
6459   double getPSR() const;
6460   double getCSR() const;
6461   double getGatePlusDiffFactor() const;
6462   double getAreaMinusDiffFactor() const;
6463 
6464   void setPAR(double ratio);
6465   void setCAR(double ratio);
6466   void setPSR(double ratio);
6467   void setCSR(double ratio);
6468 
6469   // if indices.size()==0 then these are unset
6470   // if indices.size()==1 then this is a single value rather than a PWL
6471   struct pwl_pair
6472   {
6473     const std::vector<double>& indices;
6474     const std::vector<double>& ratios;
6475   };
6476 
6477   pwl_pair getDiffPAR() const;
6478   pwl_pair getDiffCAR() const;
6479   pwl_pair getDiffPSR() const;
6480   pwl_pair getDiffCSR() const;
6481   pwl_pair getAreaDiffReduce() const;
6482 
6483   // PWL
6484   void setDiffPAR(const std::vector<double>& diff_idx,
6485                   const std::vector<double>& ratios);
6486   void setDiffCAR(const std::vector<double>& diff_idx,
6487                   const std::vector<double>& ratios);
6488   void setDiffPSR(const std::vector<double>& diff_idx,
6489                   const std::vector<double>& ratios);
6490   void setDiffCSR(const std::vector<double>& diff_idx,
6491                   const std::vector<double>& ratios);
6492 
6493   // Single value
6494   void setDiffPAR(double ratio);
6495   void setDiffCAR(double ratio);
6496   void setDiffPSR(double ratio);
6497   void setDiffCSR(double ratio);
6498 
6499   void setAreaDiffReduce(const std::vector<double>& areas,
6500                          const std::vector<double>& factors);
6501 
6502   static dbTechLayerAntennaRule* getAntennaRule(dbTech* inly, uint dbid);
6503 };
6504 
6505 ///////////////////////////////////////////////////////////////////////////////
6506 ///
6507 /// A dbTechAntennaPinModel contains model specific antenna info for a pin
6508 ///
6509 ///////////////////////////////////////////////////////////////////////////////
6510 
6511 class dbTechAntennaPinModel : public dbObject
6512 {
6513  public:
6514   void addGateAreaEntry(double inval, dbTechLayer* refly = NULL);
6515   void addMaxAreaCAREntry(double inval, dbTechLayer* refly = NULL);
6516   void addMaxSideAreaCAREntry(double inval, dbTechLayer* refly = NULL);
6517   void addMaxCutCAREntry(double inval, dbTechLayer* refly = NULL);
6518 
6519   void getGateArea(std::vector<std::pair<double, dbTechLayer*>>& data);
6520   void getMaxAreaCAR(std::vector<std::pair<double, dbTechLayer*>>& data);
6521   void getMaxSideAreaCAR(std::vector<std::pair<double, dbTechLayer*>>& data);
6522   void getMaxCutCAR(std::vector<std::pair<double, dbTechLayer*>>& data);
6523 
6524   void writeLef(dbTech* tech, lefout& writer) const;
6525 
6526   static dbTechAntennaPinModel* getAntennaPinModel(dbMaster* master, uint dbid);
6527 };
6528 
6529 ///////////////////////////////////////////////////////////////////////////////
6530 ///
6531 /// A NonDefaultRule is the element that represents a Non-default technology
6532 /// rule.
6533 ///
6534 ///////////////////////////////////////////////////////////////////////////////
6535 class dbTechNonDefaultRule : public dbObject
6536 {
6537  public:
6538   ///
6539   /// Get the rule name.
6540   ///
6541   std::string getName();
6542 
6543   ///
6544   /// Get the rule name.
6545   ///
6546   const char* getConstName();
6547 
6548   ///
6549   /// Returns true if this rule is a block rule
6550   ///
6551   bool isBlockRule();
6552 
6553   ///
6554   /// Find a specific layer-rule.
6555   /// Returns NULL if there is no layer-rule.
6556   ///
6557   dbTechLayerRule* getLayerRule(dbTechLayer* layer);
6558 
6559   ///
6560   /// Get the vias of this non-default rule.
6561   ///
6562   void getLayerRules(std::vector<dbTechLayerRule*>& layer_rules);
6563 
6564   ///
6565   /// Get the vias of this non-default rule.
6566   ///
6567   void getVias(std::vector<dbTechVia*>& vias);
6568 
6569   ///
6570   /// Find a specific rule
6571   /// Returns NULL if no rule exists.
6572   ///
6573   dbTechSameNetRule* findSameNetRule(dbTechLayer* l1, dbTechLayer* l2);
6574 
6575   ///
6576   /// Get the same-net rules of this non-default rule.
6577   ///
6578   void getSameNetRules(std::vector<dbTechSameNetRule*>& rules);
6579 
6580   /////////////////////////
6581   // 5.6 DEF additions
6582   /////////////////////////
6583 
6584   ///
6585   /// Set the hard spacing rule.
6586   ///
6587   bool getHardSpacing();
6588 
6589   ///
6590   /// Get the hard spacing rule.
6591   ///
6592   void setHardSpacing(bool value);
6593 
6594   ///
6595   ///  Add a use via.
6596   ///
6597   void addUseVia(dbTechVia* via);
6598 
6599   ///
6600   ///  Get vias to use.
6601   ///
6602   void getUseVias(std::vector<dbTechVia*>& vias);
6603 
6604   ///
6605   ///  Add a use via.
6606   ///
6607   void addUseViaRule(dbTechViaGenerateRule* rule);
6608 
6609   ///
6610   ///  Get vias to use.
6611   ///
6612   void getUseViaRules(std::vector<dbTechViaGenerateRule*>& rules);
6613 
6614   ///
6615   /// Assign a minimum number of cuts to this cut-layer
6616   ///
6617   void setMinCuts(dbTechLayer* cut_layer, int count);
6618 
6619   ///
6620   /// Get the minimum number of cuts for this cut-layer.
6621   ///
6622   /// Returns false if a value has not been specified.
6623   ///
6624   bool getMinCuts(dbTechLayer* cut_layer, int& count);
6625 
6626   ///
6627   /// Create a new non-default-rule.
6628   /// Returns NULL if a non-default-rule with this name already exists
6629   ///
6630   static dbTechNonDefaultRule* create(dbTech* tech, const char* name);
6631 
6632   ///
6633   /// Create a new non-default-rule.
6634   /// Returns NULL if a non-default-rule with this name already exists
6635   ///
6636   static dbTechNonDefaultRule* create(dbBlock* block, const char* name);
6637 
6638   ///
6639   /// Translate a database-id back to a pointer.
6640   ///
6641   static dbTechNonDefaultRule* getTechNonDefaultRule(dbTech* tech, uint oid);
6642 
6643   ///
6644   /// Translate a database-id back to a pointer.
6645   ///
6646   static dbTechNonDefaultRule* getTechNonDefaultRule(dbBlock* block, uint oid);
6647 };
6648 
6649 ///////////////////////////////////////////////////////////////////////////////
6650 ///
6651 /// A TechLayerRule is the element that represents a non-default layer
6652 /// rule.
6653 ///
6654 ///////////////////////////////////////////////////////////////////////////////
6655 class dbTechLayerRule : public dbObject
6656 {
6657  public:
6658   ///
6659   /// Get the layer this rule represents
6660   ///
6661   dbTechLayer* getLayer();
6662 
6663   ///
6664   /// Returns true if this rule is a block rule
6665   ///
6666   bool isBlockRule();
6667 
6668   ///
6669   /// Get the non-default-rule this layer-rule belongs too.
6670   ///
6671   dbTechNonDefaultRule* getNonDefaultRule();
6672 
6673   ///
6674   /// Get the minimum path-width.
6675   ///
6676   int getWidth();
6677 
6678   ///
6679   /// Set the minimum path-width.
6680   ///
6681   void setWidth(int width);
6682 
6683   ///
6684   /// Get the minimum object-to-object spacing.
6685   ///
6686   int getSpacing();
6687 
6688   ///
6689   /// Set the minimum object-to-object spacing.
6690   ///
6691   void setSpacing(int spacing);
6692 
6693   ///
6694   /// Get the resitance per square nm
6695   ///
6696   double getResistance();
6697 
6698   ///
6699   /// Set the resitance per square nm
6700   ///
6701   void setResistance(double res);
6702 
6703   ///
6704   /// Get the capacitance per square nm
6705   ///
6706   double getCapacitance();
6707 
6708   ///
6709   /// Set the capacitance per square nm
6710   ///
6711   void setCapacitance(double cap);
6712 
6713   ///
6714   /// Get the edge capacitance
6715   ///
6716   double getEdgeCapacitance();
6717 
6718   ///
6719   /// Set the edge capacitance
6720   ///
6721   void setEdgeCapacitance(double cap);
6722 
6723   ///
6724   /// Get the edge capacitance
6725   ///
6726   uint getWireExtension();
6727 
6728   ///
6729   /// Set the edge capacitance
6730   ///
6731   void setWireExtension(uint ext);
6732 
6733   ///
6734   /// Create a new layer-rule.
6735   /// Returns NULL if a layer-rule for this layer already exists.
6736   ///
6737   static dbTechLayerRule* create(dbTechNonDefaultRule* rule,
6738                                  dbTechLayer* layer);
6739 
6740   ///
6741   /// Translate a database-id back to a pointer.
6742   ///
6743   static dbTechLayerRule* getTechLayerRule(dbTech* tech, uint oid);
6744 
6745   ///
6746   /// Translate a database-id back to a pointer.
6747   ///
6748   static dbTechLayerRule* getTechLayerRule(dbBlock* block, uint oid);
6749 };
6750 
6751 ///////////////////////////////////////////////////////////////////////////////
6752 ///
6753 /// A TechSameNetRule
6754 ///
6755 ///////////////////////////////////////////////////////////////////////////////
6756 class dbTechSameNetRule : public dbObject
6757 {
6758  public:
6759   ///
6760   /// Get the layer this rule represents
6761   ///
6762   dbTechLayer* getLayer1();
6763 
6764   ///
6765   /// Get the layer this rule represents
6766   ///
6767   dbTechLayer* getLayer2();
6768 
6769   ///
6770   /// Get the minimum net-to-net spacing.
6771   ///
6772   int getSpacing();
6773 
6774   ///
6775   /// Set the minimum net-to-net spacing.
6776   ///
6777   void setSpacing(int spacing);
6778 
6779   ///
6780   /// Set the flag to allow stacked vias, the default value is false.
6781   ///
6782   void setAllowStackedVias(bool value);
6783 
6784   ///
6785   /// Get the allow stacked vias flag.
6786   ///
6787   bool getAllowStackedVias();
6788 
6789   ///
6790   /// Create a new default samenet rule.
6791   /// Returns NULL if a rule already exists between these layers.
6792   ///
6793   static dbTechSameNetRule* create(dbTechLayer* layer1, dbTechLayer* layer2);
6794   ///
6795   /// Create a new non-default samenet rule.
6796   /// Returns NULL if a rule already exists between these layers.
6797   ///
6798   static dbTechSameNetRule* create(dbTechNonDefaultRule* rule,
6799                                    dbTechLayer* layer1,
6800                                    dbTechLayer* layer2);
6801 
6802   ///
6803   /// Translate a database-id back to a pointer.
6804   ///
6805   static dbTechSameNetRule* getTechSameNetRule(dbTech* tech, uint oid);
6806 };
6807 
6808 class dbViaParams : private _dbViaParams
6809 // class dbViaParams : public _dbViaParams
6810 {
6811   friend class dbVia;
6812   friend class dbTechVia;
6813   dbTech* _tech;
6814 
6815   dbViaParams(const _dbViaParams& p);
6816 
6817  public:
6818   dbViaParams();
6819   dbViaParams(const dbViaParams& p);
6820   ~dbViaParams();
6821 
6822   int getXCutSize() const;
6823   int getYCutSize() const;
6824   int getXCutSpacing() const;
6825   int getYCutSpacing() const;
6826   int getXTopEnclosure() const;
6827   int getYTopEnclosure() const;
6828   int getXBottomEnclosure() const;
6829   int getYBottomEnclosure() const;
6830   int getNumCutRows() const;
6831   int getNumCutCols() const;
6832   int getXOrigin() const;
6833   int getYOrigin() const;
6834   int getXTopOffset() const;
6835   int getYTopOffset() const;
6836   int getXBottomOffset() const;
6837   int getYBottomOffset() const;
6838   dbTechLayer* getTopLayer() const;
6839   dbTechLayer* getCutLayer() const;
6840   dbTechLayer* getBottomLayer() const;
6841 
6842   void setXCutSize(int value);
6843   void setYCutSize(int value);
6844   void setXCutSpacing(int value);
6845   void setYCutSpacing(int value);
6846   void setXTopEnclosure(int value);
6847   void setYTopEnclosure(int value);
6848   void setXBottomEnclosure(int value);
6849   void setYBottomEnclosure(int value);
6850   void setNumCutRows(int value);
6851   void setNumCutCols(int value);
6852   void setXOrigin(int value);
6853   void setYOrigin(int value);
6854   void setXTopOffset(int value);
6855   void setYTopOffset(int value);
6856   void setXBottomOffset(int value);
6857   void setYBottomOffset(int value);
6858   void setTopLayer(dbTechLayer* layer);
6859   void setCutLayer(dbTechLayer* layer);
6860   void setBottomLayer(dbTechLayer* layer);
6861 };
6862 
6863 // Generator Code Begin ClassDefinition
6864 
6865 class dbTechLayer : public dbObject
6866 {
6867  public:
6868   enum LEF58_TYPE
6869   {
6870     NONE,
6871     NWELL,
6872     PWELL,
6873     ABOVEDIEEDGE,
6874     BELOWDIEEDGE,
6875     DIFFUSION,
6876     TRIMPOLY,
6877     MIMCAP
6878   };
6879   // User Code Begin dbTechLayerEnums
6880   // User Code End dbTechLayerEnums
6881 
6882   dbSet<dbTechLayerCutClassRule> getTechLayerCutClassRules() const;
6883 
6884   dbTechLayerCutClassRule* findTechLayerCutClassRule(const char* name) const;
6885 
6886   dbSet<dbTechLayerSpacingEolRule> getTechLayerSpacingEolRules() const;
6887 
6888   dbSet<dbTechLayerCutSpacingRule> getTechLayerCutSpacingRules() const;
6889 
6890   dbSet<dbTechLayerMinStepRule> getTechLayerMinStepRules() const;
6891 
6892   dbSet<dbTechLayerCornerSpacingRule> getTechLayerCornerSpacingRules() const;
6893 
6894   dbSet<dbTechLayerSpacingTablePrlRule> getTechLayerSpacingTablePrlRules()
6895       const;
6896 
6897   dbSet<dbTechLayerCutSpacingTableOrthRule>
6898   getTechLayerCutSpacingTableOrthRules() const;
6899 
6900   dbSet<dbTechLayerCutSpacingTableDefRule> getTechLayerCutSpacingTableDefRules()
6901       const;
6902 
6903   dbSet<dbTechLayerCutEnclosureRule> getTechLayerCutEnclosureRules() const;
6904 
6905   dbSet<dbTechLayerEolExtensionRule> getTechLayerEolExtensionRules() const;
6906 
6907   dbSet<dbTechLayerEolKeepOutRule> getTechLayerEolKeepOutRules() const;
6908 
6909   void setRectOnly(bool rect_only);
6910 
6911   bool isRectOnly() const;
6912 
6913   void setRightWayOnGridOnly(bool right_way_on_grid_only);
6914 
6915   bool isRightWayOnGridOnly() const;
6916 
6917   void setRightWayOnGridOnlyCheckMask(bool right_way_on_grid_only_check_mask);
6918 
6919   bool isRightWayOnGridOnlyCheckMask() const;
6920 
6921   void setRectOnlyExceptNonCorePins(bool rect_only_except_non_core_pins);
6922 
6923   bool isRectOnlyExceptNonCorePins() const;
6924 
6925   // User Code Begin dbTechLayer
6926   int findV55Spacing(const int width, const int prl) const;
6927 
6928   int findTwSpacing(const int width1, const int width2, const int prl) const;
6929 
6930   void setLef58Type(LEF58_TYPE type);
6931 
6932   LEF58_TYPE getLef58Type() const;
6933 
6934   ///
6935   /// Get the layer name.
6936   ///
6937   std::string getName() const;
6938 
6939   ///
6940   /// Get the layer name.
6941   ///
6942   const char* getConstName() const;
6943 
6944   ///
6945   /// Returns true if this layer has an alias.
6946   ///
6947   bool hasAlias();
6948 
6949   ///
6950   /// Get the layer alias.
6951   ///
6952   std::string getAlias();
6953 
6954   ///
6955   /// Set the layer alias.
6956   ///
6957   void setAlias(const char* alias);
6958 
6959   ///
6960   /// Get the minimum path-width.
6961   ///
6962   uint getWidth() const;
6963   void setWidth(int width);
6964 
6965   ///
6966   /// Get the minimum object-to-object spacing.
6967   ///
6968   int getSpacing();
6969   void setSpacing(int spacing);
6970 
6971   ///
6972   /// Get the minimum spacing to a wide line.
6973   ///
6974   int getSpacing(int width, int length = 0);
6975 
6976   ///
6977   /// The number of masks for this layer (aka double/triple patterning).
6978   /// Allowable values are in [1, 3].
6979   ///
6980   uint getNumMasks() const;
6981   void setNumMasks(uint number);
6982 
6983   ///
6984   /// Get the low end of the uppermost range for wide wire design rules.
6985   ///
6986   void getMaxWideDRCRange(int& owidth, int& olength);
6987   void getMinWideDRCRange(int& owidth, int& olength);
6988 
6989   /// Get the collection of spacing rules for the object, assuming
6990   /// coding in LEF 5.4 format.
6991   /// Return false if rules not encoded in this format.
6992   /// Contents of sp_rules are undefined if function returns false.
6993   ///
6994   bool getV54SpacingRules(dbSet<dbTechLayerSpacingRule>& sp_rules) const;
6995 
6996   ///
6997   /// API for version 5.5 spacing rules, expressed as a 2D matrix with
6998   /// index tables  LEF 5.4 and 5.5 rules should not co-exist -- although
6999   /// this is not enforced here.
7000   /// V5.4 and V5.5 spacing rules are optional -- in this case there is a
7001   /// single spacing value for all length/width combinations.
7002   ///
7003   bool hasV55SpacingRules() const;
7004   bool getV55SpacingWidthsAndLengths(std::vector<uint>& width_idx,
7005                                      std::vector<uint>& length_idx) const;
7006   void printV55SpacingRules(lefout& writer) const;
7007   bool getV55SpacingTable(std::vector<std::vector<uint>>& sptbl) const;
7008 
7009   void initV55LengthIndex(uint numelems);
7010   void addV55LengthEntry(uint length);
7011   void initV55WidthIndex(uint numelems);
7012   void addV55WidthEntry(uint width);
7013   void initV55SpacingTable(uint numrows, uint numcols);
7014   void addV55SpacingTableEntry(uint inrow, uint incol, uint spacing);
7015 
7016   bool getV55InfluenceRules(std::vector<dbTechV55InfluenceEntry*>& inf_tbl);
7017   dbSet<dbTechV55InfluenceEntry> getV55InfluenceEntries();
7018 
7019   ///
7020   /// API for version 5.7 two widths spacing rules, expressed as a 2D matrix
7021   /// with index tables
7022   ///
7023   bool hasTwoWidthsSpacingRules() const;
7024   void printTwoWidthsSpacingRules(lefout& writer) const;
7025   bool getTwoWidthsSpacingTable(std::vector<std::vector<uint>>& sptbl) const;
7026   uint getTwoWidthsSpacingTableNumWidths() const;
7027   uint getTwoWidthsSpacingTableWidth(uint row) const;
7028   bool getTwoWidthsSpacingTableHasPRL(uint row) const;
7029   uint getTwoWidthsSpacingTablePRL(uint row) const;
7030   uint getTwoWidthsSpacingTableEntry(uint row, uint col) const;
7031 
7032   void initTwoWidths(uint num_widths);
7033   void addTwoWidthsIndexEntry(uint width, int parallel_run_length = -1);
7034   void addTwoWidthsSpacingTableEntry(uint inrow, uint incol, uint spacing);
7035   ///
7036   ///  create container for layer specific antenna rules
7037   ///  currently only oxide1 (default) and oxide2 models supported.
7038   ///
7039   dbTechLayerAntennaRule* createDefaultAntennaRule();
7040   dbTechLayerAntennaRule* createOxide2AntennaRule();
7041 
7042   ///
7043   /// Access and write antenna rule models -- get functions will return NULL
7044   /// if model not created.
7045   ///
7046   bool hasDefaultAntennaRule() const;
7047   bool hasOxide2AntennaRule() const;
7048   dbTechLayerAntennaRule* getDefaultAntennaRule() const;
7049   dbTechLayerAntennaRule* getOxide2AntennaRule() const;
7050   void writeAntennaRulesLef(lefout& writer) const;
7051 
7052   ///
7053   ///
7054   /// Get collection of minimum cuts, minimum enclosure rules, if exist
7055   ///
7056   bool getMinimumCutRules(std::vector<dbTechMinCutRule*>& cut_rules);
7057   bool getMinEnclosureRules(std::vector<dbTechMinEncRule*>& enc_rules);
7058 
7059   dbSet<dbTechMinCutRule> getMinCutRules();
7060   dbSet<dbTechMinEncRule> getMinEncRules();
7061 
7062   ///
7063   /// Get/Set the minimum feature size (pitch).
7064   ///
7065   int getPitch();
7066   int getPitchX();
7067   int getPitchY();
7068   void setPitch(int pitch);
7069   void setPitchXY(int pitch_x, int pitch_y);
7070   bool hasXYPitch();
7071 
7072   int getOffset();
7073   int getOffsetX();
7074   int getOffsetY();
7075   void setOffset(int pitch);
7076   void setOffsetXY(int pitch_x, int pitch_y);
7077   bool hasXYOffset();
7078 
7079   ///
7080   ///  Get THICKNESS in DB units, and return indicator of existence.
7081   ///  Do not trust value of output parm if return value is false.
7082   ///
7083   bool getThickness(uint& inthk) const;
7084   void setThickness(uint thickness);
7085 
7086   ///
7087   ///  Get/set AREA parameter.  This interface is used when a
7088   ///  reasonable default exists.
7089   ///
7090   bool hasArea() const;
7091   double getArea() const;
7092   void setArea(double area);
7093 
7094   ///
7095   ///  Get/set MAXWIDTH parameter.  This interface is used when a
7096   ///  reasonable default exists.
7097   ///
7098   bool hasMaxWidth() const;
7099   uint getMaxWidth() const;
7100   void setMaxWidth(uint max_width);
7101 
7102   ///
7103   ///  Get/set min width parameter.
7104   ///
7105   uint getMinWidth() const;
7106   void setMinWidth(uint max_width);
7107 
7108   ///
7109   ///  Get/set MINSTEP parameter.  This interface is used when a
7110   ///  reasonable default exists.
7111   ///
7112   bool hasMinStep() const;
7113   uint getMinStep() const;
7114   void setMinStep(uint min_step);
7115 
7116   dbTechLayerMinStepType getMinStepType() const;
7117   void setMinStepType(dbTechLayerMinStepType type);
7118 
7119   bool hasMinStepMaxLength() const;
7120   uint getMinStepMaxLength() const;
7121   void setMinStepMaxLength(uint length);
7122 
7123   bool hasMinStepMaxEdges() const;
7124   uint getMinStepMaxEdges() const;
7125   void setMinStepMaxEdges(uint edges);
7126 
7127   ///
7128   ///  Get/set PROTRUSIONWIDTH parameter.  This interface is used when a
7129   ///  reasonable default exists.
7130   ///
7131   bool hasProtrusion() const;
7132   uint getProtrusionWidth() const;
7133   uint getProtrusionLength() const;
7134   uint getProtrusionFromWidth() const;
7135   void setProtrusion(uint pt_width, uint pt_length, uint pt_from_width);
7136 
7137   /// Get the layer-type
7138   ///
7139   dbTechLayerType getType();
7140 
7141   ///
7142   /// Get/Set the layer-direction
7143   ///
7144   dbTechLayerDir getDirection();
7145   void setDirection(dbTechLayerDir direction);
7146 
7147   ///
7148   /// Get/Set the resistance (ohms per square for routing layers;
7149   ///                         ohms per cut on via layers)
7150   ///
7151   double getResistance();
7152   void setResistance(double res);
7153 
7154   ///
7155   /// Get/Set the capacitance (pF per square micron)
7156   ///
7157   double getCapacitance();
7158   void setCapacitance(double cap);
7159 
7160   ///
7161   /// Get/Set the edge capacitance (pF per micron)
7162   ///
7163   double getEdgeCapacitance();
7164   void setEdgeCapacitance(double cap);
7165 
7166   ///
7167   /// Get/Set the wire extension
7168   ///
7169   uint getWireExtension();
7170   void setWireExtension(uint ext);
7171 
7172   ///
7173   /// Get mask-order number of this layer.
7174   ///
7175   int getNumber() const;
7176 
7177   ///
7178   /// Get routing-level of this routing layer. The routing level
7179   /// is from [1-num_layers]. This function returns 0, if this
7180   /// layer is not a routing layer.
7181   ///
7182   int getRoutingLevel();
7183 
7184   ///
7185   /// Get the layer below this layer.
7186   /// Returns NULL if at bottom of layer stack.
7187   ///
7188   dbTechLayer* getLowerLayer();
7189 
7190   ///
7191   /// Get the layer above this layer.
7192   /// Returns NULL if at top of layer stack.
7193   ///
7194   dbTechLayer* getUpperLayer();
7195 
7196   ///
7197   /// Get the technology this layer belongs too.
7198   ///
7199   dbTech* getTech();
7200 
7201   ///
7202   /// Create a new layer. The mask order is implicit in the create order.
7203   /// Returns NULL if a layer with this name already exists
7204   ///
7205   static dbTechLayer* create(dbTech* tech,
7206                              const char* name,
7207                              dbTechLayerType type);
7208 
7209   ///
7210   /// Translate a database-id back to a pointer.
7211   ///
7212   static dbTechLayer* getTechLayer(dbTech* tech, uint oid);
7213   // User Code End dbTechLayer
7214 };
7215 
7216 class dbTechLayerSpacingEolRule : public dbObject
7217 {
7218  public:
7219   // User Code Begin dbTechLayerSpacingEolRuleEnums
7220   // User Code End dbTechLayerSpacingEolRuleEnums
7221 
7222   void setEolSpace(int eol_space);
7223 
7224   int getEolSpace() const;
7225 
7226   void setEolWidth(int eol_width);
7227 
7228   int getEolWidth() const;
7229 
7230   void setWrongDirSpace(int wrong_dir_space);
7231 
7232   int getWrongDirSpace() const;
7233 
7234   void setOppositeWidth(int opposite_width);
7235 
7236   int getOppositeWidth() const;
7237 
7238   void setEolWithin(int eol_within);
7239 
7240   int getEolWithin() const;
7241 
7242   void setWrongDirWithin(int wrong_dir_within);
7243 
7244   int getWrongDirWithin() const;
7245 
7246   void setExactWidth(int exact_width);
7247 
7248   int getExactWidth() const;
7249 
7250   void setOtherWidth(int other_width);
7251 
7252   int getOtherWidth() const;
7253 
7254   void setFillTriangle(int fill_triangle);
7255 
7256   int getFillTriangle() const;
7257 
7258   void setCutClass(int cut_class);
7259 
7260   int getCutClass() const;
7261 
7262   void setWithCutSpace(int with_cut_space);
7263 
7264   int getWithCutSpace() const;
7265 
7266   void setEnclosureEndWidth(int enclosure_end_width);
7267 
7268   int getEnclosureEndWidth() const;
7269 
7270   void setEnclosureEndWithin(int enclosure_end_within);
7271 
7272   int getEnclosureEndWithin() const;
7273 
7274   void setEndPrlSpace(int end_prl_space);
7275 
7276   int getEndPrlSpace() const;
7277 
7278   void setEndPrl(int end_prl);
7279 
7280   int getEndPrl() const;
7281 
7282   void setEndToEndSpace(int end_to_end_space);
7283 
7284   int getEndToEndSpace() const;
7285 
7286   void setOneCutSpace(int one_cut_space);
7287 
7288   int getOneCutSpace() const;
7289 
7290   void setTwoCutSpace(int two_cut_space);
7291 
7292   int getTwoCutSpace() const;
7293 
7294   void setExtension(int extension);
7295 
7296   int getExtension() const;
7297 
7298   void setWrongDirExtension(int wrong_dir_extension);
7299 
7300   int getWrongDirExtension() const;
7301 
7302   void setOtherEndWidth(int other_end_width);
7303 
7304   int getOtherEndWidth() const;
7305 
7306   void setMaxLength(int max_length);
7307 
7308   int getMaxLength() const;
7309 
7310   void setMinLength(int min_length);
7311 
7312   int getMinLength() const;
7313 
7314   void setParSpace(int par_space);
7315 
7316   int getParSpace() const;
7317 
7318   void setParWithin(int par_within);
7319 
7320   int getParWithin() const;
7321 
7322   void setParPrl(int par_prl);
7323 
7324   int getParPrl() const;
7325 
7326   void setParMinLength(int par_min_length);
7327 
7328   int getParMinLength() const;
7329 
7330   void setEncloseDist(int enclose_dist);
7331 
7332   int getEncloseDist() const;
7333 
7334   void setCutToMetalSpace(int cut_to_metal_space);
7335 
7336   int getCutToMetalSpace() const;
7337 
7338   void setMinAdjLength(int min_adj_length);
7339 
7340   int getMinAdjLength() const;
7341 
7342   void setMinAdjLength1(int min_adj_length1);
7343 
7344   int getMinAdjLength1() const;
7345 
7346   void setMinAdjLength2(int min_adj_length2);
7347 
7348   int getMinAdjLength2() const;
7349 
7350   void setNotchLength(int notch_length);
7351 
7352   int getNotchLength() const;
7353 
7354   void setExactWidthValid(bool exact_width_valid);
7355 
7356   bool isExactWidthValid() const;
7357 
7358   void setWrongDirSpacingValid(bool wrong_dir_spacing_valid);
7359 
7360   bool isWrongDirSpacingValid() const;
7361 
7362   void setOppositeWidthValid(bool opposite_width_valid);
7363 
7364   bool isOppositeWidthValid() const;
7365 
7366   void setWithinValid(bool within_valid);
7367 
7368   bool isWithinValid() const;
7369 
7370   void setWrongDirWithinValid(bool wrong_dir_within_valid);
7371 
7372   bool isWrongDirWithinValid() const;
7373 
7374   void setSameMaskValid(bool same_mask_valid);
7375 
7376   bool isSameMaskValid() const;
7377 
7378   void setExceptExactWidthValid(bool except_exact_width_valid);
7379 
7380   bool isExceptExactWidthValid() const;
7381 
7382   void setFillConcaveCornerValid(bool fill_concave_corner_valid);
7383 
7384   bool isFillConcaveCornerValid() const;
7385 
7386   void setWithcutValid(bool withcut_valid);
7387 
7388   bool isWithcutValid() const;
7389 
7390   void setCutClassValid(bool cut_class_valid);
7391 
7392   bool isCutClassValid() const;
7393 
7394   void setWithCutAboveValid(bool with_cut_above_valid);
7395 
7396   bool isWithCutAboveValid() const;
7397 
7398   void setEnclosureEndValid(bool enclosure_end_valid);
7399 
7400   bool isEnclosureEndValid() const;
7401 
7402   void setEnclosureEndWithinValid(bool enclosure_end_within_valid);
7403 
7404   bool isEnclosureEndWithinValid() const;
7405 
7406   void setEndPrlSpacingValid(bool end_prl_spacing_valid);
7407 
7408   bool isEndPrlSpacingValid() const;
7409 
7410   void setPrlValid(bool prl_valid);
7411 
7412   bool isPrlValid() const;
7413 
7414   void setEndToEndValid(bool end_to_end_valid);
7415 
7416   bool isEndToEndValid() const;
7417 
7418   void setCutSpacesValid(bool cut_spaces_valid);
7419 
7420   bool isCutSpacesValid() const;
7421 
7422   void setExtensionValid(bool extension_valid);
7423 
7424   bool isExtensionValid() const;
7425 
7426   void setWrongDirExtensionValid(bool wrong_dir_extension_valid);
7427 
7428   bool isWrongDirExtensionValid() const;
7429 
7430   void setOtherEndWidthValid(bool other_end_width_valid);
7431 
7432   bool isOtherEndWidthValid() const;
7433 
7434   void setMaxLengthValid(bool max_length_valid);
7435 
7436   bool isMaxLengthValid() const;
7437 
7438   void setMinLengthValid(bool min_length_valid);
7439 
7440   bool isMinLengthValid() const;
7441 
7442   void setTwoSidesValid(bool two_sides_valid);
7443 
7444   bool isTwoSidesValid() const;
7445 
7446   void setEqualRectWidthValid(bool equal_rect_width_valid);
7447 
7448   bool isEqualRectWidthValid() const;
7449 
7450   void setParallelEdgeValid(bool parallel_edge_valid);
7451 
7452   bool isParallelEdgeValid() const;
7453 
7454   void setSubtractEolWidthValid(bool subtract_eol_width_valid);
7455 
7456   bool isSubtractEolWidthValid() const;
7457 
7458   void setParPrlValid(bool par_prl_valid);
7459 
7460   bool isParPrlValid() const;
7461 
7462   void setParMinLengthValid(bool par_min_length_valid);
7463 
7464   bool isParMinLengthValid() const;
7465 
7466   void setTwoEdgesValid(bool two_edges_valid);
7467 
7468   bool isTwoEdgesValid() const;
7469 
7470   void setSameMetalValid(bool same_metal_valid);
7471 
7472   bool isSameMetalValid() const;
7473 
7474   void setNonEolCornerOnlyValid(bool non_eol_corner_only_valid);
7475 
7476   bool isNonEolCornerOnlyValid() const;
7477 
7478   void setParallelSameMaskValid(bool parallel_same_mask_valid);
7479 
7480   bool isParallelSameMaskValid() const;
7481 
7482   void setEncloseCutValid(bool enclose_cut_valid);
7483 
7484   bool isEncloseCutValid() const;
7485 
7486   void setBelowValid(bool below_valid);
7487 
7488   bool isBelowValid() const;
7489 
7490   void setAboveValid(bool above_valid);
7491 
7492   bool isAboveValid() const;
7493 
7494   void setCutSpacingValid(bool cut_spacing_valid);
7495 
7496   bool isCutSpacingValid() const;
7497 
7498   void setAllCutsValid(bool all_cuts_valid);
7499 
7500   bool isAllCutsValid() const;
7501 
7502   void setToConcaveCornerValid(bool to_concave_corner_valid);
7503 
7504   bool isToConcaveCornerValid() const;
7505 
7506   void setMinAdjacentLengthValid(bool min_adjacent_length_valid);
7507 
7508   bool isMinAdjacentLengthValid() const;
7509 
7510   void setTwoMinAdjLengthValid(bool two_min_adj_length_valid);
7511 
7512   bool isTwoMinAdjLengthValid() const;
7513 
7514   void setToNotchLengthValid(bool to_notch_length_valid);
7515 
7516   bool isToNotchLengthValid() const;
7517 
7518   // User Code Begin dbTechLayerSpacingEolRule
7519   static dbTechLayerSpacingEolRule* create(dbTechLayer* layer);
7520 
7521   static dbTechLayerSpacingEolRule* getTechLayerSpacingEolRule(
7522       dbTechLayer* inly,
7523       uint dbid);
7524 
7525   static void destroy(dbTechLayerSpacingEolRule* rule);
7526   // User Code End dbTechLayerSpacingEolRule
7527 };
7528 
7529 class dbTechLayerMinStepRule : public dbObject
7530 {
7531  public:
7532   // User Code Begin dbTechLayerMinStepRuleEnums
7533   // User Code End dbTechLayerMinStepRuleEnums
7534 
7535   void setMinStepLength(int min_step_length);
7536 
7537   int getMinStepLength() const;
7538 
7539   void setMaxEdges(uint max_edges);
7540 
7541   uint getMaxEdges() const;
7542 
7543   void setMinAdjLength1(int min_adj_length1);
7544 
7545   int getMinAdjLength1() const;
7546 
7547   void setMinAdjLength2(int min_adj_length2);
7548 
7549   int getMinAdjLength2() const;
7550 
7551   void setEolWidth(int eol_width);
7552 
7553   int getEolWidth() const;
7554 
7555   void setMinBetweenLength(int min_between_length);
7556 
7557   int getMinBetweenLength() const;
7558 
7559   void setMaxEdgesValid(bool max_edges_valid);
7560 
7561   bool isMaxEdgesValid() const;
7562 
7563   void setMinAdjLength1Valid(bool min_adj_length1_valid);
7564 
7565   bool isMinAdjLength1Valid() const;
7566 
7567   void setNoBetweenEol(bool no_between_eol);
7568 
7569   bool isNoBetweenEol() const;
7570 
7571   void setMinAdjLength2Valid(bool min_adj_length2_valid);
7572 
7573   bool isMinAdjLength2Valid() const;
7574 
7575   void setConvexCorner(bool convex_corner);
7576 
7577   bool isConvexCorner() const;
7578 
7579   void setMinBetweenLengthValid(bool min_between_length_valid);
7580 
7581   bool isMinBetweenLengthValid() const;
7582 
7583   void setExceptSameCorners(bool except_same_corners);
7584 
7585   bool isExceptSameCorners() const;
7586 
7587   // User Code Begin dbTechLayerMinStepRule
7588   static dbTechLayerMinStepRule* create(dbTechLayer* layer);
7589 
7590   static dbTechLayerMinStepRule* getTechLayerMinStepRule(dbTechLayer* inly,
7591                                                          uint dbid);
7592 
7593   static void destroy(dbTechLayerMinStepRule* rule);
7594   // User Code End dbTechLayerMinStepRule
7595 };
7596 
7597 class dbTechLayerCornerSpacingRule : public dbObject
7598 {
7599  public:
7600   enum CornerType
7601   {
7602     CONVEXCORNER,
7603     CONCAVECORNER
7604   };
7605   // User Code Begin dbTechLayerCornerSpacingRuleEnums
7606   // User Code End dbTechLayerCornerSpacingRuleEnums
7607 
7608   void setWithin(int within);
7609 
7610   int getWithin() const;
7611 
7612   void setEolWidth(int eol_width);
7613 
7614   int getEolWidth() const;
7615 
7616   void setJogLength(int jog_length);
7617 
7618   int getJogLength() const;
7619 
7620   void setEdgeLength(int edge_length);
7621 
7622   int getEdgeLength() const;
7623 
7624   void setMinLength(int min_length);
7625 
7626   int getMinLength() const;
7627 
7628   void setExceptNotchLength(int except_notch_length);
7629 
7630   int getExceptNotchLength() const;
7631 
7632   void setSameMask(bool same_mask);
7633 
7634   bool isSameMask() const;
7635 
7636   void setCornerOnly(bool corner_only);
7637 
7638   bool isCornerOnly() const;
7639 
7640   void setExceptEol(bool except_eol);
7641 
7642   bool isExceptEol() const;
7643 
7644   void setExceptJogLength(bool except_jog_length);
7645 
7646   bool isExceptJogLength() const;
7647 
7648   void setEdgeLengthValid(bool edge_length_valid);
7649 
7650   bool isEdgeLengthValid() const;
7651 
7652   void setIncludeShape(bool include_shape);
7653 
7654   bool isIncludeShape() const;
7655 
7656   void setMinLengthValid(bool min_length_valid);
7657 
7658   bool isMinLengthValid() const;
7659 
7660   void setExceptNotch(bool except_notch);
7661 
7662   bool isExceptNotch() const;
7663 
7664   void setExceptNotchLengthValid(bool except_notch_length_valid);
7665 
7666   bool isExceptNotchLengthValid() const;
7667 
7668   void setExceptSameNet(bool except_same_net);
7669 
7670   bool isExceptSameNet() const;
7671 
7672   void setExceptSameMetal(bool except_same_metal);
7673 
7674   bool isExceptSameMetal() const;
7675 
7676   // User Code Begin dbTechLayerCornerSpacingRule
7677   void setType(CornerType _type);
7678 
7679   CornerType getType() const;
7680 
7681   void addSpacing(uint width, uint spacing1, uint spacing2 = 0);
7682 
7683   void getSpacingTable(std::vector<std::pair<int, int>>& tbl);
7684 
7685   void getWidthTable(std::vector<int>& tbl);
7686 
7687   static dbTechLayerCornerSpacingRule* create(dbTechLayer* layer);
7688 
7689   static dbTechLayerCornerSpacingRule* getTechLayerCornerSpacingRule(
7690       dbTechLayer* inly,
7691       uint dbid);
7692   static void destroy(dbTechLayerCornerSpacingRule* rule);
7693   // User Code End dbTechLayerCornerSpacingRule
7694 };
7695 
7696 class dbTechLayerSpacingTablePrlRule : public dbObject
7697 {
7698  public:
7699   // User Code Begin dbTechLayerSpacingTablePrlRuleEnums
7700   // User Code End dbTechLayerSpacingTablePrlRuleEnums
7701 
7702   void setEolWidth(int eol_width);
7703 
7704   int getEolWidth() const;
7705 
7706   void setWrongDirection(bool wrong_direction);
7707 
7708   bool isWrongDirection() const;
7709 
7710   void setSameMask(bool same_mask);
7711 
7712   bool isSameMask() const;
7713 
7714   void setExceeptEol(bool exceept_eol);
7715 
7716   bool isExceeptEol() const;
7717 
7718   // User Code Begin dbTechLayerSpacingTablePrlRule
7719   static dbTechLayerSpacingTablePrlRule* getTechLayerSpacingTablePrlRule(
7720       dbTechLayer* inly,
7721       uint dbid);
7722 
7723   static dbTechLayerSpacingTablePrlRule* create(dbTechLayer* _layer);
7724 
7725   static void destroy(dbTechLayerSpacingTablePrlRule* rule);
7726 
7727   void setTable(std::vector<int> width_tbl,
7728                 std::vector<int> length_tbl,
7729                 std::vector<std::vector<int>> spacing_tbl,
7730                 std::map<uint, std::pair<int, int>> excluded_map);
7731   void getTable(std::vector<int>& width_tbl,
7732                 std::vector<int>& length_tbl,
7733                 std::vector<std::vector<int>>& spacing_tbl,
7734                 std::map<uint, std::pair<int, int>>& excluded_map);
7735 
7736   void setSpacingTableInfluence(
7737       std::vector<std::tuple<int, int, int>> influence_tbl);
7738 
7739   int getSpacing(const int width, const int length) const;
7740 
7741   bool hasExceptWithin(int width) const;
7742 
7743   std::pair<int, int> getExceptWithin(int width) const;
7744 
7745   // User Code End dbTechLayerSpacingTablePrlRule
7746 };
7747 
7748 class dbTechLayerEolKeepOutRule : public dbObject
7749 {
7750  public:
7751   // User Code Begin dbTechLayerEolKeepOutRuleEnums
7752   // User Code End dbTechLayerEolKeepOutRuleEnums
7753 
7754   void setEolWidth(int eol_width);
7755 
7756   int getEolWidth() const;
7757 
7758   void setBackwardExt(int backward_ext);
7759 
7760   int getBackwardExt() const;
7761 
7762   void setForwardExt(int forward_ext);
7763 
7764   int getForwardExt() const;
7765 
7766   void setSideExt(int side_ext);
7767 
7768   int getSideExt() const;
7769 
7770   void setWithinLow(int within_low);
7771 
7772   int getWithinLow() const;
7773 
7774   void setWithinHigh(int within_high);
7775 
7776   int getWithinHigh() const;
7777 
7778   void setClassName(std::string class_name);
7779 
7780   std::string getClassName() const;
7781 
7782   void setClassValid(bool class_valid);
7783 
7784   bool isClassValid() const;
7785 
7786   void setCornerOnly(bool corner_only);
7787 
7788   bool isCornerOnly() const;
7789 
7790   void setExceptWithin(bool except_within);
7791 
7792   bool isExceptWithin() const;
7793 
7794   // User Code Begin dbTechLayerEolKeepOutRule
7795   static dbTechLayerEolKeepOutRule* create(dbTechLayer* layer);
7796 
7797   static dbTechLayerEolKeepOutRule* getTechLayerEolKeepOutRule(
7798       dbTechLayer* inly,
7799       uint dbid);
7800   static void destroy(dbTechLayerEolKeepOutRule* rule);
7801   // User Code End dbTechLayerEolKeepOutRule
7802 };
7803 
7804 class dbTechLayerCutClassRule : public dbObject
7805 {
7806  public:
7807   // User Code Begin dbTechLayerCutClassRuleEnums
7808   // User Code End dbTechLayerCutClassRuleEnums
7809 
7810   const char* getName() const;
7811 
7812   void setWidth(int width);
7813 
7814   int getWidth() const;
7815 
7816   void setLength(int length);
7817 
7818   int getLength() const;
7819 
7820   void setNumCuts(int num_cuts);
7821 
7822   int getNumCuts() const;
7823 
7824   void setLengthValid(bool length_valid);
7825 
7826   bool isLengthValid() const;
7827 
7828   void setCutsValid(bool cuts_valid);
7829 
7830   bool isCutsValid() const;
7831 
7832   // User Code Begin dbTechLayerCutClassRule
7833   static dbTechLayerCutClassRule* getTechLayerCutClassRule(dbTechLayer* inly,
7834                                                            uint dbid);
7835 
7836   static dbTechLayerCutClassRule* create(dbTechLayer* _layer, const char* name);
7837 
7838   static void destroy(dbTechLayerCutClassRule* rule);
7839   // User Code End dbTechLayerCutClassRule
7840 };
7841 
7842 class dbTechLayerCutSpacingRule : public dbObject
7843 {
7844  public:
7845   enum CutSpacingType
7846   {
7847     NONE,
7848     MAXXY,
7849     SAMEMASK,
7850     LAYER,
7851     ADJACENTCUTS,
7852     PARALLELOVERLAP,
7853     PARALLELWITHIN,
7854     SAMEMETALSHAREDEDGE,
7855     AREA
7856   };
7857   // User Code Begin dbTechLayerCutSpacingRuleEnums
7858   // User Code End dbTechLayerCutSpacingRuleEnums
7859 
7860   void setCutSpacing(int cut_spacing);
7861 
7862   int getCutSpacing() const;
7863 
7864   void setSecondLayer(dbTechLayer* second_layer);
7865 
7866   void setOrthogonalSpacing(int orthogonal_spacing);
7867 
7868   int getOrthogonalSpacing() const;
7869 
7870   void setWidth(int width);
7871 
7872   int getWidth() const;
7873 
7874   void setEnclosure(int enclosure);
7875 
7876   int getEnclosure() const;
7877 
7878   void setEdgeLength(int edge_length);
7879 
7880   int getEdgeLength() const;
7881 
7882   void setParWithin(int par_within);
7883 
7884   int getParWithin() const;
7885 
7886   void setParEnclosure(int par_enclosure);
7887 
7888   int getParEnclosure() const;
7889 
7890   void setEdgeEnclosure(int edge_enclosure);
7891 
7892   int getEdgeEnclosure() const;
7893 
7894   void setAdjEnclosure(int adj_enclosure);
7895 
7896   int getAdjEnclosure() const;
7897 
7898   void setAboveEnclosure(int above_enclosure);
7899 
7900   int getAboveEnclosure() const;
7901 
7902   void setAboveWidth(int above_width);
7903 
7904   int getAboveWidth() const;
7905 
7906   void setMinLength(int min_length);
7907 
7908   int getMinLength() const;
7909 
7910   void setExtension(int extension);
7911 
7912   int getExtension() const;
7913 
7914   void setEolWidth(int eol_width);
7915 
7916   int getEolWidth() const;
7917 
7918   void setNumCuts(uint num_cuts);
7919 
7920   uint getNumCuts() const;
7921 
7922   void setWithin(int within);
7923 
7924   int getWithin() const;
7925 
7926   void setSecondWithin(int second_within);
7927 
7928   int getSecondWithin() const;
7929 
7930   void setCutClass(dbTechLayerCutClassRule* cut_class);
7931 
7932   void setTwoCuts(uint two_cuts);
7933 
7934   uint getTwoCuts() const;
7935 
7936   void setPrl(uint prl);
7937 
7938   uint getPrl() const;
7939 
7940   void setParLength(uint par_length);
7941 
7942   uint getParLength() const;
7943 
7944   void setCutArea(int cut_area);
7945 
7946   int getCutArea() const;
7947 
7948   void setCenterToCenter(bool center_to_center);
7949 
7950   bool isCenterToCenter() const;
7951 
7952   void setSameNet(bool same_net);
7953 
7954   bool isSameNet() const;
7955 
7956   void setSameMetal(bool same_metal);
7957 
7958   bool isSameMetal() const;
7959 
7960   void setSameVia(bool same_via);
7961 
7962   bool isSameVia() const;
7963 
7964   void setStack(bool stack);
7965 
7966   bool isStack() const;
7967 
7968   void setOrthogonalSpacingValid(bool orthogonal_spacing_valid);
7969 
7970   bool isOrthogonalSpacingValid() const;
7971 
7972   void setAboveWidthEnclosureValid(bool above_width_enclosure_valid);
7973 
7974   bool isAboveWidthEnclosureValid() const;
7975 
7976   void setShortEdgeOnly(bool short_edge_only);
7977 
7978   bool isShortEdgeOnly() const;
7979 
7980   void setConcaveCornerWidth(bool concave_corner_width);
7981 
7982   bool isConcaveCornerWidth() const;
7983 
7984   void setConcaveCornerParallel(bool concave_corner_parallel);
7985 
7986   bool isConcaveCornerParallel() const;
7987 
7988   void setConcaveCornerEdgeLength(bool concave_corner_edge_length);
7989 
7990   bool isConcaveCornerEdgeLength() const;
7991 
7992   void setConcaveCorner(bool concave_corner);
7993 
7994   bool isConcaveCorner() const;
7995 
7996   void setExtensionValid(bool extension_valid);
7997 
7998   bool isExtensionValid() const;
7999 
8000   void setNonEolConvexCorner(bool non_eol_convex_corner);
8001 
8002   bool isNonEolConvexCorner() const;
8003 
8004   void setEolWidthValid(bool eol_width_valid);
8005 
8006   bool isEolWidthValid() const;
8007 
8008   void setMinLengthValid(bool min_length_valid);
8009 
8010   bool isMinLengthValid() const;
8011 
8012   void setAboveWidthValid(bool above_width_valid);
8013 
8014   bool isAboveWidthValid() const;
8015 
8016   void setMaskOverlap(bool mask_overlap);
8017 
8018   bool isMaskOverlap() const;
8019 
8020   void setWrongDirection(bool wrong_direction);
8021 
8022   bool isWrongDirection() const;
8023 
8024   void setAdjacentCuts(uint adjacent_cuts);
8025 
8026   uint getAdjacentCuts() const;
8027 
8028   void setExactAligned(bool exact_aligned);
8029 
8030   bool isExactAligned() const;
8031 
8032   void setCutClassToAll(bool cut_class_to_all);
8033 
8034   bool isCutClassToAll() const;
8035 
8036   void setNoPrl(bool no_prl);
8037 
8038   bool isNoPrl() const;
8039 
8040   void setSameMask(bool same_mask);
8041 
8042   bool isSameMask() const;
8043 
8044   void setExceptSamePgnet(bool except_same_pgnet);
8045 
8046   bool isExceptSamePgnet() const;
8047 
8048   void setSideParallelOverlap(bool side_parallel_overlap);
8049 
8050   bool isSideParallelOverlap() const;
8051 
8052   void setExceptSameNet(bool except_same_net);
8053 
8054   bool isExceptSameNet() const;
8055 
8056   void setExceptSameMetal(bool except_same_metal);
8057 
8058   bool isExceptSameMetal() const;
8059 
8060   void setExceptSameMetalOverlap(bool except_same_metal_overlap);
8061 
8062   bool isExceptSameMetalOverlap() const;
8063 
8064   void setExceptSameVia(bool except_same_via);
8065 
8066   bool isExceptSameVia() const;
8067 
8068   void setAbove(bool above);
8069 
8070   bool isAbove() const;
8071 
8072   void setExceptTwoEdges(bool except_two_edges);
8073 
8074   bool isExceptTwoEdges() const;
8075 
8076   void setTwoCutsValid(bool two_cuts_valid);
8077 
8078   bool isTwoCutsValid() const;
8079 
8080   void setSameCut(bool same_cut);
8081 
8082   bool isSameCut() const;
8083 
8084   void setLongEdgeOnly(bool long_edge_only);
8085 
8086   bool isLongEdgeOnly() const;
8087 
8088   void setPrlValid(bool prl_valid);
8089 
8090   bool isPrlValid() const;
8091 
8092   void setBelow(bool below);
8093 
8094   bool isBelow() const;
8095 
8096   void setParWithinEnclosureValid(bool par_within_enclosure_valid);
8097 
8098   bool isParWithinEnclosureValid() const;
8099 
8100   // User Code Begin dbTechLayerCutSpacingRule
8101   dbTechLayerCutClassRule* getCutClass() const;
8102 
8103   dbTechLayer* getSecondLayer() const;
8104 
8105   dbTechLayer* getTechLayer() const;
8106 
8107   void setType(CutSpacingType _type);
8108 
8109   CutSpacingType getType() const;
8110 
8111   static dbTechLayerCutSpacingRule* getTechLayerCutSpacingRule(
8112       dbTechLayer* inly,
8113       uint dbid);
8114 
8115   static dbTechLayerCutSpacingRule* create(dbTechLayer* _layer);
8116 
8117   static void destroy(dbTechLayerCutSpacingRule* rule);
8118   // User Code End dbTechLayerCutSpacingRule
8119 };
8120 
8121 class dbTechLayerCutSpacingTableOrthRule : public dbObject
8122 {
8123  public:
8124   // User Code Begin dbTechLayerCutSpacingTableOrthRuleEnums
8125   // User Code End dbTechLayerCutSpacingTableOrthRuleEnums
8126   void getSpacingTable(std::vector<std::pair<int, int>>& tbl) const;
8127 
8128   // User Code Begin dbTechLayerCutSpacingTableOrthRule
8129   void setSpacingTable(std::vector<std::pair<int, int>> tbl);
8130 
8131   static dbTechLayerCutSpacingTableOrthRule* create(dbTechLayer* parent);
8132 
8133   static dbTechLayerCutSpacingTableOrthRule*
8134   getTechLayerCutSpacingTableOrthSubRule(dbTechLayer* parent, uint dbid);
8135 
8136   static void destroy(dbTechLayerCutSpacingTableOrthRule* rule);
8137   // User Code End dbTechLayerCutSpacingTableOrthRule
8138 };
8139 
8140 class dbTechLayerCutSpacingTableDefRule : public dbObject
8141 {
8142  public:
8143   // User Code Begin dbTechLayerCutSpacingTableDefRuleEnums
8144   // User Code End dbTechLayerCutSpacingTableDefRuleEnums
8145 
8146   void setDefault(int spacing);
8147 
8148   int getDefault() const;
8149 
8150   void setSecondLayer(dbTechLayer* second_layer);
8151 
8152   void setPrl(int prl);
8153 
8154   int getPrl() const;
8155 
8156   void setExtension(int extension);
8157 
8158   int getExtension() const;
8159 
8160   void setDefaultValid(bool default_valid);
8161 
8162   bool isDefaultValid() const;
8163 
8164   void setSameMask(bool same_mask);
8165 
8166   bool isSameMask() const;
8167 
8168   void setSameNet(bool same_net);
8169 
8170   bool isSameNet() const;
8171 
8172   void setSameMetal(bool same_metal);
8173 
8174   bool isSameMetal() const;
8175 
8176   void setSameVia(bool same_via);
8177 
8178   bool isSameVia() const;
8179 
8180   void setLayerValid(bool layer_valid);
8181 
8182   bool isLayerValid() const;
8183 
8184   void setNoStack(bool no_stack);
8185 
8186   bool isNoStack() const;
8187 
8188   void setNonZeroEnclosure(bool non_zero_enclosure);
8189 
8190   bool isNonZeroEnclosure() const;
8191 
8192   void setPrlForAlignedCut(bool prl_for_aligned_cut);
8193 
8194   bool isPrlForAlignedCut() const;
8195 
8196   void setCenterToCenterValid(bool center_to_center_valid);
8197 
8198   bool isCenterToCenterValid() const;
8199 
8200   void setCenterAndEdgeValid(bool center_and_edge_valid);
8201 
8202   bool isCenterAndEdgeValid() const;
8203 
8204   void setNoPrl(bool no_prl);
8205 
8206   bool isNoPrl() const;
8207 
8208   void setPrlValid(bool prl_valid);
8209 
8210   bool isPrlValid() const;
8211 
8212   void setMaxXY(bool max_x_y);
8213 
8214   bool isMaxXY() const;
8215 
8216   void setEndExtensionValid(bool end_extension_valid);
8217 
8218   bool isEndExtensionValid() const;
8219 
8220   void setSideExtensionValid(bool side_extension_valid);
8221 
8222   bool isSideExtensionValid() const;
8223 
8224   void setExactAlignedSpacingValid(bool exact_aligned_spacing_valid);
8225 
8226   bool isExactAlignedSpacingValid() const;
8227 
8228   void setHorizontal(bool horizontal);
8229 
8230   bool isHorizontal() const;
8231 
8232   void setPrlHorizontal(bool prl_horizontal);
8233 
8234   bool isPrlHorizontal() const;
8235 
8236   void setVertical(bool vertical);
8237 
8238   bool isVertical() const;
8239 
8240   void setPrlVertical(bool prl_vertical);
8241 
8242   bool isPrlVertical() const;
8243 
8244   void setNonOppositeEnclosureSpacingValid(
8245       bool non_opposite_enclosure_spacing_valid);
8246 
8247   bool isNonOppositeEnclosureSpacingValid() const;
8248 
8249   void setOppositeEnclosureResizeSpacingValid(
8250       bool opposite_enclosure_resize_spacing_valid);
8251 
8252   bool isOppositeEnclosureResizeSpacingValid() const;
8253 
8254   // User Code Begin dbTechLayerCutSpacingTableDefRule
8255   void addPrlForAlignedCutEntry(dbTechLayerCutClassRule* from,
8256                                 dbTechLayerCutClassRule* to);
8257 
8258   std::vector<std::pair<dbTechLayerCutClassRule*, dbTechLayerCutClassRule*>>
8259   getPrlForAlignedCutTable() const;
8260 
8261   void addCenterToCenterEntry(dbTechLayerCutClassRule* from,
8262                               dbTechLayerCutClassRule* to);
8263 
8264   std::vector<std::pair<dbTechLayerCutClassRule*, dbTechLayerCutClassRule*>>
8265   getCenterToCenterTable() const;
8266 
8267   void addCenterAndEdgeEntry(dbTechLayerCutClassRule* from,
8268                              dbTechLayerCutClassRule* to);
8269 
8270   std::vector<std::pair<dbTechLayerCutClassRule*, dbTechLayerCutClassRule*>>
8271   getCenterAndEdgeTable() const;
8272 
8273   void addPrlEntry(dbTechLayerCutClassRule* from,
8274                    dbTechLayerCutClassRule* to,
8275                    int ccPrl);
8276 
8277   std::vector<
8278       std::tuple<dbTechLayerCutClassRule*, dbTechLayerCutClassRule*, int>>
8279   getPrlTable() const;
8280 
8281   void addEndExtensionEntry(dbTechLayerCutClassRule* cls, int ext);
8282 
8283   std::vector<std::pair<dbTechLayerCutClassRule*, int>> getEndExtensionTable()
8284       const;
8285 
8286   void addSideExtensionEntry(dbTechLayerCutClassRule* cls, int ext);
8287 
8288   std::vector<std::pair<dbTechLayerCutClassRule*, int>> getSideExtensionTable()
8289       const;
8290 
8291   void addExactElignedEntry(dbTechLayerCutClassRule* cls, int spacing);
8292 
8293   std::vector<std::pair<dbTechLayerCutClassRule*, int>> getExactAlignedTable()
8294       const;
8295 
8296   void addNonOppEncSpacingEntry(dbTechLayerCutClassRule* cls, int spacing);
8297 
8298   std::vector<std::pair<dbTechLayerCutClassRule*, int>>
8299   getNonOppEncSpacingTable() const;
8300 
8301   void addOppEncSpacingEntry(dbTechLayerCutClassRule* cls,
8302                              int rsz1,
8303                              int rsz2,
8304                              int spacing);
8305 
8306   std::vector<std::tuple<dbTechLayerCutClassRule*, int, int, int>>
8307   getOppEncSpacingTable() const;
8308 
8309   dbTechLayer* getSecondLayer() const;
8310 
8311   void setSpacingTable(std::vector<std::vector<std::pair<int, int>>> table,
8312                        std::map<std::string, uint> row_map,
8313                        std::map<std::string, uint> col_map);
8314 
8315   void getSpacingTable(std::vector<std::vector<std::pair<int, int>>>& table,
8316                        std::map<std::string, uint>& row_map,
8317                        std::map<std::string, uint>& col_map);
8318 
8319   std::pair<int, int> getSpacing(const char* class1,
8320                                  bool SIDE1,
8321                                  const char* class2,
8322                                  bool SIDE2);
8323 
8324   dbTechLayer* getTechLayer() const;
8325 
8326   static dbTechLayerCutSpacingTableDefRule* create(dbTechLayer* parent);
8327 
8328   static dbTechLayerCutSpacingTableDefRule*
8329   getTechLayerCutSpacingTableDefSubRule(dbTechLayer* parent, uint dbid);
8330 
8331   static void destroy(dbTechLayerCutSpacingTableDefRule* rule);
8332   // User Code End dbTechLayerCutSpacingTableDefRule
8333 };
8334 
8335 class dbTechLayerCutEnclosureRule : public dbObject
8336 {
8337  public:
8338   enum ENC_TYPE
8339   {
8340     DEFAULT,
8341     EOL,
8342     ENDSIDE,
8343     HORZ_AND_VERT
8344   };
8345   // User Code Begin dbTechLayerCutEnclosureRuleEnums
8346   /*
8347   ENC_TYPE describes the enclosure overhang values as following (from the
8348   lefdefref):
8349   * DEFAULT       : overhang1 overhang2
8350   * EOL           : EOL eolWidth ... eolOverhang otherOverhang ...
8351   * ENDSIDE       : END overhang1 SIDE overhang2
8352   * HORZ_AND_VERT : HORIZONTAL overhang1 VERTICAL overhang2
8353   */
8354   // User Code End dbTechLayerCutEnclosureRuleEnums
8355 
8356   void setCutClass(dbTechLayerCutClassRule* cut_class);
8357 
8358   dbTechLayerCutClassRule* getCutClass() const;
8359 
8360   void setEolWidth(int eol_width);
8361 
8362   int getEolWidth() const;
8363 
8364   void setEolMinLength(int eol_min_length);
8365 
8366   int getEolMinLength() const;
8367 
8368   void setFirstOverhang(int first_overhang);
8369 
8370   int getFirstOverhang() const;
8371 
8372   void setSecondOverhang(int second_overhang);
8373 
8374   int getSecondOverhang() const;
8375 
8376   void setSpacing(int spacing);
8377 
8378   int getSpacing() const;
8379 
8380   void setExtension(int extension);
8381 
8382   int getExtension() const;
8383 
8384   void setForwardExtension(int forward_extension);
8385 
8386   int getForwardExtension() const;
8387 
8388   void setBackwardExtension(int backward_extension);
8389 
8390   int getBackwardExtension() const;
8391 
8392   void setMinWidth(int min_width);
8393 
8394   int getMinWidth() const;
8395 
8396   void setCutWithin(int cut_within);
8397 
8398   int getCutWithin() const;
8399 
8400   void setMinLength(int min_length);
8401 
8402   int getMinLength() const;
8403 
8404   void setParLength(int par_length);
8405 
8406   int getParLength() const;
8407 
8408   void setSecondParLength(int second_par_length);
8409 
8410   int getSecondParLength() const;
8411 
8412   void setParWithin(int par_within);
8413 
8414   int getParWithin() const;
8415 
8416   void setSecondParWithin(int second_par_within);
8417 
8418   int getSecondParWithin() const;
8419 
8420   void setBelowEnclosure(int below_enclosure);
8421 
8422   int getBelowEnclosure() const;
8423 
8424   void setNumCorners(uint num_corners);
8425 
8426   uint getNumCorners() const;
8427 
8428   void setCutClassValid(bool cut_class_valid);
8429 
8430   bool isCutClassValid() const;
8431 
8432   void setAbove(bool above);
8433 
8434   bool isAbove() const;
8435 
8436   void setBelow(bool below);
8437 
8438   bool isBelow() const;
8439 
8440   void setEolMinLengthValid(bool eol_min_length_valid);
8441 
8442   bool isEolMinLengthValid() const;
8443 
8444   void setEolOnly(bool eol_only);
8445 
8446   bool isEolOnly() const;
8447 
8448   void setShortEdgeOnly(bool short_edge_only);
8449 
8450   bool isShortEdgeOnly() const;
8451 
8452   void setSideSpacingValid(bool side_spacing_valid);
8453 
8454   bool isSideSpacingValid() const;
8455 
8456   void setEndSpacingValid(bool end_spacing_valid);
8457 
8458   bool isEndSpacingValid() const;
8459 
8460   void setOffCenterLine(bool off_center_line);
8461 
8462   bool isOffCenterLine() const;
8463 
8464   void setWidthValid(bool width_valid);
8465 
8466   bool isWidthValid() const;
8467 
8468   void setIncludeAbutted(bool include_abutted);
8469 
8470   bool isIncludeAbutted() const;
8471 
8472   void setExceptExtraCut(bool except_extra_cut);
8473 
8474   bool isExceptExtraCut() const;
8475 
8476   void setPrl(bool prl);
8477 
8478   bool isPrl() const;
8479 
8480   void setNoSharedEdge(bool no_shared_edge);
8481 
8482   bool isNoSharedEdge() const;
8483 
8484   void setLengthValid(bool length_valid);
8485 
8486   bool isLengthValid() const;
8487 
8488   void setExtraCutValid(bool extra_cut_valid);
8489 
8490   bool isExtraCutValid() const;
8491 
8492   void setExtraOnly(bool extra_only);
8493 
8494   bool isExtraOnly() const;
8495 
8496   void setRedundantCutValid(bool redundant_cut_valid);
8497 
8498   bool isRedundantCutValid() const;
8499 
8500   void setParallelValid(bool parallel_valid);
8501 
8502   bool isParallelValid() const;
8503 
8504   void setSecondParallelValid(bool second_parallel_valid);
8505 
8506   bool isSecondParallelValid() const;
8507 
8508   void setSecondParWithinValid(bool second_par_within_valid);
8509 
8510   bool isSecondParWithinValid() const;
8511 
8512   void setBelowEnclosureValid(bool below_enclosure_valid);
8513 
8514   bool isBelowEnclosureValid() const;
8515 
8516   void setConcaveCornersValid(bool concave_corners_valid);
8517 
8518   bool isConcaveCornersValid() const;
8519 
8520   // User Code Begin dbTechLayerCutEnclosureRule
8521   void setType(ENC_TYPE type);
8522 
8523   ENC_TYPE getType() const;
8524 
8525   static dbTechLayerCutEnclosureRule* create(dbTechLayer* layer);
8526 
8527   static dbTechLayerCutEnclosureRule* getTechLayerCutEnclosureRule(
8528       dbTechLayer* inly,
8529       uint dbid);
8530   static void destroy(dbTechLayerCutEnclosureRule* rule);
8531   // User Code End dbTechLayerCutEnclosureRule
8532 };
8533 
8534 class dbTechLayerEolExtensionRule : public dbObject
8535 {
8536  public:
8537   // User Code Begin dbTechLayerEolExtensionRuleEnums
8538   // User Code End dbTechLayerEolExtensionRuleEnums
8539 
8540   void setSpacing(int spacing);
8541 
8542   int getSpacing() const;
8543 
8544   void getExtensionTable(std::vector<std::pair<int, int>>& tbl) const;
8545 
8546   void setParallelOnly(bool parallel_only);
8547 
8548   bool isParallelOnly() const;
8549 
8550   // User Code Begin dbTechLayerEolExtensionRule
8551 
8552   void addEntry(int eol, int ext);
8553 
8554   static dbTechLayerEolExtensionRule* create(dbTechLayer* layer);
8555 
8556   static dbTechLayerEolExtensionRule* getTechLayerEolExtensionRule(
8557       dbTechLayer* inly,
8558       uint dbid);
8559 
8560   static void destroy(dbTechLayerEolExtensionRule* rule);
8561   // User Code End dbTechLayerEolExtensionRule
8562 };
8563 
8564 class dbModule : public dbObject
8565 {
8566  public:
8567   // User Code Begin dbModuleEnums
8568   // User Code End dbModuleEnums
8569   const char* getName() const;
8570 
8571   dbModInst* getModInst() const;
8572 
8573   // User Code Begin dbModule
8574   void addInst(dbInst* inst);
8575 
8576   void removeInst(dbInst* inst);
8577 
8578   dbSet<dbInst> getInsts();
8579 
8580   dbSet<dbModInst> getChildren();
8581 
8582   dbModInst* findModInst(const char* name);
8583 
8584   static dbModule* create(dbBlock* block, const char* name);
8585 
8586   static void destroy(dbModule* module);
8587 
8588   static dbModule* getModule(dbBlock* block_, uint dbid_);
8589 
8590   // User Code End dbModule
8591 };
8592 
8593 class dbModInst : public dbObject
8594 {
8595  public:
8596   // User Code Begin dbModInstEnums
8597   // User Code End dbModInstEnums
8598 
8599   dbModule* getParent() const;
8600 
8601   dbModule* getMaster() const;
8602 
8603   dbGroup* getGroup() const;
8604 
8605   // User Code Begin dbModInst
8606   static dbModInst* create(dbModule* parentModule,
8607                            dbModule* masterModule,
8608                            const char* name);
8609 
8610   static void destroy(dbModInst* modinst);
8611 
8612   static dbSet<dbModInst>::iterator destroy(dbSet<dbModInst>::iterator& itr);
8613 
8614   static dbModInst* getModInst(dbBlock* block_, uint dbid_);
8615 
8616   std::string getName() const;
8617 
8618   std::string getHierarchalName() const;
8619   // User Code End dbModInst
8620 };
8621 
8622 class dbGroup : public dbObject
8623 {
8624  public:
8625   enum dbGroupType
8626   {
8627     PHYSICAL_CLUSTER,
8628     VOLTAGE_DOMAIN
8629   };
8630   // User Code Begin dbGroupEnums
8631   // User Code End dbGroupEnums
8632 
8633   const char* getName() const;
8634 
8635   Rect getBox() const;
8636 
8637   void setParentGroup(dbGroup* parent_group);
8638 
8639   dbGroup* getParentGroup() const;
8640 
8641   // User Code Begin dbGroup
8642 
8643   void setType(dbGroupType _type);
8644 
8645   dbGroupType getType() const;
8646 
8647   void setBox(Rect _box);
8648 
8649   bool hasBox();
8650 
8651   void addModInst(dbModInst* modinst);
8652 
8653   void removeModInst(dbModInst* modinst);
8654 
8655   dbSet<dbModInst> getModInsts();
8656 
8657   void addInst(dbInst* inst);
8658 
8659   void removeInst(dbInst* inst);
8660 
8661   dbSet<dbInst> getInsts();
8662 
8663   void addGroup(dbGroup* group);
8664 
8665   void removeGroup(dbGroup* group);
8666 
8667   dbSet<dbGroup> getGroups();
8668 
8669   void addPowerNet(dbNet* net);
8670 
8671   void addGroundNet(dbNet* net);
8672 
8673   void removeNet(dbNet* net);
8674 
8675   dbSet<dbNet> getPowerNets();
8676 
8677   dbSet<dbNet> getGroundNets();
8678 
8679   static dbGroup* create(dbBlock* block, const char* name);
8680 
8681   static dbGroup* create(dbBlock* block,
8682                          const char* name,
8683                          int x1,
8684                          int y1,
8685                          int x2,
8686                          int y2);
8687 
8688   static dbGroup* create(dbGroup* parent, const char* name);
8689 
8690   static void destroy(dbGroup* group);
8691 
8692   static dbGroup* getGroup(dbBlock* block_, uint dbid_);
8693 
8694   // User Code End dbGroup
8695 };
8696 
8697 class dbGCellGrid : public dbObject
8698 {
8699  public:
8700   struct GCellData
8701   {
8702     uint horizontal_usage = 0;
8703     uint vertical_usage = 0;
8704     uint up_usage = 0;
8705     uint horizontal_capacity = 0;
8706     uint vertical_capacity = 0;
8707     uint up_capacity = 0;
8708     uint horizontal_blockage = 0;
8709     uint vertical_blockage = 0;
8710     uint up_blockage = 0;
8711   };
8712   // User Code Begin dbGCellGridEnums
8713   // User Code End dbGCellGridEnums
8714 
8715   // User Code Begin dbGCellGrid
8716 
8717   ///
8718   /// Get the "X" grid coordinates
8719   ///
8720   void getGridX(std::vector<int>& x_grid);
8721 
8722   ///
8723   /// Get the "Y" grid coordinates
8724   ///
8725   void getGridY(std::vector<int>& y_grid);
8726 
8727   ///
8728   /// Get the block this grid belongs too.
8729   ///
8730   dbBlock* getBlock();
8731 
8732   ///
8733   /// Add a "X" grid pattern.
8734   ///
8735   void addGridPatternX(int origin_x, int line_count, int step);
8736 
8737   ///
8738   /// Add a "Y" grid pattern.
8739   ///
8740   void addGridPatternY(int origin_y, int line_count, int step);
8741 
8742   ///
8743   /// Get the number of "X" grid patterns.
8744   ///
8745   int getNumGridPatternsX();
8746 
8747   ///
8748   /// Get the number of "Y" grid patterns.
8749   ///
8750   int getNumGridPatternsY();
8751 
8752   ///
8753   /// Get the "ith" "X" grid pattern.
8754   ///
8755   void getGridPatternX(int i, int& origin_x, int& line_count, int& step);
8756 
8757   ///
8758   /// Get the "ith" "Y" grid pattern.
8759   ///
8760   void getGridPatternY(int i, int& origin_y, int& line_count, int& step);
8761   ///
8762   /// Create an empty GCell grid.
8763   /// Returns NULL if a grid already exists.
8764   ///
8765   static dbGCellGrid* create(dbBlock* block);
8766 
8767   ///
8768   /// Translate a database-id back to a pointer.
8769   ///
8770   static dbGCellGrid* getGCellGrid(dbBlock* block, uint oid);
8771 
8772   uint getXIdx(int x);
8773 
8774   uint getYIdx(int y);
8775 
8776   uint getHorizontalCapacity(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8777 
8778   uint getVerticalCapacity(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8779 
8780   uint getUpCapacity(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8781 
8782   uint getHorizontalUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8783 
8784   uint getVerticalUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8785 
8786   uint getUpUsage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8787 
8788   uint getHorizontalBlockage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8789 
8790   uint getVerticalBlockage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8791 
8792   uint getUpBlockage(dbTechLayer* layer, uint x_idx, uint y_idx) const;
8793 
8794   void setHorizontalCapacity(dbTechLayer* layer,
8795                              uint x_idx,
8796                              uint y_idx,
8797                              uint capacity);
8798 
8799   void setVerticalCapacity(dbTechLayer* layer,
8800                            uint x_idx,
8801                            uint y_idx,
8802                            uint capacity);
8803 
8804   void setUpCapacity(dbTechLayer* layer, uint x_idx, uint y_idx, uint capacity);
8805 
8806   void setHorizontalUsage(dbTechLayer* layer, uint x_idx, uint y_idx, uint use);
8807 
8808   void setVerticalUsage(dbTechLayer* layer, uint x_idx, uint y_idx, uint use);
8809 
8810   void setUpUsage(dbTechLayer* layer, uint x_idx, uint y_idx, uint use);
8811 
8812   void setHorizontalBlockage(dbTechLayer* layer,
8813                              uint x_idx,
8814                              uint y_idx,
8815                              uint blockage);
8816 
8817   void setVerticalBlockage(dbTechLayer* layer,
8818                            uint x_idx,
8819                            uint y_idx,
8820                            uint blockage);
8821 
8822   void setUpBlockage(dbTechLayer* layer, uint x_idx, uint y_idx, uint blockage);
8823 
8824   void setCapacity(dbTechLayer* layer,
8825                    uint x_idx,
8826                    uint y_idx,
8827                    uint horizontal,
8828                    uint vertical,
8829                    uint up);
8830 
8831   void setUsage(dbTechLayer* layer,
8832                 uint x_idx,
8833                 uint y_idx,
8834                 uint horizontal,
8835                 uint vertical,
8836                 uint up);
8837 
8838   void setBlockage(dbTechLayer* layer,
8839                    uint x_idx,
8840                    uint y_idx,
8841                    uint horizontal,
8842                    uint vertical,
8843                    uint up);
8844 
8845   void getCapacity(dbTechLayer* layer,
8846                    uint x_idx,
8847                    uint y_idx,
8848                    uint& horizontal,
8849                    uint& vertical,
8850                    uint& up) const;
8851 
8852   void getUsage(dbTechLayer* layer,
8853                 uint x_idx,
8854                 uint y_idx,
8855                 uint& horizontal,
8856                 uint& vertical,
8857                 uint& up) const;
8858 
8859   void getBlockage(dbTechLayer* layer,
8860                    uint x_idx,
8861                    uint y_idx,
8862                    uint& horizontal,
8863                    uint& vertical,
8864                    uint& up) const;
8865 
8866   void resetCongestionMap();
8867 
8868   void resetGrid();
8869 
8870   std::map<std::pair<uint, uint>, GCellData> getCongestionMap(dbTechLayer* layer
8871                                                               = nullptr);
8872   // User Code End dbGCellGrid
8873 };
8874 
8875 // Generator Code End ClassDefinition
8876 
8877 }  // namespace odb
8878