// File: /workspace/github_cpp_makefile_star2_O1/estwings57[P]CasHMC/sources/CommandQueue.cpp
// Function: CasHMC::CommandQueue::isIssuable(CasHMC::DRAMCommand*)
bool CommandQueue::isIssuable(DRAMCommand *issueCMD)
{
	switch(issueCMD->commandType) {
		case REFRESH:
			break;
		case ACTIVATE:
			if((BANKSTATE(issueCMD->bank)->currentBankState == IDLE || BANKSTATE(issueCMD->bank)->currentBankState == REFRESHING) 
			&& BANKSTATE(issueCMD->bank)->nextActivate <= currentClockCycle 
			&& tFAWCountdown.size() < 4) {
				return true;
			}
			else {
				return false;
			}
			break;
		case WRITE:
		case WRITE_P:
			if(BANKSTATE(issueCMD->bank)->currentBankState == ROW_ACTIVE 
			&& BANKSTATE(issueCMD->bank)->nextWrite <= currentClockCycle
			&& BANKSTATE(issueCMD->bank)->openRowAddress == issueCMD->row
			&& !(!issueCMD->atomic && rowAccessCounter[issueCMD->bank] >= MAX_ROW_ACCESSES)) {
				//Check the available buffer space of the vault controller with regard to read/write return data
				if(issueCMD->atomic) {
					return true;
				}
				else if(issueCMD->posted == false) {
					if(vaultContP->pendingDataSize+(issueCMD->dataSize/16)+1 <= (vaultContP->upBufferMax)-(vaultContP->upBuffers.size())) {
						return true;
					}
					else{
						return false;
					}
				}
				else {
					return true;
				}
			}
			else {
				return false;
			}
			break;
		case READ:
		case READ_P:
			if(BANKSTATE(issueCMD->bank)->currentBankState == ROW_ACTIVE
			&& BANKSTATE(issueCMD->bank)->nextRead <= currentClockCycle
			&& BANKSTATE(issueCMD->bank)->openRowAddress == issueCMD->row
			&& rowAccessCounter[issueCMD->bank] < MAX_ROW_ACCESSES) {
				//Check the available buffer space of the vault controller with regard to read/write return data
				if(vaultContP->pendingDataSize+(issueCMD->dataSize/16)+1 <= (vaultContP->upBufferMax)-(vaultContP->upBuffers.size())) {
					return true;
				}
				else{
					return false;
				}
			}
			else {
				return false;
			}
			break;
		case PRECHARGE:
			if(BANKSTATE(issueCMD->bank)->currentBankState == ROW_ACTIVE
			&& BANKSTATE(issueCMD->bank)->nextPrecharge <= currentClockCycle) {
				return true;
			}
			else {
				return false;
			}
			break;
		default:
			ERROR(header<<"  == Error - Trying to issue a unknown bus packet type : "<<*issueCMD<<"  (CurrentClock : "<<currentClockCycle<<")");
			exit(0);
	}
	return false;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl 0x10(%rsi), %eax
cmpq $0x8, %rax
ja 0x1724d
leaq 0x1b8f8(%rip), %rcx     # 0x32970
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x1d8(%rbx), %rax
movq 0x210(%rax), %rdx
movl 0x18(%r14), %ecx
movq 0x1d8(%rdx), %rdx
movq (%rdx,%rcx,8), %rdx
cmpl $0x1, 0x4(%rdx)
jne 0x17243
movq 0x18(%rdx), %rsi
cmpq 0x8(%rbx), %rsi
ja 0x17243
movl 0x8(%rdx), %edx
cmpl 0x20(%r14), %edx
jne 0x17243
movq 0x268(%rbx), %rdx
movl (%rdx,%rcx,4), %ecx
leaq 0x254c0(%rip), %rdx     # 0x3c594
cmpl (%rdx), %ecx
jae 0x17243
movl 0x234(%rax), %ecx
movl 0x24(%r14), %edx
shrl $0x4, %edx
addl %edx, %ecx
incl %ecx
movslq 0x1cc(%rax), %rdx
movq 0x1f0(%rax), %rsi
subq 0x1e8(%rax), %rsi
sarq $0x3, %rsi
subq %rsi, %rdx
cmpq %rcx, %rdx
setae %al
jmp 0x17245
movq 0x1d8(%rbx), %rcx
movq 0x210(%rcx), %rax
movl 0x18(%r14), %edx
movq 0x1d8(%rax), %rax
movq (%rax,%rdx,8), %rax
cmpl $0x1, 0x4(%rax)
jne 0x17243
movq 0x20(%rax), %rsi
cmpq 0x8(%rbx), %rsi
ja 0x17243
movl 0x8(%rax), %eax
cmpl 0x20(%r14), %eax
jne 0x17243
movb 0x30(%r14), %sil
movb $0x1, %al
testb %sil, %sil
jne 0x17245
movq 0x268(%rbx), %rax
movl (%rax,%rdx,4), %eax
leaq 0x2541e(%rip), %rdx     # 0x3c594
cmpl (%rdx), %eax
setb %al
setae %dl
orb %sil, %dl
jne 0x17245
cmpb $0x0, 0x28(%r14)
movb $0x1, %al
jne 0x17245
movl 0x234(%rcx), %eax
movl 0x24(%r14), %edx
shrl $0x4, %edx
addl %edx, %eax
incl %eax
movslq 0x1cc(%rcx), %rdx
movq 0x1f0(%rcx), %rsi
subq 0x1e8(%rcx), %rsi
sarq $0x3, %rsi
subq %rsi, %rdx
cmpq %rax, %rdx
jmp 0x1710c
movq 0x1d8(%rbx), %rax
movq 0x210(%rax), %rax
movl 0x18(%r14), %ecx
movq 0x1d8(%rax), %rax
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %ecx
cmpl $0x3, %ecx
je 0x171f2
testl %ecx, %ecx
jne 0x17243
movq 0x10(%rax), %rax
cmpq 0x8(%rbx), %rax
ja 0x17243
movq 0x258(%rbx), %rcx
subq 0x250(%rbx), %rcx
movb $0x1, %al
cmpq $0x10, %rcx
jae 0x17243
jmp 0x17245
movq 0x1d8(%rbx), %rax
movq 0x210(%rax), %rax
movl 0x18(%r14), %ecx
movq 0x1d8(%rax), %rax
movq (%rax,%rcx,8), %rax
cmpl $0x1, 0x4(%rax)
jne 0x17243
movq 0x28(%rax), %rcx
movb $0x1, %al
cmpq 0x8(%rbx), %rcx
jbe 0x17245
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x24d9c(%rip), %rdi     # 0x3bff0
leaq 0x19dc7(%rip), %rsi     # 0x31022
callq 0x42e0
leaq 0x1b7a1(%rip), %rsi     # 0x32a08
movq %rax, %rdi
callq 0x42e0
leaq 0x1a5c1(%rip), %rsi     # 0x31837
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x203, %esi            # imm = 0x203
callq 0x4500
leaq 0x19daf(%rip), %rsi     # 0x31041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0x1b774(%rip), %rsi     # 0x32a21
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x1caba
leaq 0x1d9c4(%rip), %rsi     # 0x34c8b
movq %rax, %rdi
callq 0x42e0
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x1d17f(%rip), %rsi     # 0x34461
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360
nop