Skip to content

Commit e03f90c

Browse files
committed
[vpr][analysis] change report_net_timing format to csv
1 parent 77799b6 commit e03f90c

File tree

1 file changed

+28
-48
lines changed

1 file changed

+28
-48
lines changed

vpr/src/analysis/timing_reports.cpp

Lines changed: 28 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -180,75 +180,55 @@ void generate_hold_timing_stats(const std::string& prefix,
180180
timing_reporter.report_unconstrained_hold(prefix + "report_unconstrained_timing.hold.rpt", *timing_info.hold_analyzer());
181181
}
182182

183-
void generate_net_timing_report(const std::string& prefix,
184-
const SetupHoldTimingInfo& timing_info,
185-
const AnalysisDelayCalculator& delay_calc) {
186-
/* Create a report file for net timing information */
187-
std::ofstream os(prefix + "report_net_timing.rpt");
183+
void generate_net_timing_report_csv(const std::string& prefix,
184+
const SetupHoldTimingInfo& timing_info,
185+
const AnalysisDelayCalculator& delay_calc) {
186+
std::ofstream os(prefix + "report_net_timing.csv");
188187
const auto& atom_netlist = g_vpr_ctx.atom().netlist();
189188
const auto& atom_lookup = g_vpr_ctx.atom().lookup();
190-
191189
const auto& timing_ctx = g_vpr_ctx.timing();
192190
const auto& timing_graph = timing_ctx.graph;
193191

194-
os << "# This file is generated by VTR" << std::endl;
195-
os << "# Version: " << vtr::VERSION << std::endl;
196-
os << "# Revision: " << vtr::VCS_REVISION << std::endl;
197-
os << "# For each net, the timing information is reported in the following format:" << std::endl;
198-
os << "# netname : Fanout : "
199-
<< "(bounding_box_xmin,bounding_box_ymin,bounding_box_layermin),(bounding_box_xmax,bounding_box_ymax,bounding_box_layermax) : "
200-
<< "source_instance <slack_on source pin> : "
201-
<< "<load pin name1> <slack on load pin name1> <net delay for this net> : "
202-
<< "<load pin name2> <slack on load pin name2> <net delay for this net> : ..."
203-
<< std::endl;
204-
205-
os << std::endl;
192+
// Write CSV header
193+
os << "netname,Fanout,bb_xmin,bb_ymin,bb_layer_min,"
194+
<< "bb_xmax,bb_ymax,bb_layer_max,"
195+
<< "src_pin_name,src_pin_slack,sinks" << std::endl;
206196

207197
for (const auto& net : atom_netlist.nets()) {
208-
/* Skip constant nets */
209-
if (atom_netlist.net_is_constant(net)) {
210-
continue;
211-
}
198+
if (atom_netlist.net_is_constant(net)) continue;
212199

213200
const auto& net_name = atom_netlist.net_name(net);
214-
215-
/* Get source pin and its timing information */
216201
const auto& source_pin = *atom_netlist.net_pins(net).begin();
217202
auto source_pin_slack = timing_info.setup_pin_slack(source_pin);
218-
/* Timing graph node id corresponding to the net's source pin */
219203
auto tg_source_node = atom_lookup.atom_pin_tnode(source_pin);
220204
VTR_ASSERT(tg_source_node.is_valid());
221205

222206
const size_t fanout = atom_netlist.net_sinks(net).size();
223207
const auto& net_bb = get_net_bounding_box(net);
224-
os << net_name << " : "
225-
<< fanout << " : "
226-
<< "(" << net_bb.xmin << "," << net_bb.ymin << "," << net_bb.layer_min << "),("
227-
<< net_bb.xmax << "," << net_bb.ymax << "," << net_bb.layer_max << ") : "
228-
<< atom_netlist.pin_name(source_pin).c_str() << " " << source_pin_slack << " : ";
229-
230-
/* Iterate over all fanout pins and print their timing information */
231-
for (size_t net_pin_index = 1; net_pin_index <= fanout; ++net_pin_index) {
232-
const auto& pin = *(atom_netlist.net_pins(net).begin() + net_pin_index);
233-
234-
/* Get timing graph node id corresponding to the fanout pin */
235-
const auto& tg_sink_node = atom_lookup.atom_pin_tnode(pin);
208+
209+
os << "\"" << net_name << "\"," // netname (quoted for safety)
210+
<< fanout << ","
211+
<< net_bb.xmin << "," << net_bb.ymin << "," << net_bb.layer_min << ","
212+
<< net_bb.xmax << "," << net_bb.ymax << "," << net_bb.layer_max << ","
213+
<< "\"" << atom_netlist.pin_name(source_pin) << "\"," << source_pin_slack << ",";
214+
215+
// Write sinks column (quoted, semicolon-delimited, each sink: name,slack,delay)
216+
os << "\"";
217+
for (size_t i = 0; i < fanout; ++i) {
218+
const auto& pin = *(atom_netlist.net_pins(net).begin() + i + 1);
219+
auto tg_sink_node = atom_lookup.atom_pin_tnode(pin);
236220
VTR_ASSERT(tg_sink_node.is_valid());
237221

238-
/* Get timing graph edge id between atom pins */
239-
const auto& tg_edge_id = timing_graph->find_edge(tg_source_node, tg_sink_node);
222+
auto tg_edge_id = timing_graph->find_edge(tg_source_node, tg_sink_node);
240223
VTR_ASSERT(tg_edge_id.is_valid());
241224

242-
/* Get timing information for the fanout pin */
243-
const auto& pin_setup_slack = timing_info.setup_pin_slack(pin);
244-
const auto& pin_delay = delay_calc.max_edge_delay(*timing_graph, tg_edge_id);
245-
225+
auto pin_setup_slack = timing_info.setup_pin_slack(pin);
226+
auto pin_delay = delay_calc.max_edge_delay(*timing_graph, tg_edge_id);
246227
const auto& pin_name = atom_netlist.pin_name(pin);
247-
os << pin_name << " " << std::scientific << pin_setup_slack << " " << pin_delay;
248-
if (net_pin_index < fanout) {
249-
os << " : ";
250-
}
228+
229+
os << pin_name << "," << pin_setup_slack << "," << pin_delay;
230+
if (i != fanout - 1) os << ";";
251231
}
252-
os << "," << std::endl;
232+
os << "\"" << std::endl; // Close quoted sinks field and finish the row
253233
}
254234
}

0 commit comments

Comments
 (0)