Tool Instruction Counter: Wrong total number of instructions and Wrong SSLI instruction type
Closed this issue · 2 comments
neittien0110 commented
neittien0110 commented
Wrong SSLI instruction type
- Source code: https://github.com/TheThirdOne/rars/blob/master/src/rars/riscv/instructions/SLLI.java
- Extracted Code:
public SLLI() { super("slli t1,t2,10", "Shift left logical : Set t1 to result of shifting t2 left by number of bits specified by immediate", BasicInstructionFormat.R_FORMAT, "0000000 ttttt sssss 001 fffff 0010011",false); }
- Detail: SLLI should be I_FORMAT.
- Propose: replace BasicInstructionFormat.R_FORMAT by BasicInstructionFormat.I_FORMAT
Wrong total number of instructions
- Source file of the tool: InstructionCounter.java
- Extracted Code to classify Instruction Type
protected void processRISCVUpdate(Observable resource, AccessNotice notice) {
//...............................................................
lastAddress = a;
counter++;
try {
ProgramStatement stmt = Memory.getInstance().getStatement(a);
// If the program is finished, getStatement() will return null,
// a null statement will cause the simulator to stall.
if(stmt != null) {
BasicInstruction instr = (BasicInstruction) stmt.getInstruction();
BasicInstructionFormat format = instr.getInstructionFormat();
if (format == BasicInstructionFormat.R_FORMAT)
counterR++;
//...............................................................
- Detail: **counter++; ** is always executed before checking stmt !=null
- Propose: move instruction counter++; to be inside the block if(stmt != null) { }
neittien0110 commented
just propose, not fix