// File: CMU-SAFARI[P]ramulator/src/LPDDR4.cpp
// Function: ramulator::LPDDR4::init_lambda()
void LPDDR4::init_lambda()
{
    lambda[int(Level::Bank)][int(Command::ACT)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::Opened;
        node->row_state[id] = State::Opened;};
    lambda[int(Level::Bank)][int(Command::PRE)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();};
    lambda[int(Level::Rank)][int(Command::PREA)] = [] (DRAM<LPDDR4>* node, int id) {
        for (auto bank : node->children) {
            bank->state = State::Closed;
            bank->row_state.clear();}};
    lambda[int(Level::Rank)][int(Command::REF)] = [] (DRAM<LPDDR4>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::RD)] = [] (DRAM<LPDDR4>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::WR)] = [] (DRAM<LPDDR4>* node, int id) {};
    lambda[int(Level::Bank)][int(Command::RDA)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();};
    lambda[int(Level::Bank)][int(Command::WRA)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::Closed;
        node->row_state.clear();};
    lambda[int(Level::Rank)][int(Command::PDE)] = [] (DRAM<LPDDR4>* node, int id) {
        for (auto bank : node->children) {
            if (bank->state == State::Closed)
                continue;
            node->state = State::ActPowerDown;
            return;
        }
        node->state = State::PrePowerDown;};
    lambda[int(Level::Rank)][int(Command::PDX)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::PowerUp;};
    lambda[int(Level::Rank)][int(Command::SREF)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::SelfRefresh;};
    lambda[int(Level::Rank)][int(Command::SREFX)] = [] (DRAM<LPDDR4>* node, int id) {
        node->state = State::PowerUp;};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
addq $0x2078, %rdi           # imm = 0x2078
addq $0x340, %rdi            # imm = 0x340
leaq -0x9(%rbp), %rsi
callq 0x1de760
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x340, %rdi            # imm = 0x340
addq $0x20, %rdi
leaq -0xa(%rbp), %rsi
callq 0x1de7b0
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x1a0, %rdi            # imm = 0x1A0
addq $0x40, %rdi
leaq -0xb(%rbp), %rsi
callq 0x1de800
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x1a0, %rdi            # imm = 0x1A0
addq $0xe0, %rdi
leaq -0xc(%rbp), %rsi
callq 0x1de850
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x340, %rdi            # imm = 0x340
addq $0x60, %rdi
leaq -0xd(%rbp), %rsi
callq 0x1de8a0
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x340, %rdi            # imm = 0x340
addq $0x80, %rdi
leaq -0xe(%rbp), %rsi
callq 0x1de8f0
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x340, %rdi            # imm = 0x340
addq $0xa0, %rdi
leaq -0xf(%rbp), %rsi
callq 0x1de940
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x340, %rdi            # imm = 0x340
addq $0xc0, %rdi
leaq -0x10(%rbp), %rsi
callq 0x1de990
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x1a0, %rdi            # imm = 0x1A0
addq $0x120, %rdi            # imm = 0x120
leaq -0x11(%rbp), %rsi
callq 0x1de9e0
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x1a0, %rdi            # imm = 0x1A0
addq $0x140, %rdi            # imm = 0x140
leaq -0x12(%rbp), %rsi
callq 0x1dea30
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x1a0, %rdi            # imm = 0x1A0
addq $0x160, %rdi            # imm = 0x160
leaq -0x13(%rbp), %rsi
callq 0x1dea80
movq -0x20(%rbp), %rdi
addq $0x2078, %rdi           # imm = 0x2078
addq $0x1a0, %rdi            # imm = 0x1A0
addq $0x180, %rdi            # imm = 0x180
leaq -0x14(%rbp), %rsi
callq 0x1dead0
addq $0x20, %rsp
popq %rbp
retq
nop