Skip to content

Commit fd47fb5

Browse files
malibertyshypark98
authored andcommitted
par: fix tclfmt in write_artnet.tcl
Signed-off-by: Matt Liberty <[email protected]>
1 parent 6ffc9e3 commit fd47fb5

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

src/par/include/par/PartitionMgr.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class Logger;
3838

3939
namespace par {
4040

41+
struct MasterInfo {
42+
int count = 0;
43+
bool isMacro = false;
44+
};
45+
4146
class Cluster;
4247
using SharedClusterVector = std::vector<std::shared_ptr<Cluster>>;
4348
class ModuleMgr;
@@ -253,7 +258,7 @@ class PartitionMgr
253258
// ArtNet SpecGen
254259
void printMemoryUsage();
255260
void getFromODB(
256-
std::unordered_map<std::string, std::pair<int, bool>>& onlyUseMasters,
261+
std::unordered_map<std::string, MasterInfo>& onlyUseMasters,
257262
std::string& top_name,
258263
int& numInsts,
259264
int& numPIs,
@@ -283,7 +288,7 @@ class PartitionMgr
283288
void Partitioning(const std::shared_ptr<TritonPart>& triton_part,
284289
const std::shared_ptr<Cluster>& cluster,
285290
SharedClusterVector& resultCV);
286-
void writeFile(const std::unordered_map<std::string, std::pair<int, bool>>&
291+
void writeFile(const std::unordered_map<std::string, MasterInfo>&
287292
onlyUseMasters,
288293
const std::string& top_name,
289294
int numInsts,

src/par/src/ArtNetSpec.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void PartitionMgr::writeArtNetSpec(const char* fileName)
7474
logger_->error(PAR, 53, "Design not loaded.");
7575
}
7676

77-
std::unordered_map<std::string, std::pair<int, bool>> onlyUseMasters;
77+
std::unordered_map<std::string, MasterInfo> onlyUseMasters;
7878
std::string top_name;
7979
int numInsts = 0;
8080
int numPIs = 0;
@@ -107,7 +107,7 @@ void PartitionMgr::writeArtNetSpec(const char* fileName)
107107
}
108108

109109
void PartitionMgr::getFromODB(
110-
std::unordered_map<std::string, std::pair<int, bool>>& onlyUseMasters,
110+
std::unordered_map<std::string, MasterInfo>& onlyUseMasters,
111111
std::string& top_name,
112112
int& numInsts,
113113
int& numPIs,
@@ -131,13 +131,15 @@ void PartitionMgr::getFromODB(
131131
for (auto inst : insts) {
132132
dbMaster* master = inst->getMaster();
133133
bool isMacro = (master->getType() == dbMasterType::BLOCK ? 1 : 0);
134-
if (master->isSequential()) {
135-
numSeq++;
136-
}
137-
if (onlyUseMasters.find(master->getName()) == onlyUseMasters.end()) {
138-
onlyUseMasters[master->getName()] = std::make_pair(0, isMacro);
134+
if (const sta::LibertyCell* lib_cell = db_network_->libertyCell(inst)) {
135+
if (lib_cell->hasSequentials()) {
136+
numSeq++;
137+
}
139138
}
140-
onlyUseMasters[master->getName()].first++;
139+
auto [it, inserted] = onlyUseMasters.try_emplace(master->getName(), MasterInfo{});
140+
MasterInfo& info = it->second;
141+
info.isMacro = isMacro;
142+
++info.count;
141143
}
142144
}
143145

@@ -671,7 +673,7 @@ void PartitionMgr::fit_mul(const double* x,
671673
}
672674

673675
void PartitionMgr::writeFile(
674-
const std::unordered_map<std::string, std::pair<int, bool>>& onlyUseMasters,
676+
const std::unordered_map<std::string, MasterInfo>& onlyUseMasters,
675677
const std::string& top_name,
676678
const int numInsts,
677679
const int numPIs,
@@ -693,12 +695,12 @@ void PartitionMgr::writeFile(
693695
outFile << "LIBRARY\n";
694696
outFile << "NAME lib\n";
695697

696-
// unordered_map<string, int> --> cellName / isMacro
697-
for (const auto& it : onlyUseMasters) {
698-
if (!it.second.second) {
699-
outFile << "STD_CELL " << it.first << '\n';
698+
// unordered_map<string, MasterInfo> --> cellName / cellCount, isMacro
699+
for (const auto& [name, info] : onlyUseMasters) {
700+
if (!info.isMacro) {
701+
outFile << "STD_CELL " << name << '\n';
700702
} else {
701-
outFile << "MACRO_CELL " << it.first << '\n';
703+
outFile << "MACRO_CELL " << name << '\n';
702704
}
703705
}
704706
outFile << '\n';
@@ -707,8 +709,8 @@ void PartitionMgr::writeFile(
707709
outFile << "NAME " << top_name << '\n';
708710
outFile << "LIBRARIES lib" << '\n';
709711
outFile << "DISTRIBUTION ";
710-
for (const auto& it : onlyUseMasters) {
711-
outFile << it.second.first << " ";
712+
for (const auto& [name, info] : onlyUseMasters) {
713+
outFile << info.count << " ";
712714
}
713715
outFile << '\n';
714716
outFile << "SIZE " << int(numInsts * Rratio) << '\n';

src/par/test/write_artnet.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ link_design gcd
99

1010
read_sdc gcd_nangate45.sdc
1111

12-
set spec_file [make_result_file write_artnet.spec]
12+
set spec_file [make_result_file write_artnet.spec]
1313
write_artnet_spec -out_file $spec_file
1414

1515
diff_files write_artnet.specok $spec_file

0 commit comments

Comments
 (0)