stat: allow gzipped liberty files

This commit is contained in:
Emil J. Tywoniak 2025-01-27 16:08:47 +01:00
parent a72074777a
commit 3afbd48f61
2 changed files with 19 additions and 5 deletions

View File

@ -23,6 +23,7 @@
#include "kernel/celltypes.h" #include "kernel/celltypes.h"
#include "passes/techmap/libparse.h" #include "passes/techmap/libparse.h"
#include "kernel/cost.h" #include "kernel/cost.h"
#include "kernel/gzip.h"
#include "libs/json11/json11.hpp" #include "libs/json11/json11.hpp"
USING_YOSYS_NAMESPACE USING_YOSYS_NAMESPACE
@ -347,13 +348,12 @@ statdata_t hierarchy_worker(std::map<RTLIL::IdString, statdata_t> &mod_stat, RTL
void read_liberty_cellarea(dict<IdString, cell_area_t> &cell_area, string liberty_file) void read_liberty_cellarea(dict<IdString, cell_area_t> &cell_area, string liberty_file)
{ {
std::ifstream f; std::istream* f = uncompressed(liberty_file.c_str());
f.open(liberty_file.c_str());
yosys_input_files.insert(liberty_file); yosys_input_files.insert(liberty_file);
if (f.fail()) if (f->fail())
log_cmd_error("Can't open liberty file `%s': %s\n", liberty_file.c_str(), strerror(errno)); log_cmd_error("Can't open liberty file `%s': %s\n", liberty_file.c_str(), strerror(errno));
LibertyParser libparser(f); LibertyParser libparser(*f);
f.close(); delete f;
for (auto cell : libparser.ast->children) for (auto cell : libparser.ast->children)
{ {

14
tests/various/stat.ys Normal file
View File

@ -0,0 +1,14 @@
read_rtlil << EOF
module \top
wire input 1 \A
wire output 2 \Y
cell \sg13g2_and2_1 \sub
connect \A \A
connect \B 1'0
connect \Y \Y
end
end
EOF
logger -expect log "Chip area for module '\\top': 9.072000" 1
logger -expect-no-warnings
stat -liberty ../../tests/liberty/foundry_data/sg13g2_stdcell_typ_1p20V_25C.lib.filtered.gz