Skip to content

Commit

Permalink
Merge pull request #26 from THU-DSP-LAB/25-regext_imm
Browse files Browse the repository at this point in the history
[fix]fix bug that regext change the imm in inst
  • Loading branch information
Jules-Kong authored Mar 7, 2024
2 parents c5aa3eb + 8a00043 commit 89aea93
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions riscv/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct state_t

struct regext_t{
//regext_t():ext_rd(0),ext_rs1(0),ext_rs2(0),ext_rs3(0),ext_imm(0),valid(0){}
uint64_t ext_rd,ext_rs1,ext_rs2,ext_rs3,ext_imm,valid;
uint64_t ext_rd,ext_rs1,ext_rs2,ext_rs3,ext_imm,valid,validi;
};
regext_t regext_info;
bool regext_enable;
Expand Down Expand Up @@ -389,6 +389,7 @@ class processor_t : public abstract_device_t
state.regext_info.ext_rs2 = (imm>>3)&7;
state.regext_info.ext_rs3 = 0;
state.regext_info.ext_imm = (imm>>6)&63;
state.regext_info.validi = 1;
}
else{
state.regext_info.ext_rs1 = (imm>>3)&7;
Expand All @@ -399,6 +400,7 @@ class processor_t : public abstract_device_t
}
void ext_clear(){
state.regext_info.valid=0;
state.regext_info.validi=0;
state.regext_info.ext_imm=0;
state.regext_info.ext_rd=0;
state.regext_info.ext_rs1 = 0;
Expand All @@ -410,7 +412,7 @@ class processor_t : public abstract_device_t
uint64_t ext_rs3(){ return state.regext_info.valid ? (state.regext_info.ext_rs3<<5) : 0;}
uint64_t ext_rd(){ return state.regext_info.valid ? (state.regext_info.ext_rd<<5) : 0;}
int64_t ext_imm(){ return state.regext_info.valid ? ( (state.regext_info.ext_imm) << 58 >> 53) : 0;}
uint64_t ext_valid() { return state.regext_info.valid;}
uint64_t ext_valid() { return state.regext_info.validi;}
private:
const isa_parser_t * const isa;

Expand Down

0 comments on commit 89aea93

Please sign in to comment.