예제 #1
0
def forwarding(src):#实现转发机制
    global e_icode
    global e_dstE
    global e_valE
    global e_valM
    global m_icode
    global m_dstE
    global m_valE
    global m_valM
    if(((e_icode=="2") or (e_icode=="3") or (e_icode=="6") or (e_icode=="8") or (e_icode=="9") or (e_icode=="a") or (e_icode=="c")) and (e_dstE==src)):
            return e_valE#对于一般的冒险,直接转发
    if((e_icode=="b") and (src=="4")):
            return e_valE#对于pop,push之类的隐含调用寄存器的情况判断
    if((e_icode=="d") and (src=="4")):
            return e_valE
    if((e_icode=="d") and (src=="5")):#对于leave的加载使用冒险判断
            return "X"
    if(((e_icode=="5") or (e_icode=="b")) and (e_dstE==src)):#对于mrmovl的加载使用冒险判断
            return "X"

    if(((m_icode=="2") or (m_icode=="3") or (m_icode=="6") or (m_icode=="8") or (m_icode=="9") or (m_icode=="a") or (m_icode=="c")) and (m_dstE==src)):#如果已经进入了memory阶段,就可以直接转发,不需要暂停一个周期
            return m_valE#一旦读取到了Memory阶段,那么所有的值都可以转发
    if((m_icode=="b") and (src=="4")):
            return m_valE
    if((m_icode=="d") and (src=="4")):
            return m_valE
    if((m_icode=="d") and (src=="5")):
            return m_valM
    if(((m_icode=="5") or (m_icode=="b")) and (m_dstE==src)):
            return m_valM

    return data.RegRead(src)
예제 #2
0
def forwarding(src):
    global e_icode
    global e_dstE
    global e_valE
    global e_valM
    global m_icode
    global m_dstE
    global m_valE
    global m_valM
    if (((e_icode == "2") or (e_icode == "3") or (e_icode == "6") or
         (e_icode == "8") or (e_icode == "9") or (e_icode == "a"))
            and (e_dstE == src)):
        return e_valE
    if ((e_icode == "b") and (src == "4")):
        return e_valE
    if (((e_icode == "5") or (e_icode == "b")) and (e_dstE == src)):
        return "X"

    if (((m_icode == "2") or (m_icode == "3") or (m_icode == "6") or
         (m_icode == "8") or (m_icode == "9") or (m_icode == "a"))
            and (m_dstE == src)):
        return m_valE
    if ((m_icode == "b") and (src == "4")):
        return m_valE
    if (((m_icode == "5") or (m_icode == "b")) and (m_dstE == src)):
        return m_valM

    return data.RegRead(src)
예제 #3
0
def getY86():
    #global register
    register = {}
    #global memory
    register = {}
    register["CF"] = data.read("CF")
    register["OF"] = data.read("OF")
    register["ZF"] = data.read("ZF")
    register["SF"] = data.read("SF")

    register["stall"] = data.read("stall")
    register["end"] = data.read("end")

    register["pc"] = data.read("pc")
    register["F_icode"] = data.read("F_icode")

    register["D_index"] = data.read("D_index")
    register["D_icode"] = data.read("D_icode")
    register["D_ifunc"] = data.read("D_ifunc")
    register["rA"] = data.read("rA")
    register["rB"] = data.read("rB")
    register["D_valC"] = data.read("D_valC")
    register["D_valP"] = data.read("D_valP")

    register["E_index"] = data.read("E_index")
    register["E_icode"] = data.read("E_icode")
    register["E_ifunc"] = data.read("E_ifunc")
    register["E_valC"] = data.read("E_valC")
    register["E_valA"] = data.read("E_valA")
    register["E_valB"] = data.read("E_valB")
    register["E_dstE"] = data.read("E_dstE")
    register["E_dstM"] = data.read("E_dstM")
    register["srcA"] = data.read("srcA")
    register["srcB"] = data.read("srcB")

    register["M_index"] = data.read("M_index")
    register["M_icode"] = data.read("M_icode")
    register["bch"] = data.read("bch")
    register["M_valE"] = data.read("M_valE")
    register["M_valM"] = data.read("M_valM")
    register["M_dstE"] = data.read("M_dstE")
    register["M_dstM"] = data.read("M_dstM")

    register["W_index"] = data.read("W_index")
    register["W_icode"] = data.read("W_icode")
    register["W_valE"] = data.read("W_valE")
    register["W_valM"] = data.read("W_valM")
    register["W_dstE"] = data.read("W_dstE")
    register["W_dstM"] = data.read("W_dstM")

    register["eax"] = data.RegRead("0")
    register["ecx"] = data.RegRead("1")
    register["edx"] = data.RegRead("2")
    register["ebx"] = data.RegRead("3")
    register["esp"] = data.RegRead("4")
    register["ebp"] = data.RegRead("5")
    register["esi"] = data.RegRead("6")
    register["edi"] = data.RegRead("7")

    register["total_cycle"] = data.intread("total_cycle")
    register["valid_cycle"] = data.intread("valid_cycle")

    memory = data.Memory
    return register, memory