Git Product home page Git Product logo

Comments (4)

lovers-under-moon avatar lovers-under-moon commented on May 24, 2024

The cell_type should be flash_type.
FEMU_OPTIONS=${FEMU_OPTIONS}",flash_type=3"

from femu.

huaicheng avatar huaicheng commented on May 24, 2024

I refactored that part of code, and haven't fully finished it yet. Stick to the default option for now. The TLC/QLC support is temporarily broken.

from femu.

lovers-under-moon avatar lovers-under-moon commented on May 24, 2024

//Due to the static, the initialization of latency data did not work, so I made some simple changes(for TLC).

static inline uint8_t get_page_type(int flash_type, int pg)
{
    static bool first_in=0;
    if(first_in==0){
        int i, j;
        int rows = (MAX_SUPPORTED_PAGES_PER_BLOCK + 5) / 6;
        int lpflag = TLC_LOWER_PAGE;
        int page_per_row=6;

        int lowp[] = {0, 1, 2, 3, 4, 5};
        int centerp[] = {6, 7};

        for (i = 0; i < sizeof(lowp)/sizeof(lowp[0]); i++)
            tlc_tbl[lowp[i]] = TLC_LOWER_PAGE;

        for (i = 0; i < sizeof(centerp)/sizeof(centerp[0]); i++)
            tlc_tbl[centerp[i]] = TLC_CENTER_PAGE;

        for (i = 0; i < rows - 2; i++) {
            for(j = 0; j < page_per_row; j += 2) {
                int idx = 8 + (i * page_per_row) + j;
                tlc_tbl[idx] = tlc_tbl[idx+1] = lpflag;
                lpflag = (lpflag == TLC_UPPER_PAGE) ? TLC_LOWER_PAGE : lpflag + 1;
            }
        }
        first_in=1;
    }
   
    switch (flash_type) {
    case SLC:
        return slc_tbl[pg];
    case MLC:
        return mlc_tbl[pg];
    case TLC:
        //printf("tlc_tblget_page地址=%p\n",tlc_tbl);
        return tlc_tbl[pg];
    case QLC:
        return qlc_tbl[pg];
    default:
        abort();
    }
}

static inline int64_t get_page_read_latency(int flash_type, int page_type)
{
    static bool get_page_read_latency_first_in=0;
    
    if(get_page_read_latency_first_in==0){
            nand_flash_timing = (NandFlashTiming) {
        /* From low pages to high/upper pages */

        /* Nand Page Read */
        .pg_rd_lat[SLC] = {
            [SLC_PAGE] = SLC_PAGE_READ_LATENCY_NS,
        },
        .pg_rd_lat[MLC] = {
            [MLC_LOWER_PAGE] = MLC_LOWER_PAGE_READ_LATENCY_NS,
            [MLC_UPPER_PAGE] = MLC_UPPER_PAGE_READ_LATENCY_NS
        },
        .pg_rd_lat[TLC] = {
            [TLC_LOWER_PAGE]  = TLC_LOWER_PAGE_READ_LATENCY_NS,
            [TLC_CENTER_PAGE] = TLC_CENTER_PAGE_READ_LATENCY_NS,
            [TLC_UPPER_PAGE]  = TLC_UPPER_PAGE_READ_LATENCY_NS,
        },
        .pg_rd_lat[QLC] = {
            [QLC_LOWER_PAGE]        = QLC_LOWER_PAGE_READ_LATENCY_NS,
            [QLC_LOWER_CENTER_PAGE] = QLC_CENTER_LOWER_PAGE_READ_LATENCY_NS,
            [QLC_UPPER_CENTER_PAGE] = QLC_CENTER_UPPER_PAGE_READ_LATENCY_NS,
            [QLC_UPPER_PAGE]        = QLC_UPPER_PAGE_READ_LATENCY_NS,
        },

        /* Nand Page Write */
        .pg_wr_lat[SLC] = {
            [SLC_PAGE] = SLC_PAGE_WRITE_LATENCY_NS,
        },
        .pg_wr_lat[MLC] = {
            [MLC_LOWER_PAGE] = MLC_LOWER_PAGE_WRITE_LATENCY_NS,
            [MLC_UPPER_PAGE] = MLC_UPPER_PAGE_WRITE_LATENCY_NS
        },
        .pg_wr_lat[TLC] = {
            [TLC_LOWER_PAGE]  = TLC_LOWER_PAGE_WRITE_LATENCY_NS,
            [TLC_CENTER_PAGE] = TLC_CENTER_PAGE_WRITE_LATENCY_NS,
            [TLC_UPPER_PAGE]  = TLC_UPPER_PAGE_WRITE_LATENCY_NS,
        },
        .pg_wr_lat[QLC] = {
            [QLC_LOWER_PAGE]        = QLC_LOWER_PAGE_WRITE_LATENCY_NS,
            [QLC_LOWER_CENTER_PAGE] = QLC_CENTER_LOWER_PAGE_WRITE_LATENCY_NS,
            [QLC_UPPER_CENTER_PAGE] = QLC_CENTER_UPPER_PAGE_WRITE_LATENCY_NS,
            [QLC_UPPER_PAGE]        = QLC_UPPER_PAGE_WRITE_LATENCY_NS,
        },

        /* Nand Block Erase */
        .blk_er_lat = {
            [SLC] = SLC_BLOCK_ERASE_LATENCY_NS,
            [MLC] = MLC_BLOCK_ERASE_LATENCY_NS,
            [TLC] = TLC_BLOCK_ERASE_LATENCY_NS,
            [QLC] = QLC_BLOCK_ERASE_LATENCY_NS,
        },

        /* Nand Page Channel Transfer */
        .chnl_pg_xfer_lat = {
            [SLC] = SLC_CHNL_PAGE_TRANSFER_LATENCY_NS,
            [MLC] = MLC_CHNL_PAGE_TRANSFER_LATENCY_NS,
            [TLC] = TLC_CHNL_PAGE_TRANSFER_LATENCY_NS,
            [QLC] = QLC_CHNL_PAGE_TRANSFER_LATENCY_NS,
        },
    };
    get_page_read_latency_first_in=1;
    }

    return nand_flash_timing.pg_rd_lat[flash_type][page_type];
}

from femu.

huaicheng avatar huaicheng commented on May 24, 2024

Good to know!

from femu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.