// File: gvaumour[P]cache-simulator/src/Hierarchy.cc
// Function: Hierarchy::Hierarchy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
Hierarchy::Hierarchy(string policy, int nbCores)
{
	ConfigCache L1Dataconfig (32768, 4 , BLOCK_SIZE , "LRU", 0);
	vector<ConfigCache> firstLevel;
	firstLevel.push_back(L1Dataconfig);

	ConfigCache L1Instconfig = L1Dataconfig;
	firstLevel.push_back(L1Instconfig);

	int nb_sets = simu_parameters.nb_sets;
	int nvm_assoc = simu_parameters.nvm_assoc;
	int sram_assoc = simu_parameters.sram_assoc;

	ConfigCache L2config ( (nvm_assoc+sram_assoc)*BLOCK_SIZE*nb_sets , sram_assoc + nvm_assoc, \
				BLOCK_SIZE , policy , nvm_assoc);
	L2config.m_printStats = true;
	vector<ConfigCache> secondLevelConfig;
	secondLevelConfig.push_back(L2config);
	
		
	m_nbLevel = 2;
	m_nbCores = nbCores;
//	m_private_caches.resize(m_nbCores);
	
	m_directory = new Directory();
	
	m_prefetcher = NULL;
	if(simu_parameters.enablePrefetch)
		m_prefetcher = new SimplePrefetcher( simu_parameters.prefetchDegree , simu_parameters.prefetchStreams , true);

	stats_beginTimeFrame = 0;
	
	for(unsigned i = 0 ; i < m_nbCores ; i++){
		m_private_caches.push_back(new Level(i , firstLevel, this) );
	}

	m_LLC = new Level(-1, secondLevelConfig , this);
	
	m_start_index = log2(BLOCK_SIZE)-1;
	
	stats_cleanWB_MainMem = 0;
	stats_dirtyWB_MainMem = 0;
	stats_writeMainMem = 0;
	stats_readMainMem = 0;
	
	stats_hitsPrefetch = 0;
	stats_issuedPrefetchs = 0;
}

// Assembly:
subq $0x228, %rsp            # imm = 0x228
movq %rsi, 0x58(%rsp)
movq %rdi, 0x220(%rsp)
movq %rsi, 0x218(%rsp)
movl %edx, 0x214(%rsp)
movq 0x220(%rsp), %rdi
movq %rdi, 0x68(%rsp)
movq %rdi, %rax
movq %rax, 0x60(%rsp)
callq 0x339f0
movq 0x68(%rsp), %rdi
addq $0x38, %rdi
movq %rdi, 0x70(%rsp)
callq 0x5540
leaq 0x1b7(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x56a0
movq 0x78(%rsp), %rdx
leaq 0x414dc(%rip), %rsi     # 0x723aa
leaq 0x1b8(%rsp), %rdi
callq 0x5530
jmp 0x30edd
leaq 0x1d8(%rsp), %rdi
movl $0x8000, %esi           # imm = 0x8000
movl $0x4, %edx
movl $0x40, %ecx
leaq 0x1b8(%rsp), %r8
xorl %r9d, %r9d
callq 0x33ac0
jmp 0x30f06
leaq 0x1b8(%rsp), %rdi
callq 0x5768
leaq 0x1b7(%rsp), %rdi
callq 0x53e0
leaq 0x188(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x33b30
movq 0x50(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x33b40
jmp 0x30f46
leaq 0x150(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x33bb0
jmp 0x30f5d
leaq 0x188(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x33b40
jmp 0x30f74
movq 0x58(%rsp), %rsi
leaq 0x63070(%rip), %rax     # 0x93ff0
movl 0x44(%rax), %ecx
movl %ecx, 0x14c(%rsp)
movl 0x40(%rax), %ecx
movl %ecx, 0x148(%rsp)
movl 0x38(%rax), %eax
movl %eax, 0x144(%rsp)
movl 0x148(%rsp), %eax
movl 0x144(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x48(%rsp)
movl 0x14c(%rsp), %ecx
imull %ecx, %eax
shll $0x6, %eax
movl %eax, 0x4c(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x51b0
jmp 0x30fd2
movl 0x48(%rsp), %edx
movl 0x4c(%rsp), %esi
movl 0x148(%rsp), %r9d
leaq 0x108(%rsp), %rdi
movl $0x40, %ecx
leaq 0xe8(%rsp), %r8
callq 0x33ac0
jmp 0x30ffe
leaq 0xe8(%rsp), %rdi
callq 0x5768
movb $0x1, 0x13c(%rsp)
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x33b30
movq 0x40(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x33b40
jmp 0x31039
movq 0x60(%rsp), %rax
movl $0x2, 0x30(%rax)
movl 0x214(%rsp), %ecx
movl %ecx, 0x34(%rax)
movl $0x30, %edi
callq 0x53a0
movq %rax, 0x38(%rsp)
jmp 0x31060
movq 0x38(%rsp), %rdi
callq 0x27730
jmp 0x3106c
movq 0x60(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
leaq 0x62f67(%rip), %rax     # 0x93ff0
testb $0x1, 0x8b(%rax)
je 0x311de
movl $0x30, %edi
callq 0x53a0
movq %rax, 0x30(%rsp)
jmp 0x310a7
movq 0x30(%rsp), %rdi
leaq 0x62f3d(%rip), %rax     # 0x93ff0
movl 0x8c(%rax), %esi
movl 0x90(%rax), %edx
movl $0x1, %ecx
callq 0x5bc60
jmp 0x310cb
movq 0x60(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x311de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x31115
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x5768
leaq 0x1b7(%rsp), %rdi
callq 0x53e0
jmp 0x314c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x314a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x3149a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x5768
jmp 0x3149a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x31480
movq 0x38(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
callq 0x5340
jmp 0x31480
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
callq 0x5340
jmp 0x31480
movq 0x60(%rsp), %rax
movq $0x0, 0x68(%rax)
movl $0x0, 0xcc(%rsp)
movq 0x60(%rsp), %rcx
movl 0xcc(%rsp), %eax
cmpl 0x34(%rcx), %eax
jae 0x3130b
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x28, %edi
callq 0x53a0
movq %rax, 0x28(%rsp)
jmp 0x31226
movb $0x1, 0xa7(%rsp)
movl 0xcc(%rsp), %eax
movl %eax, 0x1c(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x33c50
jmp 0x31250
movq 0x60(%rsp), %rcx
movl 0x1c(%rsp), %esi
movq 0x28(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x466f0
jmp 0x3126d
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movb $0x0, 0xa7(%rsp)
movq %rax, 0xc0(%rsp)
leaq 0xc0(%rsp), %rsi
callq 0x33c20
jmp 0x31296
leaq 0xa8(%rsp), %rdi
callq 0x33d50
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0x311f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x312f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x33d50
testb $0x1, 0xa7(%rsp)
jne 0x312fc
jmp 0x31306
movq 0x28(%rsp), %rdi
callq 0x5340
jmp 0x31480
movl $0x28, %edi
callq 0x53a0
movq %rax, 0x10(%rsp)
jmp 0x3131c
movb $0x1, 0x87(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x33c50
jmp 0x3133b
movq 0x60(%rsp), %rcx
movq 0x10(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x88(%rsp), %rdx
callq 0x466f0
jmp 0x31359
movq 0x60(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, 0x87(%rsp)
movq %rcx, 0x18(%rax)
leaq 0x88(%rsp), %rdi
callq 0x33d50
movl $0x40, %edi
callq 0x284e0
movsd %xmm0, 0x8(%rsp)
jmp 0x3138e
movq 0x60(%rsp), %rax
movsd 0x8(%rsp), %xmm0
movsd 0x40fa7(%rip), %xmm1    # 0x72348
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, 0x60(%rax)
movq $0x0, 0x70(%rax)
movq $0x0, 0x78(%rax)
movq $0x0, 0x88(%rax)
movq $0x0, 0x80(%rax)
movq $0x0, 0x98(%rax)
movq $0x0, 0x90(%rax)
leaq 0xd0(%rsp), %rdi
callq 0x33d50
leaq 0x108(%rsp), %rdi
callq 0x33db0
leaq 0x150(%rsp), %rdi
callq 0x33db0
leaq 0x188(%rsp), %rdi
callq 0x33d50
leaq 0x1d8(%rsp), %rdi
callq 0x33db0
addq $0x228, %rsp            # imm = 0x228
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
jmp 0x31468
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a8(%rsp)
movl %eax, 0x1a4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x33d50
testb $0x1, 0x87(%rsp)
jne 0x31474
jmp 0x3147e
movq 0x10(%rsp), %rdi
callq 0x5340
jmp 0x31480
leaq 0xd0(%rsp), %rdi
callq 0x33d50
leaq 0x108(%rsp), %rdi
callq 0x33db0
leaq 0x150(%rsp), %rdi
callq 0x33db0
leaq 0x188(%rsp), %rdi
callq 0x33d50
leaq 0x1d8(%rsp), %rdi
callq 0x33db0
movq 0x70(%rsp), %rdi
callq 0x5768
movq 0x68(%rsp), %rdi
callq 0x33a60
movq 0x1a8(%rsp), %rdi
callq 0x5690
nopw %cs:(%rax,%rax)