Merge branch 'decode_print' of https://gitlab.istic.univ-rennes1.fr/simpleos/burritos into decode_print
This commit is contained in:
commit
83c212199e
@ -470,27 +470,27 @@ impl Machine {
|
|||||||
machine.fp_reg.set_reg(inst.rd as usize, machine.fp_reg.get_reg(inst.rs1 as usize).sqrt());
|
machine.fp_reg.set_reg(inst.rd as usize, machine.fp_reg.get_reg(inst.rs1 as usize).sqrt());
|
||||||
},
|
},
|
||||||
RISCV_FP_FSGN => {
|
RISCV_FP_FSGN => {
|
||||||
let local_float = machine.fp_reg[inst.rs1 as usize];
|
let local_float = machine.fp_reg.get_reg(inst.rs1 as usize);
|
||||||
match inst.funct3 {
|
match inst.funct3 {
|
||||||
RISCV_FP_FSGN_J => {
|
RISCV_FP_FSGN_J => {
|
||||||
if machine.fp_reg[inst.rs2 as usize] < 0 {
|
if machine.fp_reg.get_reg(inst.rs2 as usize) < 0f32 {
|
||||||
machine.fp_reg[inst.rd as usize] = -local_float;
|
machine.fp_reg.set_reg(inst.rd as usize, -local_float);
|
||||||
} else {
|
} else {
|
||||||
machine.fp_reg[inst.rd as usize] = local_float;
|
machine.fp_reg.set_reg(inst.rd as usize, local_float);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RISCV_FP_FSGN_JN => {
|
RISCV_FP_FSGN_JN => {
|
||||||
if machine.fp_reg[inst.rs2 as usize] < 0 {
|
if machine.fp_reg.get_reg(inst.rs2 as usize) < 0f32 {
|
||||||
machine.fp_reg[inst.rd as usize] = local_float;
|
machine.fp_reg.set_reg(inst.rd as usize, local_float);
|
||||||
} else {
|
} else {
|
||||||
machine.fp_reg[inst.rd as usize] = -local_float;
|
machine.fp_reg.set_reg(inst.rd as usize, -local_float);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RISCV_FP_FSGN_JX => {
|
RISCV_FP_FSGN_JX => {
|
||||||
if (machine.fp_reg[inst.rs2 as usize] < 0 && machine.fp_reg[inst.rs1 as usize] >= 0) || (machine.fp_reg[inst.rs2 as usize] >= 0 && machine.fp_reg[inst.rs1 as usize] < 0) {
|
if (machine.fp_reg.get_reg(inst.rs2 as usize) < 0.0 && machine.fp_reg.get_reg(inst.rs1 as usize) >= 0.0) || (machine.fp_reg.get_reg(inst.rs2 as usize) >= 0.0 && machine.fp_reg.get_reg(inst.rs1 as usize) < 0.0) {
|
||||||
machine.fp_reg[inst.rd as usize] = -local_float;
|
machine.fp_reg.set_reg(inst.rd as usize, -local_float);
|
||||||
} else {
|
} else {
|
||||||
machine.fp_reg[inst.rd as usize] = local_float;
|
machine.fp_reg.set_reg(inst.rd as usize, local_float);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -499,14 +499,14 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
RISCV_FP_MINMAX => {
|
RISCV_FP_MINMAX => {
|
||||||
let r1 = machine.fp_reg[inst.rs1 as usize];
|
let r1 = machine.fp_reg.get_reg(inst.rs1 as usize);
|
||||||
let r2 = machine.fp_reg[inst.rs2 as usize];
|
let r2 = machine.fp_reg.get_reg(inst.rs2 as usize);
|
||||||
match inst.funct3 {
|
match inst.funct3 {
|
||||||
RISCV_FP_MINMAX_MIN => {
|
RISCV_FP_MINMAX_MIN => {
|
||||||
machine.fp_reg[inst.rd as usize] = if r1 < r2 {r1} else {r2}
|
machine.fp_reg.set_reg(inst.rd as usize, if r1 < r2 {r1} else {r2});
|
||||||
},
|
},
|
||||||
RISCV_FP_MINMAX_MAX => {
|
RISCV_FP_MINMAX_MAX => {
|
||||||
machine.fp_reg[inst.rd as usize] = if r1 > r2 {r1} else {r2}
|
machine.fp_reg.set_reg(inst.rd as usize, if r1 > r2 {r1} else {r2});
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
panic!("this instruction ({}) doesn't exists", inst.value);
|
panic!("this instruction ({}) doesn't exists", inst.value);
|
||||||
@ -515,24 +515,24 @@ impl Machine {
|
|||||||
},
|
},
|
||||||
RISCV_FP_FCVTW => {
|
RISCV_FP_FCVTW => {
|
||||||
if inst.rs2 == RISCV_FP_FCVTW_W {
|
if inst.rs2 == RISCV_FP_FCVTW_W {
|
||||||
machine.int_reg[inst.rd as usize] = machine.fp_reg[inst.rs1 as usize];
|
machine.int_reg.set_reg(inst.rd as usize, machine.fp_reg.get_reg(inst.rs1 as usize) as i64);
|
||||||
} else {
|
} else {
|
||||||
machine.int_reg[inst.rd as usize] = machine.fp_reg[inst.rs1 as usize] as u64;
|
machine.int_reg.set_reg(inst.rd as usize, (machine.fp_reg.get_reg(inst.rs1 as usize) as u64) as i64);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RISCV_FP_FCVTS => {
|
RISCV_FP_FCVTS => {
|
||||||
if inst.rs2 == RISCV_FP_FCVTS_W {
|
if inst.rs2 == RISCV_FP_FCVTS_W {
|
||||||
machine.fp_reg[inst.rd as usize] = machine.int_reg[inst.rs1 as usize];
|
machine.fp_reg.set_reg(inst.rd as usize, machine.int_reg.get_reg(inst.rs1 as usize) as f32);
|
||||||
} else {
|
} else {
|
||||||
machine.fp_reg[inst.rd as usize] = machine.int_reg[inst.rs1 as usize] as u32;
|
machine.fp_reg.set_reg(inst.rd as usize, (machine.int_reg.get_reg(inst.rs1 as usize) as u32) as f32);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RISCV_FP_FMVW => {
|
RISCV_FP_FMVW => {
|
||||||
machine.fp_reg[inst.rd as usize] = machine.int_reg[inst.rs1 as usize];
|
machine.fp_reg.set_reg(inst.rd as usize, machine.int_reg.get_reg(inst.rs1 as usize) as f32);
|
||||||
},
|
},
|
||||||
RISCV_FP_FMVXFCLASS => {
|
RISCV_FP_FMVXFCLASS => {
|
||||||
if inst.funct3 == RISCV_FP_FMVXFCLASS_FMVX {
|
if inst.funct3 == RISCV_FP_FMVXFCLASS_FMVX {
|
||||||
machine.int_reg[inst.rd as usize] = machine.fp_reg[inst.rs1 as usize];
|
machine.int_reg.set_reg(inst.rd as usize, machine.fp_reg.get_reg(inst.rs1 as usize) as i64);
|
||||||
} else {
|
} else {
|
||||||
panic!("Fclass instruction is not handled in riscv simulator");
|
panic!("Fclass instruction is not handled in riscv simulator");
|
||||||
}
|
}
|
||||||
@ -540,13 +540,13 @@ impl Machine {
|
|||||||
RISCV_FP_FCMP => {
|
RISCV_FP_FCMP => {
|
||||||
match inst.funct3 {
|
match inst.funct3 {
|
||||||
RISCV_FP_FCMP_FEQ => {
|
RISCV_FP_FCMP_FEQ => {
|
||||||
machine.int_reg[inst.rd as usize] = if machine.fp_reg[inst.rs1 as usize] == machine.fp_reg[inst.rs2 as usize] {1} else {0};
|
machine.int_reg.set_reg(inst.rd as usize, if machine.fp_reg.get_reg(inst.rs1 as usize) == machine.fp_reg.get_reg(inst.rs2 as usize) {1} else {0});
|
||||||
},
|
},
|
||||||
RISCV_FP_FCMP_FLT => {
|
RISCV_FP_FCMP_FLT => {
|
||||||
machine.int_reg[inst.rd as usize] = if machine.fp_reg[inst.rs1 as usize] < machine.fp_reg[inst.rs2 as usize] {1} else {0};
|
machine.int_reg.set_reg(inst.rd as usize, if machine.fp_reg.get_reg(inst.rs1 as usize) < machine.fp_reg.get_reg(inst.rs2 as usize) {1} else {0});
|
||||||
},
|
},
|
||||||
RISCV_FP_FCMP_FLE => {
|
RISCV_FP_FCMP_FLE => {
|
||||||
machine.int_reg[inst.rd as usize] = if machine.fp_reg[inst.rs1 as usize] <= machine.fp_reg[inst.rs2 as usize] {1} else {0};
|
machine.int_reg.set_reg(inst.rd as usize, if machine.fp_reg.get_reg(inst.rs1 as usize) <= machine.fp_reg.get_reg(inst.rs2 as usize) {1} else {0});
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
panic!("this instruction ({}) doesn't exists", inst.value);
|
panic!("this instruction ({}) doesn't exists", inst.value);
|
||||||
|
Loading…
Reference in New Issue
Block a user