hwtLib.logic package

Submodules

hwtLib.logic.binToOneHot module

class hwtLib.logic.binToOneHot.BinToOneHot[source]

Bases: hwt.synthesizer.unit.Unit

_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
static _serializeDecision(parentUnit, obj, isDeclaration, priv)

Decide to serialize only objs with uniq parameters and class

Parameters:priv – private data for this function ({frozen_params: obj})
Returns:tuple (do serialize this object, next priv)
class hwtLib.logic.binToOneHot.BinToOneHotTC(methodName='runTest')[source]

Bases: hwt.simulator.simTestCase.SimTestCase

test_basic()[source]

hwtLib.logic.bitonicSorter module

class hwtLib.logic.bitonicSorter.BitonicSorter(cmpFn=<function BitonicSorter.<lambda>>)[source]

Bases: hwt.synthesizer.unit.Unit

__init__(cmpFn=<function BitonicSorter.<lambda>>)[source]
Parameters:cmpFn – function (item0, item1) if returns true, items are not swaped
_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
bitonic_compare(cmpFn, x, layer, offset)[source]
bitonic_merge(cmpFn, x, layer, offset)[source]
bitonic_sort(cmpFn, x, layer=0, offset=0)[source]
class hwtLib.logic.bitonicSorter.BitonicSorterTC(methodName='runTest')[source]

Bases: hwt.simulator.simTestCase.SimTestCase

SIM_TIME = 40000
createUnit()[source]
getOutputs()[source]
setInputs(values)[source]
test_reversed()[source]
test_sorted()[source]

hwtLib.logic.cntrGray module

class hwtLib.logic.cntrGray.GrayCntr[source]

Bases: hwt.synthesizer.unit.Unit

_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
static _serializeDecision(parentUnit, obj, isDeclaration, priv)

Decide to serialize only objs with uniq parameters and class

Parameters:priv – private data for this function ({frozen_params: obj})
Returns:tuple (do serialize this object, next priv)
class hwtLib.logic.cntrGray.GrayCntrTC(methodName='runTest')[source]

Bases: hwt.simulator.simTestCase.SimTestCase

test_count()[source]

hwtLib.logic.crc module

class hwtLib.logic.crc.Crc[source]

Bases: hwt.synthesizer.unit.Unit

Crc generator for any crc polynom can be string in usual format or integer f.e.”x^3+x+1” or 0b1011

_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
setConfig(crcConfigCls)[source]

Apply configuration from CRC configuration class

wrapWithName(sig, name)[source]

hwtLib.logic.crcComb module

class hwtLib.logic.crcComb.CrcComb[source]

Bases: hwt.synthesizer.unit.Unit

CRC generator polynomial can be string in usual format or integer (f.e.”x^3+x+1” or 0b1011)

Attention:

Input not reflected, Result not reflected, Initial Value: 0x0, Final Xor is not applied

Variables:
  • DATA_WIDTH – width of data in signal
  • POLY – specified CRC polynome, str, int or Bits 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
_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
classmethod applyCrcXorMatrix(crcMatrix: List, inBits: List, stateBits: List, 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)

:param polyBits :note: all bits are in format [LSB:MSB]

Returns:crc_mask contains rows where each row describes which bits should be XORed to get bit of resut row is [mask_for_state_reg, mask_for_data]
static parsePoly(POLY, POLY_WIDTH) → List[int][source]
Returns:list of bits from polynome, extra MSB 1 is added len of this list is POLY_WIDTH + 1
setConfig(crcConfigCls)[source]

Apply configuration from CRC configuration class

hwtLib.logic.crcComb.extendToSize(data, items, pad=0)[source]
hwtLib.logic.crcComb.reversedBitsInBytes(bitArray)[source]
hwtLib.logic.crcComb.reversedEndianity(bitArray)[source]

hwtLib.logic.crcPoly module

class hwtLib.logic.crcPoly.CRC_1[source]

Bases: object

POLY = 1
REFIN = False
REFOUT = False
WIDTH = 1
class hwtLib.logic.crcPoly.CRC_10[source]

Bases: object

POLY = 563
WIDTH = 10
class hwtLib.logic.crcPoly.CRC_10_CDMA2000[source]

Bases: object

POLY = 985
WIDTH = 10
class hwtLib.logic.crcPoly.CRC_10_GSM[source]

Bases: object

POLY = 373
WIDTH = 10
class hwtLib.logic.crcPoly.CRC_11[source]

Bases: object

POLY = 901
WIDTH = 11
class hwtLib.logic.crcPoly.CRC_12[source]

Bases: object

POLY = 2063
WIDTH = 12
class hwtLib.logic.crcPoly.CRC_12_CDMA2000[source]

Bases: object

POLY = 3859
WIDTH = 12
class hwtLib.logic.crcPoly.CRC_12_GSM[source]

Bases: object

POLY = 3377
WIDTH = 12
class hwtLib.logic.crcPoly.CRC_13_BBC[source]

Bases: object

POLY = 7413
WIDTH = 13
class hwtLib.logic.crcPoly.CRC_14_DARC[source]

Bases: object

POLY = 2053
WIDTH = 14
class hwtLib.logic.crcPoly.CRC_14_GSM[source]

Bases: object

POLY = 8237
WIDTH = 14
class hwtLib.logic.crcPoly.CRC_15_CAN[source]

Bases: object

POLY = 17817
WIDTH = 15
class hwtLib.logic.crcPoly.CRC_15_MPT1327[source]

Bases: object

POLY = 26645
WIDTH = 15
class hwtLib.logic.crcPoly.CRC_16_ARINC[source]

Bases: object

POLY = 41003
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_CCITT[source]

Bases: object

INIT = 65535
POLY = 4129
REFIN = False
REFOUT = False
WIDTH = 16
XOROUT = 0
class hwtLib.logic.crcPoly.CRC_16_CDMA2000[source]

Bases: object

POLY = 51303
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_Chakravarty[source]

Bases: object

POLY = 12053
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_DECT[source]

Bases: object

POLY = 1417
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_DNP[source]

Bases: object

POLY = 15717
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_IBM[source]

Bases: object

INIT = 0
POLY = 32773
REFIN = True
REFOUT = True
WIDTH = 16
XOROUT = 0
class hwtLib.logic.crcPoly.CRC_16_OpenSafety_A[source]

Bases: object

POLY = 22837
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_OpenSafety_B[source]

Bases: object

POLY = 30043
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_Profibus[source]

Bases: object

POLY = 7631
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_16_T10_DIF[source]

Bases: object

POLY = 35767
WIDTH = 16
class hwtLib.logic.crcPoly.CRC_17_CAN[source]

Bases: object

POLY = 92251
WIDTH = 17
class hwtLib.logic.crcPoly.CRC_21_CAN[source]

Bases: object

POLY = 1058969
WIDTH = 21
class hwtLib.logic.crcPoly.CRC_24[source]

Bases: object

POLY = 6122955
WIDTH = 24
class hwtLib.logic.crcPoly.CRC_24_Radix_64[source]

Bases: object

POLY = 8801531
WIDTH = 24
class hwtLib.logic.crcPoly.CRC_30[source]

Bases: object

POLY = 540064199
WIDTH = 30
class hwtLib.logic.crcPoly.CRC_32[source]

Bases: object

INIT = 4294967295
POLY = 79764919
REFIN = True
REFOUT = True
RESIDUE = 3338984827
WIDTH = 32
XOROUT = 4294967295
class hwtLib.logic.crcPoly.CRC_32C[source]

Bases: object

CHECK = 3808858755
INIT = 4294967295
POLY = 517762881
REFIN = True
REFOUT = True
RESIDUE = 3080238136
WIDTH = 32
XOROUT = 4294967295
class hwtLib.logic.crcPoly.CRC_32K[source]

Bases: object

POLY = 1947962583
WIDTH = 32
class hwtLib.logic.crcPoly.CRC_32K_2[source]

Bases: object

POLY = 844641433
WIDTH = 32
class hwtLib.logic.crcPoly.CRC_32Q[source]

Bases: object

POLY = 2168537515
WIDTH = 32
class hwtLib.logic.crcPoly.CRC_3_GSM[source]

Bases: object

INIT = 0
POLY = 3
REFIN = False
REFOUT = False
WIDTH = 3
class hwtLib.logic.crcPoly.CRC_40_GSM[source]

Bases: object

POLY = 75628553
WIDTH = 40
class hwtLib.logic.crcPoly.CRC_4_ITU[source]

Bases: object

POLY = 3
WIDTH = 4
class hwtLib.logic.crcPoly.CRC_5_EPC[source]

Bases: object

POLY = 9
WIDTH = 5
class hwtLib.logic.crcPoly.CRC_5_ITU[source]

Bases: object

POLY = 21
WIDTH = 5
class hwtLib.logic.crcPoly.CRC_5_USB[source]

Bases: object

CHECK = 25
INIT = 31
POLY = 5
REFIN = True
REFOUT = True
RESIDUE = 12
WIDTH = 5
XOROUT = 31
class hwtLib.logic.crcPoly.CRC_64_ECMA[source]

Bases: object

POLY = 4823603603198064275
WIDTH = 64
class hwtLib.logic.crcPoly.CRC_64_ISO[source]

Bases: object

POLY = 27
WIDTH = 64
class hwtLib.logic.crcPoly.CRC_6_CDMA2000_A[source]

Bases: object

POLY = 39
WIDTH = 6
class hwtLib.logic.crcPoly.CRC_6_CDMA2000_B[source]

Bases: object

POLY = 7
WIDTH = 6
class hwtLib.logic.crcPoly.CRC_6_DARC[source]

Bases: object

POLY = 25
WIDTH = 6
class hwtLib.logic.crcPoly.CRC_6_GSM[source]

Bases: object

POLY = 47
WIDTH = 6
class hwtLib.logic.crcPoly.CRC_6_ITU[source]

Bases: object

POLY = 3
WIDTH = 6
class hwtLib.logic.crcPoly.CRC_7[source]

Bases: object

POLY = 9
WIDTH = 7
class hwtLib.logic.crcPoly.CRC_7_MVB[source]

Bases: object

POLY = 101
WIDTH = 7
class hwtLib.logic.crcPoly.CRC_8[source]

Bases: object

POLY = 213
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_AUTOSAR[source]

Bases: object

POLY = 47
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_Bluetooth[source]

Bases: object

POLY = 167
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_CCITT[source]

Bases: object

CHECK = 244
INIT = 0
POLY = 7
REFIN = False
REFOUT = False
RESIDUE = 0
WIDTH = 8
XOROUT = 0
class hwtLib.logic.crcPoly.CRC_8_DARC[source]

Bases: object

POLY = 57
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_Dallas_Maxim[source]

Bases: object

POLY = 49
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_GSM_B[source]

Bases: object

POLY = 73
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_SAE_J1850[source]

Bases: object

POLY = 29
WIDTH = 8
class hwtLib.logic.crcPoly.CRC_8_WCDMA[source]

Bases: object

CHECK = 37
INIT = 0
POLY = 155
REFIN = True
REFOUT = True
RESIDUE = 0
WIDTH = 8
XOROUT = 0

hwtLib.logic.crcUtils module

hwtLib.logic.crcUtils.parsePolyStr(polyStr, width)[source]
hwtLib.logic.crcUtils.parsePolyStr_parse_n(string)[source]

Parse the number part of a polynomial string term

hwtLib.logic.crcUtils.parsePolyStr_parse_p(string)[source]

Parse the power part of a polynomial string term

hwtLib.logic.lsfr module

class hwtLib.logic.lsfr.Lsfr[source]

Bases: hwt.synthesizer.unit.Unit

Linear shift feedback register, form of hardware pseudorandom generator

_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
class hwtLib.logic.lsfr.LsfrTC(methodName='runTest')[source]

Bases: hwt.simulator.simTestCase.SimTestCase

test_simple()[source]

hwtLib.logic.oneHotToBin module

class hwtLib.logic.oneHotToBin.OneHotToBin[source]

Bases: hwt.synthesizer.unit.Unit

Converts one hot signal to binary, bin.vld is high when oneHot != 0

_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr
static _serializeDecision(parentUnit, obj, isDeclaration, priv)

Decide to serialize only objs with uniq parameters and class

Parameters:priv – private data for this function ({frozen_params: obj})
Returns:tuple (do serialize this object, next priv)
hwtLib.logic.oneHotToBin.oneHotToBin(parent, signals, resName='oneHotToBin')[source]

hwtLib.logic.pid module

class hwtLib.logic.pid.PidController[source]

Bases: hwt.synthesizer.unit.Unit

The 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

Note:You can obtain coeficiet f.e. by Ziegler-Nichols method.
_config()[source]

Configure object parameters

  • setup all parameters on this object, use Param class instances to allow use of parameter inheritance
  • called in __init__ of class
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr

hwtLib.logic.segment7 module

class hwtLib.logic.segment7.Segment7[source]

Bases: hwt.synthesizer.unit.Unit

7-segment display decoder

Note:led in display becomes active when output = 0

Display pin connection on image below.

-------------
|     0     |
-------------
| 5 |   | 1 |
-------------
|     6     |
-------------
| 4 |   | 2 |
-------------
|     3     |
-------------
_declr()[source]

declarations

  • do all declarations of externally accessible objects there (Interfaces)
  • _declr method is called after _config
  • if this object is Unit all interfaces are threaten as externally accessible interfaces if this object is Interface all subinterfaces are loaded
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr