// File: dramninjasUMD[P]BOBSim/DRAMChannel.cpp
// Function: BOBSim::DRAMChannel::ReceiveOnDataBus(BOBSim::BusPacket*, unsigned int)
void DRAMChannel::ReceiveOnDataBus(BusPacket *busPacket, unsigned id)
{
	if(!(busPacket->busPacketType==READ_DATA ||
	        busPacket->busPacketType==WRITE_DATA))
	{
		ERROR("== Error - Trying to put non-data packet on data bus:" << *busPacket);
		exit(0);
	}

	if(inFlightDataPacket!=NULL)
	{
		ERROR("== Error - Bus collision while trying to receive from a rank in channel "<<channelID);
		ERROR("           Incoming Packet : "<<*busPacket);
		ERROR("           Existing Packet : "<<*inFlightDataPacket);
		ERROR("               (Time Left) : "<<inFlightDataCountdown);
		ERROR("           Clock Cycle : "<<currentClockCycle);
		exit(0);
	}
	if(DEBUG_CHANNEL) DEBUG("     == Putting data on bus [rank "<<id<<"] : " << *busPacket);

	inFlightDataPacket = busPacket;
	inFlightDataCountdown = busPacket->burstLength;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x7, 0x4(%rax)
je 0x19a11
movq -0x10(%rbp), %rax
cmpl $0x8, 0x4(%rax)
je 0x19a11
movq 0x1e656(%rip), %rdi     # 0x37ff0
leaq 0x1076f(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0x11ca2(%rip), %rsi     # 0x2b652
callq 0x31c0
movq %rax, %rdi
leaq 0x106fa(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xf4, %esi
callq 0x3380
movq %rax, %rdi
leaq 0x10746(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0x11dba(%rip), %rsi     # 0x2b7a4
callq 0x31c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x18f90
movq %rax, %rdi
movq 0x1e5a3(%rip), %rsi     # 0x37fa8
callq 0x3200
xorl %edi, %edi
callq 0x3270
movq -0x20(%rbp), %rax
cmpq $0x0, 0x270(%rax)
je 0x19c94
movq 0x1e5c6(%rip), %rdi     # 0x37ff0
leaq 0x106df(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0x11c12(%rip), %rsi     # 0x2b652
callq 0x31c0
movq %rax, %rdi
leaq 0x1066a(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xfa, %esi
callq 0x3380
movq %rax, %rdi
leaq 0x106b6(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0x11d60(%rip), %rsi     # 0x2b7da
callq 0x31c0
movq %rax, %rdi
movq -0x20(%rbp), %rax
movl 0x1e0(%rax), %esi
callq 0x32d0
movq %rax, %rdi
movq 0x1e50d(%rip), %rsi     # 0x37fa8
callq 0x3200
movq 0x1e549(%rip), %rdi     # 0x37ff0
leaq 0x10662(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0x11b95(%rip), %rsi     # 0x2b652
callq 0x31c0
movq %rax, %rdi
leaq 0x105ed(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xfb, %esi
callq 0x3380
movq %rax, %rdi
leaq 0x10639(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0x11d2c(%rip), %rsi     # 0x2b823
callq 0x31c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x18f90
movq %rax, %rdi
movq 0x1e496(%rip), %rsi     # 0x37fa8
callq 0x3200
movq 0x1e4d2(%rip), %rdi     # 0x37ff0
leaq 0x105eb(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0x11b1e(%rip), %rsi     # 0x2b652
callq 0x31c0
movq %rax, %rdi
leaq 0x10576(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xfc, %esi
callq 0x3380
movq %rax, %rdi
leaq 0x105c2(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0x11cd3(%rip), %rsi     # 0x2b841
callq 0x31c0
movq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x270(%rax), %rsi
callq 0x18f90
movq %rax, %rdi
movq 0x1e418(%rip), %rsi     # 0x37fa8
callq 0x3200
movq 0x1e454(%rip), %rdi     # 0x37ff0
leaq 0x1056d(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0x11aa0(%rip), %rsi     # 0x2b652
callq 0x31c0
movq %rax, %rdi
leaq 0x104f8(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xfd, %esi
callq 0x3380
movq %rax, %rdi
leaq 0x10544(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0x11c73(%rip), %rsi     # 0x2b85f
callq 0x31c0
movq %rax, %rdi
movq -0x20(%rbp), %rax
movl 0x278(%rax), %esi
callq 0x32d0
movq %rax, %rdi
movq 0x1e39b(%rip), %rsi     # 0x37fa8
callq 0x3200
movq 0x1e3d7(%rip), %rdi     # 0x37ff0
leaq 0x104f0(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0x11a23(%rip), %rsi     # 0x2b652
callq 0x31c0
movq %rax, %rdi
leaq 0x1047b(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xfe, %esi
callq 0x3380
movq %rax, %rdi
leaq 0x104c7(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0x11c14(%rip), %rsi     # 0x2b87d
callq 0x31c0
movq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x3070
movq %rax, %rdi
movq 0x1e320(%rip), %rsi     # 0x37fa8
callq 0x3200
xorl %edi, %edi
callq 0x3270
testb $0x1, 0x1e8a8(%rip)     # 0x38543
je 0x19cf3
leaq 0x1e6d0(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x19cf1
movq 0x1e318(%rip), %rdi     # 0x37fc8
leaq 0x11be0(%rip), %rsi     # 0x2b897
callq 0x31c0
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x32d0
movq %rax, %rdi
leaq 0x11be9(%rip), %rsi     # 0x2b8ba
callq 0x31c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x18f90
movq %rax, %rdi
movq 0x1e2bc(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x19cf3
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x270(%rax)
movq -0x10(%rbp), %rcx
movl 0x24(%rcx), %ecx
movl %ecx, 0x278(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)