This document provides a comprehensive reference for the API endpoints and functions exposed by OpenNANDLab v2.0.0.
- NAND Simulator (
opennandlab.simulator) - Flash Translation Layer (
opennandlab.ftl) - NAND Device Model (
opennandlab.nand) - Error Correction (
opennandlab.ecc) - Defect Management (
opennandlab.defect) - Performance Optimization (
opennandlab.optimization) - Firmware Integration (
opennandlab.firmware) - Analytics & Metrics (
opennandlab.analytics) - Configuration (
opennandlab.config)
The NANDController class (in src/opennandlab/simulator.py) is the central orchestrator of OpenNANDLab.
Initializes the NAND controller with the provided configuration. Automatically sets up the FTL, ECC handler, bad block manager, wear leveling engine, and other optimizations based on the Pydantic SimulatorConfig.
Initializes the NAND interface, loads metadata, and runs startup diagnostics.
Flushes the cache, saves metadata updates, and shuts down all parallel and physical components. Logs final statistics.
Reads a logical page from the NAND flash. Handles write-buffer lookup, FTL translation, bad block checking, caching, ECC decoding, and decompression.
Writes data to a logical page. Handles data compression, buffering, ECC encoding, data scrambling, wear leveling updates, and triggers Garbage Collection (GC) if the free pool falls below the threshold.
Erases a physical block and increments its P/E cycle count. Informs the wear leveling engine and invalidates corresponding cache entries.
Returns information about the NAND device configuration, firmware features, and current performance/health statistics.
Implements a page-level L2P mapping table using flat integer arrays for extreme efficiency.
Initializes the L2P and P2L tables, physical page states, free block deque, and write buffer.
Pops the next available free physical page from the current active block or allocates a new active block from the free pool.
Garbage Collection policies for reclaiming invalid pages.
Selects a victim block, copies all valid pages to newly allocated free pages, erases the victim block, and returns it to the free block pool.
Simulates a physical NAND device.
Reads raw bytes from the simulated physical block/page array.
Writes raw bytes to the simulated physical array.
Resets the simulated physical block to 0xFF bytes.
Endurance and error models.
Calculates the Raw Bit Error Rate (RBER) based on a Weibull variant model incorporating current P/E cycles and configuration limits (rber_floor, rber_ceil, rber_lambda).
Unified interface for encoding and decoding data.
Encodes data using either BCH or LDPC based on configuration.
Decodes data and returns a tuple of the corrected data and the number of errors corrected.
Initializes BCH with Galois field size m and error correction capability t. Implements Forney's algorithm for non-binary correction magnitudes.
Generates LDPC parity-check and generator matrices using the Progressive Edge-Growth (PEG) algorithm.
Marks a physical block as bad.
Returns whether a block is marked as bad.
Initializes the wear leveling engine with a priority queue (min-heap) for
Increments the P/E cycle count for the block and updates its position in the heap.
Compresses data using LZ4 or Zstandard algorithms.
Decompresses data.
Retrieves or caches data using policies such as LRU, LFU, FIFO, or TTL.
Generates a YAML firmware specification based on template parameters and current constraints.
Validates the specification schema and parameter semantics (e.g., block size must be a multiple of page size).
Collects erase counts and bad block statuses across the simulated NAND layout.
Generates statistical distribution metrics (mean, std dev, quartiles) for block erase counts.
The central, type-safe configuration object replacing loose YAML dictionaries. Contains nested configuration models:
NANDConfigFTLConfigECCConfig
Loads a YAML file and automatically maps legacy config structures into the new Pydantic SimulatorConfig model.