|
Csd 1.1.4; VERSION ${PROJECT_VERSION}
|
Classes | |
| class | invalid_csd_format |
| Exception thrown when invalid CSD characters are encountered. More... | |
| struct | MultiplierSpec |
| Specification for a single CSD multiplier coefficient. More... | |
Functions | |
| auto | to_csd (double decimal_value, int places) -> std::string |
| auto | to_csd_i (int decimal_value) -> std::string |
| auto | to_csdnnz (double decimal_value, unsigned int nnz) -> std::string |
| Convert a floating-point number to CSD with limited non-zero digits. | |
| auto | to_csdnnz_i (int decimal_value, unsigned int nnz) -> std::string |
| Convert an integer to CSD with limited non-zero digits. | |
| CONSTEXPR14 auto | to_decimal_using_switch (const char *csd) -> double |
| CONSTEXPR14 auto | to_decimal_integral (const char *&csd) -> int |
| Convert the integral part of a CSD string to a decimal. | |
| CONSTEXPR14 auto | to_decimal_fractional (const char *csd) -> double |
| Convert the fractional part of a CSD string to a decimal. | |
| CONSTEXPR14 auto | to_decimal (const char *csd) -> double |
| Convert the CSD string to a decimal. | |
| CONSTEXPR14 auto | to_decimal_i (const char *csd) -> int |
| Convert CSD string to integer. | |
| auto | generate_csd_multiplier (const std::string &csd_str, int input_width, int max_power) -> std::string |
| Generate Verilog code for a single CSD multiplier module. | |
| auto | generate_csd_multipliers (const std::vector< MultiplierSpec > &coeffs, const std::string &module_name="csd_filter") -> std::string |
| Generate Verilog for multiple CSD multipliers with cross-CSE. | |
| auto | longest_repeated_substring (const char *sv, size_t len) -> std::string |
| Find the longest repeated non-overlapping substring. | |
| void | log_with_spdlog (const std::string &message) |
| Log a message using spdlog. | |
Variables | |
| constexpr int | MAX_DECIMAL_PLACES = 20 |
| Maximum number of decimal places supported by CSD conversion. | |
| constexpr unsigned int | MIN_NONZERO_DIGITS = 1 |
| Minimum value for non-zero digit count in CSDNNZ functions. | |
| auto csd::generate_csd_multiplier | ( | const std::string & | csd_str, |
| int | input_width, | ||
| int | max_power | ||
| ) | -> std::string |
Generate Verilog code for a single CSD multiplier module.
Converts a Canonical Signed Digit (CSD) string into a synthesizable Verilog module that performs constant multiplication using shifts and additions/subtractions.
| [in] | csd_str | CSD string using '+', '-', '0' (e.g. "+00-00+0+") |
| [in] | input_width | Bit width of the input signal x |
| [in] | max_power | Highest power of two in the CSD (must be len(csd)-1) |
| std::invalid_argument | if csd_str length doesn't match max_power+1 or if the string contains characters other than '+', '-', '0' |
| auto csd::generate_csd_multipliers | ( | const std::vector< MultiplierSpec > & | coeffs, |
| const std::string & | module_name = "csd_filter" |
||
| ) | -> std::string |
Generate Verilog for multiple CSD multipliers with cross-CSE.
When the same CSD substring appears in multiple coefficients, a shared sub-expression wire is created - reducing total adder count across the entire filter.
All coefficients must share the same input_width and max_power so that the same bit position encodes the same power of two.
| [in] | coeffs | List of coefficient specifications |
| [in] | module_name | Name for the generated Verilog module |
| std::invalid_argument | on validation failure or width mismatch |
| void csd::log_with_spdlog | ( | const std::string & | message | ) |
Log a message using spdlog.
This function logs a message using the spdlog library. It provides a simple interface for logging messages throughout the csd library without exposing the full spdlog API.
| [in] | message | The message to log |