You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
def alu_controller ( alu_op , funct7 , funct3 ) : #alu_op来自主控制器, funct7和funct3来自指令的特定部位 返回alu_ctrl
if alu_op == ' 00 ' :
opreation = ' 00000 ' #lw.sw.auipc
elif alu_op == ' 01 ' :
if funct3 == ' 000 ' :
opreation = ' 00101 ' #beq
elif funct3 == ' 001 ' :
opreation = ' 00110 ' #bne
elif funct3 == ' 100 ' :
opreation = ' 00111 ' #blt
elif funct3 == ' 101 ' :
opreation = ' 01000 ' #bge
elif funct3 == ' 110 ' :
opreation = ' 01001 ' #bltu
elif funct3 == ' 111 ' :
opreation = ' 01010 ' #bgeu
else :
opreation = ' 00000 '
elif alu_op == ' 10 ' :
if funct3 == ' 000 ' :
if funct7 == ' 0100000 ' : #sub
opreation = ' 00001 '
else : #add,addi
opreation = ' 00000 '
elif funct3 == ' 100 ' :
opreation = ' 01100 ' #xor,xori
elif funct3 == ' 110 ' :
opreation = ' 00010 ' #or,ori
elif funct3 == ' 111 ' :
opreation = ' 00011 ' #and, andi
elif funct3 == ' 010 ' :
opreation = ' 00100 ' #slt,slti
elif funct3 == ' 001 ' :
opreation = ' 01101 ' #sll,slli 未存在
elif funct3 == ' 011 ' :
opreation = ' 01110 ' #sliu,sltiu 未存在
elif funct3 == ' 101 ' :
if funct7 == ' 0100000 ' : #sra,srai
opreation = ' 01111 '
else : #srl,srli
opreation = ' 10000 '
else :
opreation = ' 00000 '
elif alu_op == ' 11 ' : #jal
opreation = ' 01011 '
else :
opreation = ' 00000 '
return opreation