Skip to content

Commit a1cd3ae

Browse files
committed
odb: added 3dbx writer
Signed-off-by: Rafael Moresco <[email protected]>
1 parent b5bf95d commit a1cd3ae

File tree

7 files changed

+116
-70
lines changed

7 files changed

+116
-70
lines changed

src/OpenRoad.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ void OpenRoad::write3Dbv(const std::string& filename)
503503
writer.writeDbv(filename);
504504
}
505505

506+
void OpenRoad::write3Dbx(const std::string& filename)
507+
{
508+
odb::ThreeDBlox writer(logger_, db_);
509+
writer.writeDbx(filename);
510+
}
511+
506512
void OpenRoad::readDb(const char* filename, bool hierarchy)
507513
{
508514
try {

src/OpenRoad.i

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ write_3dbv_cmd(const char *filename)
376376
ord->write3Dbv(filename);
377377
}
378378

379+
void
380+
write_3dbx_cmd(const char *filename)
381+
{
382+
OpenRoad *ord = getOpenRoad();
383+
ord->write3Dbx(filename);
384+
}
385+
379386
void
380387
read_db_cmd(const char *filename, bool hierarchy)
381388
{

src/OpenRoad.tcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ proc read_3dbx { args } {
206206
ord::read_3dbx_cmd $filename
207207
}
208208

209+
sta::define_cmd_args "write_3dbx" {filename}
210+
211+
proc write_3dbx { args } {
212+
sta::parse_key_args "write_3dbx" args keys {} flags {}
213+
sta::check_argc_eq1 "write_3dbx" $args
214+
set filename [file nativename [lindex $args 0]]
215+
ord::write_3dbx_cmd $filename
216+
}
217+
209218
sta::define_cmd_args "write_db" {filename}
210219

211220
sta::define_cmd_args "read_db" {[-hier] filename}

src/odb/src/3dblox/dbvWriter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ void DbvWriter::writeExternal(YAML::Node& external_node,
161161
odb::dbDatabase* db)
162162
{
163163
BaseWriter::writeLef(external_node, db, chiplet);
164-
BaseWriter::writeDef(external_node, db, chiplet);
164+
if (db->getChip()->getBlock() != nullptr) {
165+
BaseWriter::writeDef(external_node, db, chiplet);
166+
}
165167
}
166168

167169
void DbvWriter::writeCoordinates(YAML::Node& coords_node,

src/odb/src/3dblox/dbxWriter.cpp

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
#include <yaml-cpp/node/node.h>
88

99
#include <string>
10+
#include <vector>
1011

1112
#include "baseWriter.h"
13+
#include "dbvWriter.h"
1214
#include "odb/db.h"
1315
#include "utl/Logger.h"
1416

@@ -20,6 +22,8 @@ DbxWriter::DbxWriter(utl::Logger* logger) : BaseWriter(logger)
2022

2123
void DbxWriter::writeFile(const std::string& filename, odb::dbDatabase* db)
2224
{
25+
DbvWriter dbvwriter(logger_);
26+
dbvwriter.writeFile(std::string(db->getChip()->getName()) + ".3dbv", db);
2327
YAML::Node root;
2428
writeYamlContent(root, db);
2529
writeYamlToFile(filename, root);
@@ -29,6 +33,8 @@ void DbxWriter::writeYamlContent(YAML::Node& root, odb::dbDatabase* db)
2933
{
3034
YAML::Node header_node = root["Header"];
3135
writeHeader(header_node, db);
36+
YAML::Node includes_node = header_node["include"];
37+
includes_node.push_back(std::string(db->getChip()->getName()) + ".3dbv");
3238

3339
YAML::Node design_node = root["Design"];
3440
writeDesign(design_node, db);
@@ -45,95 +51,104 @@ void DbxWriter::writeYamlContent(YAML::Node& root, odb::dbDatabase* db)
4551

4652
void DbxWriter::writeDesign(YAML::Node& design_node, odb::dbDatabase* db)
4753
{
48-
// TODO: Implement design writing
49-
design_node["name"] = "TopDesign";
50-
51-
YAML::Node external_node = design_node["external"];
52-
writeDesignExternal(external_node, db);
53-
}
54-
55-
void DbxWriter::writeDesignExternal(YAML::Node& external_node,
56-
odb::dbDatabase* db)
57-
{
58-
// TODO: Implement design external writing
59-
external_node["verilog_file"] = "/path/to/top.v";
54+
design_node["name"] = db->getChip()->getName();
6055
}
6156

6257
void DbxWriter::writeChipletInsts(YAML::Node& instances_node,
6358
odb::dbDatabase* db)
6459
{
65-
// TODO: Implement chiplet instances writing
6660
for (auto chiplet : db->getChips()) {
67-
YAML::Node instance_node
68-
= instances_node[std::string(chiplet->getName()) + "_inst"];
69-
writeChipletInst(instance_node, chiplet, db);
61+
for (auto inst : chiplet->getChipInsts()) {
62+
YAML::Node instance_node = instances_node[std::string(inst->getName())];
63+
writeChipletInst(instance_node, inst, db);
64+
}
7065
}
7166
}
7267

7368
void DbxWriter::writeChipletInst(YAML::Node& instance_node,
74-
odb::dbChip* chiplet,
69+
odb::dbChipInst* inst,
7570
odb::dbDatabase* db)
7671
{
77-
// TODO: Implement chiplet instance writing
78-
instance_node["reference"] = chiplet->getName();
79-
80-
YAML::Node external_node = instance_node["external"];
81-
writeChipletInstExternal(external_node, chiplet, db);
72+
auto master_name = inst->getMasterChip()->getName();
73+
instance_node["reference"] = master_name;
74+
// TODO: Identify clone instances
75+
instance_node["is_master"] = true;
8276
}
8377

8478
void DbxWriter::writeChipletInstExternal(YAML::Node& external_node,
8579
odb::dbChip* chiplet,
8680
odb::dbDatabase* db)
8781
{
88-
// TODO: Implement chiplet instance external writing
89-
external_node["verilog_file"]
90-
= "/path/to/" + std::string(chiplet->getName()) + ".v";
91-
external_node["sdc_file"]
92-
= "/path/to/" + std::string(chiplet->getName()) + ".sdc";
93-
external_node["def_file"]
94-
= "/path/to/" + std::string(chiplet->getName()) + ".def";
82+
BaseWriter::writeDef(external_node, db, chiplet);
9583
}
9684

9785
void DbxWriter::writeStack(YAML::Node& stack_node, odb::dbDatabase* db)
9886
{
99-
// TODO: Implement stack writing
100-
int z_offset = 0;
10187
for (auto chiplet : db->getChips()) {
102-
YAML::Node stack_instance_node
103-
= stack_node[std::string(chiplet->getName()) + "_inst"];
104-
writeStackInstance(stack_instance_node, chiplet, db);
105-
z_offset += chiplet->getThickness() / (double) db->getDbuPerMicron();
88+
for (auto inst : chiplet->getChipInsts()) {
89+
YAML::Node stack_instance_node = stack_node[std::string(inst->getName())];
90+
writeStackInstance(stack_instance_node, inst, db);
91+
}
10692
}
10793
}
10894

10995
void DbxWriter::writeStackInstance(YAML::Node& stack_instance_node,
110-
odb::dbChip* chiplet,
96+
odb::dbChipInst* inst,
11197
odb::dbDatabase* db)
11298
{
113-
// TODO: Implement stack instance writing
114-
auto offset_x = chiplet->getOffset().getX() / db->getDbuPerMicron();
115-
auto offset_y = chiplet->getOffset().getY() / db->getDbuPerMicron();
116-
99+
auto loc_x = inst->getLoc().x() / db->getDbuPerMicron();
100+
auto loc_y = inst->getLoc().y() / db->getDbuPerMicron();
117101
YAML::Node loc_out;
118102
loc_out.SetStyle(YAML::EmitterStyle::Flow);
119-
loc_out.push_back(offset_x);
120-
loc_out.push_back(offset_y);
103+
loc_out.push_back(loc_x);
104+
loc_out.push_back(loc_y);
121105
stack_instance_node["loc"] = loc_out;
122-
123-
stack_instance_node["z"] = 0.0; // TODO: Calculate proper z position
124-
stack_instance_node["orient"] = "R0"; // TODO: Get proper orientation
106+
stack_instance_node["z"] = inst->getLoc().z() / db->getDbuPerMicron();
107+
stack_instance_node["orient"] = inst->getOrient().getString();
125108
}
126109

127110
void DbxWriter::writeConnections(YAML::Node& connections_node,
128111
odb::dbDatabase* db)
129112
{
130-
// TODO: Implement connections writing
113+
for (auto chiplet : db->getChips()) {
114+
for (auto conn : chiplet->getChipConns()) {
115+
YAML::Node connection_node
116+
= connections_node[std::string(conn->getName())];
117+
writeConnection(connection_node, conn, db);
118+
}
119+
}
131120
}
132121

133122
void DbxWriter::writeConnection(YAML::Node& connection_node,
123+
odb::dbChipConn* conn,
134124
odb::dbDatabase* db)
135125
{
136-
// TODO: Implement connection writing
126+
connection_node["top"]
127+
= buildPath(conn->getTopRegionPath(), conn->getTopRegion());
128+
connection_node["bot"]
129+
= buildPath(conn->getBottomRegionPath(), conn->getBottomRegion());
130+
connection_node["thicness"] = conn->getThickness() / db->getDbuPerMicron();
131+
}
132+
133+
std::string DbxWriter::buildPath(const std::vector<dbChipInst*>& path_insts,
134+
odb::dbChipRegionInst* region)
135+
{
136+
if (region == nullptr) {
137+
return "~";
138+
}
139+
140+
std::string path = "";
141+
for (auto inst : path_insts) {
142+
if (!path.empty()) {
143+
path += "/";
144+
}
145+
path += inst->getName();
146+
}
147+
148+
if (!path.empty()) {
149+
path += ".regions." + region->getChipRegion()->getName();
150+
}
151+
return path;
137152
}
138153

139154
} // namespace odb

src/odb/src/3dblox/dbxWriter.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,21 @@ class DbxWriter : public BaseWriter
2929
void writeDesignExternal(YAML::Node& external_node, odb::dbDatabase* db);
3030
void writeChipletInsts(YAML::Node& instances_node, odb::dbDatabase* db);
3131
void writeChipletInst(YAML::Node& instance_node,
32-
odb::dbChip* chiplet,
32+
odb::dbChipInst* inst,
3333
odb::dbDatabase* db);
3434
void writeChipletInstExternal(YAML::Node& external_node,
3535
odb::dbChip* chiplet,
3636
odb::dbDatabase* db);
3737
void writeStack(YAML::Node& stack_node, odb::dbDatabase* db);
3838
void writeStackInstance(YAML::Node& stack_instance_node,
39-
odb::dbChip* chiplet,
39+
odb::dbChipInst* inst,
4040
odb::dbDatabase* db);
4141
void writeConnections(YAML::Node& connections_node, odb::dbDatabase* db);
42-
void writeConnection(YAML::Node& connection_node, odb::dbDatabase* db);
42+
void writeConnection(YAML::Node& connection_node,
43+
odb::dbChipConn* conn,
44+
odb::dbDatabase* db);
45+
std::string buildPath(const std::vector<dbChipInst*>& path_insts,
46+
odb::dbChipRegionInst* region);
4347
};
4448

4549
} // namespace odb

src/odb/test/write_3dbx.3dbxok

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@ Header:
22
version: 2.5
33
unit: micron
44
precision: 100000
5+
include:
6+
- TopDesign.3dbv
57
Design:
68
name: TopDesign
7-
external:
8-
verilog_file: /path/to/top.v
99
ChipletInst:
10-
SoC_inst:
10+
soc_inst_duplicate:
1111
reference: SoC
12-
external:
13-
verilog_file: /path/to/SoC.v
14-
sdc_file: /path/to/SoC.sdc
15-
def_file: /path/to/SoC.def
16-
TopDesign_inst:
17-
reference: TopDesign
18-
external:
19-
verilog_file: /path/to/TopDesign.v
20-
sdc_file: /path/to/TopDesign.sdc
21-
def_file: /path/to/TopDesign.def
12+
is_master: true
13+
soc_inst:
14+
reference: SoC
15+
is_master: true
2216
Stack:
23-
SoC_inst:
24-
loc: [0, 0]
17+
soc_inst_duplicate:
18+
loc: [100, 200]
19+
z: 300
20+
orient: MZ
21+
soc_inst:
22+
loc: [100, 200]
2523
z: 0
2624
orient: R0
27-
TopDesign_inst:
28-
loc: [0, 0]
29-
z: 0
30-
orient: R0
25+
Connection:
26+
soc_to_virtual:
27+
top: soc_inst_duplicate.regions.r1
28+
bot: "~"
29+
thicness: 0
30+
soc_to_soc:
31+
top: soc_inst_duplicate.regions.r1
32+
bot: soc_inst.regions.r1
33+
thicness: 2

0 commit comments

Comments
 (0)