slang namespace
Root namespace.
Namespaces
- namespace assert
- Assertion-related utilities.
- namespace ast
- The SystemVerilog AST.
- namespace driver
- Frontend tool driver.
- namespace parsing
- Lexing, preprocessing, and parsing functionality.
- namespace SFormat
- Utility methods for formatting strings using SystemVerilog formatting styles.
- namespace syntax
- Syntax tree manipulation.
Classes
- struct AssociativeArray
- Represents a SystemVerilog associative array, for use during constant evaluation.
- class Bag
- Bag - A general container of arbitrary objects.
-
template<typename T>class bitmask
- A convenience wrapper around an enum that is intended to be used as a combination of bitwise-combined flags.
- struct BufferID
- BufferID - Represents a source buffer.
- class BumpAllocator
- BumpAllocator - Fast O(1) allocator.
- class CommandLine
- Command line argument parser.
- struct ConstantRange
- Represents a simple constant range, fully inclusive.
- class ConstantValue
- Represents a constant (compile-time evaluated) value, of one of a few possible types.
-
template<typename T>class CopyPtr
- A smart pointer that allocates its pointee on the heap and provides value copy semantics.
-
template<bool IsConst>class CVIterator
- An iterator for child elements in a ConstantValue, if it represents an array, map, or queue.
- 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
- The DiagnosticEngine is the central point for controlling how diagnostics are categorized and issued to clients.
- class Diagnostics
- A collection of diagnostics.
-
template<typename Fn>class function_ref
- An efficient, type-erasing, non-owning reference to a callable.
-
template<typename TKey, typename TValue>class IntervalMap
- A data structure that maps from intervals (closed ranges) to values.
-
template<typename Derived, bool Contiguous = false>class iterator_facade
- Iterator facade which infers iterator types and functionality.
- class JsonWriter
- A very lightweight JSON writer.
- struct logic_t
- Represents a single 4-state bit.
-
template<typename T>class not_null
- A wrapper around a pointer that indicates that it should never be null.
- class OS
- A collection of various OS-specific utility functions.
- class PointerIntPair
- A data structure that operates as a pair of a pointer and an integer, which fits in the space of one full sized pointer by exploiting unused bits in the pointer representation.
- class PoolAllocator
- A simple pool allocator built on top of a bump allocator.
- struct real_t
- Represents an IEEE754 double precision floating point number.
-
template<typename T, typename Index>class SafeIndexedVector
- SafeIndexedVector - a flat random-access container that uses a strongly typed integer type for indexing, so that clients can store indices without chance of mistaking them for some other value.
-
template<typename F>class ScopeGuard
- A simple guard class that ensures a given function is invoked when the guard object is destroyed.
- struct shortreal_t
- Represents an IEEE754 single precision floating point number.
-
template<typename K, typename V, size_class SmallMap
t N, typename Entry = std:: pair<const K, V>, typename Alloc = detail:: hashing:: StackAllocator<Entry, N* sizeof(Entry)>> - A hash map container that allocates room for its first
N
elements on the stack. -
template<typename T, size_class SmallSet
t N, typename Alloc = detail:: hashing:: StackAllocator<T, N* sizeof(T)>> - A hash set container that allocates room for its first
N
elements on the stack. -
template<typename T, size_class SmallVector
t N = detail::calculateDefaultSmallVectorElems<T>()> - A concrete, sized version of the SmallVectorBase<T> template.
-
template<typename T>class SmallVectorBase
- Base class for a fast growable array.
- struct SourceBuffer
- Represents a source buffer; that is, the actual text of the source code along with an identifier for the buffer which potentially encodes its include stack.
- struct SourceLibrary
- A named collection of source buffers that form a library.
- class SourceLocation
- This class represents a location in source code (or within a macro expansion).
- class SourceManager
- SourceManager - Handles loading and tracking source files.
- class SourceRange
- Combines a pair of source locations that denote a range of source text.
- class SVInt
- SystemVerilog arbitrary precision integer type.
- class SVIntStorage
- POD base class for SVInt that contains all data members.
- struct SVQueue
- Represents a SystemVerilog queue, for use during constant evaluation.
- struct SVUnion
- Represents a SystemVerilog unpacked union, for use during constant evaluation.
- class ThreadPool
- A lightweight thread pool for running concurrent jobs.
- struct TimeScale
- A collection of a base time and a precision value that determines the scale of simulation time steps.
- struct TimeScaleValue
- A combination of a unit and magnitude for a time scale value.
- class TimeTrace
- Support for performance profiling via hierarchical time tracing.
- class TimeTraceScope
- A helper class that calls begin and end of the time trace profiler.
- class type_index
- A simple implementation of a type index that can stand in for std::type_index to allow building without RTTI enabled.
-
template<typename T>class TypedBumpAllocator
- A strongly-typed version of the BumpAllocator, which has the additional behavior of calling destructors on all elements when the allocator itself is destructed.
- struct UninitializedTag
- A tag type used in a SmallVector constructor to indicate that the passed capacity parameter is only for reserving uninitialized memory and not actually adding elements to the container.
- 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 } - As allowed by SystemVerilog, time scales can be expressed in one of only a few magnitudes.
- enum class GlobRank { ExactPath, SimpleName, WildcardName, Directory }
- Classifies the ranking of a glob pattern.
- enum class GlobMode { Files, Directories }
- The type of search to perform with a file system glob operation.
- enum class CommandLineFlags { None = 0, FilePath = 1, CommaList = 2 }
- Specifies flags that can apply to command line options.
- enum class LanguageVersion { v1800_2017, v1800_2023, Default = v1800_2017 }
- Specifies SystemVerilog language versions.
Typedefs
-
using bitwidth_t = uint32_
t - A type that can represent the largest possible bit width of a SystemVerilog integer.
Functions
-
auto checkedAddS32(int32_
t a, int32_ t b) -> std:: optional<int32_ t> - Performs an addition of two signed 32-bit integers and returns the result if it does not overflow.
-
auto checkedSubS32(int32_
t a, int32_ t b) -> std:: optional<int32_ t> - Performs a subtraction of two signed 32-bit integers and returns the result if it does not overflow.
-
auto checkedMulU32(uint32_
t a, uint32_ t b) -> std:: optional<uint32_ t> - Performs a multiplication of two unsigned 32-bit integers and returns the result if it does not overflow.
-
auto checkedMulU64(uint64_
t a, uint64_ t b) -> std:: optional<uint64_ t> - Performs a multiplication of two unsigned 64-bit integers and returns the result if it does not overflow.
- 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(std::
string_view timeSuffix, size_ t& lengthConsumed) -> std:: optional<TimeUnit> - 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 - Returns whether the given Unicode character is considered "printable".
-
auto charWidthUnicode(uint32_
t c) -> int - Gets the number of positions a character is likely to occupy when output on a terminal ("character width").
- 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
- Returns whether the given character is valid in a C language identifier.
- auto isBase64Char(char c) -> bool constexpr
- Returns whether the given characrer is a valid in base64 encoding.
- auto isLogicDigit(char c) -> bool constexpr
- Returns whether the given character is considered a special logic digit, which encompasses various ways to say Unknown (X) or High Impedance (Z).
-
auto getDigitValue(char c) -> uint8_
t constexpr - Gets the numeric value of the given decimal digit.
-
auto getHexDigitValue(char c) -> uint8_
t constexpr - Gets the numeric value of the given hexadecimal digit.
-
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
- Gets the length of the UTF-8 sequence starting with the given first character.
-
auto utf8Decode(const char* b,
uint32_
t* c, int* e, int& computedLen) -> const char* constexpr - Decode the next character, c from buf.
-
auto svGlob(const std::
filesystem:: path& basePath, std:: string_view pattern, GlobMode mode, SmallVector<std:: filesystem:: path>& results, bool expandEnvVars, std:: error_code& ec) -> GlobRank - Performs a file system "glob" operation to find paths matching the given pattern.
-
auto svGlobMatches(const std::
filesystem:: path& path, const std:: filesystem:: path& pattern) -> bool - Checks whether the given path matches the supplied pattern.
-
template<typename T, typename... Rest>void hash_combine(size_
t& seed, const T& v, Rest... rest) - Hash combining function, based on the function from Boost.
-
template<typename TGenerator, typename TValue>static auto getUniformIntDist(TGenerator& gen, TValue min, TValue max) -> TValue
- Gets a (mostly) uniformly distributed value within the provided [min,max] range.
-
template<typename T>static auto createRandomGenerator() -> T
- Create a randomly seeded random number generator.
-
auto toStringView(std::
span<char> text) -> std:: string_view - Converts a span of characters into a std::string_view.
-
void uintToStr(SmallVectorBase<char>& buffer,
uint32_
t value) - Converts the provided value into a string, storing it into buffer.
-
void uintToStr(SmallVectorBase<char>& buffer,
uint64_
t value) - Converts the provided value into a string, storing it into buffer.
-
auto strToInt(std::
string_view str, size_ t* pos = nullptr, int base = 10) -> std:: optional<int32_ t> - Parses the provided str in the specified base into a signed integer.
-
auto strToUInt(std::
string_view str, size_ t* pos = nullptr, int base = 10) -> std:: optional<uint32_ t> - Parses the provided str in the specified base into an unsigned integer.
-
auto strToDouble(std::
string_view str, size_ t* pos = nullptr) -> std:: optional<double> - Parses the provided str into a floating point value.
-
void strToUpper(std::
string& str) - Converts the provided string to all uppercase characters (assuming ASCII contents).
-
void strToLower(std::
string& str) - Converts the provided string to all lowercase characters (assuming ASCII contents).
- auto charToUpper(char c) -> char
- Converts a character to uppercase (assuming ASCII).
- auto charToLower(char c) -> char
- Converts a character to lowercase (assuming ASCII).
-
auto editDistance(std::
string_view left, std:: string_view right, bool allowReplacements = true, int maxDistance = 0) -> int - Determines the number of edits to the left string that are required to change it into the right string.
-
auto getU8Str(const std::
filesystem:: path& path) -> const std:: string& - Gets a string representation of the given path, in UTF-8 encoding.
-
template<typename T>auto typeName() -> std::
string_view constexpr - Returns the demangled name of the template argument's C++ type.
Enum documentation
enum class slang:: TimeScaleMagnitude: uint8_ t
#include <slang/numeric/Time.h>
As allowed by SystemVerilog, time scales can be expressed in one of only a few magnitudes.
enum class slang:: GlobRank
#include <slang/text/Glob.h>
Classifies the ranking of a glob pattern.
The LRM specifies that files that match patterns of a given rank are preferred over those that match later ranks.
Enumerators | |
---|---|
ExactPath |
A full match of an exact path without any wildcards. |
SimpleName |
A plain textual name match. |
WildcardName |
A name with wildcards. |
Directory |
A directory name (and therefore all files within that directory implicitly included). |
enum class slang:: GlobMode
#include <slang/text/Glob.h>
The type of search to perform with a file system glob operation.
Enumerators | |
---|---|
Files |
Search for files. |
Directories |
Search for directories. |
enum class slang:: CommandLineFlags
#include <slang/util/CommandLine.h>
Specifies flags that can apply to command line options.
Enumerators | |
---|---|
None |
No special flags. |
FilePath |
The option is for a file path, which should be translated relative to the current working directory. |
CommaList |
For list options, allow specifying multiple values in a single entry via a comma-separated list. |
enum class slang:: LanguageVersion
#include <slang/util/LanguageVersion.h>
Specifies SystemVerilog language versions.
Typedef documentation
using slang:: bitwidth_t = uint32_ t
#include <slang/numeric/SVInt.h>
A type that can represent the largest possible bit width of a SystemVerilog integer.
Function documentation
std:: optional<int32_ t> slang:: checkedAddS32(int32_ t a,
int32_ t b)
#include <slang/numeric/MathUtils.h>
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)
#include <slang/numeric/MathUtils.h>
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)
#include <slang/numeric/MathUtils.h>
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.
std:: optional<uint64_ t> slang:: checkedMulU64(uint64_ t a,
uint64_ t b)
#include <slang/numeric/MathUtils.h>
Performs a multiplication of two unsigned 64-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)
#include <slang/numeric/SVInt.h>
Specifies the base of an integer (for converting to/from a string)
uint32_ t slang:: clog2(const SVInt& v)
#include <slang/numeric/SVInt.h>
Returns the ceiling of the log_2 of the value. If value is zero, returns zero.
std:: optional<TimeUnit> slang:: suffixToTimeUnit(std:: string_view timeSuffix,
size_ t& lengthConsumed)
#include <slang/numeric/Time.h>
Scale unit for a time value.
bool slang:: isASCII(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is a valid ASCII character.
bool slang:: isPrintableASCII(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered "printable".
bool slang:: isPrintableUnicode(uint32_ t c)
#include <slang/text/CharInfo.h>
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)
#include <slang/text/CharInfo.h>
Gets the number of positions a character is likely to occupy when output on a terminal ("character width").
Returns | 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
#include <slang/text/CharInfo.h>
Returns whether the given character is considered whitespace.
bool slang:: isNewline(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered a new line.
bool slang:: isDecimalDigit(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered a decimal digit.
bool slang:: isOctalDigit(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered an octal digit.
bool slang:: isHexDigit(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered a hexadecimal digit.
bool slang:: isBinaryDigit(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered a binary digit.
bool slang:: isAlphaNumeric(char c) constexpr
#include <slang/text/CharInfo.h>
Returns whether the given character is considered an alphanumeric character.
bool slang:: isValidCIdChar(char c) constexpr
#include <slang/text/CharInfo.h>
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
#include <slang/text/CharInfo.h>
Returns whether the given characrer is a valid in base64 encoding.
bool slang:: isLogicDigit(char c) constexpr
#include <slang/text/CharInfo.h>
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
#include <slang/text/CharInfo.h>
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
#include <slang/text/CharInfo.h>
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
#include <slang/text/CharInfo.h>
Gets the hexadecimal character for the given number (which should be less than 16).
int slang:: utf8Len(unsigned char first) constexpr
#include <slang/text/CharInfo.h>
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,
int& computedLen) constexpr
#include <slang/text/CharInfo.h>
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.
GlobRank slang:: svGlob(const std:: filesystem:: path& basePath,
std:: string_view pattern,
GlobMode mode,
SmallVector<std:: filesystem:: path>& results,
bool expandEnvVars,
std:: error_code& ec)
#include <slang/text/Glob.h>
Performs a file system "glob" operation to find paths matching the given pattern.
Parameters | |
---|---|
basePath | The path in which to search. If empty, uses the current working directory. |
pattern | The pattern to match against paths |
mode | The type of search to perform (either for files or for directories) |
results | The list of paths that matched the given pattern |
expandEnvVars | If true, environment variables references in the pattern will be expanded before searching. References can be of the form $VAR, , and ${VAR}. |
ec | An error code that will be cleared on success and set to a value on failure. Failure to match is only indicated when the pattern is an exact path with no wildcards. |
Returns | A rank that indicates the strength of the match result. |
The pattern is in the format described by the LRM 33.3.1, which follows normal path syntax but allows for '?' and '*' wildcards, along with '...' to mean recursive directory search.
bool slang:: svGlobMatches(const std:: filesystem:: path& path,
const std:: filesystem:: path& pattern)
#include <slang/text/Glob.h>
Checks whether the given path matches the supplied pattern.
#include <slang/util/Hash.h>
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.
#include <slang/util/Random.h>
template<typename TGenerator, typename TValue>
static TValue slang:: getUniformIntDist(TGenerator& gen,
TValue min,
TValue max)
Gets a (mostly) uniformly distributed value within the provided [min,max] range.
This is a poor man's implementation of std::uniform_int_distribution because the standard type isn't required to produce identical results across implementations.
This implementation is potentially slightly biased if you use a large range but slang doesn't need super precisely distributed random numbers for anything so it's fine.
#include <slang/util/Random.h>
template<typename T>
static T slang:: createRandomGenerator()
Create a randomly seeded random number generator.
std:: string_view slang:: toStringView(std:: span<char> text)
#include <slang/util/String.h>
Converts a span of characters into a std::string_view.
void slang:: uintToStr(SmallVectorBase<char>& buffer,
uint32_ t value)
#include <slang/util/String.h>
Converts the provided value into a string, storing it into buffer.
void slang:: uintToStr(SmallVectorBase<char>& buffer,
uint64_ t value)
#include <slang/util/String.h>
Converts the provided value into a string, storing it into buffer.
std:: optional<int32_ t> slang:: strToInt(std:: string_view str,
size_ t* pos = nullptr,
int base = 10)
#include <slang/util/String.h>
Parses the provided str in the specified base into a signed integer.
Returns | the converted value, or nullopt if conversion fails (invalid string, overflow, etc). |
---|
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(std:: string_view str,
size_ t* pos = nullptr,
int base = 10)
#include <slang/util/String.h>
Parses the provided str in the specified base into an unsigned integer.
Returns | the converted value, or nullopt if conversion fails (invalid string, overflow, etc). |
---|
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(std:: string_view str,
size_ t* pos = nullptr)
#include <slang/util/String.h>
Parses the provided str into a floating point value.
Returns | the converted value, or nullopt if conversion fails (invalid string, overflow, etc). |
---|
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)
#include <slang/util/String.h>
Converts the provided string to all uppercase characters (assuming ASCII contents).
The string is converted in place.
void slang:: strToLower(std:: string& str)
#include <slang/util/String.h>
Converts the provided string to all lowercase characters (assuming ASCII contents).
The string is converted in place.
char slang:: charToUpper(char c)
#include <slang/util/String.h>
Converts a character to uppercase (assuming ASCII).
char slang:: charToLower(char c)
#include <slang/util/String.h>
Converts a character to lowercase (assuming ASCII).
int slang:: editDistance(std:: string_view left,
std:: string_view right,
bool allowReplacements = true,
int maxDistance = 0)
#include <slang/util/String.h>
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.
const std:: string& slang:: getU8Str(const std:: filesystem:: path& path)
#include <slang/util/String.h>
Gets a string representation of the given path, in UTF-8 encoding.
#include <slang/util/TypeTraits.h>
template<typename T>
std:: string_view slang:: typeName() constexpr
Returns the demangled name of the template argument's C++ type.