// File: Ziang95[P]Tomasulo_simulator/FU.cpp
// Function: flpMtplr::FU_automat()
void flpMtplr::FU_automat()
{
    next_vdd = 0;
    FU_QEntry shift_out;
    while (true)
    {
        at_rising_edge(next_vdd);
        if (squash_p.flag)
        {
            for (int i = 0; i<CPU_cfg->fp_mul->exe_time - 1; i++)
                if (pLatency_Q[i].res && is_prev_index(squash_p.ROB_i, pLatency_Q[i].dest, squash_p.R_f, squash_p.R_r))
                    pLatency_Q[i].res = nullptr;
            squash_p.flag = false;
        }
        task.res = nullptr;
        auto newTask = queue.deQ();
        if (newTask != nullptr)
        {
            task = *newTask;
            ROBEntry *R = CPU_ROB->get_entry(task.dest);
            R->output.exe = sys_clk.get_prog_cyc();
            msg_log("Calculating FLP "+to_string(task.oprnd1->f)+" X "+to_string(task.oprnd2->f), 3);
            task.res->f = task.oprnd1->f * task.oprnd2->f;
        }
        shift(task, shift_out);
        if (shift_out.res)
            fCDB.enQ(shift_out.res, shift_out.dest);
        at_falling_edge(next_vdd);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
movl $0x0, 0x3888(%rax)
movq -0x110(%rbp), %rdi
addq $0x3888, %rdi           # imm = 0x3888
callq 0x12130
movq -0x110(%rbp), %rax
testb $0x1, 0x38a4(%rax)
je 0x6f69
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
leaq 0x28594(%rip), %rcx     # 0x2f450
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6f5b
movq -0x110(%rbp), %rax
movq 0x38a8(%rax), %rax
movslq -0x44(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x6f4b
movq -0x110(%rbp), %rax
movl 0x38a0(%rax), %edi
movq 0x38a8(%rax), %rcx
movslq -0x44(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %esi
movl 0x3898(%rax), %edx
movl 0x389c(%rax), %ecx
callq 0x1aec0
testb $0x1, %al
jne 0x6f2a
jmp 0x6f4b
movq -0x110(%rbp), %rax
movq 0x38a8(%rax), %rax
movslq -0x44(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
jmp 0x6f4d
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x6eb2
movq -0x110(%rbp), %rax
movb $0x0, 0x38a4(%rax)
movq -0x110(%rbp), %rdi
movq $0x0, 0x3840(%rdi)
addq $0x8, %rdi
callq 0x5790
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x71a0
movq -0x110(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq %rdx, 0x3868(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x3858(%rax)
movups %xmm1, 0x3848(%rax)
movups %xmm0, 0x3838(%rax)
leaq 0x28490(%rip), %rcx     # 0x2f460
movq (%rcx), %rdi
movl 0x383c(%rax), %esi
callq 0xe4d0
movq %rax, -0x58(%rbp)
leaq 0x28daf(%rip), %rdi     # 0x2fd98
callq 0x116c0
movl %eax, %edx
movq -0x110(%rbp), %rax
movq -0x58(%rbp), %rcx
movl %edx, 0x54(%rcx)
movq 0x3848(%rax), %rax
movss (%rax), %xmm0
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x8860
movq -0x118(%rbp), %rdx
leaq 0x1b050(%rip), %rsi     # 0x2207a
leaq -0xb8(%rbp), %rdi
callq 0x83c0
jmp 0x7038
leaq 0x1b04c(%rip), %rdx     # 0x2208b
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x8810
jmp 0x7054
movq -0x110(%rbp), %rax
movq 0x3850(%rax), %rax
movss (%rax), %xmm0
leaq -0x108(%rbp), %rdi
callq 0x8860
jmp 0x7074
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x8740
jmp 0x708d
leaq -0x78(%rbp), %rdi
movl $0x3, %esi
callq 0x12060
jmp 0x709d
leaq -0x78(%rbp), %rdi
callq 0x4240
leaq -0x108(%rbp), %rdi
callq 0x4240
leaq -0x98(%rbp), %rdi
callq 0x4240
leaq -0xb8(%rbp), %rdi
callq 0x4240
leaq -0xd8(%rbp), %rdi
callq 0x4240
movq -0x110(%rbp), %rax
movq 0x3848(%rax), %rcx
movss (%rcx), %xmm0
movq 0x3850(%rax), %rcx
mulss (%rcx), %xmm0
movq 0x3840(%rax), %rax
movss %xmm0, (%rax)
jmp 0x71a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x7192
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x7186
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x717a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x716e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4240
leaq -0x108(%rbp), %rdi
callq 0x4240
leaq -0x98(%rbp), %rdi
callq 0x4240
leaq -0xb8(%rbp), %rdi
callq 0x4240
leaq -0xd8(%rbp), %rdi
callq 0x4240
jmp 0x71ec
movq -0x110(%rbp), %rdi
movq %rdi, %rsi
addq $0x3838, %rsi           # imm = 0x3838
leaq -0x40(%rbp), %rdx
callq 0x6d70
cmpq $0x0, -0x38(%rbp)
je 0x71d4
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %edx
leaq 0x28341(%rip), %rdi     # 0x2f510
callq 0x4de0
movq -0x110(%rbp), %rdi
addq $0x3888, %rdi           # imm = 0x3888
callq 0x121a0
jmp 0x6e84
movq -0xe0(%rbp), %rdi
callq 0x45f0
nopl (%rax,%rax)