1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (c) 2020, The Regents of the University of California
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 #include "dbFill.h"
34
35 #include "db.h"
36 #include "dbBlock.h"
37 #include "dbBlockCallBackObj.h"
38 #include "dbDatabase.h"
39 #include "dbDiff.hpp"
40 #include "dbTable.h"
41 #include "dbTable.hpp"
42 #include "dbTech.h"
43 #include "dbTechLayer.h"
44
45 namespace odb {
46
47 template class dbTable<_dbFill>;
48
operator ==(const _dbFill & rhs) const49 bool _dbFill::operator==(const _dbFill& rhs) const
50 {
51 if (_flags._opc != rhs._flags._opc)
52 return false;
53
54 if (_flags._mask_id != rhs._flags._mask_id)
55 return false;
56
57 if (_flags._layer_id != rhs._flags._layer_id)
58 return false;
59
60 if (_rect != rhs._rect)
61 return false;
62
63 return true;
64 }
65
operator <(const _dbFill & rhs) const66 bool _dbFill::operator<(const _dbFill& rhs) const
67 {
68 if (_rect < rhs._rect)
69 return true;
70
71 if (_rect > rhs._rect)
72 return false;
73
74 if (_flags._opc < rhs._flags._opc)
75 return true;
76
77 if (_flags._opc > rhs._flags._opc)
78 return false;
79
80 if (_flags._mask_id < rhs._flags._mask_id)
81 return true;
82
83 if (_flags._mask_id > rhs._flags._mask_id)
84 return false;
85
86 if (_flags._layer_id < rhs._flags._layer_id)
87 return true;
88
89 if (_flags._layer_id > rhs._flags._layer_id)
90 return false;
91
92 return false;
93 }
94
differences(dbDiff & diff,const char * field,const _dbFill & rhs) const95 void _dbFill::differences(dbDiff& diff,
96 const char* field,
97 const _dbFill& rhs) const
98 {
99 DIFF_BEGIN
100 DIFF_FIELD(_flags._opc);
101 DIFF_FIELD(_flags._mask_id);
102 DIFF_FIELD(_flags._layer_id);
103 DIFF_FIELD(_rect);
104 DIFF_END
105 }
106
out(dbDiff & diff,char side,const char * field) const107 void _dbFill::out(dbDiff& diff, char side, const char* field) const
108 {
109 DIFF_OUT_BEGIN
110 DIFF_OUT_FIELD(_flags._opc);
111 DIFF_OUT_FIELD(_flags._mask_id);
112 DIFF_OUT_FIELD(_flags._layer_id);
113 DIFF_OUT_FIELD(_rect);
114 DIFF_END
115 }
116
getTechLayer() const117 _dbTechLayer* _dbFill::getTechLayer() const
118 {
119 _dbDatabase* db = (_dbDatabase*) getDatabase();
120 _dbTech* tech = db->_tech_tbl->getPtr(db->_tech);
121 return tech->_layer_tbl->getPtr(_flags._layer_id);
122 }
123
124 ////////////////////////////////////////////////////////////////////
125 //
126 // dbFill - Methods
127 //
128 ////////////////////////////////////////////////////////////////////
129
getRect(Rect & rect)130 void dbFill::getRect(Rect& rect)
131 {
132 _dbFill* fill = (_dbFill*) this;
133 rect = fill->_rect;
134 }
135
needsOPC()136 bool dbFill::needsOPC()
137 {
138 _dbFill* fill = (_dbFill*) this;
139 return fill->_flags._opc;
140 }
141
maskNumber()142 uint dbFill::maskNumber()
143 {
144 _dbFill* fill = (_dbFill*) this;
145 return fill->_flags._mask_id;
146 }
147
getTechLayer()148 dbTechLayer* dbFill::getTechLayer()
149 {
150 _dbFill* fill = (_dbFill*) this;
151 return (dbTechLayer*) fill->getTechLayer();
152 }
153
create(dbBlock * block,bool needs_opc,uint mask_number,dbTechLayer * layer,int x1,int y1,int x2,int y2)154 dbFill* dbFill::create(dbBlock* block,
155 bool needs_opc,
156 uint mask_number,
157 dbTechLayer* layer,
158 int x1,
159 int y1,
160 int x2,
161 int y2)
162 {
163 _dbBlock* block_internal = (_dbBlock*) block;
164 _dbFill* fill = block_internal->_fill_tbl->create();
165 fill->_flags._opc = needs_opc;
166 fill->_flags._mask_id = mask_number;
167 fill->_flags._layer_id = layer->getImpl()->getOID();
168 fill->_rect.init(x1, y1, x2, y2);
169
170 std::list<dbBlockCallBackObj*>::iterator cbitr;
171 for (cbitr = block_internal->_callbacks.begin();
172 cbitr != block_internal->_callbacks.end();
173 ++cbitr) {
174 (*cbitr)->inDbFillCreate((dbFill*) fill);
175 }
176
177 return (dbFill*) fill;
178 }
179
destroy(dbFill * fill_)180 void dbFill::destroy(dbFill* fill_)
181 {
182 _dbFill* fill = (_dbFill*) fill_;
183 _dbBlock* block = (_dbBlock*) fill->getOwner();
184 dbProperty::destroyProperties(fill);
185 block->_fill_tbl->destroy(fill);
186 }
187
destroy(dbSet<dbFill>::iterator & itr)188 dbSet<dbFill>::iterator dbFill::destroy(dbSet<dbFill>::iterator& itr)
189 {
190 dbFill* r = *itr;
191 dbSet<dbFill>::iterator next = ++itr;
192 destroy(r);
193 return next;
194 }
195
getFill(dbBlock * block_,uint dbid_)196 dbFill* dbFill::getFill(dbBlock* block_, uint dbid_)
197 {
198 _dbBlock* block = (_dbBlock*) block_;
199 return (dbFill*) block->_fill_tbl->getPtr(dbid_);
200 }
201
202 } // namespace odb
203