// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]ramulator/src/WideIO2.cpp
// Function: ramulator::WideIO2::WideIO2(ramulator::WideIO2::Org, ramulator::WideIO2::Speed, int)
WideIO2::WideIO2(Org org, Speed speed, int channels) :  
    speed_entry(speed_table[int(speed)]),
    read_latency(speed_entry.nCL + speed_entry.nDQSCK + speed_entry.nBL)
{
    switch(int(org)){
        case int(Org::WideIO2_8Gb):
            org_entry.size = (8<<10) / channels;
            org_entry.dq = 64;
            if (channels == 4) {
                org_entry.size = 2<<10;
                org_entry.count[int(Level::Channel)] = channels;
                org_entry.count[int(Level::Rank)] = 0;
                org_entry.count[int(Level::Bank)] = 8;
                org_entry.count[int(Level::Row)] = 1<<13;
                org_entry.count[int(Level::Column)] = 1<<9;
            } else if (channels == 8) {
                org_entry.size = 1<<10;
                org_entry.count[int(Level::Channel)] = channels;
                org_entry.count[int(Level::Rank)] = 0;
                org_entry.count[int(Level::Bank)] = 4;
                org_entry.count[int(Level::Row)] = 1<<14;
                org_entry.count[int(Level::Column)] = 1<<8;
            } else assert(false && "The WideIO2 interface supports 4 or 8 physical channels.");
            break;
        default: assert(false);
    }
    speed_entry.nRPab = (channels == 4)? speed_entry.nRP8b: speed_entry.nRPpb;
    init_prereq();
    init_rowhit(); // SAUGATA: added row hit function
    init_lambda();
    init_timing();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r12d
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
leaq 0xe5ad(%rip), %rsi      # 0x157161
leaq 0xe5a9(%rip), %rdx      # 0x157164
callq 0x17586
leaq 0x20(%rbx), %r14
leaq 0x30(%rbx), %rax
movq %rax, 0x20(%rbx)
leaq 0xe592(%rip), %rsi      # 0x157165
leaq 0xe58e(%rip), %rdx      # 0x157168
movq %r14, %rdi
callq 0x17586
leaq 0x40(%rbx), %r14
leaq 0x50(%rbx), %rax
movq %rax, 0x40(%rbx)
leaq 0x131b0(%rip), %rsi     # 0x15bda5
leaq 0x131ac(%rip), %rdx     # 0x15bda8
movq %r14, %rdi
callq 0x17586
leaq 0x60(%rbx), %r14
leaq 0x70(%rbx), %rax
movq %rax, 0x60(%rbx)
leaq 0xe552(%rip), %rsi      # 0x157169
leaq 0xe54d(%rip), %rdx      # 0x15716b
movq %r14, %rdi
callq 0x17586
leaq 0x80(%rbx), %r14
leaq 0x90(%rbx), %rax
movq %rax, 0x80(%rbx)
leaq 0x4f60(%rip), %rsi      # 0x14dba2
leaq 0x4f5b(%rip), %rdx      # 0x14dba4
movq %r14, %rdi
callq 0x17586
leaq 0xa0(%rbx), %r14
leaq 0xb0(%rbx), %rax
movq %rax, 0xa0(%rbx)
leaq 0xe4ff(%rip), %rsi      # 0x15716c
leaq 0xe4fb(%rip), %rdx      # 0x15716f
movq %r14, %rdi
callq 0x17586
leaq 0xc0(%rbx), %r14
leaq 0xd0(%rbx), %rax
movq %rax, 0xc0(%rbx)
leaq 0xe4d8(%rip), %rsi      # 0x157170
leaq 0xe4d4(%rip), %rdx      # 0x157173
movq %r14, %rdi
callq 0x17586
leaq 0xe0(%rbx), %r14
leaq 0xf0(%rbx), %rax
movq %rax, 0xe0(%rbx)
leaq 0x175bf(%rip), %rsi     # 0x160282
leaq 0x175bb(%rip), %rdx     # 0x160285
movq %r14, %rdi
callq 0x17586
leaq 0x100(%rbx), %r14
leaq 0x110(%rbx), %rax
movq %rax, 0x100(%rbx)
leaq 0x11bdc(%rip), %rsi     # 0x15a8ca
leaq 0x11bda(%rip), %rdx     # 0x15a8cf
movq %r14, %rdi
callq 0x17586
leaq 0x120(%rbx), %r14
leaq 0x130(%rbx), %rax
movq %rax, 0x120(%rbx)
leaq 0x13090(%rip), %rsi     # 0x15bda9
leaq 0x1308b(%rip), %rdx     # 0x15bdab
movq %r14, %rdi
callq 0x17586
leaq 0x140(%rbx), %r14
leaq 0x150(%rbx), %rax
movq %rax, 0x140(%rbx)
leaq 0xe434(%rip), %rsi      # 0x157178
leaq 0xe430(%rip), %rdx      # 0x15717b
movq %r14, %rdi
callq 0x17586
leaq 0x160(%rbx), %r14
leaq 0x170(%rbx), %rax
movq %rax, 0x160(%rbx)
leaq 0x1303d(%rip), %rsi     # 0x15bdac
leaq 0x1303a(%rip), %rdx     # 0x15bdb0
movq %r14, %rdi
callq 0x17586
leaq 0x180(%rbx), %r14
leaq 0x190(%rbx), %rax
movq %rax, 0x180(%rbx)
leaq 0x13017(%rip), %rsi     # 0x15bdb1
leaq 0x13015(%rip), %rdx     # 0x15bdb6
movq %r14, %rdi
callq 0x17586
movups 0x18fa0(%rip), %xmm0    # 0x161d50
movups %xmm0, 0x1c0(%rbx)
movups 0x18f82(%rip), %xmm0    # 0x161d40
movups %xmm0, 0x1b0(%rbx)
movups 0x18f64(%rip), %xmm0    # 0x161d30
movups %xmm0, 0x1a0(%rbx)
movl $0x1, 0x1d0(%rbx)
movups 0x18f80(%rip), %xmm0    # 0x161d64
movups %xmm0, 0x1d4(%rbx)
movl $0x6, 0x1e4(%rbx)
movups 0x11d54(%rip), %xmm0    # 0x15ab50
movups %xmm0, 0x1e8(%rbx)
movq $0xb, 0x1f8(%rbx)
leaq 0x200(%rbx), %rdi
movl $0x820, %edx            # imm = 0x820
xorl %esi, %esi
callq 0xb1d0
leaq 0xa20(%rbx), %rdi
movl $0x820, %edx            # imm = 0x820
xorl %esi, %esi
callq 0xb1d0
leaq 0x1240(%rbx), %rdi
movl $0x820, %edx            # imm = 0x820
xorl %esi, %esi
callq 0xb1d0
leaq 0x1a60(%rbx), %rdi
movl $0x618, %edx            # imm = 0x618
xorl %esi, %esi
callq 0xb1d0
leaq 0x2078(%rbx), %rdi
movl $0x820, %edx            # imm = 0x820
xorl %esi, %esi
callq 0xb1d0
movabsq $0x4000000004, %rax     # imm = 0x4000000004
movq %rax, 0x28b4(%rbx)
leaq 0x28c0(%rbx), %rdi
leaq 0x18eec(%rip), %rsi     # 0x161d78
movl $0xf0, %edx
callq 0xb270
leaq 0x29b0(%rbx), %rdi
movslq %r12d, %rax
imulq $0x78, %rax, %rax
leaq (%rbx,%rax), %rsi
addq $0x28c0, %rsi           # imm = 0x28C0
movl $0xf, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl 0x29d0(%rbx), %eax
addl 0x29d8(%rbx), %eax
addl 0x29c8(%rbx), %eax
movl %eax, 0x2a28(%rbx)
testl %r15d, %r15d
jne 0x148f9a
movl $0x2000, %ecx           # imm = 0x2000
movl $0x2000, %eax           # imm = 0x2000
xorl %edx, %edx
idivl %ebp
movl %eax, 0x2898(%rbx)
movl $0x40, 0x289c(%rbx)
cmpl $0x4, %ebp
je 0x148f1f
cmpl $0x8, %ebp
jne 0x148fb9
movl $0x29e0, %eax           # imm = 0x29E0
movl $0x100, %edx            # imm = 0x100
movl $0x4000, %ecx           # imm = 0x4000
movl $0x4, %esi
movl $0x400, %edi            # imm = 0x400
jmp 0x148f33
movl $0x29e4, %eax           # imm = 0x29E4
movl $0x200, %edx            # imm = 0x200
movl $0x8, %esi
movl $0x800, %edi            # imm = 0x800
leaq 0x1a0(%rbx), %r14
movl %edi, 0x2898(%rbx)
movl %ebp, 0x28a0(%rbx)
movl $0x0, 0x28a4(%rbx)
movl %esi, 0x28a8(%rbx)
movl %ecx, 0x28ac(%rbx)
movl %edx, 0x28b0(%rbx)
movl (%rbx,%rax), %eax
movl %eax, 0x29e8(%rbx)
movq %rbx, %rdi
callq 0x149144
movq %rbx, %rdi
callq 0x14939c
movq %rbx, %rdi
callq 0x149432
movq %rbx, %rdi
callq 0x14980a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x43b8(%rip), %rdi      # 0x14d359
leaq 0x18ad1(%rip), %rsi     # 0x161a79
leaq 0x18ada(%rip), %rcx     # 0x161a89
movl $0x2e, %edx
callq 0xb200
leaq 0x18a75(%rip), %rdi     # 0x161a35
leaq 0x18ab2(%rip), %rsi     # 0x161a79
leaq 0x18abb(%rip), %rcx     # 0x161a89
movl $0x2c, %edx
callq 0xb200
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
jmp 0x148fee
movq %rax, %r15
cmpq %rbx, %r14
je 0x14912e
addq $-0x10, %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x149012
movq (%r14), %rsi
incq %rsi
callq 0xb2f0
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %rbx, %r14
movq %rax, %r14
jne 0x148ffe
jmp 0x14912e
movq %rax, %r15
movq %rbx, %r14
jmp 0x148ff1
movq %rax, %r15
leaq 0x2878(%rbx), %r12
xorl %r13d, %r13d
movq 0x2888(%rbx,%r13), %rax
testq %rax, %rax
je 0x149057
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x14903c
movl $0x2070, %r12d          # imm = 0x2070
movq -0x10(%rbx,%r12), %rdi
testq %rdi, %rdi
je 0x149080
movq (%rbx,%r12), %rsi
subq %rdi, %rsi
callq 0xb2f0
addq $-0x18, %r12
cmpq $0x1a58, %r12           # imm = 0x1A58
jne 0x14906a
leaq 0x1a40(%rbx), %r12
xorl %r13d, %r13d
movq 0x1a50(%rbx,%r13), %rax
testq %rax, %rax
je 0x1490b2
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x149097
leaq 0x1220(%rbx), %r12
xorl %r13d, %r13d
movq 0x1230(%rbx,%r13), %rax
testq %rax, %rax
je 0x1490e4
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x1490c9
leaq 0xa00(%rbx), %r12
xorl %r13d, %r13d
movq 0xa10(%rbx,%r13), %rax
testq %rax, %rax
je 0x149116
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x1490fb
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc423
movq %r15, %rdi
callq 0xb510
jmp 0x14913c
jmp 0x14913c
jmp 0x14913c
movq %rax, %rdi
callq 0x1718f