hwtLib.mem package¶
A package dedicated to a memory related components, interfaces and utilities.
Subpackages¶
Submodules¶
hwtLib.mem.bramPortEndpoint module¶
- class hwtLib.mem.bramPortEndpoint.BramPortEndpoint(structTemplate, hwIOCls=<class 'hwt.hwIOs.std.HwIOBramPort_noClk'>, shouldEnterFn=None)[source]¶
Bases:
BusEndpointDelegate transaction from BrapmPort interface to interfaces for fields of specified structure.
- HDL params:
ADDR_WIDTH - default value 32 of type int
DATA_WIDTH - default value 32 of type int
HAS_R - default value True of type bool
HAS_W - default value True of type bool
HAS_BE - default value False of type bool
- 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
bus - of type hwt.hwIOs.std.HwIOBramPort_noClk - SLAVE
decoded - of type hwt.hwIOs.hwIOStruct.HwIOStruct with dtype=struct { <HBits, 32bits, unsigned> reg0 <HBits, 32bits, unsigned> reg1 <HBits, 32bits, unsigned>[1024] segment0 <HBits, 32bits, unsigned>[1024] segment1 <HBits, 32bits, unsigned>[1028] nonAligned0 } - MASTER
- __annotations__ = {}¶
- __init__(structTemplate, hwIOCls=<class 'hwt.hwIOs.std.HwIOBramPort_noClk'>, shouldEnterFn=None)[source]¶
- Parameters:
structTemplate – instance of HStruct which describes address space of this endpoint
hwIOCls – class of bus interface which should be used
shouldEnterFn – function(root_t, structFieldPath) 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 module of address (e.g. 8 bits for char * pointer, 36 for 36 bit bram)
- _getWordAddrStep()¶
- Returns:
size of one word in module of address
hwtLib.mem.bramPortSimMemSpaceMaster module¶
- class hwtLib.mem.bramPortSimMemSpaceMaster.BramPortSimMemSpaceMaster(bus, registerMap)[source]¶
Bases:
AbstractMemSpaceMasterController of BramPort simulation agent which keeps track of transactions and allows struct like data access
- __annotations__ = {}¶
hwtLib.mem.cam module¶
- class hwtLib.mem.cam.Cam(hdlName: str | None = None)[source]¶
Bases:
HwModuleContent addressable memory. MATCH_LATENCY = 1
- HDL params:
KEY_WIDTH - default value 15 of type int
ITEMS - default value 32 of type int
USE_VLD_BIT - default value True of type boolif true the validity bit is a part of the CAM record
- 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
match - of type hwt.hwIOs.std.HwIODataRdVld - SLAVE
out - of type hwt.hwIOs.std.HwIODataRdVld - MASTER
write - of type hwtLib.commonHwIO.addr_data.HwIOAddrDataVldRdVld - SLAVE
- __annotations__ = {}¶
- class hwtLib.mem.cam.CamMultiPort(hdlName: str | None = None)[source]¶
Bases:
CamA variant of
Camwith multiple ports for lookup- HDL params:
KEY_WIDTH - default value 15 of type int
ITEMS - default value 32 of type int
USE_VLD_BIT - default value True of type bool
MATCH_PORT_CNT - default value 2 of type intnumber of CAM ports for matching, if None there is only as single port otherwise there is an array of such a ports of specified size
- 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
match - of type hwt.hwIOs.hwIOArray.HwIOArray - SLAVE
out - of type hwt.hwIOs.hwIOArray.HwIOArray - MASTER
write - of type hwtLib.commonHwIO.addr_data.HwIOAddrDataVldRdVld - SLAVE
- __annotations__ = {}¶
hwtLib.mem.cuckooHashTablWithRam module¶
- class hwtLib.mem.cuckooHashTablWithRam.CuckooHashTableWithRam(polynomials)[source]¶
Bases:
CuckooHashTableA cuckoo hash table core with integrated memory
- HDL params:
TABLE_SIZE - default value 32 of type int
DATA_WIDTH - default value 32 of type int
KEY_WIDTH - default value 8 of type int
LOOKUP_KEY - default value False of type bool
TABLE_CNT - default value 2 of type int
MAX_LOOKUP_OVERLAP - default value 16 of type int
MAX_REINSERT - default value 15 of type int
POLYNOMIALS - default value (<class ‘hwtLib.logic.crcPoly.CRC_32’>, <class ‘hwtLib.logic.crcPoly.CRC_32C’>) of type tuple
- 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
insert - of type hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsert - SLAVE
insertRes - of type hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsertRes - MASTER
lookup - of type hwtLib.mem.hashTable_intf.HwIOLookupKey - SLAVE
lookupRes - of type hwtLib.mem.hashTable_intf.HwIOLookupResult - MASTER
delete - of type hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsert - SLAVE
clean - of type hwt.hwIOs.std.HwIORdVldSync - SLAVE
- HDL components:
table_cores_0 - of type hwtLib.mem.hashTableCoreWithRam.HashTableCoreWithRam
table_cores_1 - of type hwtLib.mem.hashTableCoreWithRam.HashTableCoreWithRam
gen_lookupRes_reg_0 - of type hwtLib.handshaked.reg.HandshakedReg
gen_lookupRes_reg_1 - of type hwtLib.handshaked.reg.HandshakedReg
- __annotations__ = {}¶
hwtLib.mem.cuckooHashTable module¶
- class hwtLib.mem.cuckooHashTable.CuckooHashTable[source]¶
Bases:
HashTableCoreCuckoo hash uses more tables with different hash functions
Lookup is performed in all tables at once and if item is found in any table. The 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 any table contains invalid item. The item is stored there and insert operation is complete. If there was a valid item under this key in all tables. One is selected and it is swapped with current item. Insert process then repeats with this item. Until some invalid item (empty slot) is found.
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 for ever. insert time: O(inf)
- HDL params:
TABLE_SIZE - default value 32 of type int
DATA_WIDTH - default value 32 of type int
KEY_WIDTH - default value 8 of type int
LOOKUP_KEY - default value False of type bool
TABLE_CNT - default value 2 of type int
MAX_LOOKUP_OVERLAP - default value 16 of type int
MAX_REINSERT - default value 15 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
insert - of type hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsert - SLAVE
insertRes - of type hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsertRes - MASTER
lookup - of type hwtLib.mem.hashTable_intf.HwIOLookupKey - SLAVE
lookupRes - of type hwtLib.mem.hashTable_intf.HwIOLookupResult - MASTER
delete - of type hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsert - SLAVE
clean - of type hwt.hwIOs.std.HwIORdVldSync - SLAVE
tables - of type hwt.hwIOs.hwIOArray.HwIOArray - MASTER
- __annotations__ = {}¶
- configure_tables(tables: List[HashTableCore])[source]¶
share the configuration with the table engines
- lookupRes_driver(state: RtlSignal, lookupFoundOH: RtlSignal)[source]¶
If lookup request comes from external interface “lookup” propagate results from tables to “lookupRes”.
- stash_load(isIdle, lookupResNext, insertTargetOH, stash, lookup_not_in_progress, another_lookup_possible)[source]¶
load a stash register from lookup/insert/delete interface
- tables_insert_driver(state: RtlSignal, insertTargetOH: RtlSignal, insertIndex: RtlSignal, stash: RtlSignal)[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 with data for insert/lookup/delete from table
hwtLib.mem.cuckooHashTable_intf module¶
- class hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsert(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIORdVldSyncCuckoo hash insert interface
- __annotations__ = {}¶
- class hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsertAgent(sim, hwIO)[source]¶
Bases:
HwIODataRdVldAgentAgent for HwIOCuckooInsert interface
- __annotations__ = {}¶
- class hwtLib.mem.cuckooHashTable_intf.HwIOCuckooInsertRes(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIOCuckooInsertAn interface with an result of insert operation.
- Variables:
pop – signal if 1 the key and data on this interface contains the item which had to be removed during insert because the insertion limit was exceeded
- __annotations__ = {}¶
hwtLib.mem.fifo module¶
- class hwtLib.mem.fifo.Fifo(hdlName: str | None = None)[source]¶
Bases:
HwModuleGeneric FIFO usually mapped to BRAM. :note: 1clk to write, 1clk to read
- 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
- HDL params:
DATA_WIDTH - default value 8 of type int
DEPTH - default value 16 of type int
EXPORT_SIZE - default value True of type bool
EXPORT_SPACE - default value True of type bool
INIT_DATA - default value (1, 2, 3) of type tuple
INIT_DATA_FIRST_WORD - 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
dataIn - of type hwt.hwIOs.std.HwIOFifoWriter - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOFifoReader - MASTER
size - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 5bits, unsigned> - MASTER
space - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 5bits, unsigned> - MASTER
- __annotations__ = {}¶
- constructFifoSizeLogic(fifo_read: HBitsRtlSignal, fifo_write: HBitsRtlSignal)[source]¶
- constructFifoSpaceLogic(fifo_read: HBitsRtlSignal, fifo_write: HBitsRtlSignal)[source]¶
hwtLib.mem.fifoArray module¶
- class hwtLib.mem.fifoArray.FifoArray(hdlName: str | None = None)[source]¶
Bases:
HwModuleThis component is an array of list nodes, which can be used to emulate multiple FIFOs. The memory is shared and the number of lists stored in this array is limited only by memory.
Corresponds to data structure:
// note that in implementation each part of struct item is stored in separate array struct item { value_t value; item * next; bool valid; bool last; }; item items[ITEMS];
- HDL params:
ITEMS - default value 4 of type int
DATA_WIDTH - default value 8 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
insert - of type hwtLib.mem.fifoArray.FifoArrayInsertInterface - SLAVE
pop - of type hwtLib.mem.fifoArray.FifoArrayPopInterface - MASTER
- __annotations__ = {}¶
- class hwtLib.mem.fifoArray.FifoArrayInsertInterface(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIORdVldSyncBiDirectionalData- Variables:
~.append – if append = 1 the item is appended to last list item specified using “addr” else new list is created and “addr” value is ignored
~.addr – an address with potential end of the list
~.data – data to store in next list node
~.addr_ret – an address where the item was inserted to
- HDL params:
ADDR_WIDTH - default value 32 of type int
DATA_WIDTH - default value 32 of type int
- HDL IO:
addr - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
append - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
data - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
addr_ret - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN (Master=IN)
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
- __annotations__ = {}¶
- class hwtLib.mem.fifoArray.FifoArrayInsertInterfaceAgent(sim, hwIO)[source]¶
Bases:
HwIORdVldSyncBiDirectionalDataAgentSimulation agent for
FifoArrayInsertInterfaceinterface- __annotations__ = {}¶
- class hwtLib.mem.fifoArray.FifoArrayPopInterface(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIOAddrInDataOutRdVld- Variables:
~.addr – the address of the list head to read from:
~.data – the return data which was read
~.last – flag which tell if this node was last in this list and thus this list is now empty and deallocated
~.addr_next – address on a next item in this FIFO
- HDL params:
ADDR_WIDTH - default value 32 of type int
DATA_WIDTH - default value 32 of type int
- HDL IO:
addr - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN (Master=IN)
data - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
last - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
addr_next - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.fifoArray.FifoArrayPopInterfaceAgent(sim, hwIO)[source]¶
Bases:
HwIOAddrInDataOutRdVldAgentSimulation agent for
FifoArrayPopInterfaceAgentinterface- __annotations__ = {}¶
hwtLib.mem.fifoAsync module¶
- class hwtLib.mem.fifoAsync.FifoAsync(hdlName: str | None = None)[source]¶
Bases:
FifoAsynchronous FIFO using BRAM/LUT memory, based on: * https://github.com/ZipCPU/website/blob/master/examples/afifo.v * https://github.com/alexforencich/verilog-axis/blob/master/rtl/axis_async_fifo.v
- HDL params:
DATA_WIDTH - default value 64 of type int
DEPTH - default value 4 of type int
EXPORT_SIZE - default value False of type bool
EXPORT_SPACE - default value False of type bool
INIT_DATA - default value () of type tuple
INIT_DATA_FIRST_WORD - default value <class ‘hwt.constants.NOT_SPECIFIED’> of type type
IN_FREQ - default value 100000000 of type int
OUT_FREQ - default value 100000000 of type int
- HDL IO:
dataIn_clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
dataOut_clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
dataIn_rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
dataIn - of type hwt.hwIOs.std.HwIOFifoWriter - SLAVE
dataOut_rst_n - of type hwt.hwIOs.std.HwIORst_n with dtype=<HBits, 1bit, n> - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOFifoReader - MASTER
- __annotations__ = {}¶
hwtLib.mem.fifoCopy module¶
- class hwtLib.mem.fifoCopy.FifoCopy(hdlName: str | None = None)[source]¶
Bases:
FifoFifo with an extra signals to control replay of lastly stored data
- HDL params:
DATA_WIDTH - default value 8 of type int
DEPTH - default value 16 of type int
EXPORT_SIZE - default value False of type bool
EXPORT_SPACE - default value False of type bool
INIT_DATA - default value () of type tuple
INIT_DATA_FIRST_WORD - default value <class ‘hwt.constants.NOT_SPECIFIED’> 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.HwIOFifoWriter - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOFifoReader - MASTER
dataOut_copy_frame - of type hwt.hwIOs.std.HwIODataVld - SLAVE The channel which drives when to capture start of the frame and when to start relaying previously stored frame from the marked start
- __annotations__ = {}¶
hwtLib.mem.fifoDrop module¶
- class hwtLib.mem.fifoDrop.FifoDrop(hdlName: str | None = None)[source]¶
Bases:
FifoFifo with an extra signals for writter which allows to commit or discard data chung writen in to fifo.
- HDL params:
DATA_WIDTH - default value 8 of type int
DEPTH - default value 16 of type int
EXPORT_SIZE - default value True of type bool
EXPORT_SPACE - default value True of type bool
INIT_DATA - default value () of type tuple
INIT_DATA_FIRST_WORD - default value <class ‘hwt.constants.NOT_SPECIFIED’> 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 hwtLib.mem.fifoDrop.FifoWriterDropable - SLAVE
dataOut - of type hwt.hwIOs.std.HwIOFifoReader - MASTER
size - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 5bits, unsigned> - MASTER
space - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 5bits, unsigned> - MASTER
- __annotations__ = {}¶
- class hwtLib.mem.fifoDrop.FifoWriterDropable(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIOFifoWriterFIFO write port interface witch commit and discard signal used to drop data chunks already written in FIFO
- Variables:
~.commit – if 1 all the written data are made available to reader, including current data word
~.discard – if 1 all written data which were not commited are discarded including current data word
- HDL params:
DATA_WIDTH - default value 8 of type int
- HDL IO:
en - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
wait - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
data - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 8bits> - UNKNOWN
commit - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
discard - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.fifoDrop.FifoWriterDropableAgent(sim: HdlSimulator, hwIO: HwIOFifoWriter, allowNoReset=False)[source]¶
Bases:
HwIOFifoWriterAgent- __annotations__ = {}¶
hwtLib.mem.fifoPtrLogic module¶
- class hwtLib.mem.fifoPtrLogic.FifoPtrLogic(parent: HwModule, DEPTH: int, RAM_SIZE: int | None = None, INIT_SIZE: int = 0)[source]¶
Bases:
object- Note:
r_ptr=index which is going to be read
- Note:
w_ptr=index which is going to be written
Variant of read_ptr/write_ptr implementations¶
- note:
in all variants r_ptr is initialized to 0, w_ptr to number of interms preloaded in FIFO
- note:
variants with ram.R_LATENCY=1 will latch mem[rd_ptr] if fifo_read so the mem[rd_ptr] is not safe to be written in any variant unless the fifo is empty
Variant with r_wait = w_ptr == r_ptr¶
EFFECTIVE_DEPTH = DEPTH - 1
timing issues: w_wait expressions contain add and saturation
ram.R_LATENCY=1: https://vlsiverify.com/verilog/verilog-codes/synchronous-fifo/
Variant with r_wait = count != 0¶
Use of explicit count register may be resource/timing inefficient
EFFECTIVE_DEPTH = DEPTH
https://www.digikey.com/en/maker/tutorials/2025/fifo-design-in-systemverilog
Variant with item lock flag¶
Uses explicit flag to check if the w_ptr moved to r_ptr or r_ptr moved to w_ptr * EFFECTIVE_DEPTH = DEPTH
Variant with XORed item lock flag¶
Distributed last_was_r set to crossed0_r, crossed0_w crossed0_r/crossed0_w is filipped if pointer overflows * EFFECTIVE_DEPTH = DEPTH .. code-block::python
r_is_before_w = crossed0_r == crossed0_w w_is_before_r = crossed0_r != crossed0_w full = w_wait = (w_ptr._eq(r_ptr)) & ~r_is_before_w empty = r_wait = (w_ptr._eq(r_ptr)) & r_is_before_w
- ram.R_LATENCY=1: https://gist.github.com/C47D/e299230c65b82a87d7fc83579d78b168?permalink_comment_id=4216482#gistcomment-4216482
only for pow2 depth
- _fifo_ptr_distance(ptr0: HBitsRtlSignal, ptr1: HBitsRtlSignal)[source]¶
Computes distance from ptr0 to ptr1
- _is_fifo_ptr_add_possible(ptr0: RtlSignal, ptr1: RtlSignal | int, allow_eq: RtlSignal, ptr0IncrVal: HBitsRtlSignal | int) RtlSignal[source]¶
- static _normalize_EnWaitIncrValTuple(en_wait_incrVal: tuple[HBitsRtlSignal, HBitsRtlSignal] | tuple[HBitsRtlSignal, HBitsRtlSignal, int | HBitsRtlSignal]) tuple[HBitsRtlSignal, HBitsRtlSignal] | tuple[HBitsRtlSignal, HBitsRtlSignal, int | HBitsRtlSignal][source]¶
- _should_use_distributed_locks(write_en_wait_incrVal: tuple[HBitsRtlSignal, HBitsRtlSignal] | tuple[HBitsRtlSignal, HBitsRtlSignal, int | HBitsRtlSignal], read_en_wait_incrVal_list: list[tuple[HBitsRtlSignal, HBitsRtlSignal] | tuple[HBitsRtlSignal, HBitsRtlSignal, int | HBitsRtlSignal]]) bool[source]¶
Use distibuted locks if the check for overflow needs to check incrVal because
- fifo_pointers(write_en_wait_incrVal: tuple[HBitsRtlSignal, HBitsRtlSignal] | tuple[HBitsRtlSignal, HBitsRtlSignal, int | HBitsRtlSignal], read_en_wait_incrVal_list: list[tuple[HBitsRtlSignal, HBitsRtlSignal] | tuple[HBitsRtlSignal, HBitsRtlSignal, int | HBitsRtlSignal]]) list[tuple[RtlSignal, RtlSignal]][source]¶
Create fifo writer and reader pointers and enable/wait logic This functions supports multiple reader pointers
- Note:
Multiple read pointers are useful when the data in fifo passes
through multiple states, this efficiently means that instead of two FIFOs betwen some components we can use just 1 with multiple read poiners. For example 1st read pointer may represent if the data is beeing processed (lock) and the second if the data processing was finished and the item in fifo is deallocated (commit).
hwtLib.mem.hashTableCore module¶
- class hwtLib.mem.hashTableCore.HashTableCore(polynome)[source]¶
Bases:
HwModuleGeneric 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 item_vld; 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 lookup interface should have hash signal
~.LOOKUP_KEY – flag if lookup interface should have key signal
~.POLYNOME – polynome for crc hash used in this table
- HDL params:
ITEMS_CNT - default value 32 of type int
KEY_WIDTH - default value 16 of type int
DATA_WIDTH - default value 8 of type int
LOOKUP_ID_WIDTH - default value 0 of type int
LOOKUP_HASH - default value False of type bool
LOOKUP_KEY - default value False of type bool
- 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
io - of type hwtLib.mem.hashTable_intf.HwIOHashTable - SLAVE
r - of type hwtLib.handshaked.ramAsAddrDataRdVld.HwIORamRdVldR - MASTER
w - of type hwtLib.commonHwIO.addr_data.HwIOAddrDataRdVld - MASTER
- HDL components:
hash - of type hwtLib.logic.crcComb.CrcComb
gen_origKeyIn_reg_0 - of type hwtLib.handshaked.reg.HandshakedReg
- __annotations__ = {}¶
- insertLogic(ramW: HwIOAddrDataRdVld)[source]¶
- lookupLogic(ramR: HwIORamRdVldR)[source]¶
hwtLib.mem.hashTableCoreWithRam module¶
- class hwtLib.mem.hashTableCoreWithRam.HashTableCoreWithRam(polynome)[source]¶
Bases:
HashTableCore- HDL params:
ITEMS_CNT - default value 32 of type int
KEY_WIDTH - default value 16 of type int
DATA_WIDTH - default value 8 of type int
LOOKUP_ID_WIDTH - default value 0 of type int
LOOKUP_HASH - default value False of type bool
LOOKUP_KEY - default value False of type bool
- 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
io - of type hwtLib.mem.hashTable_intf.HwIOHashTable - SLAVE
- HDL components:
hash - of type hwtLib.logic.crcComb.CrcComb
table - of type hwtLib.mem.ram.RamSingleClock
tableConnector - of type hwtLib.handshaked.ramAsAddrDataRdVld.RamAsAddrDataRdVld
gen_origKeyIn_reg_0 - of type hwtLib.handshaked.reg.HandshakedReg
- __annotations__ = {}¶
hwtLib.mem.hashTable_intf module¶
- class hwtLib.mem.hashTable_intf.HwIOHashTable(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIO- HDL params:
ITEMS_CNT - default value 32 of type int
KEY_WIDTH - default value 16 of type int
DATA_WIDTH - default value 8 of type int
LOOKUP_ID_WIDTH - default value 0 of type int
LOOKUP_HASH - default value False of type bool
LOOKUP_KEY - default value False of type bool
- HDL IO:
insert - of type hwtLib.mem.hashTable_intf.HwIOInsert - UNKNOWN
lookup - of type hwtLib.mem.hashTable_intf.HwIOLookupKey - UNKNOWN
lookupRes - of type hwtLib.mem.hashTable_intf.HwIOLookupResult - UNKNOWN (Master=IN)
- __annotations__ = {}¶
- class hwtLib.mem.hashTable_intf.HwIOHashTableAgent(sim: HdlSimulator, hwIO: HwIOHashTable)[source]¶
Bases:
AgentBase- __annotations__ = {}¶
- __init__(sim: HdlSimulator, hwIO: HwIOHashTable)[source]¶
- class hwtLib.mem.hashTable_intf.HwIOInsert(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIORdVldSync- HDL params:
HASH_WIDTH - default value 8 of type int
KEY_WIDTH - default value 8 of type int
DATA_WIDTH - default value 0 of type int
- HDL IO:
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
hash - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 8bits> - UNKNOWN
key - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 8bits> - UNKNOWN
item_vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.hashTable_intf.HwIOInsertAgent(sim: HdlSimulator, hwIO: HwIOInsert)[source]¶
Bases:
HwIODataRdVldAgentSimulation agent for .HwIOInsert interface
- data format:
if interface has data signal, data format is tuple (hash, key, data, item_vld)
if interface does not have data signal, data format is tuple (hash, key, item_vld)
- __annotations__ = {}¶
- __init__(sim: HdlSimulator, hwIO: HwIOInsert)[source]¶
- Parameters:
rst – tuple (rst signal, rst_negated flag)
- class hwtLib.mem.hashTable_intf.HwIOLookupKey(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIORdVldSync- HDL params:
LOOKUP_ID_WIDTH - default value 0 of type int
KEY_WIDTH - default value 8 of type int
- HDL IO:
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
key - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 8bits> - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.hashTable_intf.HwIOLookupKeyAgent(sim: HdlSimulator, hwIO: HwIOLookupKey)[source]¶
Bases:
HwIODataRdVldAgentSimulation agent for HwIOLookupKey interface
- __annotations__ = {}¶
- __init__(sim: HdlSimulator, hwIO: HwIOLookupKey)[source]¶
- Parameters:
rst – tuple (rst signal, rst_negated flag)
- class hwtLib.mem.hashTable_intf.HwIOLookupResult(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIODataRdVldHwIO 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
- HDL params:
HASH_WIDTH - default value 8 of type int
KEY_WIDTH - default value 8 of type int
DATA_WIDTH - default value 0 of type int
LOOKUP_ID_WIDTH - default value 0 of type int
LOOKUP_HASH - default value False of type bool
LOOKUP_KEY - default value False of type bool
- HDL IO:
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
found - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
occupied - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.hashTable_intf.HwIOLookupResultAgent(sim, hwIO)[source]¶
Bases:
HwIODataRdVldAgentSimulation agent for .HwIOLookupResult data is stored in .data data format is tuple (hash, key, data, found) but some items can be missing depending on configuration of interface
- __annotations__ = {}¶
hwtLib.mem.lutRam module¶
hwtLib.mem.ram module¶
- class hwtLib.mem.ram.RamMultiClock(hdlName: str | None = None)[source]¶
Bases:
HwModuleRAM where each port has an independent clock. It can be configured to true dual port RAM etc. It can also be configured to have write mask or to be composed from multiple smaller memories.
- HDL params:
ADDR_WIDTH - default value 10 of type int
DATA_WIDTH - default value 64 of type int
PORT_CNT - default value 2 of type int
HAS_BE - default value False of type bool
MAX_BLOCK_DATA_WIDTH - default value None of type None
INIT_DATA - default value None of type None
READ_LATENCY - default value 1 of type int
- HDL IO:
port - of type hwt.hwIOs.hwIOArray.HwIOArray - SLAVE
- PORT_CLS¶
alias of
HwIOBramPort
- __annotations__ = {}¶
- class hwtLib.mem.ram.RamSingleClock(hdlName: str | None = None)[source]¶
Bases:
HwModuleRAM/ROM with only one clock signal. It can be configured to have arbitrary number of ports. It can also be configured to have write mask or to be composed from multiple smaller memories.
- HDL params:
ADDR_WIDTH - default value 10 of type int
DATA_WIDTH - default value 64 of type int
PORT_CNT - default value 1 of type intHwParam which specifies number of ram ports, it can be int or tuple of READ_WRITE, WRITE, READ to specify rw access for each port separately
HAS_BE - default value False of type boolHwParam, if True the write ports will have byte enable signal
MAX_BLOCK_DATA_WIDTH - default value None of type None
INIT_DATA - default value None of type None
READ_LATENCY - default value 1 of type intlatency in clock cycles from read enable=1 to read data appear on the output 0=distmem, 1=BRAM
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
port - of type hwt.hwIOs.hwIOArray.HwIOArray - SLAVE
- PORT_CLS¶
alias of
HwIOBramPort_noClk
- __annotations__ = {}¶
hwtLib.mem.ramCumulativeMask module¶
- class hwtLib.mem.ramCumulativeMask.BramPort_withReadMask_withoutClk(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIOBramPort_noClkBlock RAM port with a
enhandshaked interface for arbitration- Variables:
do_accumulate – HwIOSignal if 1 the mask bits are or-ed together with the value in stored in ram
do_overwrite – HwIOSignal if 1 the the data mask in ram is set to current we value
dout_mask – Read port contains this signal which contains the cumulative validity mask for the data.
- HDL params:
ADDR_WIDTH - default value 32 of type int
DATA_WIDTH - default value 64 of type int
HAS_R - default value True of type bool
HAS_W - default value True of type bool
HAS_BE - default value False of type bool
- HDL IO:
addr - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
din - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 64bits> - UNKNOWN
dout - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 64bits> - UNKNOWN (Master=IN)
en - of type hwt.hwIOs.std.HwIORdVldSync - UNKNOWN
we - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.ramCumulativeMask.RamCumulativeMask(hdlName: str | None = None)[source]¶
Bases:
RamSingleClockRAM which stores also byte enable value for each data word (to keep track of which bytes were updated).
- Note:
BramPort_withReadMask_withoutClkcontains the informations about how to control this component.
- PORT_CLS¶
alias of
BramPort_withReadMask_withoutClk
- __annotations__ = {}¶
hwtLib.mem.ramTransactional module¶
- class hwtLib.mem.ramTransactional.RamTransactional(hdlName: str | None = None)[source]¶
Bases:
HwModuleA RAM with 1 read port and 1 write port with flush before functionality. If the flush is activate the current data is read first before it is overwritten by write data. This memory supports multiword transaction and the swap, read and write is atomic in relation with other transactions.
- HDL params:
ADDR_WIDTH - default value 8 of type int
DATA_WIDTH - default value 8 of type int
WORD_WIDTH - default value 16 of type int
MAX_BLOCK_DATA_WIDTH - default value None of type None
W_PRIV_T - default value None of type None
R_ID_WIDTH - 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
r - of type hwtLib.mem.ramTransactional_io.TransRamHsR - SLAVE
w - of type hwtLib.mem.ramTransactional_io.TransRamHsW - SLAVE
flush_data - of type hwtLib.mem.ramTransactional_io.TransRamHsW - MASTER
- HDL components:
data_array - of type hwtLib.mem.ram.RamSingleClock
data_arr_r_to_hs - of type hwtLib.handshaked.ramAsAddrDataRdVld.RamAsAddrDataRdVld
data_arr_w_to_hs - of type hwtLib.handshaked.ramAsAddrDataRdVld.RamAsAddrDataRdVld
r_meta_0 - of type hwtLib.handshaked.reg.HandshakedReg
r_meta_1 - of type hwtLib.handshaked.reg.HandshakedReg
- __annotations__ = {}¶
- construct_r_meta(flush_req: RtlSignal, read_pending: RtlSignal, r: HwIORamRdVldR, w: HwIOAddrDataRdVld, w_index: HwIOStruct, r_index_o: HwIOStruct) HandshakedReg[source]¶
- construct_ram_io() Tuple[HwIORamRdVldR, HwIOAddrDataRdVld][source]¶
- construct_read_part(r: TransRamHsR, w_addr: RtlSignal, da_r: HwIORamRdVldR, r_meta: List[HandshakedReg], flush_req: RtlSignal, read_pending: RtlSignal, r_index_o: HwIOStruct, r_index_i: HwIOStruct, flush_data: TransRamHsW)[source]¶
- construct_write_part(w: TransRamHsW, da_r: HwIORamRdVldR, da_w: HwIOAddrDataRdVld, w_index_i: HwIOStruct, w_index_o, r_index_o, r_meta_din: HwIOStructRdVld)[source]¶
hwtLib.mem.ramTransactional_io module¶
- class hwtLib.mem.ramTransactional_io.TransRamHsR(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIOHandshaked RAM port
- HDL params:
DATA_WIDTH - default value 8 of type int
USE_STRB - default value True of type bool
ID_WIDTH - default value 0 of type int
ADDR_WIDTH - default value 32 of type int
- HDL IO:
addr - of type hwtLib.mem.ramTransactional_io.TransRamHsR_addr - UNKNOWN
data - of type hwtLib.amba.axi4s.Axi4Stream - UNKNOWN (Master=IN)
- __annotations__ = {}¶
- class hwtLib.mem.ramTransactional_io.TransRamHsR_addr(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIORdVldSync- HDL params:
PRIV_T - default value None of type None
ADDR_WIDTH - default value 32 of type int
- HDL IO:
addr - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
- __annotations__ = {}¶
- class hwtLib.mem.ramTransactional_io.TransRamHsW(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
HwIO- HDL params:
DATA_WIDTH - default value 64 of type int
USE_STRB - default value True of type bool
PRIV_T - default value None of type None
ADDR_WIDTH - default value 32 of type int
USE_FLUSH - default value True of type bool
- HDL IO:
addr - of type hwtLib.mem.ramTransactional_io.TransRamHsW_addr - UNKNOWN
data - of type hwtLib.amba.axi4s.Axi4Stream - UNKNOWN
- __annotations__ = {}¶
- class hwtLib.mem.ramTransactional_io.TransRamHsW_addr(masterDir=DIRECTION.OUT, hdlName: str | dict[str, str] | None = None, loadConfig=True)[source]¶
Bases:
TransRamHsR_addr- HDL params:
PRIV_T - default value None of type None
ADDR_WIDTH - default value 32 of type int
USE_FLUSH - default value True of type bool
- HDL IO:
addr - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 32bits> - UNKNOWN
vld - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
rd - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN (Master=IN)
flush - of type hwt.hwIOs.std.HwIOSignal with dtype=<HBits, 1bit> - UNKNOWN
- __annotations__ = {}¶
hwtLib.mem.ramXor module¶
- class hwtLib.mem.ramXor.RamXorSingleClock(hdlName: str | None = None)[source]¶
Bases:
RamSingleClockMultiport XOR based RAM with only one clock signal
- HDL params:
ADDR_WIDTH - default value 10 of type int
DATA_WIDTH - default value 64 of type int
PORT_CNT - default value (‘WRITE’, ‘WRITE’, ‘READ’) of type tuple
HAS_BE - default value False of type bool
MAX_BLOCK_DATA_WIDTH - default value None of type None
INIT_DATA - default value None of type None
READ_LATENCY - default value 1 of type int
PRIMITIVE_MEMORY_PORTS - default value (‘WRITE’, ‘READ’) of type tuplememory port of native memory from which this memory is built.
- HDL IO:
clk - of type hwt.hwIOs.std.HwIOClk with dtype=<HBits, 1bit> - SLAVE
rst - of type hwt.hwIOs.std.HwIORst with dtype=<HBits, 1bit> - SLAVE
port - of type hwt.hwIOs.hwIOArray.HwIOArray - SLAVE
- HDL components:
w_rams_0_1 - of type hwtLib.mem.ram.RamSingleClock
w_rams_1_0 - of type hwtLib.mem.ram.RamSingleClock
r_rams_0_0 - of type hwtLib.mem.ram.RamSingleClock
r_rams_0_1 - of type hwtLib.mem.ram.RamSingleClock
- __annotations__ = {}¶