slang namespace

Root namespace.

Namespaces

namespace ast
The SystemVerilog AST.
namespace driver
Frontend tool driver.
namespace parsing
Lexing, preprocessing, and parsing functionality.
namespace syntax
Syntax tree manipulation.

Classes

struct AssociativeArray
Represents a SystemVerilog associative array, for use during constant evaluation.
class Bag
template<typename T>
class bitmask
struct BufferID
class BumpAllocator
class CommandLine
struct ConstantRange
class ConstantValue
template<typename T>
class CopyPtr
class CVConstIterator
class CVIterator
class DiagCode
A compact code that represents a diagnostic.
class Diagnostic
Wraps up a reported diagnostic along with location in source and any arguments.
class DiagnosticEngine
class Diagnostics
A collection of diagnostics.
template<typename Fn>
class function_ref
template<typename DerivedT, typename IteratorCategoryT, typename T, typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T*, typename ReferenceT = T&>
class iterator_facade
template<typename TIterator>
class iterator_range
A range represented by an interator pair, begin and end.
class JsonWriter
struct logic_t
template<typename T>
class not_null
class OS
A collection of various OS-specific utility functions.
struct real_t
template<typename T, typename Index>
class SafeIndexedVector
template<typename F>
class ScopeGuard
struct shortreal_t
template<typename K, typename V, size_t N, typename Entry = ska::detailv3::sherwood_v3_entry<std::pair<K, V>>, typename Alloc = StackAllocator<Entry, N>>
class SmallMap
template<typename T, size_t N, typename Entry = ska::detailv3::sherwood_v3_entry<T>, typename Alloc = StackAllocator<Entry, N>>
class SmallSet
template<typename T>
class SmallVector
template<typename T, size_t N>
class SmallVectorSized
struct SourceBuffer
class SourceLocation
class SourceManager
class SourceRange
Combines a pair of source locations that denote a range of source text.
template<typename T>
class StringTable
class SVInt
class SVIntStorage
struct SVQueue
Represents a SystemVerilog queue, for use during constant evaluation.
struct SVUnion
Represents a SystemVerilog unpacked union, for use during constant evaluation.
struct TimeScale
struct TimeScaleValue
A combination of a unit and magnitude for a time scale value.
class TimeTrace
class TimeTraceScope
template<typename T>
class TypedBumpAllocator
class VersionInfo
Provides access to compile-time generated version info about the library.

Enums

enum class TimeScaleMagnitude: uint8_t { One = 1, Ten = 10, Hundred = 100 }

Typedefs

using bitwidth_t = uint32_t
A type that can represent the largest possible bit width of a SystemVerilog integer.

Functions

auto countLeadingZeros32(uint32_t value) -> uint32_t
auto countLeadingZeros64(uint64_t value) -> uint32_t
auto checkedAddS32(int32_t a, int32_t b) -> std::optional<int32_t>
auto checkedSubS32(int32_t a, int32_t b) -> std::optional<int32_t>
auto checkedMulU32(uint32_t a, uint32_t b) -> std::optional<uint32_t>
auto literalBaseFromChar(char base, LiteralBase& result) -> bool
Specifies the base of an integer (for converting to/from a string)
auto clog2(const SVInt& v) -> uint32_t
Returns the ceiling of the log_2 of the value. If value is zero, returns zero.
auto suffixToTimeUnit(string_view timeSuffix, TimeUnit& unit) -> bool
Scale unit for a time value.
auto isASCII(char c) -> bool constexpr
Returns whether the given character is a valid ASCII character.
auto isPrintableASCII(char c) -> bool constexpr
Returns whether the given character is considered "printable".
auto isPrintableUnicode(uint32_t c) -> bool
auto charWidthUnicode(uint32_t c) -> int
auto isWhitespace(char c) -> bool constexpr
Returns whether the given character is considered whitespace.
auto isNewline(char c) -> bool constexpr
Returns whether the given character is considered a new line.
auto isDecimalDigit(char c) -> bool constexpr
Returns whether the given character is considered a decimal digit.
auto isOctalDigit(char c) -> bool constexpr
Returns whether the given character is considered an octal digit.
auto isHexDigit(char c) -> bool constexpr
Returns whether the given character is considered a hexadecimal digit.
auto isBinaryDigit(char c) -> bool constexpr
Returns whether the given character is considered a binary digit.
auto isAlphaNumeric(char c) -> bool constexpr
Returns whether the given character is considered an alphanumeric character.
auto isValidCIdChar(char c) -> bool constexpr
auto isBase64Char(char c) -> bool constexpr
Returns whether the given characrer is a valid in base64 encoding.
auto isLogicDigit(char c) -> bool constexpr
auto getDigitValue(char c) -> uint8_t constexpr
auto getHexDigitValue(char c) -> uint8_t constexpr
auto getHexForDigit(uint32_t num, bool lowerCase = false) -> char constexpr
Gets the hexadecimal character for the given number (which should be less than 16).
auto utf8Len(unsigned char first) -> int constexpr
auto utf8Decode(const char* b, uint32_t* c, int* e) -> const char* constexpr
template<typename T, typename... Rest>
void hash_combine(size_t& seed, const T& v, Rest... rest)
template<typename T>
auto make_range(T begin, T end) -> iterator_range<T>
Constructs an iterator_range from two provided iterators (inferring the types involved).
template<typename TContainer>
auto make_reverse_range(TContainer&& container) -> auto
auto toStringView(span<char> text) -> string_view
Converts a span of characters into a string_view.
void uintToStr(SmallVector<char>& buffer, uint32_t value)
Converts the provided value into a string, storing it into buffer.
void uintToStr(SmallVector<char>& buffer, uint64_t value)
Converts the provided value into a string, storing it into buffer.
auto strToInt(string_view str, size_t* pos = nullptr, int base = 10) -> std::optional<int32_t>
auto strToUInt(string_view str, size_t* pos = nullptr, int base = 10) -> std::optional<uint32_t>
auto strToDouble(string_view str, size_t* pos = nullptr) -> std::optional<double>
void strToUpper(std::string& str)
void strToLower(std::string& str)
auto editDistance(string_view left, string_view right, bool allowReplacements = true, int maxDistance = 0) -> int
auto widen(string_view str) -> string_view
Widens the provided UTF8 string into UTF16 wchars.
auto narrow(string_view str) -> string_view
Widens the provided UTF16 string into UTF8.

Enum documentation

enum class slang::TimeScaleMagnitude: uint8_t

As allowed by SystemVerilog, time scales can be expressed in one of only a few magnitudes.

Typedef documentation

using slang::bitwidth_t = uint32_t

A type that can represent the largest possible bit width of a SystemVerilog integer.

Function documentation

uint32_t slang::countLeadingZeros32(uint32_t value)

If value is zero, returns 32. Otherwise, returns the number of zeros, starting from the MSB.

uint32_t slang::countLeadingZeros64(uint64_t value)

If value is zero, returns 64. Otherwise, returns the number of zeros, starting from the MSB.

std::optional<int32_t> slang::checkedAddS32(int32_t a, int32_t b)

Performs an addition of two signed 32-bit integers and returns the result if it does not overflow. If it does, nullopt is returned instead.

std::optional<int32_t> slang::checkedSubS32(int32_t a, int32_t b)

Performs a subtraction of two signed 32-bit integers and returns the result if it does not overflow. If it does, nullopt is returned instead.

std::optional<uint32_t> slang::checkedMulU32(uint32_t a, uint32_t b)

Performs a multiplication of two unsigned 32-bit integers and returns the result if it does not overflow. If it does, nullopt is returned instead.

bool slang::literalBaseFromChar(char base, LiteralBase& result)

Specifies the base of an integer (for converting to/from a string)

uint32_t slang::clog2(const SVInt& v)

Returns the ceiling of the log_2 of the value. If value is zero, returns zero.

bool slang::suffixToTimeUnit(string_view timeSuffix, TimeUnit& unit)

Scale unit for a time value.

bool slang::isASCII(char c) constexpr

Returns whether the given character is a valid ASCII character.

bool slang::isPrintableASCII(char c) constexpr

Returns whether the given character is considered "printable".

bool slang::isPrintableUnicode(uint32_t c)

Returns whether the given Unicode character is considered "printable". Unicode code points of the categories L, M, N, P, S and Zs are considered printable. In addition, U+00AD SOFT HYPHEN is also considered printable, as it's actually displayed on most terminals.

int slang::charWidthUnicode(uint32_t c)

Returns

Character width:

  • 0 for non-spacing and enclosing combining marks;
  • 2 for CJK characters excluding halfwidth forms;
  • 1 for all remaining characters.

Gets the number of positions a character is likely to occupy when output on a terminal ("character width"). This depends on the implementation of the terminal, and there's no standard definition of character width. The implementation defines it in a way that is expected to be compatible with a generic Unicode-capable terminal.

bool slang::isWhitespace(char c) constexpr

Returns whether the given character is considered whitespace.

bool slang::isNewline(char c) constexpr

Returns whether the given character is considered a new line.

bool slang::isDecimalDigit(char c) constexpr

Returns whether the given character is considered a decimal digit.

bool slang::isOctalDigit(char c) constexpr

Returns whether the given character is considered an octal digit.

bool slang::isHexDigit(char c) constexpr

Returns whether the given character is considered a hexadecimal digit.

bool slang::isBinaryDigit(char c) constexpr

Returns whether the given character is considered a binary digit.

bool slang::isAlphaNumeric(char c) constexpr

Returns whether the given character is considered an alphanumeric character.

bool slang::isValidCIdChar(char c) constexpr

Returns whether the given character is valid in a C language identifier. That includes all alphanumeric characters and the underscore.

bool slang::isBase64Char(char c) constexpr

Returns whether the given characrer is a valid in base64 encoding.

bool slang::isLogicDigit(char c) constexpr

Returns whether the given character is considered a special logic digit, which encompasses various ways to say Unknown (X) or High Impedance (Z).

uint8_t slang::getDigitValue(char c) constexpr

Gets the numeric value of the given decimal digit. If the given character is not a valid decimal digit, the result is undefined.

uint8_t slang::getHexDigitValue(char c) constexpr

Gets the numeric value of the given hexadecimal digit. If the given character is not a valid hexadecimal digit, the result is undefined.

char slang::getHexForDigit(uint32_t num, bool lowerCase = false) constexpr

Gets the hexadecimal character for the given number (which should be less than 16).

int slang::utf8Len(unsigned char first) constexpr

Gets the length of the UTF-8 sequence starting with the given first character. Returns 0 if the given character is invalid for a UTF-8 sequence.

const char* slang::utf8Decode(const char* b, uint32_t* c, int* e) constexpr

Decode the next character, c from buf

Since this is a branchless decoder, four bytes will be read from the buffer regardless of the actual length of the next character. This means the buffer must have at least three bytes of zero padding following the end of the data stream.

Errors are reported in e which will be non-zero if the parsed character was somehow invalid: invalid byte sequence, non-canonical encoding, or a surrogate half.

The function returns a pointer to the next character. When an error occurs, this pointer will be a guess that depends on the particular error, but it will always advance at least one byte.

template<typename T, typename... Rest>
void slang::hash_combine(size_t& seed, const T& v, Rest... rest)

Hash combining function, based on the function from Boost. It hashes the provided v object and combines it with the previous hash value in seed.

template<typename T>
iterator_range<T> slang::make_range(T begin, T end)

Constructs an iterator_range from two provided iterators (inferring the types involved).

template<typename TContainer>
auto slang::make_reverse_range(TContainer&& container)

Constructs a reversed iterator_range from the provided container, using std::make_reverse_iterator.

string_view slang::toStringView(span<char> text)

Converts a span of characters into a string_view.

void slang::uintToStr(SmallVector<char>& buffer, uint32_t value)

Converts the provided value into a string, storing it into buffer.

void slang::uintToStr(SmallVector<char>& buffer, uint64_t value)

Converts the provided value into a string, storing it into buffer.

std::optional<int32_t> slang::strToInt(string_view str, size_t* pos = nullptr, int base = 10)

Returns the converted value, or nullopt if conversion fails (invalid string, overflow, etc).

Parses the provided str in the specified base into a signed integer. If pos is non-null, it will be set to point to the first character in the source string that was not part of the conversion.

std::optional<uint32_t> slang::strToUInt(string_view str, size_t* pos = nullptr, int base = 10)

Returns the converted value, or nullopt if conversion fails (invalid string, overflow, etc).

Parses the provided str in the specified base into an unsigned integer. If pos is non-null, it will be set to point to the first character in the source string that was not part of the conversion.

std::optional<double> slang::strToDouble(string_view str, size_t* pos = nullptr)

Returns the converted value, or nullopt if conversion fails (invalid string, overflow, etc).

Parses the provided str into a floating point value. If pos is non-null, it will be set to point to the first character in the source string that was not part of the conversion.

void slang::strToUpper(std::string& str)

Converts the provided string to all uppercase characters (assuming ASCII contents). The string is converted in place.

void slang::strToLower(std::string& str)

Converts the provided string to all lowercase characters (assuming ASCII contents). The string is converted in place.

int slang::editDistance(string_view left, string_view right, bool allowReplacements = true, int maxDistance = 0)

Determines the number of edits to the left string that are required to change it into the right string. If allowReplacements is true, characters can be substituted as needed. Otherwise, only swaps are allowed.

If maxDistance is >0 and the computed distance is at least that much, give up and return maxDistance + 1.

string_view slang::widen(string_view str)

Widens the provided UTF8 string into UTF16 wchars.

string_view slang::narrow(string_view str)

Widens the provided UTF16 string into UTF8.