1 /* 2 * databaseInt.h -- 3 * 4 * Definitions internal to the database module. 5 * 6 * ********************************************************************* 7 * * Copyright (C) 1985, 1990 Regents of the University of California. * 8 * * Permission to use, copy, modify, and distribute this * 9 * * software and its documentation for any purpose and without * 10 * * fee is hereby granted, provided that the above copyright * 11 * * notice appear in all copies. The University of California * 12 * * makes no representations about the suitability of this * 13 * * software for any purpose. It is provided "as is" without * 14 * * express or implied warranty. Export of this software outside * 15 * * of the United States of America may require an export license. * 16 * ********************************************************************* 17 * 18 * Needs to include: magic.h, tile.h, database.h 19 * 20 * rcsid $Header: /usr/cvsroot/magic-8.0/database/databaseInt.h,v 1.3 2010/06/24 12:37:15 tim Exp $ 21 */ 22 23 #ifndef _DATABASEINT_H 24 #define _DATABASEINT_H 25 26 #include "database/database.h" 27 28 /* ----------- Argument to area search when writing out cell ---------- */ 29 30 struct writeArg 31 { 32 char *wa_name; /* Filename of output file */ 33 FILE *wa_file; /* File to which to output */ 34 TileType wa_type; /* Type of tile being searched for */ 35 bool wa_found; /* Have any tiles been found yet? */ 36 int wa_reducer; /* Scale factor for all geometry */ 37 int wa_plane; /* Current plane being searched */ 38 }; 39 40 /* --------------------- Undo info for painting ----------------------- */ 41 42 /* The following is the structure of the undo info saved for each tile */ 43 typedef struct 44 { 45 Rect pue_rect; /* Rectangle painted/erased */ 46 TileType pue_oldtype; /* Material erased */ 47 TileType pue_newtype; /* Material painted */ 48 char pue_plane; /* Plane index affected */ 49 } paintUE; 50 51 /* The following is the structure of the undo info saved for a split tile */ 52 typedef struct 53 { 54 Point sue_point; /* lower-left position of split/joined tile */ 55 int sue_splitx; /* x position of split/join */ 56 char sue_plane; /* Plane of material that was split/joined */ 57 } splitUE; 58 59 /* -------------- Codes for undo of cell use operations --------------- */ 60 61 #define UNDO_CELL_CLRID 0 /* Clear use id */ 62 #define UNDO_CELL_SETID 1 /* Set use id */ 63 #define UNDO_CELL_PLACE 2 /* Create and place cell use */ 64 #define UNDO_CELL_DELETE 3 /* Delete and destroy cell use */ 65 #define UNDO_CELL_LOCKDOWN 4 /* Lock down a cell use */ 66 67 /* --------------- Default types and planes, and name lists ----------- */ 68 69 /* 70 * Type or plane names. 71 * These are invisible outside of the technology module 72 * except via DBTechNameType() and DBTechNamePlane(). 73 * The first name in any list is by convention pointed 74 * to by DBTypeLongNameTbl[] or DBPlaneLongNameTbl[] 75 * respectively. 76 */ 77 typedef struct namelist 78 { 79 struct namelist *sn_next; /* Next name in table */ 80 struct namelist *sn_prev; /* Previous name in table */ 81 char *sn_name; /* Text of name */ 82 ClientData sn_value; /* Value (TileType or plane number) */ 83 bool sn_primary; /* If TRUE, this is the primary name */ 84 bool sn_alias; /* If TRUE, this is an alias name */ 85 } NameList; 86 87 typedef struct 88 { 89 int dp_plane; /* Internal index for this plane */ 90 char *dp_names; /* List of comma-separated names */ 91 } DefaultPlane; 92 93 typedef struct 94 { 95 TileType dt_type; /* This type's number */ 96 int dt_plane; /* Plane on which this type resides */ 97 char *dt_names; /* List of comma-separated names. The first 98 * is the "long" name of the type. 99 */ 100 bool dt_print; /* TRUE if layer is to be printed by 101 * DBTechPrintTypes. These are layers 102 * that user would normally paint. 103 */ 104 } DefaultType; 105 106 extern NameList dbTypeNameLists; /* Type abbreviations */ 107 extern NameList dbPlaneNameLists; /* Plane abbreviations */ 108 extern DefaultPlane dbTechDefaultPlanes[]; /* Builtin planes */ 109 extern DefaultType dbTechDefaultTypes[]; /* Builtin types */ 110 111 /* ------------------- Layer composition tables ----------------------- */ 112 113 /* 114 * Contacts in Magic are funny beasts. Instead of representing the via 115 * holes separately from the two layers they connect, Magic bundles them 116 * into a single "type" that implies the presence of adjacent vias. 117 * In the discussion that follows, "contact" means the aggregate described 118 * by a line in the "contacts" section of the technology file, while "type" 119 * has its usual meaning, namely a TileType. "Painting a contact" means 120 * painting its primary type, namely the one that appeared in the "types" 121 * section of the technology file (as opposed to any automatically generated 122 * tile types). 123 * 124 * Magic represents contacts between tile planes by storing the tile type 125 * on each plane, each of which is referred to as an "image" of the 126 * particular type of contact on its respective plane. The primary contact 127 * type indicates the planes it connects to, and also the "residues" on 128 * each connected plane (residues are the types that would be present if 129 * there were no contact). 130 * 131 * When the technology file is read, the "types" section defines the tile 132 * type names that users will paint and erase. Contacts can be painted 133 * and erased by a single name, but actually consist of several tiles; 134 * the "contacts" section provides the information needed to automatically 135 * generate the tiles needed to represent a contact with the specified 136 * connectivity. 137 * 138 * Magic's scheme has a couple of important properties. Each contact 139 * defined in the technology file determines a set of planes that will 140 * be painted with the type when that contact is painted over empty 141 * space. 142 * 143 * The LayerInfo structure is used primarily to store information about 144 * the various types of contacts, although it contains degenerate information 145 * about non-contact types as well. 146 */ 147 148 typedef struct 149 { 150 TileType l_type; /* Back-index into dbLayerInfo[] */ 151 bool l_isContact; /* TRUE if this layer has images */ 152 153 /* Residues of this contact on its contacted planes. */ 154 TileTypeBitMask l_residues; 155 156 /* Mask of connected planes, including this one */ 157 PlaneMask l_pmask; 158 } LayerInfo; 159 160 extern LayerInfo dbLayerInfo[]; 161 extern LayerInfo *dbContactInfo[]; 162 extern int dbNumContacts; 163 extern int dbNumImages; 164 165 /* Macros for above table */ 166 #define LayerPlaneMask(t) dbLayerInfo[t].l_pmask 167 #define IsContact(t) dbLayerInfo[t].l_isContact 168 169 /* --------------------- Composition rule tables ---------------------- */ 170 171 /* Saved contact compose/erase rules */ 172 typedef struct 173 { 174 TileType rp_a, rp_b; /* Two types in pair */ 175 } TypePair; 176 177 typedef struct 178 { 179 int r_ruleType; /* Kind of rule (RULE_* below) */ 180 TileType r_result; /* Result type */ 181 int r_npairs; /* Number of type pairs in rule */ 182 TypePair r_pairs[NT]; /* Pairs of types in rule */ 183 } Rule; 184 185 /* 186 * Types of rules in the compose section of a technology file 187 * (represented in the Rule structure above). 188 */ 189 #define RULE_DECOMPOSE 0 190 #define RULE_COMPOSE 1 191 #define RULE_PAINT 2 192 #define RULE_ERASE 3 193 194 extern int dbNumSavedRules; 195 extern Rule dbSavedRules[]; 196 197 /* -------------------- Internal procedure headers -------------------- */ 198 199 extern void DBUndoPutLabel(); 200 extern void DBUndoEraseLabel(); 201 extern void DBUndoCellUse(); 202 extern void DBStampMismatch(); 203 extern void DBFlagMismatches(); 204 extern void DBTechAddNameToType(); 205 206 extern void dbComputeBbox(); 207 extern void dbFreeCellPlane(); 208 extern void dbFreePaintPlane(); 209 extern bool dbTechAddPaint(); 210 extern bool dbTechAddErase(); 211 ClientData dbTechNameLookup(); 212 ClientData dbTechNameLookupExact(); 213 214 /* --------------- Internal database technology variables ------------- */ 215 216 /* 217 * Macros to set the paint result tables. 218 * The argument order is different from the index order in 219 * the tables, for historical reasons. 220 * 221 * Usage: 222 * dbSetPaintEntry(oldType, paintType, planeNum, resultType) 223 * dbSetEraseEntry(oldType, paintType, planeNum, resultType) 224 * dbSetWriteEntry(oldType, paintType, resultType) 225 */ 226 #define dbSetPaintEntry(h,t,p,r) (DBPaintResultTbl[p][t][h] = r) 227 #define dbSetEraseEntry(h,t,p,r) (DBEraseResultTbl[p][t][h] = r) 228 #define dbSetWriteEntry(h,t,r) (DBWriteResultTbl[t][h] = r) 229 230 extern TileTypeBitMask dbNotDefaultEraseTbl[]; 231 extern TileTypeBitMask dbNotDefaultPaintTbl[]; 232 233 #define IsDefaultErase(h, e) (!TTMaskHasType(&dbNotDefaultEraseTbl[h], e)) 234 #define IsDefaultPaint(h, p) (!TTMaskHasType(&dbNotDefaultPaintTbl[h], p)) 235 236 /* 237 * Macros to determine whether painting or erasing type s affects 238 * type t on its home plane. The check for t != TT_SPACE is because 239 * TT_SPACE has no specific home plane and is handled specially. 240 */ 241 #define PAINTAFFECTS(t, s) \ 242 ((t) != TT_SPACE && DBStdPaintEntry((t), (s), DBPlane(t)) != (t)) 243 #define ERASEAFFECTS(t, s) \ 244 ((t) != TT_SPACE && DBStdEraseEntry((t), (s), DBPlane(t)) != (t)) 245 246 #endif /* _DATABASEINT_H */ 247