Skip to content

HammingOperators

class HammingOperators

@brief Hamming distance and weight operators

Implements operators for analyzing signal transitions and bit patterns: - hamming-weight-all-signals-all-timestamps - Calculate Hamming weight across all signals - hamming-distance-all-signals-all-timestamps - Calculate Hamming distance between consecutive timestamps

Functions

Name Description
count_ones Count the number of '1' bits in a string representation of a value
value_to_binary_string Convert a value to binary string representation
pad_to_length Pad a string to a specific length with leading zeros
hamming_distance Calculate Hamming distance between two binary strings.

Function Details

count_ones

static inline int count_ones(const std::string& bits)

Count the number of '1' bits in a string representation of a value

hamming_distance

static int hamming_distance(const std::string& s1, const std::string& s2)

Calculate Hamming distance between two binary strings. Compares by set-bit-ness (only '1' counts as set), not raw character equality: a literal '!=' would count every 'x'-vs-'0' position as a difference, even though 'x'/'z' are treated as an unset bit everywhere else in this file (count_ones() above) and in WAL++'s Fast Mode -- that mismatch previously produced a spurious full-width distance spike on every wide signal's first resolve from its initial all-x value to a concrete one (the common reset-then-load case).

pad_to_length

static std::string pad_to_length(const std::string& str, size_t length)

Pad a string to a specific length with leading zeros

value_to_binary_string

static std::string value_to_binary_string(const Value& value)

Convert a value to binary string representation