SILICON
Loading...
Searching...
No Matches
num_formatting.cpp File Reference
#include "num_formatting.hpp"
#include <boost/multiprecision/cpp_int/import_export.hpp>
#include <algorithm>
#include <cctype>
#include <format>
#include <ios>
#include <iterator>
#include <map>
#include <ranges>
#include <stdexcept>
#include <utility>
#include <vector>
#include <core/wireUtils.hpp>
Include dependency graph for num_formatting.cpp:

Go to the source code of this file.

Namespaces

namespace  SILICON
namespace  SILICON::core

Functions

std::string formatInteger (const BigInt &value, const BusValueFormat format, const std::size_t bitWidth)
std::optional< BigInt > parseInteger (std::string_view text, const BusValueFormat format, const std::size_t bitWidth)
BusValue maxValueForBusWidth (const std::size_t width)
BusValue busValueFromInteger (const BigInt &value, std::size_t width)
 Builds an LSB-first BusValue from the low width bits of an integer. Negative values use two's complement and sign extension; nonnegative values use zero extension. Values are truncated to width bits; zero width is empty.
BigInt integerFromBusValue (const BusValue &value, Signedness signedness=Signedness::UNSIGNED)
 Decodes an LSB-first BusValue as an unsigned arbitrary-precision integer. Empty values yield zero. UNKNOWN or ERROR bits throw std::invalid_argument.
BusValue busValueFromBits (std::string_view bits)
 Strictly decodes an MSB-first raw string containing 0, 1, X, or E.
std::string formatValue (const BusValue &value, BusValueFormat format, std::size_t fixedWidth=0)
 Format an LSB-first BusValue for display.
ParsedBusValue valueFromStr (std::string_view text)
 Parse user-facing decimal, hexadecimal, octal, binary, or four-state text.
std::optional< BusValue > resizeParsedValue (const ParsedBusValue &parsed, std::size_t width)
 Adapts a parsed textual value to an exact destination width.