Header menu logo issie

NumberHelpers Module

Nested modules

Modules Description

Constants

Functions and values

Function or value Description

BigIntToPaddedString maxChars radix width n

Full Usage: BigIntToPaddedString maxChars radix width n

Parameters:
    maxChars : int
    radix : NumberBase
    width : int
    n : bigint

Returns: string

Print a bigint (n) as a string with a given radix and width. If the string is too long, truncate it. MaxChars: the max printedlength of the string in char widths (emm). Radix: the radix to use for the string. width: the bus width within which n should be printed.

maxChars : int
radix : NumberBase
width : int
n : bigint
Returns: string

UInt32ToPaddedString maxChars radix width n

Full Usage: UInt32ToPaddedString maxChars radix width n

Parameters:
    maxChars : int
    radix : NumberBase
    width : int
    n : uint32

Returns: string

Print a uint32 (n) as a string with a given radix and width. If the string is too long, truncate it. MaxChars: the max printedlength of the string in char widths (emm). Radix: the radix to use for the string. width: the bus width within which n should be printed.

maxChars : int
radix : NumberBase
width : int
n : uint32
Returns: string

big16

Full Usage: big16

Returns: BigInteger
Returns: BigInteger

big32

Full Usage: big32

Returns: BigInteger
Returns: BigInteger

big64

Full Usage: big64

Returns: BigInteger
Returns: BigInteger

big8

Full Usage: big8

Returns: BigInteger
Returns: BigInteger

binBignum num

Full Usage: binBignum num

Parameters:
    num : bigint

Returns: string

Display a bignum as binary, always using 'b' prefix.

num : bigint
Returns: string

bitToString bit

Full Usage: bitToString bit

Parameters:
Returns: string

Convert a bit to string.

bit : Bit
Returns: string

checkWidth width num

Full Usage: checkWidth width num

Parameters:
    width : int
    num : bigint

Returns: string option

Check a number is formed by at most bits.

width : int
num : bigint
Returns: string option

convertBigintToFastData width b

Full Usage: convertBigintToFastData width b

Parameters:
    width : int
    b : bigint

Returns: FastData
width : int
b : bigint
Returns: FastData

convertBigintToInt32 b

Full Usage: convertBigintToInt32 b

Parameters:
    b : bigint

Returns: int32
b : bigint
Returns: int32

convertBigintToUInt32 w b

Full Usage: convertBigintToUInt32 w b

Parameters:
    w : int
    b : bigint

Returns: uint32
w : int
b : bigint
Returns: uint32

convertFastDataToBigint d

Full Usage: convertFastDataToBigint d

Parameters:
Returns: bigint

convert to a bigint - always works. Bits < width will be correct.

d : FastData
Returns: bigint

convertFastDataToInt d

Full Usage: convertFastDataToInt d

Parameters:
Returns: uint32

convert to int with an exception if data is too large

d : FastData
Returns: uint32

convertFastDataToInt32 d

Full Usage: convertFastDataToInt32 d

Parameters:
Returns: int32

Lossy conversion of bigint to int32 without exceptions TODO: change this - and all dependencies with 32 bit int - to bigint?

d : FastData
Returns: int32

convertFastDataToWireData fastDat

Full Usage: convertFastDataToWireData fastDat

Parameters:
Returns: WireData
fastDat : FastData
Returns: WireData

convertIntToFastData width n

Full Usage: convertIntToFastData width n

Parameters:
    width : int
    n : uint32

Returns: FastData
width : int
n : uint32
Returns: FastData

convertIntToWireData width num

Full Usage: convertIntToWireData width num

Parameters:
    width : int
    num : bigint

Returns: WireData

Convert an int into a Bit list with the provided width. The Least Significant Bits are the one with low index (e.g. LSB is at position 0, MSB is at position N). Little Endian. If the number has more bits than width, then more bits will be returned.

width : int
num : bigint
Returns: WireData

convertWireDataToFastData wd

Full Usage: convertWireDataToFastData wd

Parameters:
Returns: FastData
wd : WireData
Returns: FastData

convertWireDataToInt bits

Full Usage: convertWireDataToInt bits

Parameters:
Returns: bigint

Convert a list of Bits into an int. The Least Significant Bits are the one with low index (e.g. LSB is at position 0, MSB is at position N). Little Endian.

bits : WireData
Returns: bigint

decBignum num

Full Usage: decBignum num

Parameters:
    num : bigint

Returns: string

The same as sDecBignum with width of 0. Display the bignum in signed decimal as is.

num : bigint
Returns: string

emptyFastData

Full Usage: emptyFastData

Returns: FastData
Returns: FastData

fastDataToPaddedString maxChars radix fd

Full Usage: fastDataToPaddedString maxChars radix fd

Parameters:
Returns: string

Print a FastData as a string with a given radix and width. If the string is too long, truncate it. MaxChars: the max printedlength of the string in char widths (emm). Radix: the radix to use for the string. Fd: the FastData to print.

maxChars : int
radix : NumberBase
fd : FastData
Returns: string

fillBinBignum width

Full Usage: fillBinBignum width

Parameters:
    width : int

Returns: bigint -> string

Fill a binary printed bignum with zeros to a given width. Add commas every 4 bits fro readability.

width : int
Returns: bigint -> string

fillHexBignum width n

Full Usage: fillHexBignum width n

Parameters:
    width : int
    n : bigint

Returns: string

Fill a hex printed bigint with zeros to a given width in bits. Add commas every 4 digits for readability.

width : int
n : bigint
Returns: string

hexBignum num

Full Usage: hexBignum num

Parameters:
    num : bigint

Returns: string

Display a bignum as hex, always using 'x' prefix. NB - printf %x does bnot work for bignums

num : bigint
Returns: string

sDecBignum width num

Full Usage: sDecBignum width num

Parameters:
    width : int
    num : bigint

Returns: string

Display bigint as signed twos complement value if width > 0. Otherwise display bigint in signed decimal as is.

width : int
num : bigint
Returns: string

strToBigint str

Full Usage: strToBigint str

Parameters:
    str : string

Returns: Result<bigint, string>

Try to convert a string to a bigint, or return an error message if that was not possible.

str : string
Returns: Result<bigint, string>

strToIntCheckWidth width str

Full Usage: strToIntCheckWidth width str

Parameters:
    width : int
    str : string

Returns: Result<bigint, string>

Convert a string to a number making sure that it has no more bits than specified in width.

width : int
str : string
Returns: Result<bigint, string>

toDecimal num numBase width

Full Usage: toDecimal num numBase width

Parameters:
    num : string
    numBase : string
    width : string

Returns: BigInteger

Converts a binary, hex or decimal number to decimal Non-standard - used by Verilog code. Should rationalise?

num : string
numBase : string
width : string
Returns: BigInteger

twosComp width n

Full Usage: twosComp width n

Parameters:
    width : int
    n : bigint

Returns: bigint

Make negative bigints into the equivalent two's complement positive value. Must be given a width.

width : int
n : bigint
Returns: bigint

twosCompValue width n

Full Usage: twosCompValue width n

Parameters:
    width : int
    n : bigint

Returns: bigint

Make twos comp bigint n into the equivalent signed bignum value. Must be given a width.

width : int
n : bigint
Returns: bigint

valToPaddedString width radix value

Full Usage: valToPaddedString width radix value

Parameters:
Returns: string

Convert bigint to string according to radix. Binary and hex numbers are zero padded to width Binary is displayed as hex if width > 16 Single-bit binary or hex numbers do not have x or b prefix. Multi-bit hex or binary numbers do.

width : int
radix : NumberBase
value : bigint
Returns: string

Type something to start searching.