Skip to content

Commit 980a0a1

Browse files
committed
stat: allow gzipped liberty files
1 parent 7aefd4b commit 980a0a1

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

passes/cmds/stat.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "kernel/celltypes.h"
2424
#include "passes/techmap/libparse.h"
2525
#include "kernel/cost.h"
26+
#include "kernel/gzip.h"
2627
#include "libs/json11/json11.hpp"
2728

2829
USING_YOSYS_NAMESPACE
@@ -347,13 +348,12 @@ statdata_t hierarchy_worker(std::map<RTLIL::IdString, statdata_t> &mod_stat, RTL
347348

348349
void read_liberty_cellarea(dict<IdString, cell_area_t> &cell_area, string liberty_file)
349350
{
350-
std::ifstream f;
351-
f.open(liberty_file.c_str());
351+
std::istream* f = uncompressed(liberty_file.c_str());
352352
yosys_input_files.insert(liberty_file);
353-
if (f.fail())
353+
if (f->fail())
354354
log_cmd_error("Can't open liberty file `%s': %s\n", liberty_file.c_str(), strerror(errno));
355-
LibertyParser libparser(f);
356-
f.close();
355+
LibertyParser libparser(*f);
356+
delete f;
357357

358358
for (auto cell : libparser.ast->children)
359359
{

tests/various/stat.ys

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
read_rtlil << EOF
2+
module \top
3+
wire input 1 \A
4+
wire output 2 \Y
5+
cell \sg13g2_and2_1 \sub
6+
connect \A \A
7+
connect \B 1'0
8+
connect \Y \Y
9+
end
10+
end
11+
EOF
12+
logger -expect log "Chip area for module '\\top': 9.072000" 1
13+
logger -expect-no-warnings
14+
stat -liberty ../../tests/liberty/foundry_data/sg13g2_stdcell_typ_1p20V_25C.lib.filtered.gz

0 commit comments

Comments
 (0)