Skip to content

Commit

Permalink
dft: references to consts wherever possible
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Gaber <[email protected]>
  • Loading branch information
donn committed Dec 23, 2024
1 parent 3e2b84d commit 3bc69bf
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/dft/include/dft/Dft.hh
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class Dft
void scanReplace();

void insertDft(bool per_chain_enable,
std::string scan_enable_name_pattern,
std::string scan_in_name_pattern,
std::string scan_out_name_pattern);
const std::string& scan_enable_name_pattern,
const std::string& scan_in_name_pattern,
const std::string& scan_out_name_pattern);

// Returns a mutable version of DftConfig
DftConfig* getMutableDftConfig();
Expand All @@ -112,7 +112,7 @@ class Dft
void reportDftConfig() const;

// Writes scan chains in a JSON format
void writeScanChains(std::string filename);
void writeScanChains(const std::string& filename);

private:
// If we need to run pre_dft to create the internal state
Expand Down
8 changes: 4 additions & 4 deletions src/dft/src/Dft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Dft::scanReplace()
scan_replace_->scanReplace();
}

void Dft::writeScanChains(std::string filename)
void Dft::writeScanChains(const std::string& filename)
{
using boost::property_tree::ptree;
if (need_to_run_pre_dft_) {
Expand Down Expand Up @@ -144,9 +144,9 @@ void Dft::writeScanChains(std::string filename)
}

void Dft::insertDft(bool per_chain_enable,
std::string scan_enable_name_pattern,
std::string scan_in_name_pattern,
std::string scan_out_name_pattern)
const std::string& scan_enable_name_pattern,
const std::string& scan_in_name_pattern,
const std::string& scan_out_name_pattern)
{
if (need_to_run_pre_dft_) {
pre_dft();
Expand Down
10 changes: 5 additions & 5 deletions src/dft/src/dft.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ sta::define_cmd_args "insert_dft" {
}
proc insert_dft { args } {
sta::parse_key_args "insert_dft" args \
keys {-scan_enable_name_pattern -scan_in_name_pattern -scan_out_name_pattern}\
keys {-scan_enable_name_pattern -scan_in_name_pattern -scan_out_name_pattern} \
flags {-per_chain_enable}

if { [ord::get_db_block] == "NULL" } {
utl::error DFT 9 "No design block found."
}

foreach {flag default} {
-scan_enable_name_pattern "scan_enable_{}"
-scan_in_name_pattern "scan_in_{}"
Expand All @@ -94,9 +94,9 @@ proc insert_dft { args } {
set keys($flag) $default
}
}
dft::insert_dft [info exists flags(-per_chain_enable)]\
$keys(-scan_enable_name_pattern)\
$keys(-scan_in_name_pattern)\
dft::insert_dft [info exists flags(-per_chain_enable)] \
$keys(-scan_enable_name_pattern) \
$keys(-scan_in_name_pattern) \
$keys(-scan_out_name_pattern)
}

Expand Down
36 changes: 18 additions & 18 deletions src/dft/src/stitch/ScanStitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ void ScanStitch::Stitch(odb::dbBlock* block,
last_scan_cell->connectScanOut(scan_out_load);
}

static std::pair<std::string, std::optional<std::string>>
split_term_identifier(std::string& input, const char* kind, utl::Logger* logger)
static std::pair<std::string, std::optional<std::string>> split_term_identifier(
const std::string& input,
const char* kind,
utl::Logger* logger)
{
size_t tracker = 0;
size_t slash_position;
Expand All @@ -127,7 +129,7 @@ split_term_identifier(std::string& input, const char* kind, utl::Logger* logger)

ScanDriver ScanStitch::FindOrCreateDriver(const char* kind,
odb::dbBlock* block,
std::string with_name,
const std::string& with_name,
utl::Logger* logger)
{
auto term_info = split_term_identifier(with_name, kind, logger);
Expand Down Expand Up @@ -171,22 +173,22 @@ ScanDriver ScanStitch::FindOrCreateDriver(const char* kind,
}

ScanDriver ScanStitch::FindOrCreateScanEnable(odb::dbBlock* block,
std::string with_name,
const std::string& with_name,
utl::Logger* logger)
{
return FindOrCreateDriver("scan-enable", block, with_name, logger);
}

ScanDriver ScanStitch::FindOrCreateScanIn(odb::dbBlock* block,
std::string with_name,
const std::string& with_name,
utl::Logger* logger)
{
return FindOrCreateDriver("scan-in", block, with_name, logger);
}

ScanLoad ScanStitch::FindOrCreateScanOut(odb::dbBlock* block,
const ScanDriver& cell_scan_out,
std::string with_name,
const std::string& with_name,
utl::Logger* logger)
{
const char* kind = "scan-out";
Expand Down Expand Up @@ -220,19 +222,17 @@ ScanLoad ScanStitch::FindOrCreateScanOut(odb::dbBlock* block,
iterm->getIoType().getString());
}
return ScanLoad(iterm);
} else {
auto bterm = block->findBTerm(with_name.data());
if (bterm != nullptr) {
if (bterm->getIoType() != odb::dbIoType::OUTPUT) {
logger->error(
utl::DFT,
40,
"Top-level pin '{}' specified as {} is not an output port",
term_info.first,
kind);
}
return ScanLoad(bterm);
}
auto bterm = block->findBTerm(with_name.data());
if (bterm != nullptr) {
if (bterm->getIoType() != odb::dbIoType::OUTPUT) {
logger->error(utl::DFT,
40,
"Top-level pin '{}' specified as {} is not an output port",
term_info.first,
kind);
}
return ScanLoad(bterm);
}

// TODO: Trace forward the scan out net so we can see if it is connected to a
Expand Down
10 changes: 5 additions & 5 deletions src/dft/src/stitch/ScanStitch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ class ScanStitch
private:
ScanDriver FindOrCreateDriver(const char* kind,
odb::dbBlock* block,
std::string with_name,
const std::string& with_name,
utl::Logger* logger);
ScanDriver FindOrCreateScanEnable(odb::dbBlock* block,
std::string with_name,
const std::string& with_name,
utl::Logger* logger);
ScanDriver FindOrCreateScanIn(odb::dbBlock* block,
std::string with_name,
const std::string& with_name,
utl::Logger* logger);
ScanLoad FindOrCreateScanOut(odb::dbBlock* block,
const ScanDriver& cell_scan_out,
std::string with_name,
const std::string& with_name,
utl::Logger* logger);

// Typesafe function to create Ports for the scan chains.
template <typename Port>
inline Port CreateNewPort(odb::dbBlock* block,
std::string port_name,
const std::string& port_name,
utl::Logger* logger,
odb::dbNet* net = nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion src/dft/src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool IsScanCell(const sta::LibertyCell* libertyCell)
}

odb::dbBTerm* CreateNewPort(odb::dbBlock* block,
std::string port_name,
const std::string& port_name,
utl::Logger* logger,
odb::dbNet* net)
{
Expand Down
2 changes: 1 addition & 1 deletion src/dft/src/utils/Utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool IsScanCell(const sta::LibertyCell* libertyCell);

// Convenience method to create a new port
odb::dbBTerm* CreateNewPort(odb::dbBlock* block,
std::string port_name,
const std::string& port_name,
utl::Logger* logger,
odb::dbNet* net = nullptr);

Expand Down

0 comments on commit 3bc69bf

Please sign in to comment.