From 13972108380fb859ceab95e9dacac4e1a876393c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20=C4=90=E1=BB=A9c=20Ti=E1=BA=BFn?= Date: Fri, 1 Nov 2024 07:43:54 +0700 Subject: [PATCH 1/2] Update SLLI.java SLLI instruction should be I_FORMAT See also: https://github.com/TheThirdOne/rars/issues/222 --- src/rars/riscv/instructions/SLLI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rars/riscv/instructions/SLLI.java b/src/rars/riscv/instructions/SLLI.java index 550b2b12..8f7584be 100644 --- a/src/rars/riscv/instructions/SLLI.java +++ b/src/rars/riscv/instructions/SLLI.java @@ -36,7 +36,7 @@ a copy of this software and associated documentation files (the public class SLLI extends BasicInstruction { 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); + BasicInstructionFormat.I_FORMAT, "0000000 ttttt sssss 001 fffff 0010011",false); } public void simulate(ProgramStatement statement) { From 9e34081b9e9e91796054d583a9161c2116aae3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20=C4=90=E1=BB=A9c=20Ti=E1=BA=BFn?= Date: Fri, 1 Nov 2024 07:46:35 +0700 Subject: [PATCH 2/2] Update InstructionCounter.java Wrong total number of instructions Detail: **counter++; ** is always executed before checking stmt !=null Propose: move instruction counter++; to be inside the block if(stmt != null) { } See also: https://github.com/TheThirdOne/rars/issues/222 --- src/rars/tools/InstructionCounter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rars/tools/InstructionCounter.java b/src/rars/tools/InstructionCounter.java index bcf84694..9a907b6c 100644 --- a/src/rars/tools/InstructionCounter.java +++ b/src/rars/tools/InstructionCounter.java @@ -283,13 +283,13 @@ protected void processRISCVUpdate(Observable resource, AccessNotice notice) { int a = m.getAddress(); if (a == lastAddress) return; 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) { + counter++; BasicInstruction instr = (BasicInstruction) stmt.getInstruction(); BasicInstructionFormat format = instr.getInstructionFormat(); if (format == BasicInstructionFormat.R_FORMAT)