mirror of
https://github.com/YosysHQ/yosys
synced 2025-12-15 08:48:59 +00:00
Remove cover() coverage tracking
This commit is contained in:
parent
52b1245547
commit
638e904f91
8 changed files with 2 additions and 556 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue