hwtLib.logic package¶
Submodules¶
hwtLib.logic.bcdToBin module¶
- class hwtLib.logic.bcdToBin.BcdToBin(hdlName: str | None = None)[source]¶
Bases:
HwModuleConvert a BCD number to binary encoding This uses the double-dabble algorithm in reverse. The conversion of a BCD number to an n-bit binary number will take n+3 cycles to complete.
based on: https://github.com/kevinpt/vhdl-extras/blob/master/rtl/extras/bcd_conversion.vhdl
- HDL params:
BCD_DIGITS - default value 3 of type int
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
din - of type hwt.hwIOs.std.HwIODataRdVld - SLAVE
dout - of type hwt.hwIOs.std.HwIODataRdVld - MASTER
- __annotations__ = {}¶
hwtLib.logic.binToBcd module¶
- class hwtLib.logic.binToBcd.BinToBcd(hdlName: str | None = None)[source]¶
Bases:
HwModuleConvert binary to BCD (Binary coded decimal) format (BCD is a format where each 4 bites represents a single decimal digit 0-9)
based on https://github.com/kb000/bin2bcd/blob/master/rtl/bin2bcd32.v
- HDL params:
INPUT_WIDTH - default value 64 of type int
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
din - of type hwt.hwIOs.std.HwIODataRdVld - SLAVE
dout - of type hwt.hwIOs.std.HwIODataRdVld - MASTER
- __annotations__ = {}¶
hwtLib.logic.binToOneHot module¶
- class hwtLib.logic.binToOneHot.BinToOneHot(hdlName: str | None = None)[source]¶
Bases:
HwModuleLittle endian encoded number to number in one-hot encoding
- HDL params:
DATA_WIDTH - default value 8 of type int
- HDL IO:
din - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 3bits> - SLAVE
en - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - SLAVE
dout - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 8bits> - MASTER
- __annotations__ = {}¶
hwtLib.logic.bitonicSorter module¶
- class hwtLib.logic.bitonicSorter.BitonicSorter(cmpFn=<function BitonicSorter.<lambda>>)[source]¶
Bases:
HwModuleBitonic sorter of arbitrary data
- HDL params:
ITEMS - default value 2 of type int
DATA_WIDTH - default value 64 of type int
SIGNED - default value False of type bool
- HDL IO:
inputs - of type hwt.hwIOs.hwIOArray.HwIOArray - SLAVE
outputs - of type hwt.hwIOs.hwIOArray.HwIOArray - MASTER
- __annotations__ = {}¶
hwtLib.logic.cntrGray module¶
- class hwtLib.logic.cntrGray.GrayCntr(hdlName: str | None = None)[source]¶
Bases:
HwModuleCounter for gray code
- HDL params:
DATA_WIDTH - default value 4 of type int
INIT_VAL - default value 0 of type int
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
en - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 4bits> - MASTER
- __annotations__ = {}¶
- class hwtLib.logic.cntrGray.GrayCntrTC(methodName='runTest')[source]¶
Bases:
SimTestCase- __annotations__ = {}¶
- _classSetupFailed = False¶
- _class_cleanups = []¶
- hwtLib.logic.cntrGray.binToGray(sigOrConst) RtlSignalBase[source]¶
Convert value or signal from binary encoding to gray encoding
hwtLib.logic.countLeading module¶
- class hwtLib.logic.countLeading.CountLeadingOnes(hdlName: str | None = None)[source]¶
Bases:
_CountLeadingCount leading zeros in bit vector (leading means from MSB side)
- HDL params:
DATA_WIDTH - default value 2 of type int
- HDL IO:
data_in - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - SLAVE
data_out - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - MASTER
- __annotations__ = {}¶
- class hwtLib.logic.countLeading.CountLeadingZeros(hdlName: str | None = None)[source]¶
Bases:
_CountLeadingCount leading zeros in bit vector (leading means from MSB side)
- HDL params:
DATA_WIDTH - default value 2 of type int
- HDL IO:
data_in - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - SLAVE
data_out - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - MASTER
- __annotations__ = {}¶
- class hwtLib.logic.countLeading.CountTrailingOnes(hdlName: str | None = None)[source]¶
Bases:
_CountLeadingCount trailing zeros in bit vector (trailing means from LSB side)
- HDL params:
DATA_WIDTH - default value 2 of type int
- HDL IO:
data_in - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - SLAVE
data_out - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - MASTER
- __annotations__ = {}¶
- class hwtLib.logic.countLeading.CountTrailingZeros(hdlName: str | None = None)[source]¶
Bases:
_CountLeadingCount trailing zeros in bit vector (trailing means from LSB side)
- HDL params:
DATA_WIDTH - default value 2 of type int
- HDL IO:
data_in - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - SLAVE
data_out - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 2bits> - MASTER
- __annotations__ = {}¶
- class hwtLib.logic.countLeading._CountLeading(hdlName: str | None = None)[source]¶
Bases:
HwModuleCount leading zeros/ones in bit vector
- __annotations__ = {}¶
- hwtLib.logic.countLeading._countLeadingRecurse(dataIn: RtlSignalBase[HBits], bitValToCount: int) HBitsRtlSignal | HBitsConst[source]¶
Construct a balanced tree for counter of leading 0/1
- Attention:
result is not final result, it is only for 0 to width-1 values
- hwtLib.logic.countLeading._countTrailingRecurse(dataIn: RtlSignalBase[HBits], bitValToCount: int) HBitsRtlSignal | HBitsConst[source]¶
Version of
_countLeadingRecurse()which counts from the back of the vector (upper bits first)
- hwtLib.logic.countLeading.countBits(dataIn: RtlSignalBase[HBits], bitValToCount: int, leading: bool) HBitsRtlSignal | HBitsConst[source]¶
- Parameters:
bitValToCount – parameter to switch between count of zeros and ones
leading – flag which switches between leading (from MSB side) and trailing (from LSB side) count
- Returns:
number of bits set to bitValToCount value
hwtLib.logic.crc module¶
- class hwtLib.logic.crc.Crc(hdlName: str | None = None)[source]¶
Bases:
HwModuleCrc generator for any crc, polynome can be string in usual format or integer (“x^3+x+1” or 0b1011)
- HDL params:
DATA_WIDTH - default value 24 of type intnumber of bits of data in
IN_IS_BIGENDIAN - default value False of type bool
POLY_TY - default value <class ‘hwtLib.logic.crcPoly.CRC_32’> of type type
LATENCY - default value 1 of type intnumber of cycles from data in to data out
MASK_GRANULARITY - default value 8 of type intif None, there is no mask for data in, else it must be an int which represents number of bits per 1 bit of mask signal, this allows this component to compute crc for smaller bitwidth than data_in width
CONTAINS_STATE_REG - default value True of type boolif True the state register is present in this component otherwise the stateIn io is used as a value of current sate
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
dataIn - of type hwtLib.commonHwIO.data_mask_last_hs.HwIODataMaskLastRdVld - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - MASTER
- __annotations__ = {}¶
hwtLib.logic.crcComb module¶
- class hwtLib.logic.crcComb.CrcComb(hdlName: str | None = None)[source]¶
Bases:
HwModuleCRC generator, polynomial can be string in usual format or integer (“x^3+x+1” or 0b1011)
- Variables:
~.DATA_WIDTH – width of data in signal
~.POLY – specified CRC polynome, str, int or HBits value
~.POLY_WIDTH – width of POLY
~.REFIN – This is a boolean parameter. If it is FALSE, input bytes are processed with bit 7 being treated as the most significant bit (MSB) and bit 0 being treated as the least significant bit. If this parameter is FALSE, each byte is reflected before being processed.
~.REFOUT – Same as REFIN except for output
~.XOROUT – value to xor result with
- HDL params:
DATA_WIDTH - default value 11 of type int
IN_IS_BIGENDIAN - default value False of type bool
POLY_TY - default value <class ‘hwtLib.logic.crcPoly.CRC_5_USB’> of type type
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
dataIn - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 11bits> - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 5bits> - MASTER
- __annotations__ = {}¶
- classmethod applyCrcXorMatrix(crcMatrix: List[List[List[int]]], inBits: List[RtlSignal], stateBits: List[RtlSignal | HBitsConst], refin: bool) List[source]¶
- static buildCrcXorMatrix(data_width: int, polyBits: List[bool]) List[Tuple[List[bool], List[bool]]][source]¶
- Parameters:
data_width – number of bits in input (excluding bits of signal wit current crc state)
polyBits – list of bits in specified polynome
- Note:
all bits are in format LSB downto MSB
- Returns:
crc_mask contains rows where each row describes which bits should be XORed to get bit of result row is [mask_for_state_reg, mask_for_data]
hwtLib.logic.crcPoly module¶
Library of common CRC configurations
- note:
POLY is the polynome of CRC and specifies which bits should be xored together.
- note:
WIDTH - specifies the width of CRC state/value
- note:
REFIN - If it is True the bits in each byte are reversed before processing.
- note:
REFOUT If it is set to FALSE, the final value in the register is fed into the XOROUT stage directly, otherwise, if this parameter is TRUE, the final register value is reflected first.
- note:
XOROUT This is an WIDTH-bit value. It is XORed to the final register value (after the REFOUT) stage before the value is returned as the official checksum.
- note:
- note:
- class hwtLib.logic.crcPoly.CRC3_ROHC[source]¶
Bases:
CRC_POLYCRC-3/ROHC (Robust header compression rfc3095)
- CHECK = 6¶
- INIT = 7¶
- POLY = 3¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 0¶
- WIDTH = 3¶
- class hwtLib.logic.crcPoly.CRC_1[source]¶
Bases:
CRC_POLYalso known as parity bit
- POLY = 1¶
- WIDTH = 1¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_10[source]¶
Bases:
CRC_POLYUsed in ATM; I.610
- POLY = 563¶
- WIDTH = 10¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_10_CDMA2000[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 985¶
- WIDTH = 10¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_10_GSM[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 373¶
- WIDTH = 10¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_11[source]¶
Bases:
CRC_POLYUsed in FlexRay
- POLY = 901¶
- WIDTH = 11¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_12[source]¶
Bases:
CRC_POLYUsed in telecom systems
- POLY = 2063¶
- WIDTH = 12¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_12_CDMA2000[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 3859¶
- WIDTH = 12¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_12_GSM[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 3377¶
- WIDTH = 12¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_13_BBC[source]¶
Bases:
CRC_POLYUsed in Time signal, Radio teleswitch
- POLY = 7413¶
- WIDTH = 13¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_14_DARC[source]¶
Bases:
CRC_POLYUsed in Data Radio Channel[19]
- POLY = 2053¶
- WIDTH = 14¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_14_GSM[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 8237¶
- WIDTH = 14¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_15_CAN[source]¶
Bases:
CRC_POLY- POLY = 17817¶
- WIDTH = 15¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_15_MPT1327[source]¶
Bases:
CRC_POLY- POLY = 26645¶
- WIDTH = 15¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_ARINC[source]¶
Bases:
CRC_POLYUsed in ACARS applications
- POLY = 41003¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_CCITT[source]¶
Bases:
CRC_POLYUsed in X.25, V.41, HDLC FCS, XMODEM, Bluetooth, PACTOR, SD, DigRF, many others; Also known as CRC_CCITT
- INIT = 65535¶
- POLY = 4129¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_CDMA2000[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 51303¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_Chakravarty[source]¶
Bases:
CRC_POLYUsed in Optimal for payloads ≤64 bits
- POLY = 12053¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_DECT[source]¶
Bases:
CRC_POLYUsed in cordless telephones
- POLY = 1417¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_DNP[source]¶
Bases:
CRC_POLYUsed in DNP, IEC 870, M-Bus
- POLY = 15717¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_IBM[source]¶
Bases:
CRC_POLYUsed in Bisync, Modbus, ANSI X3.28, SIA DC-07, many others; Also known as CRC_16 and CRC_16-ANSI
- POLY = 32773¶
- REFIN = True¶
- REFOUT = True¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_OpenSafety_A[source]¶
Bases:
CRC_POLYUsed in safety fieldbus
- POLY = 22837¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_OpenSafety_B[source]¶
Bases:
CRC_POLYUsed in safety fieldbus
- POLY = 30043¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_Profibus[source]¶
Bases:
CRC_POLYUsed in fieldbus networks
- POLY = 7631¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_T10_DIF[source]¶
Bases:
CRC_POLYUsed in SCSI DIF
- POLY = 35767¶
- WIDTH = 16¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_16_USB[source]¶
Bases:
object- CHECK = 46280¶
- INIT = 65535¶
- POLY = 32773¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 45057¶
- WIDTH = 16¶
- XOROUT = 65535¶
- class hwtLib.logic.crcPoly.CRC_17_CAN[source]¶
Bases:
CRC_POLYUsed in CAN FD
- POLY = 92251¶
- WIDTH = 17¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_21_CAN[source]¶
Bases:
CRC_POLYUsed in CAN FD
- POLY = 1058969¶
- WIDTH = 21¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_24[source]¶
Bases:
CRC_POLYUsed in FlexRay
- POLY = 6122955¶
- WIDTH = 24¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_24_Radix_64[source]¶
Bases:
CRC_POLYUsed in OpenPGP, RTCM104v3
- POLY = 8801531¶
- WIDTH = 24¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_30[source]¶
Bases:
CRC_POLYUsed in CDMA
- POLY = 540064199¶
- WIDTH = 30¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_32[source]¶
Bases:
CRC_POLYUsed in HDLC, ANSI X3.66, ITU-T V.42, Ethernet, Serial ATA, MPEG-2, PKZIP, Gzip, Bzip2, PNG, many others
- INIT = 4294967295¶
- POLY = 79764919¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 3338984827¶
- WIDTH = 32¶
- XOROUT = 4294967295¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_32C[source]¶
Bases:
CRC_POLYUsed in (Castagnoli), iSCSI, SCTP, G.hn payload, SSE4.2, Btrfs, ext4, Ceph
- CHECK = 3808858755¶
- INIT = 4294967295¶
- POLY = 517762881¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 3080238136¶
- WIDTH = 32¶
- XOROUT = 4294967295¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_32K[source]¶
Bases:
CRC_POLYKoopman {1,3,28}
- POLY = 1947962583¶
- WIDTH = 32¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_32K_2[source]¶
Bases:
CRC_POLYKoopman {1,1,30}
- POLY = 844641433¶
- WIDTH = 32¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_32Q[source]¶
Bases:
CRC_POLYUsed in aviation; AIXM
- POLY = 2168537515¶
- WIDTH = 32¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_3_GSM[source]¶
Bases:
CRC_POLYUsed in mobile networks
- INIT = 0¶
- POLY = 3¶
- WIDTH = 3¶
- XOROUT = 7¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_40_GSM[source]¶
Bases:
CRC_POLYUsed in GSM control channel[40][41]
- POLY = 75628553¶
- WIDTH = 40¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_4_ITU[source]¶
Bases:
CRC_POLYG.704
- CHECK = 7¶
- POLY = 3¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 0¶
- WIDTH = 4¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_5_EPC[source]¶
Bases:
CRC_POLYGen 2 RFID EPC-C1G2
- CHECK = 0¶
- POLY = 9¶
- RESIDUE = 0¶
- WIDTH = 5¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_5_ITU[source]¶
Bases:
CRC_POLYG.704
- POLY = 21¶
- WIDTH = 5¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_5_USB[source]¶
Bases:
CRC_POLYUSB token packets
- CHECK = 25¶
- INIT = 31¶
- POLY = 5¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 12¶
- WIDTH = 5¶
- XOROUT = 31¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_64_ECMA[source]¶
Bases:
CRC_POLYUsed in ECMA-182, XZ Utils
- POLY = 4823603603198064275¶
- WIDTH = 64¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_64_ISO[source]¶
Bases:
CRC_POLYUsed in HDLC, Swiss-Prot/TrEMBL; considered weak for hashing
- POLY = 27¶
- WIDTH = 64¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_6_CDMA2000_A[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 39¶
- WIDTH = 6¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_6_CDMA2000_B[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 7¶
- WIDTH = 6¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_6_DARC[source]¶
Bases:
CRC_POLYData Radio Channel
- POLY = 25¶
- WIDTH = 6¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_6_GSM[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 47¶
- WIDTH = 6¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_6_ITU[source]¶
Bases:
CRC_POLYUsed in G.704
- POLY = 3¶
- WIDTH = 6¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_7[source]¶
Bases:
CRC_POLYUsed in telecom systems, G.707,G.832, MMC, SD
- POLY = 9¶
- WIDTH = 7¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_7_MVB[source]¶
Bases:
CRC_POLYUsed in Train Communication Network, IEC 60870-5
- POLY = 101¶
- WIDTH = 7¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8[source]¶
Bases:
CRC_POLYUsed in DVB-S2
- POLY = 213¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_AUTOSAR[source]¶
Bases:
CRC_POLYUsed in automotive integration, OpenSafety
- POLY = 47¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_Bluetooth[source]¶
Bases:
CRC_POLYUsed in wireless connectivity
- POLY = 167¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_CCITT[source]¶
Bases:
CRC_POLYUsed in I.432.1; ATM HEC, ISDN HEC and cell delineation
- CHECK = 244¶
- POLY = 7¶
- RESIDUE = 0¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_DARC[source]¶
Bases:
CRC_POLYUsed in Data Radio Channel
- POLY = 57¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_Dallas_Maxim[source]¶
Bases:
CRC_POLYUsed in 1-Wire bus
- POLY = 49¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_GSM_B[source]¶
Bases:
CRC_POLYUsed in mobile networks
- POLY = 73¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_SAE_J1850[source]¶
Bases:
CRC_POLYUsed in AES3
- POLY = 29¶
- WIDTH = 8¶
- __annotations__ = {}¶
- class hwtLib.logic.crcPoly.CRC_8_WCDMA[source]¶
Bases:
CRC_POLYUsed in mobile networks
- CHECK = 37¶
- INIT = 0¶
- POLY = 155¶
- REFIN = True¶
- REFOUT = True¶
- RESIDUE = 0¶
- WIDTH = 8¶
- __annotations__ = {}¶
hwtLib.logic.crcUtils module¶
hwtLib.logic.crc_test_utils module¶
- class hwtLib.logic.crc_test_utils.NaiveCrcAccumulator(params: CRC_POLY, value: int | None = None)[source]¶
Bases:
objectHolds the intermediate state of the CRC algorithm.
Based on http://www.nightmare.com/~ryb/
- __init__(params: CRC_POLY, value: int | None = None)[source]¶
- Parameters:
value – The initial register value to use. The result previous of a previous CRC calculation, can be used here to continue calculation with more data. If this parameter is
Noneor not given, the register will be initialized with algorithm’s default seed value.
hwtLib.logic.lfsr module¶
- class hwtLib.logic.lfsr.Lfsr(hdlName: str | None = None)[source]¶
Bases:
HwModuleLinear shift feedback register generator, form of hardware pseudorandom generator.
- HDL params:
POLY_WIDTH - default value 8 of type int
POLY - default value 136 of type int
INIT - default value 1 of type int
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - MASTER
- __annotations__ = {}¶
hwtLib.logic.oneHotToBin module¶
- class hwtLib.logic.oneHotToBin.OneHotToBin(hdlName: str | None = None)[source]¶
Bases:
HwModuleConverts one hot signal to binary, bin.vld is high when oneHot != 0
- HDL params:
ONE_HOT_WIDTH - default value 8 of type int
- HDL IO:
oneHot - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 8bits> - SLAVE
bin - of type hwt.hwIOs.std.HwIODataVld - MASTER
- __annotations__ = {}¶
hwtLib.logic.pid module¶
- class hwtLib.logic.pid.PidController(hdlName: str | None = None)[source]¶
Bases:
HwModuleThe PID Control block compares the input to the target and calculates an error. Based on this error, a output value is calculated that should result in a smaller error on the next iteration of the loop, assuming your parameters are tuned properly.
u(k) = u(k-1) + a0*e(k) + a1*y(k) + a2*y(k-1) + a3*y(k-2)
e(k): error in this step (= target value - input) y(k): input in step k ax: PID coeficient
The PID parameter inputs for this equation are slightly different from the traditional K_p, K_i, and K_d.
a0 = K_i * T_s a1 = -K_p - K_d / T_s a2 = K_p + 2K_d/T_s a3 = - K_d / T_s
- HDL params:
DATAIN_WIDTH - default value 16 of type int
DATAOUT_WIDTH - default value 16 of type int
COEF_WIDTH - default value 16 of type int
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
input - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 16bits, signed> - SLAVE
output - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 16bits, signed> - MASTER
target - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 16bits, signed> - SLAVE
coefs - of type hwt.hwIOs.hwIOArray.HwIOArray - SLAVE
- __annotations__ = {}¶