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
build_CRC_XOR(inputBits, xorMatrix)[source]
parsePoly(POLY_WIDTH)[source]
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 Value: 0x0

_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
parsePoly()[source]

hwtLib.logic.crcPoly module

hwtLib.logic.crcUtils module

hwtLib.logic.crcUtils.buildCrcMatrix(coefs, polyWidth, dataWidth)[source]
hwtLib.logic.crcUtils.buildCrcMatrix_dataMatrix(coefs, polyWidth, dataWidth)[source]

generate LSFR reg, matrix[MxN]

Parameters:
  • coefs – Polynomial coefficients
  • polyWidth – number of bits of Polynomial
  • dataWidth – number of bits of data signal
hwtLib.logic.crcUtils.buildCrcMatrix_reg0Matrix(coefs, polyWidth, dataWidth)[source]
hwtLib.logic.crcUtils.crc_serial_shift(num_bits_to_shift, polySize, coefs, lfsr_cur, dataWidth, data_cur)[source]
Parameters:
  • polySize – bit size of polynomial
  • coefs – array of 1,0 which representing the polynomial
  • lfsr_cur – array with single 1 flag which specifies for which bit we are currently counting the crc
Pram dataWidth:

bit widtho of input signal to this crc round

Pram data_cur:

ray with single 1 flag which specifies for which bit we are currently counting the crc

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:

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

Module contents