@@ -183,16 +183,93 @@ void ThreeDBlox::createChipInst(const ChipletInst& chip_inst)
183183 chip_inst.name );
184184 }
185185 dbChipInst* inst = dbChipInst::create (db_->getChip (), chip, chip_inst.name );
186+ inst->setLoc (Point3D (chip_inst.loc .x * db_->getDbuPerMicron (),
187+ chip_inst.loc .y * db_->getDbuPerMicron (),
188+ chip_inst.z * db_->getDbuPerMicron ()));
189+ // TODO: set orient
190+ }
191+ std::vector<std::string> splitPath (const std::string& path)
192+ {
193+ std::vector<std::string> parts;
194+ std::istringstream stream (path);
195+ std::string part;
196+
197+ while (std::getline (stream, part, ' /' )) {
198+ if (!part.empty ()) {
199+ parts.push_back (part);
200+ }
201+ }
202+
203+ return parts;
204+ }
205+
206+ dbChipRegionInst* ThreeDBlox::resolvePath (const std::string& path,
207+ std::vector<dbChipInst*>& path_insts)
208+ {
209+ if (path == " ~" ) {
210+ return nullptr ;
211+ }
212+ // Split the path by '/'
213+ std::vector<std::string> path_parts = splitPath (path);
214+
215+ if (path_parts.empty ()) {
216+ logger_->error (utl::ODB, 524 , " 3DBX Parser Error: Invalid path {}" , path);
217+ }
218+
219+ // The last part should contain ".regions.regionName"
220+ std::string last_part = path_parts.back ();
221+ size_t regions_pos = last_part.find (" .regions." );
222+ if (regions_pos == std::string::npos) {
223+ return nullptr ; // Invalid format
224+ }
225+
226+ // Extract chip instance name and region name from last part
227+ std::string last_chip_inst = last_part.substr (0 , regions_pos);
228+ std::string region_name = last_part.substr (regions_pos + 9 );
229+
230+ // Replace the last part with just the chip instance name
231+ path_parts.back () = last_chip_inst;
232+
233+ // TODO: Traverse hierarchy and find region
234+ path_insts.reserve (path_parts.size ());
235+ dbChip* curr_chip = db_->getChip ();
236+ dbChipInst* curr_chip_inst = nullptr ;
237+ for (auto inst_name : path_parts) {
238+ curr_chip_inst = curr_chip->findChipInst (inst_name);
239+ if (curr_chip_inst == nullptr ) {
240+ logger_->error (utl::ODB,
241+ 522 ,
242+ " 3DBX Parser Error: Chip instance {} not found in path {}" ,
243+ inst_name,
244+ path);
245+ }
246+ path_insts.push_back (curr_chip_inst);
247+ curr_chip = curr_chip_inst->getMasterChip ();
248+ }
249+ auto region = curr_chip_inst->findChipRegionInst (region_name);
250+ if (region == nullptr ) {
251+ logger_->error (utl::ODB,
252+ 523 ,
253+ " 3DBX Parser Error: Chip region {} not found in path {}" ,
254+ region_name,
255+ path);
256+ }
257+ return region;
186258}
187259void ThreeDBlox::createConnection (const Connection& connection)
188260{
189- // dbChip* top_chip = db_->findChip(connection.top.c_str());
190- // dbChip* bottom_chip = db_->findChip(connection.bot.c_str());
191- // if (top_chip == nullptr || bottom_chip == nullptr) {
192- // logger_->error(utl::ODB,
193- // 520,
194- // "3DBX Parser Error: Connection top or bottom chip not
195- // found " "for connection {}", connection.name);
196- // }
261+ auto top_path = connection.top ;
262+ auto bottom_path = connection.bot ;
263+ std::vector<dbChipInst*> top_region_path;
264+ std::vector<dbChipInst*> bottom_region_path;
265+ auto top_region = resolvePath (top_path, top_region_path);
266+ auto bottom_region = resolvePath (bottom_path, bottom_region_path);
267+ auto conn = odb::dbChipConn::create (connection.name ,
268+ db_->getChip (),
269+ top_region_path,
270+ top_region,
271+ bottom_region_path,
272+ bottom_region);
273+ conn->setThickness (connection.thickness * db_->getDbuPerMicron ());
197274}
198275} // namespace odb
0 commit comments