// File: /workspace/github_cpp_makefile_star2_O3/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 0xeb4d(%rip), %rsi      # 0x1541d1
leaq 0xeb49(%rip), %rdx      # 0x1541d4
callq 0x175a0
leaq 0x20(%rbx), %r14
leaq 0x30(%rbx), %rax
movq %rax, 0x20(%rbx)
leaq 0xeb32(%rip), %rsi      # 0x1541d5
leaq 0xeb2e(%rip), %rdx      # 0x1541d8
movq %r14, %rdi
callq 0x175a0
leaq 0x40(%rbx), %r14
leaq 0x50(%rbx), %rax
movq %rax, 0x40(%rbx)
leaq 0x13740(%rip), %rsi     # 0x158e05
leaq 0x1373c(%rip), %rdx     # 0x158e08
movq %r14, %rdi
callq 0x175a0
leaq 0x60(%rbx), %r14
leaq 0x70(%rbx), %rax
movq %rax, 0x60(%rbx)
leaq 0xeaf2(%rip), %rsi      # 0x1541d9
leaq 0xeaed(%rip), %rdx      # 0x1541db
movq %r14, %rdi
callq 0x175a0
leaq 0x80(%rbx), %r14
leaq 0x90(%rbx), %rax
movq %rax, 0x80(%rbx)
leaq 0x54d0(%rip), %rsi      # 0x14abe2
leaq 0x54cb(%rip), %rdx      # 0x14abe4
movq %r14, %rdi
callq 0x175a0
leaq 0xa0(%rbx), %r14
leaq 0xb0(%rbx), %rax
movq %rax, 0xa0(%rbx)
leaq 0xea9f(%rip), %rsi      # 0x1541dc
leaq 0xea9b(%rip), %rdx      # 0x1541df
movq %r14, %rdi
callq 0x175a0
leaq 0xc0(%rbx), %r14
leaq 0xd0(%rbx), %rax
movq %rax, 0xc0(%rbx)
leaq 0xea78(%rip), %rsi      # 0x1541e0
leaq 0xea74(%rip), %rdx      # 0x1541e3
movq %r14, %rdi
callq 0x175a0
leaq 0xe0(%rbx), %r14
leaq 0xf0(%rbx), %rax
movq %rax, 0xe0(%rbx)
leaq 0x17b94(%rip), %rsi     # 0x15d327
leaq 0x17b90(%rip), %rdx     # 0x15d32a
movq %r14, %rdi
callq 0x175a0
leaq 0x100(%rbx), %r14
leaq 0x110(%rbx), %rax
movq %rax, 0x100(%rbx)
leaq 0x121a6(%rip), %rsi     # 0x157964
leaq 0x121a4(%rip), %rdx     # 0x157969
movq %r14, %rdi
callq 0x175a0
leaq 0x120(%rbx), %r14
leaq 0x130(%rbx), %rax
movq %rax, 0x120(%rbx)
leaq 0x13620(%rip), %rsi     # 0x158e09
leaq 0x1361b(%rip), %rdx     # 0x158e0b
movq %r14, %rdi
callq 0x175a0
leaq 0x140(%rbx), %r14
leaq 0x150(%rbx), %rax
movq %rax, 0x140(%rbx)
leaq 0xe9d4(%rip), %rsi      # 0x1541e8
leaq 0xe9d0(%rip), %rdx      # 0x1541eb
movq %r14, %rdi
callq 0x175a0
leaq 0x160(%rbx), %r14
leaq 0x170(%rbx), %rax
movq %rax, 0x160(%rbx)
leaq 0x135cd(%rip), %rsi     # 0x158e0c
leaq 0x135ca(%rip), %rdx     # 0x158e10
movq %r14, %rdi
callq 0x175a0
leaq 0x180(%rbx), %r14
leaq 0x190(%rbx), %rax
movq %rax, 0x180(%rbx)
leaq 0x135a7(%rip), %rsi     # 0x158e11
leaq 0x135a5(%rip), %rdx     # 0x158e16
movq %r14, %rdi
callq 0x175a0
movups 0x19560(%rip), %xmm0    # 0x15ede0
movups %xmm0, 0x1c0(%rbx)
movups 0x19542(%rip), %xmm0    # 0x15edd0
movups %xmm0, 0x1b0(%rbx)
movups 0x19524(%rip), %xmm0    # 0x15edc0
movups %xmm0, 0x1a0(%rbx)
movl $0x1, 0x1d0(%rbx)
movups 0x19540(%rip), %xmm0    # 0x15edf4
movups %xmm0, 0x1d4(%rbx)
movl $0x6, 0x1e4(%rbx)
movups 0x1231c(%rip), %xmm0    # 0x157be8
movups %xmm0, 0x1e8(%rbx)
movq $0xb, 0x1f8(%rbx)
leaq 0x200(%rbx), %rdi
movl $0x2698, %edx           # imm = 0x2698
xorl %esi, %esi
callq 0xb1d0
movabsq $0x4000000004, %rax     # imm = 0x4000000004
movq %rax, 0x28b4(%rbx)
leaq 0x28c0(%rbx), %rdi
leaq 0x194f8(%rip), %rsi     # 0x15ee08
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 0x145a15
movl $0x2000, %eax           # imm = 0x2000
xorl %edx, %edx
idivl %ebp
movl %eax, 0x2898(%rbx)
movl $0x40, 0x289c(%rbx)
cmpl $0x4, %ebp
je 0x14599c
cmpl $0x8, %ebp
jne 0x145a34
movsd 0x19105(%rip), %xmm0    # 0x15ea90
movl $0x29e0, %eax           # imm = 0x29E0
movl $0x100, %ecx            # imm = 0x100
movl $0x400, %edx            # imm = 0x400
jmp 0x1459b3
movsd 0x190dc(%rip), %xmm0    # 0x15ea80
movl $0x29e4, %eax           # imm = 0x29E4
movl $0x200, %ecx            # imm = 0x200
movl $0x800, %edx            # imm = 0x800
leaq 0x1a0(%rbx), %r14
movl %edx, 0x2898(%rbx)
movl %ebp, 0x28a0(%rbx)
movl $0x0, 0x28a4(%rbx)
movlps %xmm0, 0x28a8(%rbx)
movl %ecx, 0x28b0(%rbx)
movl (%rbx,%rax), %eax
movl %eax, 0x29e8(%rbx)
movq %rbx, %rdi
callq 0x145bae
movq %rbx, %rdi
callq 0x145dc0
movq %rbx, %rdi
callq 0x145e48
movq %rbx, %rdi
callq 0x1461a2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x497d(%rip), %rdi      # 0x14a399
leaq 0x190e6(%rip), %rsi     # 0x15eb09
leaq 0x190ef(%rip), %rcx     # 0x15eb19
movl $0x2e, %edx
callq 0xb200
leaq 0x1908a(%rip), %rdi     # 0x15eac5
leaq 0x190c7(%rip), %rsi     # 0x15eb09
leaq 0x190d0(%rip), %rcx     # 0x15eb19
movl $0x2c, %edx
callq 0xb200
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
jmp 0x145a69
movq %rax, %r15
addq $-0x10, %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x145a84
movq (%r14), %rsi
incq %rsi
callq 0xb2f0
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %rbx, %r14
movq %rax, %r14
jne 0x145a70
movq %r15, %rdi
callq 0xb510
movq %rax, %r15
leaq 0x2878(%rbx), %r12
xorl %r13d, %r13d
movq 0x2888(%rbx,%r13), %rax
testq %rax, %rax
je 0x145ac4
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x145aa9
movl $0x2070, %r12d          # imm = 0x2070
movq -0x10(%rbx,%r12), %rdi
testq %rdi, %rdi
je 0x145aed
movq (%rbx,%r12), %rsi
subq %rdi, %rsi
callq 0xb2f0
addq $-0x18, %r12
cmpq $0x1a58, %r12           # imm = 0x1A58
jne 0x145ad7
leaq 0x1a40(%rbx), %r12
xorl %r13d, %r13d
movq 0x1a50(%rbx,%r13), %rax
testq %rax, %rax
je 0x145b1f
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x145b04
leaq 0x1220(%rbx), %r12
xorl %r13d, %r13d
movq 0x1230(%rbx,%r13), %rax
testq %rax, %rax
je 0x145b51
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x145b36
leaq 0xa00(%rbx), %r12
xorl %r13d, %r13d
movq 0xa10(%rbx,%r13), %rax
testq %rax, %rax
je 0x145b83
leaq (%r12,%r13), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $-0x20, %r13
cmpq $-0x820, %r13           # imm = 0xF7E0
jne 0x145b68
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc454
jmp 0x145a94
jmp 0x145ba6
jmp 0x145ba6
jmp 0x145ba6
movq %rax, %rdi
callq 0x171a3