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
3 changes: 3 additions & 0 deletions include/sta/Sta.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,9 @@ public:
// TCL variable sta_input_port_default_clock.
bool useDefaultArrivalClock() const;
void setUseDefaultArrivalClock(bool enable);
// TCL variable sta_strip_escaped_bus.
bool stripEscapedBus() const;
void setStripEscapedBus(bool enable);
////////////////////////////////////////////////////////////////

Properties &properties() { return properties_; }
Expand Down
4 changes: 4 additions & 0 deletions include/sta/Variables.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public:
void setUseDefaultArrivalClock(bool enable);
bool pocvEnabled() const { return pocv_enabled_; }
void setPocvEnabled(bool enabled);
// TCL variable sta_strip_escaped_bus.
bool stripEscapedBus() const { return strip_escaped_bus_; }
void setStripEscapedBus(bool enable) { strip_escaped_bus_ = enable; }

private:
bool crpr_enabled_;
Expand All @@ -94,6 +97,7 @@ private:
bool propagate_all_clks_;
bool use_default_arrival_clock_;
bool pocv_enabled_;
bool strip_escaped_bus_;
};

} // namespace
3 changes: 2 additions & 1 deletion sdc/Variables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Variables::Variables() :
dynamic_loop_breaking_(false),
propagate_all_clks_(false),
use_default_arrival_clock_(false),
pocv_enabled_(false)
pocv_enabled_(false),
strip_escaped_bus_(false)
{
}

Expand Down
13 changes: 13 additions & 0 deletions search/Search.i
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,19 @@ levelize()
sta->levelize()->levelize();
}

bool
strip_escaped_bus()
{
return Sta::sta()->stripEscapedBus();
}

void
set_strip_escaped_bus(bool enable)
{
Sta::sta()->setStripEscapedBus(enable);
}


%} // inline

////////////////////////////////////////////////////////////////
Expand Down
13 changes: 13 additions & 0 deletions search/Sta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,19 @@ Sta::setClkThruTristateEnabled(bool enable)
}
}

bool
Sta::stripEscapedBus() const
{
return variables_->stripEscapedBus();
}

void
Sta::setStripEscapedBus(bool enable)
{
variables_->setStripEscapedBus(enable);
}


////////////////////////////////////////////////////////////////

Corner *
Expand Down
8 changes: 8 additions & 0 deletions tcl/Variables.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ proc trace_pocv_enabled { name1 name2 op } {
pocv_enabled set_pocv_enabled
}

trace variable ::sta_strip_escaped_bus "rw" \
sta::trace_strip_escaped_bus

proc trace_strip_escaped_bus { name1 name2 op } {
trace_boolean_var $op ::sta_strip_escaped_bus \
strip_escaped_bus set_strip_escaped_bus
}

# Report path numeric field width is digits + extra.
set report_path_field_width_extra 5

Expand Down
1 change: 1 addition & 0 deletions test/regression_vars.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ record_sta_tests {
report_checks_src_attr
report_json1
report_json2
sdc_strip_escaped_bus
suppress_msg
verilog_attribute
verilog_specify
Expand Down
2 changes: 2 additions & 0 deletions test/sdc_strip_escaped_bus.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Error: sdc_strip_escaped_bus.tcl line 11, pin 'a' not found.
Error: sdc_strip_escaped_bus.tcl line 12, pin 'y' not found.
21 changes: 21 additions & 0 deletions test/sdc_strip_escaped_bus.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# sdc clock annotation for 2d array

# Load design and create clock
set sta_continue_on_error 1
read_verilog sdc_strip_escaped_bus.v
link_design sdc_strip_escaped_bus
create_clock -name clk -period 1000

# sta_strip_escaped_bus 0: should produce errors for { a } and { y }
set sta_strip_escaped_bus 0
set_input_delay -clock clk 3 { a }
set_output_delay -clock clk 3 { y }
set_input_delay -clock clk 4 { a[0] }
set_output_delay -clock clk 4 { y[0] }

# sta_strip_escaped_bus 1
set sta_strip_escaped_bus 1
set_input_delay -clock clk 0 { a }
set_output_delay -clock clk 0 { y }
set_input_delay -clock clk 1 { a[0] }
set_output_delay -clock clk 1 { y[0] }
22 changes: 22 additions & 0 deletions test/sdc_strip_escaped_bus.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module sdc_strip_escaped_bus(\a[3] , \a[2] , \a[1] , \a[0] , \y[3] , \y[2] , \y[1] , \y[0] );
input [3:0] \a[0] ;
wire [3:0] \a[0] ;
input [3:0] \a[1] ;
wire [3:0] \a[1] ;
input [3:0] \a[2] ;
wire [3:0] \a[2] ;
input [3:0] \a[3] ;
wire [3:0] \a[3] ;
output [3:0] \y[0] ;
wire [3:0] \y[0] ;
output [3:0] \y[1] ;
wire [3:0] \y[1] ;
output [3:0] \y[2] ;
wire [3:0] \y[2] ;
output [3:0] \y[3] ;
wire [3:0] \y[3] ;
assign \y[0] = \a[0] ;
assign \y[1] = \a[1] ;
assign \y[2] = \a[2] ;
assign \y[3] = \a[3] ;
endmodule
31 changes: 29 additions & 2 deletions util/PatternMatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
// This notice may not be removed or altered from any source distribution.

#include "PatternMatch.hh"
#include "Sta.hh"
#include <cstring>
#include <regex>
#include <tcl.h>

namespace sta {

using std::regex;
using std::string;

PatternMatch::PatternMatch(const char *pattern,
Expand Down Expand Up @@ -117,13 +120,35 @@ PatternMatch::match(const string &str) const
return match(str.c_str());
}

string
stripEscapedBus(string str)
{
// strip escaped bus indices from str
// bus\[8\] -> bus
// bus\[8\]\[7\] -> bus
// bus\[8\]\[7\]\[6\] -> bus
// bus\[8\].hello -> bus\[8\].hello
// bus\[hello\].world -> bus\[hello\].world
// etc.
string result = str;
regex trailing_numeric_pattern(R"(\\\[\s*\d+\s*\\\]$)");
string prev_result;
do {
prev_result = result;
result = std::regex_replace(result, trailing_numeric_pattern, "");
} while (result != prev_result);
return result;
}

bool
PatternMatch::match(const char *str) const
{
if (regexp_)
return Tcl_RegExpExec(nullptr, regexp_, str, str) == 1;
else
return patternMatch(pattern_, str);
return patternMatch(pattern_, str)
|| (Sta::sta()->stripEscapedBus() &&
patternMatch(pattern_, stripEscapedBus(str).c_str()));
}

bool
Expand All @@ -132,7 +157,9 @@ PatternMatch::matchNoCase(const char *str) const
if (regexp_)
return Tcl_RegExpExec(0, regexp_, str, str) == 1;
else
return patternMatchNoCase(pattern_, str, nocase_);
return patternMatchNoCase(pattern_, str, nocase_)
|| (Sta::sta()->stripEscapedBus() &&
patternMatchNoCase(pattern_, stripEscapedBus(str).c_str(), nocase_));
}

////////////////////////////////////////////////////////////////
Expand Down