mirror of https://github.com/YosysHQ/yosys.git
Remove cover() coverage tracking
This commit is contained in:
parent
52b1245547
commit
638e904f91
9
Makefile
9
Makefile
|
|
@ -21,7 +21,6 @@ ENABLE_VERIFIC_HIER_TREE := 1
|
|||
ENABLE_VERIFIC_YOSYSHQ_EXTENSIONS := 0
|
||||
ENABLE_VERIFIC_EDIF := 0
|
||||
ENABLE_VERIFIC_LIBERTY := 0
|
||||
ENABLE_COVER := 1
|
||||
ENABLE_LIBYOSYS := 0
|
||||
ENABLE_LIBYOSYS_STATIC := 0
|
||||
ENABLE_ZLIB := 1
|
||||
|
|
@ -249,9 +248,6 @@ ifneq ($(SANITIZER),)
|
|||
$(info [Clang Sanitizer] $(SANITIZER))
|
||||
CXXFLAGS += -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=$(SANITIZER)
|
||||
LINKFLAGS += -g -fsanitize=$(SANITIZER)
|
||||
ifneq ($(findstring address,$(SANITIZER)),)
|
||||
ENABLE_COVER := 0
|
||||
endif
|
||||
ifneq ($(findstring memory,$(SANITIZER)),)
|
||||
CXXFLAGS += -fPIE -fsanitize-memory-track-origins
|
||||
LINKFLAGS += -fPIE -fsanitize-memory-track-origins
|
||||
|
|
@ -548,10 +544,6 @@ LIBS_VERIFIC += -Wl,--whole-archive $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VE
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_COVER),1)
|
||||
CXXFLAGS += -DYOSYS_ENABLE_COVER
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_CCACHE),1)
|
||||
CXX := ccache $(CXX)
|
||||
else
|
||||
|
|
@ -729,7 +721,6 @@ OBJS += passes/hierarchy/hierarchy.o
|
|||
OBJS += passes/cmds/select.o
|
||||
OBJS += passes/cmds/show.o
|
||||
OBJS += passes/cmds/stat.o
|
||||
OBJS += passes/cmds/cover.o
|
||||
OBJS += passes/cmds/design.o
|
||||
OBJS += passes/cmds/plugin.o
|
||||
|
||||
|
|
|
|||
|
|
@ -764,33 +764,6 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
|
||||
if (getenv("YOSYS_COVER_DIR") || getenv("YOSYS_COVER_FILE"))
|
||||
{
|
||||
string filename;
|
||||
FILE *f;
|
||||
|
||||
if (getenv("YOSYS_COVER_DIR")) {
|
||||
filename = stringf("%s/yosys_cover_%d_XXXXXX.txt", getenv("YOSYS_COVER_DIR"), getpid());
|
||||
filename = make_temp_file(filename);
|
||||
} else {
|
||||
filename = getenv("YOSYS_COVER_FILE");
|
||||
}
|
||||
|
||||
f = fopen(filename.c_str(), "a+");
|
||||
|
||||
if (f == NULL)
|
||||
log_error("Can't create coverage file `%s'.\n", filename);
|
||||
|
||||
log("<writing coverage file \"%s\">\n", filename);
|
||||
|
||||
for (auto &it : get_coverage_data())
|
||||
fprintf(f, "%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
log_check_expected();
|
||||
|
||||
yosys_atexit();
|
||||
|
|
|
|||
|
|
@ -681,55 +681,4 @@ void log_check_expected()
|
|||
check_err("prefixed error", pattern, item);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
// This is the magic behind the code coverage counters
|
||||
// ---------------------------------------------------
|
||||
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
|
||||
|
||||
dict<std::string, std::pair<std::string, int>> extra_coverage_data;
|
||||
|
||||
void cover_extra(std::string parent, std::string id, bool increment) {
|
||||
if (extra_coverage_data.count(id) == 0) {
|
||||
for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++)
|
||||
if (p->id == parent)
|
||||
extra_coverage_data[id].first = stringf("%s:%d:%s", p->file, p->line, p->func);
|
||||
log_assert(extra_coverage_data.count(id));
|
||||
}
|
||||
if (increment)
|
||||
extra_coverage_data[id].second++;
|
||||
}
|
||||
|
||||
dict<std::string, std::pair<std::string, int>> get_coverage_data()
|
||||
{
|
||||
dict<std::string, std::pair<std::string, int>> coverage_data;
|
||||
|
||||
for (auto &it : pass_register) {
|
||||
std::string key = stringf("passes.%s", it.first);
|
||||
coverage_data[key].first = stringf("%s:%d:%s", __FILE__, __LINE__, __FUNCTION__);
|
||||
coverage_data[key].second += it.second->call_counter;
|
||||
}
|
||||
|
||||
for (auto &it : extra_coverage_data) {
|
||||
if (coverage_data.count(it.first))
|
||||
log_warning("found duplicate coverage id \"%s\".\n", it.first);
|
||||
coverage_data[it.first].first = it.second.first;
|
||||
coverage_data[it.first].second += it.second.second;
|
||||
}
|
||||
|
||||
for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++) {
|
||||
if (coverage_data.count(p->id))
|
||||
log_warning("found duplicate coverage id \"%s\".\n", p->id);
|
||||
coverage_data[p->id].first = stringf("%s:%d:%s", p->file, p->line, p->func);
|
||||
coverage_data[p->id].second += p->counter.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
for (auto &it : coverage_data)
|
||||
if (!it.second.first.compare(0, strlen(YOSYS_SRC "/"), YOSYS_SRC "/"))
|
||||
it.second.first = it.second.first.substr(strlen(YOSYS_SRC "/"));
|
||||
|
||||
return coverage_data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
|
|
|||
48
kernel/log.h
48
kernel/log.h
|
|
@ -291,54 +291,6 @@ void log_abort_internal(const char *file, int line);
|
|||
#define log_ping() YOSYS_NAMESPACE_PREFIX log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||
|
||||
|
||||
// ---------------------------------------------------
|
||||
// This is the magic behind the code coverage counters
|
||||
// ---------------------------------------------------
|
||||
|
||||
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
|
||||
|
||||
#define cover(_id) do { \
|
||||
static CoverData __d __attribute__((section("yosys_cover_list"), aligned(1), used)) = { __FILE__, __FUNCTION__, _id, __LINE__, 0 }; \
|
||||
__d.counter.fetch_add(1, std::memory_order_relaxed); \
|
||||
} while (0)
|
||||
|
||||
struct CoverData {
|
||||
const char *file, *func, *id;
|
||||
int line;
|
||||
std::atomic<int> counter;
|
||||
};
|
||||
|
||||
// this two symbols are created by the linker __start_yosys_cover_listfor the "yosys_cover_list" ELF section
|
||||
extern "C" struct CoverData __start_yosys_cover_list[];
|
||||
extern "C" struct CoverData __stop_yosys_cover_list[];
|
||||
|
||||
extern dict<std::string, std::pair<std::string, int>> extra_coverage_data;
|
||||
|
||||
void cover_extra(std::string parent, std::string id, bool increment = true);
|
||||
dict<std::string, std::pair<std::string, int>> get_coverage_data();
|
||||
|
||||
#define cover_list(_id, ...) do { cover(_id); \
|
||||
std::string r = cover_list_worker(_id, __VA_ARGS__); \
|
||||
log_assert(r.empty()); \
|
||||
} while (0)
|
||||
|
||||
static inline std::string cover_list_worker(std::string, std::string last) {
|
||||
return last;
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
std::string cover_list_worker(std::string prefix, std::string first, T... rest) {
|
||||
std::string selected = cover_list_worker(prefix, rest...);
|
||||
cover_extra(prefix, prefix + "." + first, first == selected);
|
||||
return first == selected ? "" : selected;
|
||||
}
|
||||
|
||||
#else
|
||||
# define cover(...) do { } while (0)
|
||||
# define cover_list(...) do { } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// everything below this line are utilities for troubleshooting
|
||||
// ------------------------------------------------------------
|
||||
|
|
|
|||
190
kernel/rtlil.cc
190
kernel/rtlil.cc
|
|
@ -883,8 +883,6 @@ RTLIL::State RTLIL::Const::const_iterator::operator*() const {
|
|||
|
||||
bool RTLIL::Const::is_fully_zero() const
|
||||
{
|
||||
cover("kernel.rtlil.const.is_fully_zero");
|
||||
|
||||
if (auto str = get_if_str()) {
|
||||
for (char ch : *str)
|
||||
if (ch != 0)
|
||||
|
|
@ -903,8 +901,6 @@ bool RTLIL::Const::is_fully_zero() const
|
|||
|
||||
bool RTLIL::Const::is_fully_ones() const
|
||||
{
|
||||
cover("kernel.rtlil.const.is_fully_ones");
|
||||
|
||||
if (auto str = get_if_str()) {
|
||||
for (char ch : *str)
|
||||
if (ch != (char)0xff)
|
||||
|
|
@ -922,8 +918,6 @@ bool RTLIL::Const::is_fully_ones() const
|
|||
|
||||
bool RTLIL::Const::is_fully_def() const
|
||||
{
|
||||
cover("kernel.rtlil.const.is_fully_def");
|
||||
|
||||
if (is_str())
|
||||
return true;
|
||||
|
||||
|
|
@ -937,8 +931,6 @@ bool RTLIL::Const::is_fully_def() const
|
|||
|
||||
bool RTLIL::Const::is_fully_undef() const
|
||||
{
|
||||
cover("kernel.rtlil.const.is_fully_undef");
|
||||
|
||||
if (auto str = get_if_str())
|
||||
return str->empty();
|
||||
|
||||
|
|
@ -952,8 +944,6 @@ bool RTLIL::Const::is_fully_undef() const
|
|||
|
||||
bool RTLIL::Const::is_fully_undef_x_only() const
|
||||
{
|
||||
cover("kernel.rtlil.const.is_fully_undef_x_only");
|
||||
|
||||
if (auto str = get_if_str())
|
||||
return str->empty();
|
||||
|
||||
|
|
@ -967,8 +957,6 @@ bool RTLIL::Const::is_fully_undef_x_only() const
|
|||
|
||||
bool RTLIL::Const::is_onehot(int *pos) const
|
||||
{
|
||||
cover("kernel.rtlil.const.is_onehot");
|
||||
|
||||
bool found = false;
|
||||
int size = GetSize(*this);
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
|
@ -4648,8 +4636,6 @@ bool RTLIL::SigChunk::operator !=(const RTLIL::SigChunk &other) const
|
|||
|
||||
RTLIL::SigSpec::SigSpec(std::initializer_list<RTLIL::SigSpec> parts)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.list");
|
||||
|
||||
init_empty_bits();
|
||||
log_assert(parts.size() > 0);
|
||||
auto ie = parts.begin();
|
||||
|
|
@ -4660,8 +4646,6 @@ RTLIL::SigSpec::SigSpec(std::initializer_list<RTLIL::SigSpec> parts)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const RTLIL::Const &value)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.const");
|
||||
|
||||
if (GetSize(value) != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(value);
|
||||
|
|
@ -4673,8 +4657,6 @@ RTLIL::SigSpec::SigSpec(const RTLIL::Const &value)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(RTLIL::Const &&value)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.const.move");
|
||||
|
||||
if (GetSize(value) != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(value);
|
||||
|
|
@ -4686,8 +4668,6 @@ RTLIL::SigSpec::SigSpec(RTLIL::Const &&value)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const RTLIL::SigChunk &chunk)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.chunk");
|
||||
|
||||
if (chunk.width != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(chunk);
|
||||
|
|
@ -4699,8 +4679,6 @@ RTLIL::SigSpec::SigSpec(const RTLIL::SigChunk &chunk)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(RTLIL::SigChunk &&chunk)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.chunk.move");
|
||||
|
||||
if (chunk.width != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(chunk);
|
||||
|
|
@ -4712,8 +4690,6 @@ RTLIL::SigSpec::SigSpec(RTLIL::SigChunk &&chunk)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.wire");
|
||||
|
||||
if (wire->width != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(wire);
|
||||
|
|
@ -4725,8 +4701,6 @@ RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int offset, int width)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.wire_part");
|
||||
|
||||
if (width != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(wire, offset, width);
|
||||
|
|
@ -4738,8 +4712,6 @@ RTLIL::SigSpec::SigSpec(RTLIL::Wire *wire, int offset, int width)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const std::string &str)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.str");
|
||||
|
||||
if (str.size() != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(str);
|
||||
|
|
@ -4751,8 +4723,6 @@ RTLIL::SigSpec::SigSpec(const std::string &str)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(int val, int width)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.int");
|
||||
|
||||
if (width != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(val, width);
|
||||
|
|
@ -4763,8 +4733,6 @@ RTLIL::SigSpec::SigSpec(int val, int width)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(RTLIL::State bit, int width)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.state");
|
||||
|
||||
if (width != 0) {
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(bit, width);
|
||||
|
|
@ -4775,8 +4743,6 @@ RTLIL::SigSpec::SigSpec(RTLIL::State bit, int width)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const RTLIL::SigBit &bit, int width)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.bit");
|
||||
|
||||
if (width != 0) {
|
||||
if (bit.wire == NULL) {
|
||||
rep_ = CHUNK;
|
||||
|
|
@ -4797,8 +4763,6 @@ RTLIL::SigSpec::SigSpec(const RTLIL::SigBit &bit, int width)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const std::vector<RTLIL::SigChunk> &chunks)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.stdvec_chunks");
|
||||
|
||||
init_empty_bits();
|
||||
for (const auto &c : chunks)
|
||||
append(c);
|
||||
|
|
@ -4807,8 +4771,6 @@ RTLIL::SigSpec::SigSpec(const std::vector<RTLIL::SigChunk> &chunks)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const std::vector<RTLIL::SigBit> &bits)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.stdvec_bits");
|
||||
|
||||
init_empty_bits();
|
||||
for (const auto &bit : bits)
|
||||
append(bit);
|
||||
|
|
@ -4817,8 +4779,6 @@ RTLIL::SigSpec::SigSpec(const std::vector<RTLIL::SigBit> &bits)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const pool<RTLIL::SigBit> &bits)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.pool_bits");
|
||||
|
||||
init_empty_bits();
|
||||
for (const auto &bit : bits)
|
||||
append(bit);
|
||||
|
|
@ -4827,8 +4787,6 @@ RTLIL::SigSpec::SigSpec(const pool<RTLIL::SigBit> &bits)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(const std::set<RTLIL::SigBit> &bits)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.stdset_bits");
|
||||
|
||||
init_empty_bits();
|
||||
for (const auto &bit : bits)
|
||||
append(bit);
|
||||
|
|
@ -4837,8 +4795,6 @@ RTLIL::SigSpec::SigSpec(const std::set<RTLIL::SigBit> &bits)
|
|||
|
||||
RTLIL::SigSpec::SigSpec(bool bit)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.init.bool");
|
||||
|
||||
rep_ = CHUNK;
|
||||
new (&chunk_) RTLIL::SigChunk(bit ? RTLIL::S1 : RTLIL::S0);
|
||||
check();
|
||||
|
|
@ -4874,8 +4830,6 @@ void RTLIL::SigSpec::unpack()
|
|||
if (rep_ == BITS)
|
||||
return;
|
||||
|
||||
cover("kernel.rtlil.sigspec.convert.unpack");
|
||||
|
||||
std::vector<RTLIL::SigBit> bits;
|
||||
bits.reserve(chunk_.width);
|
||||
for (int i = 0; i < chunk_.width; i++)
|
||||
|
|
@ -4891,8 +4845,6 @@ void RTLIL::SigSpec::try_repack()
|
|||
if (rep_ != BITS)
|
||||
return;
|
||||
|
||||
cover("kernel.rtlil.sigspec.convert.try_repack");
|
||||
|
||||
int bits_size = GetSize(bits_);
|
||||
if (bits_size == 0)
|
||||
return;
|
||||
|
|
@ -4921,8 +4873,6 @@ void RTLIL::SigSpec::try_repack()
|
|||
|
||||
Hasher::hash_t RTLIL::SigSpec::updhash() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.hash");
|
||||
|
||||
Hasher h;
|
||||
for (auto &c : chunks())
|
||||
if (c.wire == NULL) {
|
||||
|
|
@ -4943,7 +4893,6 @@ Hasher::hash_t RTLIL::SigSpec::updhash() const
|
|||
void RTLIL::SigSpec::sort()
|
||||
{
|
||||
unpack();
|
||||
cover("kernel.rtlil.sigspec.sort");
|
||||
std::sort(bits_.begin(), bits_.end());
|
||||
hash_.clear();
|
||||
try_repack();
|
||||
|
|
@ -4952,8 +4901,6 @@ void RTLIL::SigSpec::sort()
|
|||
void RTLIL::SigSpec::sort_and_unify()
|
||||
{
|
||||
unpack();
|
||||
cover("kernel.rtlil.sigspec.sort_and_unify");
|
||||
|
||||
// A copy of the bits vector is used to prevent duplicating the logic from
|
||||
// SigSpec::SigSpec(std::vector<SigBit>). This incurrs an extra copy but
|
||||
// that isn't showing up as significant in profiles.
|
||||
|
|
@ -5009,8 +4956,6 @@ void RTLIL::SigSpec::replace(const dict<RTLIL::SigBit, RTLIL::SigBit> &rules)
|
|||
|
||||
void RTLIL::SigSpec::replace(const dict<RTLIL::SigBit, RTLIL::SigBit> &rules, RTLIL::SigSpec *other) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.replace_dict");
|
||||
|
||||
log_assert(other != NULL);
|
||||
log_assert(size() == other->size());
|
||||
|
||||
|
|
@ -5038,8 +4983,6 @@ void RTLIL::SigSpec::replace(const std::map<RTLIL::SigBit, RTLIL::SigBit> &rules
|
|||
|
||||
void RTLIL::SigSpec::replace(const std::map<RTLIL::SigBit, RTLIL::SigBit> &rules, RTLIL::SigSpec *other) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.replace_map");
|
||||
|
||||
log_assert(other != NULL);
|
||||
log_assert(size() == other->size());
|
||||
|
||||
|
|
@ -5073,11 +5016,6 @@ void RTLIL::SigSpec::remove(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other
|
|||
|
||||
void RTLIL::SigSpec::remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
|
||||
{
|
||||
if (other)
|
||||
cover("kernel.rtlil.sigspec.remove_other");
|
||||
else
|
||||
cover("kernel.rtlil.sigspec.remove");
|
||||
|
||||
unpack();
|
||||
if (other != NULL) {
|
||||
log_assert(size() == other->size());
|
||||
|
|
@ -5128,11 +5066,6 @@ void RTLIL::SigSpec::remove(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *
|
|||
|
||||
void RTLIL::SigSpec::remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other)
|
||||
{
|
||||
if (other)
|
||||
cover("kernel.rtlil.sigspec.remove_other");
|
||||
else
|
||||
cover("kernel.rtlil.sigspec.remove");
|
||||
|
||||
unpack();
|
||||
|
||||
if (other != NULL) {
|
||||
|
|
@ -5166,11 +5099,6 @@ void RTLIL::SigSpec::remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec
|
|||
|
||||
void RTLIL::SigSpec::remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other)
|
||||
{
|
||||
if (other)
|
||||
cover("kernel.rtlil.sigspec.remove_other");
|
||||
else
|
||||
cover("kernel.rtlil.sigspec.remove");
|
||||
|
||||
unpack();
|
||||
|
||||
if (other != NULL) {
|
||||
|
|
@ -5204,11 +5132,6 @@ void RTLIL::SigSpec::remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigS
|
|||
|
||||
void RTLIL::SigSpec::remove2(const pool<RTLIL::Wire*> &pattern, RTLIL::SigSpec *other)
|
||||
{
|
||||
if (other)
|
||||
cover("kernel.rtlil.sigspec.remove_other");
|
||||
else
|
||||
cover("kernel.rtlil.sigspec.remove");
|
||||
|
||||
unpack();
|
||||
|
||||
if (other != NULL) {
|
||||
|
|
@ -5242,11 +5165,6 @@ void RTLIL::SigSpec::remove2(const pool<RTLIL::Wire*> &pattern, RTLIL::SigSpec *
|
|||
|
||||
RTLIL::SigSpec RTLIL::SigSpec::extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other) const
|
||||
{
|
||||
if (other)
|
||||
cover("kernel.rtlil.sigspec.extract_other");
|
||||
else
|
||||
cover("kernel.rtlil.sigspec.extract");
|
||||
|
||||
log_assert(other == NULL || size() == other->size());
|
||||
|
||||
RTLIL::SigSpec ret;
|
||||
|
|
@ -5280,11 +5198,6 @@ RTLIL::SigSpec RTLIL::SigSpec::extract(const RTLIL::SigSpec &pattern, const RTLI
|
|||
|
||||
RTLIL::SigSpec RTLIL::SigSpec::extract(const pool<RTLIL::SigBit> &pattern, const RTLIL::SigSpec *other) const
|
||||
{
|
||||
if (other)
|
||||
cover("kernel.rtlil.sigspec.extract_other");
|
||||
else
|
||||
cover("kernel.rtlil.sigspec.extract");
|
||||
|
||||
log_assert(other == NULL || size() == other->size());
|
||||
|
||||
std::vector<RTLIL::SigBit> bits_match = to_sigbit_vector();
|
||||
|
|
@ -5310,8 +5223,6 @@ RTLIL::SigSpec RTLIL::SigSpec::extract(const pool<RTLIL::SigBit> &pattern, const
|
|||
|
||||
void RTLIL::SigSpec::replace(int offset, const RTLIL::SigSpec &with)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.replace_pos");
|
||||
|
||||
if (with.size() == 0)
|
||||
return;
|
||||
|
||||
|
|
@ -5336,8 +5247,6 @@ void RTLIL::SigSpec::remove_const()
|
|||
{
|
||||
if (rep_ == CHUNK)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.remove_const.packed");
|
||||
|
||||
if (chunk_.wire == NULL) {
|
||||
chunk_.~SigChunk();
|
||||
init_empty_bits();
|
||||
|
|
@ -5346,8 +5255,6 @@ void RTLIL::SigSpec::remove_const()
|
|||
}
|
||||
else
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.remove_const.unpacked");
|
||||
|
||||
std::vector<RTLIL::SigBit> new_bits;
|
||||
new_bits.reserve(bits_.size());
|
||||
for (auto &bit : bits_)
|
||||
|
|
@ -5365,8 +5272,6 @@ void RTLIL::SigSpec::remove_const()
|
|||
|
||||
void RTLIL::SigSpec::remove(int offset, int length)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.remove_pos");
|
||||
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
|
|
@ -5389,8 +5294,6 @@ RTLIL::SigSpec RTLIL::SigSpec::extract(int offset, int length) const
|
|||
log_assert(length >= 0);
|
||||
log_assert(offset + length <= size());
|
||||
|
||||
cover("kernel.rtlil.sigspec.extract_pos");
|
||||
|
||||
SigSpec extracted;
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
|
|
@ -5444,8 +5347,6 @@ void RTLIL::SigSpec::append(const RTLIL::SigSpec &signal)
|
|||
return;
|
||||
}
|
||||
|
||||
cover("kernel.rtlil.sigspec.append");
|
||||
|
||||
hash_.clear();
|
||||
if (rep_ == CHUNK && signal.rep_ == CHUNK && chunk_.wire == signal.chunk_.wire) {
|
||||
if (chunk_.wire == NULL) {
|
||||
|
|
@ -5477,8 +5378,6 @@ void RTLIL::SigSpec::append(const RTLIL::SigBit &bit)
|
|||
}
|
||||
|
||||
if (rep_ == CHUNK && chunk_.wire == bit.wire) {
|
||||
cover("kernel.rtlil.sigspec.append_bit.packed");
|
||||
|
||||
if (chunk_.wire == NULL) {
|
||||
chunk_.data.push_back(bit.data);
|
||||
chunk_.width++;
|
||||
|
|
@ -5492,15 +5391,12 @@ void RTLIL::SigSpec::append(const RTLIL::SigBit &bit)
|
|||
|
||||
unpack();
|
||||
|
||||
cover("kernel.rtlil.sigspec.append_bit.unpacked");
|
||||
bits_.push_back(bit);
|
||||
check();
|
||||
}
|
||||
|
||||
void RTLIL::SigSpec::extend_u0(int width, bool is_signed)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.extend_u0");
|
||||
|
||||
if (size() > width)
|
||||
remove(width, size() - width);
|
||||
|
||||
|
|
@ -5515,8 +5411,6 @@ void RTLIL::SigSpec::extend_u0(int width, bool is_signed)
|
|||
|
||||
RTLIL::SigSpec RTLIL::SigSpec::repeat(int num) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.repeat");
|
||||
|
||||
RTLIL::SigSpec sig;
|
||||
for (int i = 0; i < num; i++)
|
||||
sig.append(*this);
|
||||
|
|
@ -5528,8 +5422,6 @@ void RTLIL::SigSpec::check(Module *mod) const
|
|||
{
|
||||
if (rep_ == CHUNK)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.check.packed");
|
||||
|
||||
log_assert(chunk_.width != 0);
|
||||
if (chunk_.wire == NULL) {
|
||||
log_assert(chunk_.offset == 0);
|
||||
|
|
@ -5543,14 +5435,8 @@ void RTLIL::SigSpec::check(Module *mod) const
|
|||
log_assert(chunk_.wire->module == mod);
|
||||
}
|
||||
}
|
||||
else if (size() > 64)
|
||||
else if (size() <= 64)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.check.skip");
|
||||
}
|
||||
else
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.check.unpacked");
|
||||
|
||||
if (mod != nullptr) {
|
||||
for (const RTLIL::SigBit &bit : bits_)
|
||||
if (bit.wire != nullptr)
|
||||
|
|
@ -5562,8 +5448,6 @@ void RTLIL::SigSpec::check(Module *mod) const
|
|||
|
||||
bool RTLIL::SigSpec::operator <(const RTLIL::SigSpec &other) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.comp_lt");
|
||||
|
||||
if (this == &other)
|
||||
return false;
|
||||
|
||||
|
|
@ -5577,14 +5461,11 @@ bool RTLIL::SigSpec::operator <(const RTLIL::SigSpec &other) const
|
|||
++other_it;
|
||||
}
|
||||
|
||||
cover("kernel.rtlil.sigspec.comp_lt.equal");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::SigSpec::operator ==(const RTLIL::SigSpec &other) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.comp_eq");
|
||||
|
||||
if (this == &other)
|
||||
return true;
|
||||
|
||||
|
|
@ -5598,14 +5479,11 @@ bool RTLIL::SigSpec::operator ==(const RTLIL::SigSpec &other) const
|
|||
++other_it;
|
||||
}
|
||||
|
||||
cover("kernel.rtlil.sigspec.comp_eq.equal");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTLIL::SigSpec::is_wire() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_wire");
|
||||
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
if (it == cs.end())
|
||||
|
|
@ -5616,8 +5494,6 @@ bool RTLIL::SigSpec::is_wire() const
|
|||
|
||||
bool RTLIL::SigSpec::is_chunk() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_chunk");
|
||||
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
if (it == cs.end())
|
||||
|
|
@ -5635,8 +5511,6 @@ bool RTLIL::SigSpec::known_driver() const
|
|||
|
||||
bool RTLIL::SigSpec::is_fully_const() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_fully_const");
|
||||
|
||||
for (auto &chunk : chunks())
|
||||
if (chunk.width > 0 && chunk.wire != NULL)
|
||||
return false;
|
||||
|
|
@ -5645,8 +5519,6 @@ bool RTLIL::SigSpec::is_fully_const() const
|
|||
|
||||
bool RTLIL::SigSpec::is_fully_zero() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_fully_zero");
|
||||
|
||||
for (auto &chunk : chunks()) {
|
||||
if (chunk.width > 0 && chunk.wire != NULL)
|
||||
return false;
|
||||
|
|
@ -5659,8 +5531,6 @@ bool RTLIL::SigSpec::is_fully_zero() const
|
|||
|
||||
bool RTLIL::SigSpec::is_fully_ones() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_fully_ones");
|
||||
|
||||
for (auto &chunk : chunks()) {
|
||||
if (chunk.width > 0 && chunk.wire != NULL)
|
||||
return false;
|
||||
|
|
@ -5673,8 +5543,6 @@ bool RTLIL::SigSpec::is_fully_ones() const
|
|||
|
||||
bool RTLIL::SigSpec::is_fully_def() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_fully_def");
|
||||
|
||||
for (auto &chunk : chunks()) {
|
||||
if (chunk.width > 0 && chunk.wire != NULL)
|
||||
return false;
|
||||
|
|
@ -5687,8 +5555,6 @@ bool RTLIL::SigSpec::is_fully_def() const
|
|||
|
||||
bool RTLIL::SigSpec::is_fully_undef() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_fully_undef");
|
||||
|
||||
for (auto &chunk : chunks()) {
|
||||
if (chunk.width > 0 && chunk.wire != NULL)
|
||||
return false;
|
||||
|
|
@ -5701,8 +5567,6 @@ bool RTLIL::SigSpec::is_fully_undef() const
|
|||
|
||||
bool RTLIL::SigSpec::has_const() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.has_const");
|
||||
|
||||
for (auto &chunk : chunks())
|
||||
if (chunk.width > 0 && chunk.wire == NULL)
|
||||
return true;
|
||||
|
|
@ -5711,8 +5575,6 @@ bool RTLIL::SigSpec::has_const() const
|
|||
|
||||
bool RTLIL::SigSpec::has_const(State state) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.has_const");
|
||||
|
||||
for (auto &chunk : chunks())
|
||||
if (chunk.width > 0 && chunk.wire == NULL && std::find(chunk.data.begin(), chunk.data.end(), state) != chunk.data.end())
|
||||
return true;
|
||||
|
|
@ -5722,8 +5584,6 @@ bool RTLIL::SigSpec::has_const(State state) const
|
|||
|
||||
bool RTLIL::SigSpec::has_marked_bits() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.has_marked_bits");
|
||||
|
||||
for (auto &chunk : chunks())
|
||||
if (chunk.width > 0 && chunk.wire == NULL) {
|
||||
for (RTLIL::State d : chunk.data)
|
||||
|
|
@ -5735,8 +5595,6 @@ bool RTLIL::SigSpec::has_marked_bits() const
|
|||
|
||||
bool RTLIL::SigSpec::is_onehot(int *pos) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.is_onehot");
|
||||
|
||||
if (std::optional<RTLIL::Const> c = try_as_const())
|
||||
return c->is_onehot(pos);
|
||||
return false;
|
||||
|
|
@ -5744,8 +5602,6 @@ bool RTLIL::SigSpec::is_onehot(int *pos) const
|
|||
|
||||
bool RTLIL::SigSpec::as_bool() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_bool");
|
||||
|
||||
std::optional<RTLIL::Const> c = try_as_const();
|
||||
log_assert(c.has_value());
|
||||
return c->as_bool();
|
||||
|
|
@ -5753,8 +5609,6 @@ bool RTLIL::SigSpec::as_bool() const
|
|||
|
||||
int RTLIL::SigSpec::as_int(bool is_signed) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_int");
|
||||
|
||||
std::optional<RTLIL::Const> c = try_as_const();
|
||||
log_assert(c.has_value());
|
||||
return c->as_int(is_signed);
|
||||
|
|
@ -5762,8 +5616,6 @@ int RTLIL::SigSpec::as_int(bool is_signed) const
|
|||
|
||||
bool RTLIL::SigSpec::convertible_to_int(bool is_signed) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.convertible_to_int");
|
||||
|
||||
std::optional<RTLIL::Const> c = try_as_const();
|
||||
if (!c.has_value())
|
||||
return false;
|
||||
|
|
@ -5772,8 +5624,6 @@ bool RTLIL::SigSpec::convertible_to_int(bool is_signed) const
|
|||
|
||||
std::optional<int> RTLIL::SigSpec::try_as_int(bool is_signed) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.try_as_int");
|
||||
|
||||
std::optional<RTLIL::Const> c = try_as_const();
|
||||
if (!c.has_value())
|
||||
return std::nullopt;
|
||||
|
|
@ -5782,8 +5632,6 @@ std::optional<int> RTLIL::SigSpec::try_as_int(bool is_signed) const
|
|||
|
||||
int RTLIL::SigSpec::as_int_saturating(bool is_signed) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.try_as_int");
|
||||
|
||||
std::optional<RTLIL::Const> c = try_as_const();
|
||||
log_assert(c.has_value());
|
||||
return c->as_int_saturating(is_signed);
|
||||
|
|
@ -5791,8 +5639,6 @@ int RTLIL::SigSpec::as_int_saturating(bool is_signed) const
|
|||
|
||||
std::string RTLIL::SigSpec::as_string() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_string");
|
||||
|
||||
std::string str;
|
||||
str.reserve(size());
|
||||
std::vector<RTLIL::SigChunk> chunks = *this;
|
||||
|
|
@ -5808,8 +5654,6 @@ std::string RTLIL::SigSpec::as_string() const
|
|||
|
||||
std::optional<RTLIL::Const> RTLIL::SigSpec::try_as_const() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_const");
|
||||
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
if (it == cs.end())
|
||||
|
|
@ -5822,8 +5666,6 @@ std::optional<RTLIL::Const> RTLIL::SigSpec::try_as_const() const
|
|||
|
||||
RTLIL::Const RTLIL::SigSpec::as_const() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_const");
|
||||
|
||||
std::optional<RTLIL::Const> c = try_as_const();
|
||||
log_assert(c.has_value());
|
||||
return *c;
|
||||
|
|
@ -5831,8 +5673,6 @@ RTLIL::Const RTLIL::SigSpec::as_const() const
|
|||
|
||||
RTLIL::Wire *RTLIL::SigSpec::as_wire() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_wire");
|
||||
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
log_assert(it != cs.end());
|
||||
|
|
@ -5843,8 +5683,6 @@ RTLIL::Wire *RTLIL::SigSpec::as_wire() const
|
|||
|
||||
RTLIL::SigChunk RTLIL::SigSpec::as_chunk() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_chunk");
|
||||
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
log_assert(it != cs.end());
|
||||
|
|
@ -5855,14 +5693,11 @@ RTLIL::SigChunk RTLIL::SigSpec::as_chunk() const
|
|||
|
||||
RTLIL::SigBit RTLIL::SigSpec::as_bit() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.as_bit");
|
||||
return RTLIL::SigBit(*this);
|
||||
}
|
||||
|
||||
bool RTLIL::SigSpec::match(const char* pattern) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.match");
|
||||
|
||||
int pattern_len = strlen(pattern);
|
||||
log_assert(pattern_len == size());
|
||||
|
||||
|
|
@ -5892,8 +5727,6 @@ bool RTLIL::SigSpec::match(const char* pattern) const
|
|||
|
||||
std::set<RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_set() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.to_sigbit_set");
|
||||
|
||||
std::set<RTLIL::SigBit> sigbits;
|
||||
for (auto &c : chunks())
|
||||
for (int i = 0; i < c.width; i++)
|
||||
|
|
@ -5903,8 +5736,6 @@ std::set<RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_set() const
|
|||
|
||||
pool<RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_pool() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.to_sigbit_pool");
|
||||
|
||||
pool<RTLIL::SigBit> sigbits;
|
||||
sigbits.reserve(size());
|
||||
for (auto &c : chunks())
|
||||
|
|
@ -5915,8 +5746,6 @@ pool<RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_pool() const
|
|||
|
||||
std::vector<RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_vector() const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.to_sigbit_vector");
|
||||
|
||||
std::vector<RTLIL::SigBit> result;
|
||||
result.reserve(size());
|
||||
for (SigBit bit : *this)
|
||||
|
|
@ -5926,8 +5755,6 @@ std::vector<RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_vector() const
|
|||
|
||||
std::map<RTLIL::SigBit, RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_map(const RTLIL::SigSpec &other) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.to_sigbit_map");
|
||||
|
||||
int this_size = size();
|
||||
log_assert(this_size == other.size());
|
||||
|
||||
|
|
@ -5940,8 +5767,6 @@ std::map<RTLIL::SigBit, RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_map(const RTLIL
|
|||
|
||||
dict<RTLIL::SigBit, RTLIL::SigBit> RTLIL::SigSpec::to_sigbit_dict(const RTLIL::SigSpec &other) const
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.to_sigbit_dict");
|
||||
|
||||
int this_size = size();
|
||||
log_assert(this_size == other.size());
|
||||
|
||||
|
|
@ -5965,9 +5790,6 @@ static void sigspec_parse_split(std::vector<std::string> &tokens, const std::str
|
|||
|
||||
bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
|
||||
{
|
||||
cover("kernel.rtlil.sigspec.parse");
|
||||
|
||||
|
||||
std::vector<std::string> tokens;
|
||||
sigspec_parse_split(tokens, str, ',');
|
||||
|
||||
|
|
@ -5981,7 +5803,6 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri
|
|||
continue;
|
||||
|
||||
if (('0' <= netname[0] && netname[0] <= '9') || netname[0] == '\'') {
|
||||
cover("kernel.rtlil.sigspec.parse.const");
|
||||
VERILOG_FRONTEND::ConstParser p{Location()};
|
||||
auto ast = p.const2ast(netname);
|
||||
if (ast == nullptr)
|
||||
|
|
@ -5993,8 +5814,6 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri
|
|||
if (module == NULL)
|
||||
return false;
|
||||
|
||||
cover("kernel.rtlil.sigspec.parse.net");
|
||||
|
||||
if (netname[0] != '$' && netname[0] != '\\')
|
||||
netname = "\\" + netname;
|
||||
|
||||
|
|
@ -6023,13 +5842,11 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri
|
|||
std::vector<std::string> index_tokens;
|
||||
sigspec_parse_split(index_tokens, indices.substr(1, indices.size()-2), ':');
|
||||
if (index_tokens.size() == 1) {
|
||||
cover("kernel.rtlil.sigspec.parse.bit_sel");
|
||||
int a = atoi(index_tokens.at(0).c_str());
|
||||
if (a < 0 || a >= wire->width)
|
||||
return false;
|
||||
sig.append(RTLIL::SigSpec(wire, a));
|
||||
} else {
|
||||
cover("kernel.rtlil.sigspec.parse.part_sel");
|
||||
int a = atoi(index_tokens.at(0).c_str());
|
||||
int b = atoi(index_tokens.at(1).c_str());
|
||||
if (a > b) {
|
||||
|
|
@ -6054,8 +5871,6 @@ bool RTLIL::SigSpec::parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL
|
|||
if (str.empty() || str[0] != '@')
|
||||
return parse(sig, module, str);
|
||||
|
||||
cover("kernel.rtlil.sigspec.parse.sel");
|
||||
|
||||
str = RTLIL::escape_id(str.substr(1));
|
||||
if (design->selection_vars.count(str) == 0)
|
||||
return false;
|
||||
|
|
@ -6072,13 +5887,11 @@ bool RTLIL::SigSpec::parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL
|
|||
bool RTLIL::SigSpec::parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)
|
||||
{
|
||||
if (str == "0") {
|
||||
cover("kernel.rtlil.sigspec.parse.rhs_zeros");
|
||||
sig = RTLIL::SigSpec(RTLIL::State::S0, lhs.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str == "~0") {
|
||||
cover("kernel.rtlil.sigspec.parse.rhs_ones");
|
||||
sig = RTLIL::SigSpec(RTLIL::State::S1, lhs.size());
|
||||
return true;
|
||||
}
|
||||
|
|
@ -6088,7 +5901,6 @@ bool RTLIL::SigSpec::parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, R
|
|||
long int val = strtol(p, &endptr, 10);
|
||||
if (endptr && endptr != p && *endptr == 0) {
|
||||
sig = RTLIL::SigSpec(val, lhs.size());
|
||||
cover("kernel.rtlil.sigspec.parse.rhs_dec");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ OBJS += passes/cmds/logcmd.o
|
|||
OBJS += passes/cmds/tee.o
|
||||
OBJS += passes/cmds/write_file.o
|
||||
OBJS += passes/cmds/connwrappers.o
|
||||
OBJS += passes/cmds/cover.o
|
||||
OBJS += passes/cmds/trace.o
|
||||
OBJS += passes/cmds/plugin.o
|
||||
OBJS += passes/cmds/check.o
|
||||
|
|
|
|||
|
|
@ -1,163 +0,0 @@
|
|||
/*
|
||||
* yosys -- Yosys Open SYnthesis Suite
|
||||
*
|
||||
* Copyright (C) 2014 Claire Xenia Wolf <claire@yosyshq.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "kernel/yosys.h"
|
||||
#include "kernel/log_help.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
#else
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
USING_YOSYS_NAMESPACE
|
||||
PRIVATE_NAMESPACE_BEGIN
|
||||
|
||||
struct CoverPass : public Pass {
|
||||
CoverPass() : Pass("cover", "print code coverage counters") {
|
||||
internal();
|
||||
}
|
||||
bool formatted_help() override {
|
||||
auto *help = PrettyHelp::get_current();
|
||||
help->set_group("passes/status");
|
||||
return false;
|
||||
}
|
||||
void help() override
|
||||
{
|
||||
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
||||
log("\n");
|
||||
log(" cover [options] [pattern]\n");
|
||||
log("\n");
|
||||
log("Print the code coverage counters collected using the cover() macro in the Yosys\n");
|
||||
log("C++ code. This is useful to figure out what parts of Yosys are utilized by a\n");
|
||||
log("test bench.\n");
|
||||
log("\n");
|
||||
log(" -q\n");
|
||||
log(" Do not print output to the normal destination (console and/or log file)\n");
|
||||
log("\n");
|
||||
log(" -o file\n");
|
||||
log(" Write output to this file, truncate if exists.\n");
|
||||
log("\n");
|
||||
log(" -a file\n");
|
||||
log(" Write output to this file, append if exists.\n");
|
||||
log("\n");
|
||||
log(" -d dir\n");
|
||||
log(" Write output to a newly created file in the specified directory.\n");
|
||||
log("\n");
|
||||
log("When one or more pattern (shell wildcards) are specified, then only counters\n");
|
||||
log("matching at least one pattern are printed.\n");
|
||||
log("\n");
|
||||
log("\n");
|
||||
log("It is also possible to instruct Yosys to print the coverage counters on program\n");
|
||||
log("exit to a file using environment variables:\n");
|
||||
log("\n");
|
||||
log(" YOSYS_COVER_DIR=\"{dir-name}\" yosys {args}\n");
|
||||
log("\n");
|
||||
log(" This will create a file (with an auto-generated name) in this\n");
|
||||
log(" directory and write the coverage counters to it.\n");
|
||||
log("\n");
|
||||
log(" YOSYS_COVER_FILE=\"{file-name}\" yosys {args}\n");
|
||||
log("\n");
|
||||
log(" This will append the coverage counters to the specified file.\n");
|
||||
log("\n");
|
||||
log("\n");
|
||||
log("Hint: Use the following AWK command to consolidate Yosys coverage files:\n");
|
||||
log("\n");
|
||||
log(" gawk '{ p[$3] = $1; c[$3] += $2; } END { for (i in p)\n");
|
||||
log(" printf \"%%-60s %%10d %%s\\n\", p[i], c[i], i; }' {files} | sort -k3\n");
|
||||
log("\n");
|
||||
log("\n");
|
||||
log("Coverage counters are only available in Yosys for Linux.\n");
|
||||
log("\n");
|
||||
}
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||
{
|
||||
std::vector<FILE*> out_files;
|
||||
std::vector<std::string> patterns;
|
||||
bool do_log = true;
|
||||
|
||||
size_t argidx;
|
||||
for (argidx = 1; argidx < args.size(); argidx++)
|
||||
{
|
||||
if (args[argidx] == "-q") {
|
||||
do_log = false;
|
||||
continue;
|
||||
}
|
||||
if ((args[argidx] == "-o" || args[argidx] == "-a" || args[argidx] == "-d") && argidx+1 < args.size()) {
|
||||
const char *open_mode = args[argidx] == "-a" ? "a+" : "w";
|
||||
const std::string &filename = args[++argidx];
|
||||
FILE *f = nullptr;
|
||||
if (args[argidx-1] == "-d") {
|
||||
#if defined(_WIN32) || defined(__wasm)
|
||||
log_cmd_error("The 'cover -d' option is not supported on this platform.\n");
|
||||
#else
|
||||
char filename_buffer[4096];
|
||||
snprintf(filename_buffer, 4096, "%s/yosys_cover_%d_XXXXXX.txt", filename.c_str(), getpid());
|
||||
f = fdopen(mkstemps(filename_buffer, 4), "w");
|
||||
#endif
|
||||
} else {
|
||||
f = fopen(filename.c_str(), open_mode);
|
||||
}
|
||||
if (f == NULL) {
|
||||
for (auto f : out_files)
|
||||
fclose(f);
|
||||
log_cmd_error("Can't create file %s%s.\n", args[argidx-1] == "-d" ? "in directory " : "", args[argidx]);
|
||||
}
|
||||
out_files.push_back(f);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
while (argidx < args.size() && args[argidx].compare(0, 1, "-") != 0)
|
||||
patterns.push_back(args[argidx++]);
|
||||
extra_args(args, argidx, design);
|
||||
|
||||
if (do_log) {
|
||||
log_header(design, "Printing code coverage counters.\n");
|
||||
log("\n");
|
||||
}
|
||||
|
||||
#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
|
||||
for (auto &it : get_coverage_data()) {
|
||||
if (!patterns.empty()) {
|
||||
for (auto &p : patterns)
|
||||
if (patmatch(p.c_str(), it.first.c_str()))
|
||||
goto pattern_match;
|
||||
continue;
|
||||
}
|
||||
pattern_match:
|
||||
for (auto f : out_files)
|
||||
fprintf(f, "%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
|
||||
if (do_log)
|
||||
log("%-60s %10d %s\n", it.second.first, it.second.second, it.first);
|
||||
}
|
||||
#else
|
||||
for (auto f : out_files)
|
||||
fclose(f);
|
||||
|
||||
log_cmd_error("This version of Yosys was not built with support for code coverage counters.\n");
|
||||
#endif
|
||||
|
||||
for (auto f : out_files)
|
||||
fclose(f);
|
||||
}
|
||||
} CoverPass;
|
||||
|
||||
PRIVATE_NAMESPACE_END
|
||||
|
|
@ -297,8 +297,6 @@ bool group_cell_inputs(RTLIL::Module *module, RTLIL::Cell *cell, bool commutativ
|
|||
log_debug("\n");
|
||||
}
|
||||
|
||||
cover_list("opt.opt_expr.fine.group", "$not", "$pos", "$and", "$or", "$xor", "$xnor", cell->type.str());
|
||||
|
||||
module->remove(cell);
|
||||
did_something = true;
|
||||
return true;
|
||||
|
|
@ -520,7 +518,7 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
|
||||
for (auto cell : cells.sorted)
|
||||
{
|
||||
#define ACTION_DO(_p_, _s_) do { cover("opt.opt_expr.action_" S__LINE__); replace_cell(assign_map, module, cell, input.as_string(), _p_, _s_); goto next_cell; } while (0)
|
||||
#define ACTION_DO(_p_, _s_) do { replace_cell(assign_map, module, cell, input.as_string(), _p_, _s_); goto next_cell; } while (0)
|
||||
#define ACTION_DO_Y(_v_) ACTION_DO(ID::Y, RTLIL::SigSpec(RTLIL::State::S ## _v_))
|
||||
|
||||
bool detect_const_and = false;
|
||||
|
|
@ -567,19 +565,16 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
}
|
||||
|
||||
if (detect_const_and && (found_zero || found_inv || (found_undef && consume_x))) {
|
||||
cover("opt.opt_expr.const_and");
|
||||
replace_cell(assign_map, module, cell, "const_and", ID::Y, RTLIL::State::S0);
|
||||
goto next_cell;
|
||||
}
|
||||
|
||||
if (detect_const_or && (found_one || found_inv || (found_undef && consume_x))) {
|
||||
cover("opt.opt_expr.const_or");
|
||||
replace_cell(assign_map, module, cell, "const_or", ID::Y, RTLIL::State::S1);
|
||||
goto next_cell;
|
||||
}
|
||||
|
||||
if (non_const_input != State::Sm && !found_undef) {
|
||||
cover("opt.opt_expr.and_or_buffer");
|
||||
replace_cell(assign_map, module, cell, "and_or_buffer", ID::Y, non_const_input);
|
||||
goto next_cell;
|
||||
}
|
||||
|
|
@ -591,12 +586,10 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
SigBit sig_b = assign_map(cell->getPort(ID::B));
|
||||
if (!keepdc && (sig_a == sig_b || sig_a == State::Sx || sig_a == State::Sz || sig_b == State::Sx || sig_b == State::Sz)) {
|
||||
if (cell->type.in(ID($xor), ID($_XOR_))) {
|
||||
cover("opt.opt_expr.const_xor");
|
||||
replace_cell(assign_map, module, cell, "const_xor", ID::Y, RTLIL::State::S0);
|
||||
goto next_cell;
|
||||
}
|
||||
if (cell->type.in(ID($xnor), ID($_XNOR_))) {
|
||||
cover("opt.opt_expr.const_xnor");
|
||||
// For consistency since simplemap does $xnor -> $_XOR_ + $_NOT_
|
||||
int width = GetSize(cell->getPort(ID::Y));
|
||||
replace_cell(assign_map, module, cell, "const_xnor", ID::Y, SigSpec(RTLIL::State::S1, width));
|
||||
|
|
@ -609,7 +602,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
std::swap(sig_a, sig_b);
|
||||
if (sig_b == State::S0 || sig_b == State::S1) {
|
||||
if (cell->type.in(ID($xor), ID($_XOR_))) {
|
||||
cover("opt.opt_expr.xor_buffer");
|
||||
SigSpec sig_y;
|
||||
if (cell->type == ID($xor))
|
||||
sig_y = (sig_b == State::S1 ? module->Not(NEW_ID, sig_a).as_bit() : sig_a);
|
||||
|
|
@ -620,7 +612,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
goto next_cell;
|
||||
}
|
||||
if (cell->type.in(ID($xnor), ID($_XNOR_))) {
|
||||
cover("opt.opt_expr.xnor_buffer");
|
||||
SigSpec sig_y;
|
||||
if (cell->type == ID($xnor)) {
|
||||
sig_y = (sig_b == State::S1 ? sig_a : module->Not(NEW_ID, sig_a).as_bit());
|
||||
|
|
@ -641,13 +632,11 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
GetSize(cell->getPort(ID::A)) == 1 && GetSize(cell->getPort(ID::Y)) == 1)
|
||||
{
|
||||
if (cell->type == ID($reduce_xnor)) {
|
||||
cover("opt.opt_expr.reduce_xnor_not");
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with $not cell.\n",
|
||||
log_id(cell->type), log_id(cell->name), log_id(module));
|
||||
cell->type = ID($not);
|
||||
did_something = true;
|
||||
} else {
|
||||
cover("opt.opt_expr.unary_buffer");
|
||||
replace_cell(assign_map, module, cell, "unary_buffer", ID::Y, cell->getPort(ID::A));
|
||||
}
|
||||
goto next_cell;
|
||||
|
|
@ -663,7 +652,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
|
||||
if (a_fully_const != b_fully_const)
|
||||
{
|
||||
cover("opt.opt_expr.bitwise_logic_one_const");
|
||||
log_debug("Replacing %s cell `%s' in module `%s' having one fully constant input\n",
|
||||
log_id(cell->type), log_id(cell->name), log_id(module));
|
||||
RTLIL::SigSpec sig_y = assign_map(cell->getPort(ID::Y));
|
||||
|
|
@ -815,7 +803,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
new_sig_a.append(neutral_bit);
|
||||
|
||||
if (GetSize(new_sig_a) < GetSize(sig_a)) {
|
||||
cover_list("opt.opt_expr.fine.neutral_A", "$logic_not", "$logic_and", "$logic_or", "$reduce_or", "$reduce_and", "$reduce_bool", cell->type.str());
|
||||
log_debug("Replacing port A of %s cell `%s' in module `%s' with shorter expression: %s -> %s\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str(), log_signal(sig_a), log_signal(new_sig_a));
|
||||
cell->setPort(ID::A, new_sig_a);
|
||||
|
|
@ -838,7 +825,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
new_sig_b.append(neutral_bit);
|
||||
|
||||
if (GetSize(new_sig_b) < GetSize(sig_b)) {
|
||||
cover_list("opt.opt_expr.fine.neutral_B", "$logic_and", "$logic_or", cell->type.str());
|
||||
log_debug("Replacing port B of %s cell `%s' in module `%s' with shorter expression: %s -> %s\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str(), log_signal(sig_b), log_signal(new_sig_b));
|
||||
cell->setPort(ID::B, new_sig_b);
|
||||
|
|
@ -864,7 +850,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
}
|
||||
|
||||
if (new_a != RTLIL::State::Sm && RTLIL::SigSpec(new_a) != sig_a) {
|
||||
cover("opt.opt_expr.fine.$reduce_and");
|
||||
log_debug("Replacing port A of %s cell `%s' in module `%s' with constant driver: %s -> %s\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str(), log_signal(sig_a), log_signal(new_a));
|
||||
cell->setPort(ID::A, sig_a = new_a);
|
||||
|
|
@ -890,7 +875,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
}
|
||||
|
||||
if (new_a != RTLIL::State::Sm && RTLIL::SigSpec(new_a) != sig_a) {
|
||||
cover_list("opt.opt_expr.fine.A", "$logic_not", "$logic_and", "$logic_or", "$reduce_or", "$reduce_bool", cell->type.str());
|
||||
log_debug("Replacing port A of %s cell `%s' in module `%s' with constant driver: %s -> %s\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str(), log_signal(sig_a), log_signal(new_a));
|
||||
cell->setPort(ID::A, sig_a = new_a);
|
||||
|
|
@ -916,7 +900,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
}
|
||||
|
||||
if (new_b != RTLIL::State::Sm && RTLIL::SigSpec(new_b) != sig_b) {
|
||||
cover_list("opt.opt_expr.fine.B", "$logic_and", "$logic_or", cell->type.str());
|
||||
log_debug("Replacing port B of %s cell `%s' in module `%s' with constant driver: %s -> %s\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str(), log_signal(sig_b), log_signal(new_b));
|
||||
cell->setPort(ID::B, sig_b = new_b);
|
||||
|
|
@ -951,7 +934,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
break;
|
||||
}
|
||||
if (i > 0) {
|
||||
cover_list("opt.opt_expr.fine", "$add", "$sub", cell->type.str());
|
||||
log_debug("Stripping %d LSB bits of %s cell %s in module %s.\n", i, log_id(cell->type), log_id(cell), log_id(module));
|
||||
SigSpec new_a = sig_a.extract_end(i);
|
||||
SigSpec new_b = sig_b.extract_end(i);
|
||||
|
|
@ -1008,7 +990,6 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
break;
|
||||
}
|
||||
if (i > 0) {
|
||||
cover("opt.opt_expr.fine.$alu");
|
||||
log_debug("Stripping %d LSB bits of %s cell %s in module %s.\n", i, log_id(cell->type), log_id(cell), log_id(module));
|
||||
SigSpec new_a = sig_a.extract_end(i);
|
||||
SigSpec new_b = sig_b.extract_end(i);
|
||||
|
|
@ -1047,8 +1028,6 @@ skip_fine_alu:
|
|||
|
||||
if (0) {
|
||||
found_the_x_bit:
|
||||
cover_list("opt.opt_expr.xbit", "$reduce_xor", "$reduce_xnor", "$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx",
|
||||
"$lt", "$le", "$ge", "$gt", "$neg", "$add", "$sub", "$mul", "$div", "$mod", "$divfloor", "$modfloor", "$pow", cell->type.str());
|
||||
if (cell->type.in(ID($reduce_xor), ID($reduce_xnor), ID($lt), ID($le), ID($ge), ID($gt)))
|
||||
replace_cell(assign_map, module, cell, "x-bit in input", ID::Y, RTLIL::State::Sx);
|
||||
else
|
||||
|
|
@ -1070,7 +1049,6 @@ skip_fine_alu:
|
|||
}
|
||||
|
||||
if (width < GetSize(sig_a)) {
|
||||
cover_list("opt.opt_expr.trim", "$shiftx", "$shift", cell->type.str());
|
||||
sig_a.remove(width, GetSize(sig_a)-width);
|
||||
cell->setPort(ID::A, sig_a);
|
||||
cell->setParam(ID::A_WIDTH, width);
|
||||
|
|
@ -1081,13 +1059,11 @@ skip_fine_alu:
|
|||
|
||||
if (cell->type.in(ID($_NOT_), ID($not), ID($logic_not)) && GetSize(cell->getPort(ID::Y)) == 1 &&
|
||||
invert_map.count(assign_map(cell->getPort(ID::A))) != 0) {
|
||||
cover_list("opt.opt_expr.invert.double", "$_NOT_", "$not", "$logic_not", cell->type.str());
|
||||
replace_cell(assign_map, module, cell, "double_invert", ID::Y, invert_map.at(assign_map(cell->getPort(ID::A))));
|
||||
goto next_cell;
|
||||
}
|
||||
|
||||
if (cell->type.in(ID($_MUX_), ID($mux)) && invert_map.count(assign_map(cell->getPort(ID::S))) != 0) {
|
||||
cover_list("opt.opt_expr.invert.muxsel", "$_MUX_", "$mux", cell->type.str());
|
||||
log_debug("Optimizing away select inverter for %s cell `%s' in module `%s'.\n", log_id(cell->type), log_id(cell), log_id(module));
|
||||
RTLIL::SigSpec tmp = cell->getPort(ID::A);
|
||||
cell->setPort(ID::A, cell->getPort(ID::B));
|
||||
|
|
@ -1170,7 +1146,6 @@ skip_fine_alu:
|
|||
if (input.match(" 1")) ACTION_DO(ID::Y, input.extract(1, 1));
|
||||
if (input.match("01 ")) ACTION_DO(ID::Y, input.extract(0, 1));
|
||||
if (input.match("10 ")) {
|
||||
cover("opt.opt_expr.mux_to_inv");
|
||||
cell->type = ID($_NOT_);
|
||||
cell->setPort(ID::A, input.extract(0, 1));
|
||||
cell->unsetPort(ID::B);
|
||||
|
|
@ -1197,7 +1172,6 @@ skip_fine_alu:
|
|||
if (input == State::S1)
|
||||
ACTION_DO(ID::Y, cell->getPort(ID::A));
|
||||
if (input == State::S0 && !a.is_fully_undef()) {
|
||||
cover("opt.opt_expr.action_" S__LINE__);
|
||||
log_debug("Replacing data input of %s cell `%s' in module `%s' with constant undef.\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str());
|
||||
cell->setPort(ID::A, SigSpec(State::Sx, GetSize(a)));
|
||||
|
|
@ -1222,7 +1196,6 @@ skip_fine_alu:
|
|||
log_assert(GetSize(a) == GetSize(b));
|
||||
for (int i = 0; i < GetSize(a); i++) {
|
||||
if (a[i].wire == NULL && b[i].wire == NULL && a[i] != b[i] && a[i].data <= RTLIL::State::S1 && b[i].data <= RTLIL::State::S1) {
|
||||
cover_list("opt.opt_expr.eqneq.isneq", "$eq", "$ne", "$eqx", "$nex", cell->type.str());
|
||||
RTLIL::SigSpec new_y = RTLIL::SigSpec(cell->type.in(ID($eq), ID($eqx)) ? RTLIL::State::S0 : RTLIL::State::S1);
|
||||
new_y.extend_u0(cell->parameters[ID::Y_WIDTH].as_int(), false);
|
||||
replace_cell(assign_map, module, cell, "isneq", ID::Y, new_y);
|
||||
|
|
@ -1235,7 +1208,6 @@ skip_fine_alu:
|
|||
}
|
||||
|
||||
if (new_a.size() == 0) {
|
||||
cover_list("opt.opt_expr.eqneq.empty", "$eq", "$ne", "$eqx", "$nex", cell->type.str());
|
||||
RTLIL::SigSpec new_y = RTLIL::SigSpec(cell->type.in(ID($eq), ID($eqx)) ? RTLIL::State::S1 : RTLIL::State::S0);
|
||||
new_y.extend_u0(cell->parameters[ID::Y_WIDTH].as_int(), false);
|
||||
replace_cell(assign_map, module, cell, "empty", ID::Y, new_y);
|
||||
|
|
@ -1243,7 +1215,6 @@ skip_fine_alu:
|
|||
}
|
||||
|
||||
if (new_a.size() < a.size() || new_b.size() < b.size()) {
|
||||
cover_list("opt.opt_expr.eqneq.resize", "$eq", "$ne", "$eqx", "$nex", cell->type.str());
|
||||
cell->setPort(ID::A, new_a);
|
||||
cell->setPort(ID::B, new_b);
|
||||
cell->parameters[ID::A_WIDTH] = new_a.size();
|
||||
|
|
@ -1258,7 +1229,6 @@ skip_fine_alu:
|
|||
RTLIL::SigSpec b = assign_map(cell->getPort(ID::B));
|
||||
|
||||
if (a.is_fully_const() && !b.is_fully_const()) {
|
||||
cover_list("opt.opt_expr.eqneq.swapconst", "$eq", "$ne", cell->type.str());
|
||||
cell->setPort(ID::A, b);
|
||||
cell->setPort(ID::B, a);
|
||||
std::swap(a, b);
|
||||
|
|
@ -1273,7 +1243,6 @@ skip_fine_alu:
|
|||
RTLIL::SigSpec input = b;
|
||||
ACTION_DO(ID::Y, cell->getPort(ID::A));
|
||||
} else {
|
||||
cover_list("opt.opt_expr.eqneq.isnot", "$eq", "$ne", cell->type.str());
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with inverter.\n", log_id(cell->type), log_id(cell), log_id(module));
|
||||
cell->type = ID($not);
|
||||
cell->parameters.erase(ID::B_WIDTH);
|
||||
|
|
@ -1288,7 +1257,6 @@ skip_fine_alu:
|
|||
if (cell->type.in(ID($eq), ID($ne)) &&
|
||||
(assign_map(cell->getPort(ID::A)).is_fully_zero() || assign_map(cell->getPort(ID::B)).is_fully_zero()))
|
||||
{
|
||||
cover_list("opt.opt_expr.eqneq.cmpzero", "$eq", "$ne", cell->type.str());
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with %s.\n", log_id(cell->type), log_id(cell),
|
||||
log_id(module), cell->type == ID($eq) ? "$logic_not" : "$reduce_bool");
|
||||
cell->type = cell->type == ID($eq) ? ID($logic_not) : ID($reduce_bool);
|
||||
|
|
@ -1336,8 +1304,6 @@ skip_fine_alu:
|
|||
sig_y[i] = sig_a[GetSize(sig_a)-1];
|
||||
}
|
||||
|
||||
cover_list("opt.opt_expr.constshift", "$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx", cell->type.str());
|
||||
|
||||
log_debug("Replacing %s cell `%s' (B=%s, SHR=%d) in module `%s' with fixed wiring: %s\n",
|
||||
log_id(cell->type), log_id(cell), log_signal(assign_map(cell->getPort(ID::B))), shift_bits, log_id(module), log_signal(sig_y));
|
||||
|
||||
|
|
@ -1410,11 +1376,6 @@ skip_fine_alu:
|
|||
|
||||
if (identity_wrt_a || identity_wrt_b)
|
||||
{
|
||||
if (identity_wrt_a)
|
||||
cover_list("opt.opt_expr.identwrt.a", "$add", "$sub", "$alu", "$or", "$xor", "$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx", "$mul", "$div", cell->type.str());
|
||||
if (identity_wrt_b)
|
||||
cover_list("opt.opt_expr.identwrt.b", "$add", "$sub", "$alu", "$or", "$xor", "$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx", "$mul", "$div", cell->type.str());
|
||||
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with identity for port %c.\n",
|
||||
cell->type.c_str(), cell->name.c_str(), module->name.c_str(), identity_wrt_a ? 'A' : 'B');
|
||||
|
||||
|
|
@ -1463,14 +1424,12 @@ skip_identity:
|
|||
|
||||
if (mux_bool && cell->type.in(ID($mux), ID($_MUX_)) &&
|
||||
cell->getPort(ID::A) == State::S0 && cell->getPort(ID::B) == State::S1) {
|
||||
cover_list("opt.opt_expr.mux_bool", "$mux", "$_MUX_", cell->type.str());
|
||||
replace_cell(assign_map, module, cell, "mux_bool", ID::Y, cell->getPort(ID::S));
|
||||
goto next_cell;
|
||||
}
|
||||
|
||||
if (mux_bool && cell->type.in(ID($mux), ID($_MUX_)) &&
|
||||
cell->getPort(ID::A) == State::S1 && cell->getPort(ID::B) == State::S0) {
|
||||
cover_list("opt.opt_expr.mux_invert", "$mux", "$_MUX_", cell->type.str());
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with inverter.\n", log_id(cell->type), log_id(cell), log_id(module));
|
||||
cell->setPort(ID::A, cell->getPort(ID::S));
|
||||
cell->unsetPort(ID::B);
|
||||
|
|
@ -1489,7 +1448,6 @@ skip_identity:
|
|||
}
|
||||
|
||||
if (consume_x && mux_bool && cell->type.in(ID($mux), ID($_MUX_)) && cell->getPort(ID::A) == State::S0) {
|
||||
cover_list("opt.opt_expr.mux_and", "$mux", "$_MUX_", cell->type.str());
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with and-gate.\n", log_id(cell->type), log_id(cell), log_id(module));
|
||||
cell->setPort(ID::A, cell->getPort(ID::S));
|
||||
cell->unsetPort(ID::S);
|
||||
|
|
@ -1509,7 +1467,6 @@ skip_identity:
|
|||
}
|
||||
|
||||
if (consume_x && mux_bool && cell->type.in(ID($mux), ID($_MUX_)) && cell->getPort(ID::B) == State::S1) {
|
||||
cover_list("opt.opt_expr.mux_or", "$mux", "$_MUX_", cell->type.str());
|
||||
log_debug("Replacing %s cell `%s' in module `%s' with or-gate.\n", log_id(cell->type), log_id(cell), log_id(module));
|
||||
cell->setPort(ID::B, cell->getPort(ID::S));
|
||||
cell->unsetPort(ID::S);
|
||||
|
|
@ -1533,7 +1490,6 @@ skip_identity:
|
|||
int width = GetSize(cell->getPort(ID::A));
|
||||
if ((cell->getPort(ID::A).is_fully_undef() && cell->getPort(ID::B).is_fully_undef()) ||
|
||||
cell->getPort(ID::S).is_fully_undef()) {
|
||||
cover_list("opt.opt_expr.mux_undef", "$mux", "$pmux", cell->type.str());
|
||||
replace_cell(assign_map, module, cell, "mux_undef", ID::Y, cell->getPort(ID::A));
|
||||
goto next_cell;
|
||||
}
|
||||
|
|
@ -1552,17 +1508,14 @@ skip_identity:
|
|||
new_s = new_s.extract(0, new_s.size()-1);
|
||||
}
|
||||
if (new_s.size() == 0) {
|
||||
cover_list("opt.opt_expr.mux_empty", "$mux", "$pmux", cell->type.str());
|
||||
replace_cell(assign_map, module, cell, "mux_empty", ID::Y, new_a);
|
||||
goto next_cell;
|
||||
}
|
||||
if (new_a == RTLIL::SigSpec(RTLIL::State::S0) && new_b == RTLIL::SigSpec(RTLIL::State::S1)) {
|
||||
cover_list("opt.opt_expr.mux_sel01", "$mux", "$pmux", cell->type.str());
|
||||
replace_cell(assign_map, module, cell, "mux_sel01", ID::Y, new_s);
|
||||
goto next_cell;
|
||||
}
|
||||
if (cell->getPort(ID::S).size() != new_s.size()) {
|
||||
cover_list("opt.opt_expr.mux_reduce", "$mux", "$pmux", cell->type.str());
|
||||
log_debug("Optimized away %d select inputs of %s cell `%s' in module `%s'.\n",
|
||||
GetSize(cell->getPort(ID::S)) - GetSize(new_s), log_id(cell->type), log_id(cell), log_id(module));
|
||||
cell->setPort(ID::A, new_a);
|
||||
|
|
@ -1602,7 +1555,6 @@ skip_identity:
|
|||
RTLIL::SigSpec y(RTLIL::const_ ## _t(a.as_const(), dummy_arg, \
|
||||
cell->parameters[ID::A_SIGNED].as_bool(), false, \
|
||||
cell->parameters[ID::Y_WIDTH].as_int())); \
|
||||
cover("opt.opt_expr.const.$" #_t); \
|
||||
replace_cell(assign_map, module, cell, stringf("%s", log_signal(a)), ID::Y, y); \
|
||||
goto next_cell; \
|
||||
} \
|
||||
|
|
@ -1617,7 +1569,6 @@ skip_identity:
|
|||
cell->parameters[ID::A_SIGNED].as_bool(), \
|
||||
cell->parameters[ID::B_SIGNED].as_bool(), \
|
||||
cell->parameters[ID::Y_WIDTH].as_int())); \
|
||||
cover("opt.opt_expr.const.$" #_t); \
|
||||
replace_cell(assign_map, module, cell, stringf("%s, %s", log_signal(a), log_signal(b)), ID::Y, y); \
|
||||
goto next_cell; \
|
||||
} \
|
||||
|
|
@ -1629,7 +1580,6 @@ skip_identity:
|
|||
assign_map.apply(a), assign_map.apply(b); \
|
||||
if (a.is_fully_const() && b.is_fully_const()) { \
|
||||
RTLIL::SigSpec y(RTLIL::const_ ## _t(a.as_const(), b.as_const())); \
|
||||
cover("opt.opt_expr.const.$" #_t); \
|
||||
replace_cell(assign_map, module, cell, stringf("%s, %s", log_signal(a), log_signal(b)), ID::Y, y); \
|
||||
goto next_cell; \
|
||||
} \
|
||||
|
|
@ -1642,7 +1592,6 @@ skip_identity:
|
|||
assign_map.apply(a), assign_map.apply(b), assign_map.apply(s); \
|
||||
if (a.is_fully_const() && b.is_fully_const() && s.is_fully_const()) { \
|
||||
RTLIL::SigSpec y(RTLIL::const_ ## _t(a.as_const(), b.as_const(), s.as_const())); \
|
||||
cover("opt.opt_expr.const.$" #_t); \
|
||||
replace_cell(assign_map, module, cell, stringf("%s, %s, %s", log_signal(a), log_signal(b), log_signal(s)), ID::Y, y); \
|
||||
goto next_cell; \
|
||||
} \
|
||||
|
|
@ -1759,8 +1708,6 @@ skip_identity:
|
|||
{
|
||||
if (sig_a.is_fully_zero())
|
||||
{
|
||||
cover("opt.opt_expr.mul_shift.zero");
|
||||
|
||||
log_debug("Replacing multiply-by-zero cell `%s' in module `%s' with zero-driver.\n",
|
||||
cell->name.c_str(), module->name.c_str());
|
||||
|
||||
|
|
@ -1774,11 +1721,6 @@ skip_identity:
|
|||
int exp;
|
||||
if (sig_a.is_onehot(&exp) && !(a_signed && exp == GetSize(sig_a) - 1))
|
||||
{
|
||||
if (swapped_ab)
|
||||
cover("opt.opt_expr.mul_shift.swapped");
|
||||
else
|
||||
cover("opt.opt_expr.mul_shift.unswapped");
|
||||
|
||||
log_debug("Replacing multiply-by-%s cell `%s' in module `%s' with shift-by-%d.\n",
|
||||
log_signal(sig_a), cell->name.c_str(), module->name.c_str(), exp);
|
||||
|
||||
|
|
@ -1812,8 +1754,6 @@ skip_identity:
|
|||
break;
|
||||
if (a_zeros || b_zeros) {
|
||||
int y_zeros = a_zeros + b_zeros;
|
||||
cover("opt.opt_expr.mul_low_zeros");
|
||||
|
||||
log_debug("Removing low %d A and %d B bits from cell `%s' in module `%s'.\n",
|
||||
a_zeros, b_zeros, cell->name.c_str(), module->name.c_str());
|
||||
|
||||
|
|
@ -1855,8 +1795,6 @@ skip_identity:
|
|||
{
|
||||
if (sig_b.is_fully_zero())
|
||||
{
|
||||
cover("opt.opt_expr.divmod_zero");
|
||||
|
||||
log_debug("Replacing divide-by-zero cell `%s' in module `%s' with undef-driver.\n",
|
||||
cell->name.c_str(), module->name.c_str());
|
||||
|
||||
|
|
@ -1872,8 +1810,6 @@ skip_identity:
|
|||
{
|
||||
if (cell->type.in(ID($div), ID($divfloor)))
|
||||
{
|
||||
cover("opt.opt_expr.div_shift");
|
||||
|
||||
bool is_truncating = cell->type == ID($div);
|
||||
log_debug("Replacing %s-divide-by-%s cell `%s' in module `%s' with shift-by-%d.\n",
|
||||
is_truncating ? "truncating" : "flooring",
|
||||
|
|
@ -1902,8 +1838,6 @@ skip_identity:
|
|||
}
|
||||
else if (cell->type.in(ID($mod), ID($modfloor)))
|
||||
{
|
||||
cover("opt.opt_expr.mod_mask");
|
||||
|
||||
bool is_truncating = cell->type == ID($mod);
|
||||
log_debug("Replacing %s-modulo-by-%s cell `%s' in module `%s' with bitmask.\n",
|
||||
is_truncating ? "truncating" : "flooring",
|
||||
|
|
@ -2028,7 +1962,6 @@ skip_identity:
|
|||
sig_ci = p.second;
|
||||
}
|
||||
|
||||
cover("opt.opt_expr.alu_split");
|
||||
module->remove(cell);
|
||||
|
||||
did_something = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue