hwtLib.mem package

Submodules

hwtLib.mem.bramPortEndpoint module

class hwtLib.mem.bramPortEndpoint.BramPortEndpoint(structTemplate, intfCls=<class 'hwt.interfaces.std.BramPort_withoutClk'>, shouldEnterFn=None)[source]

Bases: hwtLib.abstract.busEndpoint.BusEndpoint

Delegate transaction from BrapmPort interface to interfaces for fields of specified structure

Attention:interfaces are dynamically generated from names of fields in structure template
__init__(structTemplate, intfCls=<class 'hwt.interfaces.std.BramPort_withoutClk'>, shouldEnterFn=None)[source]
Parameters:
  • structTemplate – instance of HStruct which describes address space of this endpoint
  • intfCls – class of bus interface which should be used
  • shouldEnterFn – function(structField) return (shouldEnter, shouldUse) where shouldEnter is flag that means iterator over this interface should look inside of this actual object and shouldUse flag means that this field should be used (to create interface)
_getAddrStep()
Returns:how many bits is one unit of address (f.e. 8 bits for char * pointer, 36 for 36 bit bram)
_getWordAddrStep()
Returns:size of one word in unit of address
_impl()[source]

implementations

  • implement functionality of design there
  • called after _declr

hwtLib.mem.bramPortSimMemSpaceMaster module

class hwtLib.mem.bramPortSimMemSpaceMaster.BramPortSimMemSpaceMaster(bus, registerMap)[source]

Bases: hwtLib.sim.abstractMemSpaceMaster.AbstractMemSpaceMaster

_read(addr, size, onDone)[source]

Add read transaction to agent of interface :param addr: address value on bus to read froms :param size: size of data to read in bites :param onDone: on read done callback function(sim) -> None

_write(addr, size, data, mask, onDone=None)[source]

Add write transaction to agent of interface

Parameters:
  • addr – address value on bus to write on
  • size – size of data to write in bites
  • data – data to write on bus
  • onDone – on write done callback function(sim) -> None
_writeAddr(addrChannel, addr, size)[source]

hwtLib.mem.cam module

class hwtLib.mem.cam.Cam[source]

Bases: hwt.synthesizer.unit.Unit

Content addressable memory

Simple combinational version

MATCH_LATENCY = 1

_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)
matchHandler(mem)[source]
writeHandler(mem)[source]

hwtLib.mem.clkSynchronizer module

class hwtLib.mem.clkSynchronizer.ClkSynchronizer[source]

Bases: hwt.synthesizer.unit.Unit

Signal synchronization between two clock domains http://www.sunburst-design.com/papers/CummingsSNUG2008Boston_CDC.pdf

_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.mem.cuckooHashTable module

class hwtLib.mem.cuckooHashTable.CInsertIntf(masterDir=<DIRECTION.OUT: 1>, asArraySize=None, loadConfig=True)[source]

Bases: hwt.interfaces.std.HandshakeSync

_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
_initSimAgent()[source]
class hwtLib.mem.cuckooHashTable.CInsertIntfAgent(intf)[source]

Bases: hwt.interfaces.agents.handshaked.HandshakedAgent

Agent for CInsertIntf interface

__init__(intf)[source]

Initialize self. See help(type(self)) for accurate signature.

doRead(s)[source]

extract data from interface

doWrite(s, data)[source]

write data to interface

class hwtLib.mem.cuckooHashTable.CuckooHashTable(polynomials=[1947962583, 517762881])[source]

Bases: hwtLib.mem.hashTableCore.HashTableCore

Cuckoo hash uses more tables with different hash functions

Lookup is performed in all tables at once and if item is found in any table item is found otherwise item is not in tables. lookup time: O(1)

Insert has to first lookup if item is in any table. If there is such a item it is replaced. If there is any empty element item is stored there. If there is a valid item under this key in all tables. One is selected and it is replaced by current item. Insert process then repeats with this item.

Inserting into table does not have to be successful and in this case, fsm ends up in infinite loop and it will be reinserting items.

_images/aafig-b839187d71b78fc51c27d7343b6960a091736db6.gif
__init__(polynomials=[1947962583, 517762881])[source]
Parameters:polynomials – list of polynomials for crc hashers used in tables for each item in this list table will be instantiated
_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
cleanUpAddrIterator(en)[source]
insertAddrSelect(targetOH, state, cleanAddr)[source]
insetOfTablesDriver(state, insertTargetOH, insertIndex, stash, isExternLookup)[source]
Parameters:
  • state – state register of main fsm
  • insertTargetOH – index of table where insert should be performed, one hot encoding
  • insertIndex – address for table where item should be placed
  • stash – stash register
  • isExternLookup – flag for lookup initialized by external “lookup” interface
lookupOfTablesDriver(state, tableKey)[source]
lookupResDriver(state, lookupOrigin, lookupAck, insertFoundOH)[source]

If lookup request comes from external interface “lookup” propagate results from tables to “lookupRes”.

lookupResOfTablesDriver(resRead, resAck)[source]
stashLoad(isIdle, stash, lookupOrigin_out)[source]
class hwtLib.mem.cuckooHashTable.ORIGIN_TYPE[source]

Bases: object

DELETE = 2
INSERT = 0
LOOKUP = 1

hwtLib.mem.fifo module

class hwtLib.mem.fifo.Fifo[source]

Bases: hwt.synthesizer.unit.Unit

Generic fifo instance usually mapped to BRAM

Variables:
  • EXPORT_SIZE – parameter, if true “size” signal will be exported
  • size – optional signal with count of items stored in this fifo
  • EXPORT_SPACE – parameter, if true “space” signal is exported
  • space – optional signal with count of items which can be added to this fifo
_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.mem.fifoAsync module

class hwtLib.mem.fifoAsync.FifoAsync[source]

Bases: hwtLib.mem.fifo.Fifo

Asynchronous fifo using BRAM memory, based on: http://www.asic-world.com/examples/vhdl/asyn_fifo.html

_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.mem.hashTableCore module

class hwtLib.mem.hashTableCore.HashTableCore(polynome)[source]

Bases: hwt.synthesizer.unit.Unit

Generic hash table, in block RAM there is a input key which is hashed ad this has is used as an index into memory item on this place is checked and returned on “lookupRes” interface (item does have to be found, see “found” flag in LookupResultIntf)

memory is an array of items in format

struct item {
    bool vldFlag;
    data_t data;
    key_t key;
};
Variables:
  • ITEMS_CNT – number of items in memory of hash table
  • KEY_WIDTH – width of the key used by hash table
  • DATA_WIDTH – width of data, can be zero and then no data interface is instantiated
  • LOOKUP_ID_WIDTH – width of id signal for lookup (tag used only by parent component to mark this lookup for later result processing, can be 0)
  • LOOKUP_HASH – flag if this interface should have hash signal
  • LOOKUP_KEY – flag if this interface should have key signal
  • POLYNOME – polynome for crc hash used in this table
_images/aafig-d7d9ac883d06df0b118a81a8fddcfae99e4ffe6a.gif
__init__(polynome)[source]

Initialize self. See help(type(self)) for accurate signature.

_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
insertLogic(ramW)[source]
lookupLogic(ramR)[source]
parseItem(sig)[source]

Parse data stored in hash table

hwtLib.mem.hashTable_intf module

class hwtLib.mem.hashTable_intf.InsertIntf(masterDir=<DIRECTION.OUT: 1>, asArraySize=None, loadConfig=True)[source]

Bases: hwt.interfaces.std.HandshakeSync

_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
_initSimAgent()[source]
class hwtLib.mem.hashTable_intf.InsertIntfAgent(intf)[source]

Bases: hwt.interfaces.agents.handshaked.HandshakedAgent

Simulation agent for .InsertIntf interface

data format:
  • if interface has data signal, data format is tuple (hash, key, data, vldFlag)
  • if interface does not have data signal, data format is tuple (hash, key, vldFlag)
__init__(intf)[source]

Initialize self. See help(type(self)) for accurate signature.

doRead(s)[source]

extract data from interface

doWrite(s, data)[source]

write data to interface

class hwtLib.mem.hashTable_intf.LookupKeyIntf(masterDir=<DIRECTION.OUT: 1>, asArraySize=None, loadConfig=True)[source]

Bases: hwt.interfaces.std.HandshakeSync

_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
_initSimAgent()[source]
class hwtLib.mem.hashTable_intf.LookupKeyIntfAgent(intf)[source]

Bases: hwt.interfaces.agents.handshaked.HandshakedAgent

Simulation agent for LookupKeyIntf interface

__init__(intf)[source]

Initialize self. See help(type(self)) for accurate signature.

doRead(s)[source]

extract data from interface

doWrite(s, data)[source]

write data to interface

class hwtLib.mem.hashTable_intf.LookupResultIntf(masterDir=<DIRECTION.OUT: 1>, asArraySize=None, loadConfig=True)[source]

Bases: hwt.interfaces.std.Handshaked

Interface for result of lookup in hash table

Variables:
  • HASH_WIDTH – width of the hash used by hash table
  • KEY_WIDTH – width of the key used by hash table
  • LOOKUP_HASH – flag if this interface should have hash signal
  • LOOKUP_KEY – flag if this interface should have hash signal
  • hash – hash for this key (= index in this table)
  • key – original key which was searched for
  • data – data under this key
  • occupied – flag which tells if there is an valid item under this key
_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
_initSimAgent()[source]
class hwtLib.mem.hashTable_intf.LookupResultIntfAgent(intf)[source]

Bases: hwt.interfaces.agents.handshaked.HandshakedAgent

Simulation agent for .LookupResultIntf data is stored in .data data format is tuple (hash, key, data, found) but some items can be missing depending on configuration of interface

__init__(intf)[source]

Initialize self. See help(type(self)) for accurate signature.

doRead(s)[source]

extract data from interface

doWrite(s, data)[source]

write data to interface

hwtLib.mem.lutRam module

class hwtLib.mem.lutRam.RAM64X1S

Bases: hwt.synthesizer.unit.Unit

_config()
_declr()
_impl()
static _serializeDecision(parentUnit, obj, isDeclaration, priv)

Always decide not to serialize obj

Parameters:priv – private data for this function first unit of this class
Returns:tuple (do serialize this object, next priv)
hwtLib.mem.lutRam.mkLutRamCls(DATA_WIDTH)[source]

Lut ram generator hdl code will be excluded from serialization because we expect vendor library to contains it

hwtLib.mem.ram module

class hwtLib.mem.ram.RamSingleClock[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)
_sportPort(index) → None[source]
connectPort(port: hwt.interfaces.std.BramPort_withoutClk, mem: hwt.synthesizer.rtlLevel.rtlSignal.RtlSignal)[source]
static genPortName(index) → str[source]
getPortByIndx(index) → hwt.interfaces.std.BramPort_withoutClk[source]
class hwtLib.mem.ram.Ram_dp[source]

Bases: hwtLib.mem.ram.Ram_sp

_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.mem.ram.Ram_sp[source]

Bases: hwt.synthesizer.unit.Unit

Write first variant

_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)
connectPort(port, mem)[source]

Module contents