Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/odb/include/odb/3dblox.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ThreeDBlox
void check();
void writeDbv(const std::string& dbv_file, odb::dbChip* chip);
void writeDbx(const std::string& dbx_file, odb::dbChip* chip);
void writeBMap(const std::string& bmap_file, odb::dbChipRegion* region);

private:
void createChiplet(const ChipletDef& chiplet);
Expand Down
25 changes: 25 additions & 0 deletions src/odb/src/3dblox/3dblox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>

#include "bmapParser.h"
#include "bmapWriter.h"
#include "checker.h"
#include "dbvParser.h"
#include "dbvWriter.h"
Expand Down Expand Up @@ -121,6 +122,16 @@ std::unordered_set<odb::dbLib*> getUsedLibs(odb::dbChip* chip)
}
return libs;
}
std::unordered_set<odb::dbChipRegion*> getChipletRegions(odb::dbChip* chip)
{
std::unordered_set<odb::dbChipRegion*> regions;
for (const auto chipinst : chip->getChipInsts()) {
for (const auto region : chipinst->getMasterChip()->getChipRegions()) {
regions.insert(region);
}
}
return regions;
}
std::string getResultsDirectoryPath(const std::string& file_path)
{
std::string current_dir_path;
Expand Down Expand Up @@ -169,6 +180,13 @@ void ThreeDBlox::writeDbv(const std::string& dbv_file, odb::dbChip* chip)
odb::lefout lef_writer(logger_, stream_handler.getStream());
lef_writer.writeLib(lib);
}
// write bmaps
for (auto region : getChipletRegions(chip)) {
std::string bmap_file_path = current_dir_path
+ std::string(region->getChip()->getName())
+ "_" + region->getName() + ".bmap";
writeBMap(bmap_file_path, region);
}

DbvWriter writer(logger_, db_);
writer.writeChiplet(dbv_file, chip);
Expand All @@ -184,6 +202,13 @@ void ThreeDBlox::writeDbx(const std::string& dbx_file, odb::dbChip* chip)
writeDbv(current_dir_path + chip->getName() + ".3dbv", chip);
}

void ThreeDBlox::writeBMap(const std::string& bmap_file,
odb::dbChipRegion* region)
{
BmapWriter writer(logger_);
writer.writeFile(bmap_file, region);
}

void ThreeDBlox::calculateSize(dbChip* chip)
{
Rect box;
Expand Down
1 change: 1 addition & 0 deletions src/odb/src/3dblox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_library(3dblox
dbxParser.cpp
baseWriter.cpp
dbvWriter.cpp
bmapWriter.cpp
3dblox.cpp
checker.cpp
)
Expand Down
62 changes: 62 additions & 0 deletions src/odb/src/3dblox/bmapWriter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2019-2025, The OpenROAD Authors

#include "bmapWriter.h"

#include <fstream>
#include <string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: included header iostream is not used directly [misc-include-cleaner]

Suggested change
#include <string>
#include <string>


#include "odb/db.h"
#include "utl/Logger.h"

namespace odb {

BmapWriter::BmapWriter(utl::Logger* logger) : logger_(logger)
{
}

void BmapWriter::writeFile(const std::string& filename,
odb::dbChipRegion* region)
{
const auto u = region->getDb()->getDbuPerMicron();
std::ofstream bmap_file(filename);
if (bmap_file.is_open()) {
for (auto bump : region->getChipBumps()) {
std::string line;
const auto inst_name = bump->getInst()->getName();
const auto cell_type = bump->getInst()->getMaster()->getName();
auto point = bump->getInst()->getOrigin();
line.append(inst_name);
line.append(" ");
line.append(cell_type);
line.append(" ");
line.append(std::to_string(point.getX() / u));
line.append(" ");
line.append(std::to_string(point.getY() / u));
line.append(" ");
if (bump->getBTerm() != nullptr) {
line.append(bump->getBTerm()->getName());
} else {
line.append("-");
}
line.append(" ");
if (bump->getNet() != nullptr) {
line.append(bump->getNet()->getName());
} else {
line.append("-");
}
line.append("\n");
bmap_file << line;
}
bmap_file.close();
} else {
logError("Unable to open file");
}
}

void BmapWriter::logError(const std::string& message)
{
logger_->error(utl::ODB, 562, "Write Error: {}", message);
}

} // namespace odb
28 changes: 28 additions & 0 deletions src/odb/src/3dblox/bmapWriter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2019-2025, The OpenROAD Authors

#pragma once

#include <string>

#include "odb/db.h"

namespace utl {
class Logger;
}
namespace odb {

class BmapWriter
{
public:
BmapWriter(utl::Logger* logger);

void writeFile(const std::string& filename, odb::dbChipRegion* region);

private:
void logError(const std::string& message);

utl::Logger* logger_;
};

} // namespace odb
3 changes: 3 additions & 0 deletions src/odb/src/3dblox/dbvWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ void DbvWriter::writeRegion(YAML::Node& region_node, odb::dbChipRegion* region)
region_node["side"] = "internal_ext";
break;
}
std::string bmap_file = std::string(region->getChip()->getName()) + "_"
+ region->getName() + ".bmap";
region_node["bmap"] = bmap_file;
if (auto layer = region->getLayer(); layer != nullptr) {
region_node["layer"] = layer->getName();
}
Expand Down
1 change: 1 addition & 0 deletions src/odb/test/write_3dbv.3dbvok
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ChipletDef:
regions:
r1:
side: front
bmap: SoC_r1.bmap
coords:
- [0, 0]
- [955, 0]
Expand Down