我正在尝试解析以下区域文件以获得总组合区域,非组合区域和总单元区域,但是我没有成功并且觉得我不知道如何执行此操作。我尝试读取每个值,但我一直收到错误:
所以我希望能够将以下值存储在三个独立的数组中:
20368.919640, 2050.360019, 22419.279659
这是我的档案:
****************************************
Report : area
Design : mymodule
Version: F-2011.09-SP1
Date : Sat Mar 28 17:00:30 2015
****************************************
Library(s) Used:
PLEXPVT (File: /bin/comp/temp/tech.2.1/PLEXPVT-PLEXPVT-CDS_4.1/libs/PLEXPVT.25C.db)
PLEXPVT (File: /bin/comp/temp/tech.2.1/PLEXPVT-PLEXPVT-CDS_6.0/libs/PLEXPVT.25C.db)
Number of ports: 277
Number of nets: 5905
Number of cells: 5341
Number of combinational cells: 5092
Number of sequential cells: 249
Number of macros: 0
Number of buf/inv: 606
Number of references: 212
Combinational area: 20368.919640
Noncombinational area: 2050.360019
Net Interconnect area: undefined (Wire load has zero net area)
Total cell area: 22419.279659
Total area: undefined
Hierarchical area distribution
------------------------------
Global cell area Local cell area
------------------- -----------------------------
Hierarchical cell Absolute Percent Combi- Noncombi- Black
Total Total national national boxes Design-------------------------------- ---------- ------- ---------- --------- ------ ---------
mymodule 22419.2797 100.0 20368.9196 2050.3600 0.0000 mymodule
-------------------------------- ---------- ------- ---------- --------- ------ ---------
Total 20368.9196 2050.3600 0.0000
答案 0 :(得分:1)
一种简单的方法不是试图理解所有内容,而只关注包含所需数据的行;例如:
double comb=0, ncomb=0, tcell=0;
int comb_count=0, ncomb_count=0, tcell_count=0;
std::ifstream input(filename);
for (std::string L; std::getline(input, L);) {
if (get_data(L, "Combinational area", &comb)) comb_count++;
if (get_data(L, "Noncombinational area", &ncomb)) ncomb_count++;
if (get_data(L, "Total cell area", &tcell)) tcell_count++;
}
if (comb_count==1 && ncomb_count==1 && tcell_count==1) {
// The file contained exactly one of each
vcomb.push_back(comb);
vncomb.push_back(ncomb);
vtcell.push_back(tcell);
} else {
// Something was missing or data repeated
...
}
其中get_data
只是
bool get_data(const std::string L,
const std::string& prefix,
double *v) {
return (sscanf(L.c_str(), (prefix + ": %lf").c_str(), v) == 1);
}