// File: estwings57[P]CasHMC/sources/DRAM.cpp
// Function: CasHMC::DRAM::DRAM(std::basic_ofstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&, unsigned int, CasHMC::VaultController*)
DRAM::DRAM(ofstream &debugOut_, ofstream &stateOut_, unsigned id, VaultController *contP):
	SimulatorObject(debugOut_, stateOut_),
	DRAMID(id),
	vaultContP(contP)
{
	classID << DRAMID;
	header = "        (DR_" + classID.str() + ")";
	
	readData = NULL;
	dataCyclesLeft = 0;

	bankStates.reserve(NUM_BANKS);
	for(int b=0; b<NUM_BANKS; b++) {
		bankStates.push_back(new BankState(b));
	}
	previousBankState = vector<BankStateType>(NUM_BANKS, IDLE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x21ff0
movq -0xd0(%rbp), %rdi
leaq 0x38e3c(%rip), %rax     # 0x65a90
movq %rax, (%rdi)
movl -0x1c(%rbp), %eax
movl %eax, 0x1c8(%rdi)
movq -0x28(%rbp), %rax
movq %rax, 0x1d0(%rdi)
addq $0x1d8, %rdi            # imm = 0x1D8
movq %rdi, -0xf0(%rbp)
callq 0x2f620
movq -0xd0(%rbp), %rdi
addq $0x1f0, %rdi            # imm = 0x1F0
movq %rdi, -0xe8(%rbp)
callq 0x2f640
movq -0xd0(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movq %rdi, -0xe0(%rbp)
callq 0x22480
movq -0xd0(%rbp), %rdi
addq $0x230, %rdi            # imm = 0x230
movq %rdi, -0xd8(%rbp)
callq 0x18070
movq -0xd0(%rbp), %rax
movq %rax, %rdi
addq $0x50, %rdi
movl 0x1c8(%rax), %esi
callq 0x44c0
jmp 0x2cce7
movq -0xd0(%rbp), %rsi
addq $0x40, %rsi
leaq -0x98(%rbp), %rdi
callq 0x4370
jmp 0x2cd00
leaq 0x2629c(%rip), %rsi     # 0x52fa3
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x179c0
jmp 0x2cd19
leaq 0x27659(%rip), %rdx     # 0x54379
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x18020
jmp 0x2cd2f
movq -0xd0(%rbp), %rdi
addq $0x20, %rdi
leaq -0x58(%rbp), %rsi
movq %rsi, -0xf8(%rbp)
callq 0x4470
movq -0xf8(%rbp), %rdi
callq 0x46e8
leaq -0x78(%rbp), %rdi
callq 0x46e8
leaq -0x98(%rbp), %rdi
callq 0x46e8
movq -0xd0(%rbp), %rdi
movq $0x0, 0x208(%rdi)
movl $0x0, 0x210(%rdi)
addq $0x1d8, %rdi            # imm = 0x1D8
leaq 0x3988b(%rip), %rax     # 0x66620
movslq (%rax), %rsi
callq 0x2f660
jmp 0x2cd9f
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
leaq 0x3986a(%rip), %rcx     # 0x66620
cmpl (%rcx), %eax
jge 0x2ce99
movq -0xd0(%rbp), %rax
addq $0x1d8, %rax            # imm = 0x1D8
movq %rax, -0x108(%rbp)
movl $0x40, %edi
callq 0x4390
movq %rax, -0x100(%rbp)
jmp 0x2cde5
movq -0x100(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x7260
jmp 0x2cdf9
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x2f760
jmp 0x2ce1c
jmp 0x2ce1e
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x2cda9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2cf3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2ce66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x46e8
leaq -0x98(%rbp), %rdi
callq 0x46e8
jmp 0x2cf3d
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x40, %esi
callq 0x43a0
jmp 0x2cf3d
leaq 0x39780(%rip), %rax     # 0x66620
movslq (%rax), %rax
movq %rax, -0x118(%rbp)
movl $0x0, -0xc4(%rbp)
leaq -0xc5(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x2f790
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
leaq -0xc4(%rbp), %rdx
callq 0x2f7b0
jmp 0x2ceea
movq -0xd0(%rbp), %rdi
addq $0x1f0, %rdi            # imm = 0x1F0
leaq -0xc0(%rbp), %rsi
callq 0x2f830
leaq -0xc0(%rbp), %rdi
callq 0x2f860
leaq -0xc5(%rbp), %rdi
callq 0x2f8c0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc5(%rbp), %rdi
callq 0x2f8c0
movq -0xd8(%rbp), %rdi
callq 0x18160
movq -0xe0(%rbp), %rdi
callq 0x225f0
movq -0xe8(%rbp), %rdi
callq 0x2f860
movq -0xf0(%rbp), %rdi
callq 0x2f8e0
movq -0xd0(%rbp), %rdi
callq 0x22e30
movq -0x30(%rbp), %rdi
callq 0x4630
nopw %cs:(%rax,%rax)