Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector3vl

Three-value logic vectors.

This is a data class -- its contents are not mutable. Operations on logic vectors return a freshly allocated vector.

The internal representation is two bit vectors: bit vector A and B. The value at position n is encoded by two bits, one at position n in bit vector A, the other at same position in bit vector B. The bit combinations have the following meanings:

  • A: 0, B: 0 -- logical 0,
  • A: 0, B: 1 -- undefined value, "x",
  • A: 1, B: 1 -- logical 1.

Hierarchy

  • Vector3vl

Index

Constructors

Private constructor

  • new Vector3vl(bits: number, avec: Uint32Array, bvec: Uint32Array): Vector3vl
  • Private constructor for three-value logic vectors.

    Only for internal use.

    Parameters

    • bits: number

      Number of bits in the vector.

    • avec: Uint32Array

      Bit vector A.

    • bvec: Uint32Array

      Bit vector B.

    Returns Vector3vl

Properties

Private _avec

_avec: Uint32Array

Bit vector A.

Private _bits

_bits: number

Number of bits in the vector.

Private _bvec

_bvec: Uint32Array

Bit vector B.

Static empty

empty: Vector3vl = Vector3vl.zeros(0)

An empty vector.

Static one

one: Vector3vl = Vector3vl.ones(1)

A single one.

Static x

x: Vector3vl = Vector3vl.xes(1)

A single undefined value.

Static zero

zero: Vector3vl = Vector3vl.zeros(1)

A single zero.

Accessors

Private _lastmask

  • get _lastmask(): number
  • Mask for unused bits.

    For internal use.

    Returns number

bits

  • get bits(): number
  • Number of bits in the vector.

    Returns number

isDefined

  • get isDefined(): boolean
  • Tests if there is any defined bit in the vector.

    Returns boolean

isFullyDefined

  • get isFullyDefined(): boolean
  • Tests if every bit in the vector is defined.

    Returns boolean

isHigh

  • get isHigh(): boolean
  • Tests if the vector is all ones.

    Returns boolean

isLow

  • get isLow(): boolean
  • Tests if the vector is all zeros.

    Returns boolean

lsb

  • get lsb(): number
  • Least significant bit in the vector. Returns -1, 0 or 1.

    Returns number

msb

  • get msb(): number
  • Most significant bit in the vector. Returns -1, 0 or 1.

    Returns number

Methods

and

  • Bitwise AND of two vectors.

    The vectors need to be the same bit length.

    Parameters

    Returns Vector3vl

concat

  • Concatenates vectors, including this one, into a single vector.

    Parameters

    Returns Vector3vl

eq

get

  • get(n: number): number
  • Gets nth value in the vector. Returns -1, 0 or 1.

    Parameters

    • n: number

    Returns number

nand

  • Bitwise NAND of two vectors.

    The vectors need to be the same bit length.

    Parameters

    Returns Vector3vl

nor

  • Bitwise NOR of two vectors.

    The vectors need to be the same bit length.

    Parameters

    Returns Vector3vl

normalize

  • normalize(): void
  • Normalize the vector.

    Because of the representation used, if bits is not a multiple of 32, some internal bits do not contribute to the vector value, and for performance reasons can get arbitrary values in the course of computations. This procedure clears these bits. For internal use.

    Returns void

not

or

  • Bitwise OR of two vectors.

    The vectors need to be the same bit length.

    Parameters

    Returns Vector3vl

reduceAnd

  • Reducing AND of a vector.

    ANDs all bits of the vector together, producing a single bit.

    Returns Vector3vl

    Singleton vector.

reduceNand

  • Reducing NAND of a vector.

    NANDs all bits of the vector together, producing a single bit.

    Returns Vector3vl

    Singleton vector.

reduceNor

  • Reducing NOR of a vector.

    NORs all bits of the vector together, producing a single bit.

    Returns Vector3vl

    Singleton vector.

reduceOr

  • Reducing OR of a vector.

    ORs all bits of the vector together, producing a single bit.

    Returns Vector3vl

    Singleton vector.

reduceXnor

  • Reducing XNOR of a vector.

    XNORs all bits of the vector together, producing a single bit.

    Returns Vector3vl

    Singleton vector.

reduceXor

  • Reducing XOR of a vector.

    XORs all bits of the vector together, producing a single bit.

    Returns Vector3vl

    Singleton vector.

slice

  • slice(start?: number, end?: number): Vector3vl
  • Return a subvector.

    Uses same conventions as the slice function for JS arrays.

    Parameters

    • Optional start: number

      Number of the first bit to include in the result. If omitted, first bit of the vector is used.

    • Optional end: number

      Number of the last bit to include in the result, plus one. If omitted, last bit of the vector is used.

    Returns Vector3vl

toArray

  • toArray(): any[]
  • Returns an array representation of the vector.

    The resulting array contains values -1, 0, 1.

    Returns any[]

toBin

  • toBin(): string
  • Returns a binary representation of the vector.

    Three characters are used:

    • '0' for logical 0,
    • 'x' for undefined value,
    • '1' for logical 1.

    Returns string

toHex

  • toHex(): string
  • Returns an hexadecimal representation of the vector.

    Returned characters can be '0' to '9', 'a' to 'f' and 'x'. An 'x' value is returned if any of the four bits is undefined.

    Returns string

toIterator

  • toIterator(skip: number): Generator<number, void, unknown>
  • Returns an iterator describing the vector.

    In each returned value, first skip bits come from the vector B, the next skip bits come from the vector A.

    This function calls toIteratorAnySkip or toIteratorPow2.

    Parameters

    • skip: number

      Number of bits in a single iterator step. 1 to 16.

    Returns Generator<number, void, unknown>

toIteratorAnySkip

  • toIteratorAnySkip(skip: number): Generator<number, void, unknown>
  • Returns an iterator describing the vector.

    In each returned value, first skip bits come from the vector B, the next skip bits come from the vector A.

    Parameters

    • skip: number

      Number of bits in a single iterator step. 1 to 16.

    Returns Generator<number, void, unknown>

toIteratorPow2

  • toIteratorPow2(skip: number): Generator<number, void, unknown>
  • Returns an iterator describing the vector.

    In each returned value, first skip bits come from the vector B, the next skip bits come from the vector A.

    Parameters

    • skip: number

      Number of bits in a single iterator step. 1, 2, 4, 8 or 16.

    Returns Generator<number, void, unknown>

toOct

  • toOct(): string
  • Returns an octal representation of the vector.

    Returned characters can be '0' to '7' and 'x'. An 'x' value is returned if any of the three bits is undefined.

    Returns string

toString

  • toString(): string
  • Returns a string describing the vector.

    Returns string

xmask

xnor

  • Bitwise XNOR of two vectors.

    The vectors need to be the same bit length.

    Parameters

    Returns Vector3vl

xor

  • Bitwise XOR of two vectors.

    The vectors need to be the same bit length.

    Parameters

    Returns Vector3vl

Static concat

  • Concatenate vectors into a single big vector.

    Parameters

    • Rest ...vs: Vector3vl[]

      Vectors to concatenate. Arguments are ordered least significant bit first.

    Returns Vector3vl

Static fromArray

  • Construct a vector from an array of numbers.

    The following interpretation is used:

    • -1 for logical 0,
    • 0 for undefined value,
    • 1 for logical 1.

    Parameters

    • data: number[]

      Input array.

    Returns Vector3vl

Static fromBin

  • fromBin(data: string, nbits?: number): Vector3vl
  • Construct a vector from a binary string.

    Three characters are accepted:

    • '0' for logical 0,
    • 'x' for undefined value,
    • '1' for logical 1.

    If nbits is given, data is either truncated, or extended with undefined values.

    Parameters

    • data: string

      The binary string to be parsed.

    • Optional nbits: number

      Number of bits in the vector. If omitted, the resulting vector has number of bits equal to the length of data.

    Returns Vector3vl

Static fromBool

  • Construct a singleton vector containing b.

    Parameters

    • b: boolean

    Returns Vector3vl

Static fromHex

  • fromHex(data: string, nbits?: number): Vector3vl
  • Construct a vector from a hexadecimal number.

    Characters '0' to '9', 'a' to 'f' and 'x' are accepted. The character 'x' means three undefined bits.

    If nbits is given, data is either truncated, or extended with undefined values.

    Parameters

    • data: string

      The hexadecimal string to be parsed.

    • Optional nbits: number

      Number of bits in the vector. If omitted, the resulting vector has number of bits equal to the length of data times four.

    Returns Vector3vl

Static fromIterator

  • fromIterator(iter: Iterable<number>, skip: number, nbits: number): Vector3vl
  • Construct a vector from an iterable.

    This function calls fromIteratorAnySkip or fromIteratorPow2.

    Parameters

    • iter: Iterable<number>

      Iterable returning initialization values, least to most significant. First skip bits go to vector B, next skip bits go to vector A.

    • skip: number

      Number of bits in a single iterator step. 1 to 16.

    • nbits: number

      Number of bits in the vector.

    Returns Vector3vl

Static fromIteratorAnySkip

  • fromIteratorAnySkip(iter: Iterable<number>, skip: number, nbits: number): Vector3vl
  • Construct a vector from an iterable.

    This function is more generic, but slower, than fromIteratorPow2.

    Parameters

    • iter: Iterable<number>

      Iterable returning initialization values, least to most significant. First skip bits go to vector B, next skip bits go to vector A.

    • skip: number

      Number of bits in a single iterator step. 1 to 16.

    • nbits: number

      Number of bits in the vector.

    Returns Vector3vl

Static fromIteratorPow2

  • fromIteratorPow2(iter: Iterable<number>, skip: number, nbits: number): Vector3vl
  • Construct a vector from an iterable.

    This function is limited to power of 2 skip values. For generic version, see fromIteratorAnySkip.

    Parameters

    • iter: Iterable<number>

      Iterable returning initialization values, least to most significant. First skip bits go to vector B, next skip bits go to vector A.

    • skip: number

      Number of bits in a single iterator step. Limited to powers of 2: 1, 2, 4, 8, 16.

    • nbits: number

      Number of bits in the vector.

    Returns Vector3vl

Static fromOct

  • fromOct(data: string, nbits?: number): Vector3vl
  • Construct a vector from an octal number.

    Characters '0' to '7' and 'x' are accepted. The character 'x' means three undefined bits.

    If nbits is given, data is either truncated, or extended with undefined values.

    Parameters

    • data: string

      The octal string to be parsed.

    • Optional nbits: number

      Number of bits in the vector. If omitted, the resulting vector has number of bits equal to the length of data times three.

    Returns Vector3vl

Static make

  • Construct a vector with a constant value at each position.

    Parameters

    • bits: number

      Number of bits in the vector.

    • init: InitType

      Initializer. Recognized values:

      • false, -1, '0' for logical 0,
      • 0, 'x' for undefined value,
      • true, 1, '1' for logical 1.

    Returns Vector3vl

Static ones

  • Construct a vector containing only ones.

    Parameters

    • bits: number

      Number of bits in the vector.

    Returns Vector3vl

Static xes

  • Construct a vector containing only undefined values.

    Parameters

    • bits: number

      Number of bits in the vector.

    Returns Vector3vl

Static zeros

  • Construct a vector containing only zeros.

    Parameters

    • bits: number

      Number of bits in the vector.

    Returns Vector3vl

Generated using TypeDoc