From d96aa80e59606fdf91e1562068b0b6f7a0373ee7 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 14 May 2021 01:58:46 -0600 Subject: [PATCH 01/51] ignore build files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 093805de..9b0d08dc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ out .classpath .project examples/riscv + +# RARS build +build/ +rars.jar From e846a9d21bfd0b9d725329db0860a12010477c87 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 14 May 2021 01:59:40 -0600 Subject: [PATCH 02/51] lr.w and sc.w syntax support --- src/PseudoOps.txt | 4 ++ src/rars/riscv/BasicInstructionFormat.java | 3 +- src/rars/riscv/instructions/Atomic.java | 44 ++++++++++++++++++++++ src/rars/riscv/instructions/LR_W.java | 29 ++++++++++++++ src/rars/riscv/instructions/SC_W.java | 33 ++++++++++++++++ 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 src/rars/riscv/instructions/Atomic.java create mode 100644 src/rars/riscv/instructions/LR_W.java create mode 100644 src/rars/riscv/instructions/SC_W.java diff --git a/src/PseudoOps.txt b/src/PseudoOps.txt index d9870286..8c5568bf 100644 --- a/src/PseudoOps.txt +++ b/src/PseudoOps.txt @@ -265,3 +265,7 @@ fgt.s t1, f2, f3 ;fle.s RG1, RG2, RG3 ;#Floating Greater Than: if f1 > f2, fge.s t1, f2, f3 ;flt.s RG1, RG2, RG3 ;#Floating Greater Than or Equal: if f1 >= f2, set t1 to 1, else set t1 to 0 fgt.d t1, f2, f3 ;fle.d RG1, RG2, RG3 ;#Floating Greater Than (64 bit): if f1 > f2, set t1 to 1, else set t1 to 0 fge.d t1, f2, f3 ;flt.d RG1, RG2, RG3 ;#Floating Greater Than or Equal (64 bit): if f1 >= f2, set t1 to 1, else set t1 to 0 + +######################### atomic pseudo-ops ########################## +lr.w t1,(t2) ;lw RG1,0(RG3) ;#Load Reserved Word : Set t1 to contents of effective memory word address and reserves memory word address +sc.w t1,t2,(t3) ;sw RG1,0(RG3) ;#Store Conditional Word : Tries to store t2 contents into effective memory word address and returns store result in t1 diff --git a/src/rars/riscv/BasicInstructionFormat.java b/src/rars/riscv/BasicInstructionFormat.java index c607e051..a037566a 100644 --- a/src/rars/riscv/BasicInstructionFormat.java +++ b/src/rars/riscv/BasicInstructionFormat.java @@ -41,5 +41,6 @@ public enum BasicInstructionFormat { S_FORMAT, // 2 src registers + small immediate B_FORMAT, // 2 src registers + small immediate shifted left U_FORMAT, // 1 dst register + large immediate - J_FORMAT // 1 dst register + large immediate for jumping + J_FORMAT, // 1 dst register + large immediate for jumping + A_FORMAT, // 1 dst and 1 or 2 src register } diff --git a/src/rars/riscv/instructions/Atomic.java b/src/rars/riscv/instructions/Atomic.java new file mode 100644 index 00000000..335a9af9 --- /dev/null +++ b/src/rars/riscv/instructions/Atomic.java @@ -0,0 +1,44 @@ +package rars.riscv.instructions; + +import rars.riscv.BasicInstruction; +import rars.riscv.BasicInstructionFormat; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +/** + * Base class for all Atomic instructions + * + * @author Giancarlo Pernudi Segura + * @version May 2017 + */ +public abstract class Atomic extends BasicInstruction { + public Atomic(String usage, String description, String funct3, String funct5) { + super(usage, description, BasicInstructionFormat.A_FORMAT, + funct5 + " 00sssss ttttt " + funct3 + " fffff 0101111"); + } +} diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LR_W.java new file mode 100644 index 00000000..be9e6196 --- /dev/null +++ b/src/rars/riscv/instructions/LR_W.java @@ -0,0 +1,29 @@ +package rars.riscv.instructions; + +import rars.Globals; +import rars.riscv.hardware.AddressErrorException; +import rars.ProgramStatement; +import rars.SimulationException; +import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.RegisterFile; +import rars.riscv.BasicInstruction; +import rars.riscv.BasicInstructionFormat; + +public class LR_W extends Atomic { + public LR_W() { + super("lr.w t1, (t2)", "Set t1 to contents of effective memory word address and reserve", "010", "00010"); + } + + public void simulate(ProgramStatement statement) throws SimulationException { + int[] operands = statement.getOperands(); + try { + RegisterFile.updateRegister(operands[0], load(RegisterFile.getValue(operands[1]))); + } catch (AddressErrorException e) { + throw new SimulationException(statement, e); + } + } + + private long load(int address) throws AddressErrorException { + return Globals.memory.getWord(address); + } +} diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SC_W.java new file mode 100644 index 00000000..13d2ab77 --- /dev/null +++ b/src/rars/riscv/instructions/SC_W.java @@ -0,0 +1,33 @@ +package rars.riscv.instructions; + +import rars.Globals; +import rars.riscv.hardware.AddressErrorException; +import rars.ProgramStatement; +import rars.SimulationException; +import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.RegisterFile; +import rars.riscv.BasicInstruction; +import rars.riscv.BasicInstructionFormat; + +public class SC_W extends Atomic { + public SC_W() { + super("sc.w t1, (t2)", "Try to store t1 to contents of effective memory word address, sets t0 to store attempt result", "010", "00011"); + } + + public void simulate(ProgramStatement statement) throws SimulationException { + int[] operands = statement.getOperands(); + System.out.println(operands[0]); + System.out.println(operands[1]); + System.out.println(operands[2]); + operands[1] = (operands[1] << 20) >> 20; + try { + store(RegisterFile.getValue(0), RegisterFile.getValue(operands[0])); + } catch (AddressErrorException e) { + throw new SimulationException(statement, e); + } + } + + private void store(int address, long value) throws AddressErrorException { + Globals.memory.setWord(address, data); + } +} From 73633781e93a4dda0527c4a06a5ba9f32a8fc4b5 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 14 May 2021 23:41:10 -0600 Subject: [PATCH 03/51] fix sc.w instructions --- src/PseudoOps.txt | 4 ++-- src/rars/riscv/instructions/LR_W.java | 3 --- src/rars/riscv/instructions/SC_W.java | 17 ++++++----------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/PseudoOps.txt b/src/PseudoOps.txt index 8c5568bf..dcb8a6de 100644 --- a/src/PseudoOps.txt +++ b/src/PseudoOps.txt @@ -267,5 +267,5 @@ fgt.d t1, f2, f3 ;fle.d RG1, RG2, RG3 ;#Floating Greater Than (64 bit): if fge.d t1, f2, f3 ;flt.d RG1, RG2, RG3 ;#Floating Greater Than or Equal (64 bit): if f1 >= f2, set t1 to 1, else set t1 to 0 ######################### atomic pseudo-ops ########################## -lr.w t1,(t2) ;lw RG1,0(RG3) ;#Load Reserved Word : Set t1 to contents of effective memory word address and reserves memory word address -sc.w t1,t2,(t3) ;sw RG1,0(RG3) ;#Store Conditional Word : Tries to store t2 contents into effective memory word address and returns store result in t1 +lr.w t1,(t2) ;lr.w RG1,(RG3) ;#Load Reserved Word : Set t1 to contents of effective memory word address and reserves memory word address +sc.w t1,t2,(t3) ;sc.w RG1,RG2,(RG3) ;#Store Conditional Word : Tries to store t2 contents into effective memory word address and returns store result in t1 diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LR_W.java index be9e6196..57f91b30 100644 --- a/src/rars/riscv/instructions/LR_W.java +++ b/src/rars/riscv/instructions/LR_W.java @@ -4,10 +4,7 @@ import rars.riscv.hardware.AddressErrorException; import rars.ProgramStatement; import rars.SimulationException; -import rars.riscv.hardware.AddressErrorException; import rars.riscv.hardware.RegisterFile; -import rars.riscv.BasicInstruction; -import rars.riscv.BasicInstructionFormat; public class LR_W extends Atomic { public LR_W() { diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SC_W.java index 13d2ab77..143d8219 100644 --- a/src/rars/riscv/instructions/SC_W.java +++ b/src/rars/riscv/instructions/SC_W.java @@ -4,30 +4,25 @@ import rars.riscv.hardware.AddressErrorException; import rars.ProgramStatement; import rars.SimulationException; -import rars.riscv.hardware.AddressErrorException; import rars.riscv.hardware.RegisterFile; -import rars.riscv.BasicInstruction; -import rars.riscv.BasicInstructionFormat; public class SC_W extends Atomic { public SC_W() { - super("sc.w t1, (t2)", "Try to store t1 to contents of effective memory word address, sets t0 to store attempt result", "010", "00011"); + super("sc.w t0, t1, (t2)", "Try to store t1 to contents of effective memory word address, sets t0 to store attempt result", "010", "00011"); } public void simulate(ProgramStatement statement) throws SimulationException { int[] operands = statement.getOperands(); - System.out.println(operands[0]); - System.out.println(operands[1]); - System.out.println(operands[2]); - operands[1] = (operands[1] << 20) >> 20; try { - store(RegisterFile.getValue(0), RegisterFile.getValue(operands[0])); + int result = store(RegisterFile.getValue(operands[2]), RegisterFile.getValue(operands[1])); + RegisterFile.updateRegister(operands[0], result); } catch (AddressErrorException e) { throw new SimulationException(statement, e); } } - private void store(int address, long value) throws AddressErrorException { - Globals.memory.setWord(address, data); + private int store(int address, int value) throws AddressErrorException { + Globals.memory.setWord(address, value); + return 0; } } From fd13240c0d6cbcfeb2e9f60043c0c7d6f700e01a Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Tue, 25 May 2021 22:53:41 +0530 Subject: [PATCH 04/51] ReserveTable for 2 processors with shared memory --- src/rars/api/Program.java | 2 ++ src/rars/riscv/instructions/LR_W.java | 5 +++++ src/rars/riscv/instructions/SC_W.java | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rars/api/Program.java b/src/rars/api/Program.java index f0b0f0db..a5c8b589 100644 --- a/src/rars/api/Program.java +++ b/src/rars/api/Program.java @@ -54,6 +54,7 @@ public Program() { public Program(Options set){ Globals.initialize(false); + ReserveTable.ResetReserve(); this.set = set; code = new RISCVprogram(); assembled = new Memory(); @@ -130,6 +131,7 @@ private ErrorList assemble(ArrayList programs) throws AssemblyExce */ public void setup(ArrayList args, String STDIN){ RegisterFile.resetRegisters(); + ReserveTable.ResetReserve(); FloatingPointRegisterFile.resetRegisters(); ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LR_W.java index 57f91b30..849e2326 100644 --- a/src/rars/riscv/instructions/LR_W.java +++ b/src/rars/riscv/instructions/LR_W.java @@ -5,6 +5,8 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReserveTable; + public class LR_W extends Atomic { public LR_W() { @@ -21,6 +23,9 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long load(int address) throws AddressErrorException { + // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + + ReserveTable.lr_w1(address); return Globals.memory.getWord(address); } } diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SC_W.java index 143d8219..1157de44 100644 --- a/src/rars/riscv/instructions/SC_W.java +++ b/src/rars/riscv/instructions/SC_W.java @@ -5,6 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReserveTable; public class SC_W extends Atomic { public SC_W() { @@ -22,7 +23,11 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private int store(int address, int value) throws AddressErrorException { - Globals.memory.setWord(address, value); - return 0; + // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + if(ReserveTable.sc_w1(address)){ + Globals.memory.setWord(address, value); + return 0; + } + return -1; } } From 2514a831aca721995cd5f507311053fe4ef4e546 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Tue, 25 May 2021 23:16:58 +0530 Subject: [PATCH 05/51] macOS .DS_Store --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9b0d08dc..4df50ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ examples/riscv # RARS build build/ rars.jar + +# macOS +.DS_Store From fcac4779c8e6976e9f80ccbd8e80a6f63946da2f Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Tue, 25 May 2021 22:53:41 +0530 Subject: [PATCH 06/51] ReserveTable for 2 processors with shared memory --- src/rars/api/Program.java | 2 ++ src/rars/riscv/instructions/LR_W.java | 5 +++++ src/rars/riscv/instructions/SC_W.java | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rars/api/Program.java b/src/rars/api/Program.java index f0b0f0db..a5c8b589 100644 --- a/src/rars/api/Program.java +++ b/src/rars/api/Program.java @@ -54,6 +54,7 @@ public Program() { public Program(Options set){ Globals.initialize(false); + ReserveTable.ResetReserve(); this.set = set; code = new RISCVprogram(); assembled = new Memory(); @@ -130,6 +131,7 @@ private ErrorList assemble(ArrayList programs) throws AssemblyExce */ public void setup(ArrayList args, String STDIN){ RegisterFile.resetRegisters(); + ReserveTable.ResetReserve(); FloatingPointRegisterFile.resetRegisters(); ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LR_W.java index 57f91b30..849e2326 100644 --- a/src/rars/riscv/instructions/LR_W.java +++ b/src/rars/riscv/instructions/LR_W.java @@ -5,6 +5,8 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReserveTable; + public class LR_W extends Atomic { public LR_W() { @@ -21,6 +23,9 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long load(int address) throws AddressErrorException { + // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + + ReserveTable.lr_w1(address); return Globals.memory.getWord(address); } } diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SC_W.java index 143d8219..1157de44 100644 --- a/src/rars/riscv/instructions/SC_W.java +++ b/src/rars/riscv/instructions/SC_W.java @@ -5,6 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReserveTable; public class SC_W extends Atomic { public SC_W() { @@ -22,7 +23,11 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private int store(int address, int value) throws AddressErrorException { - Globals.memory.setWord(address, value); - return 0; + // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + if(ReserveTable.sc_w1(address)){ + Globals.memory.setWord(address, value); + return 0; + } + return -1; } } From e9022e0f0e13ceb1184aa3ded65e7d58c5edef8f Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Tue, 25 May 2021 23:26:34 +0530 Subject: [PATCH 07/51] Reserve Table --- src/rars/riscv/hardware/ReserveTable.java | 93 +++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/rars/riscv/hardware/ReserveTable.java diff --git a/src/rars/riscv/hardware/ReserveTable.java b/src/rars/riscv/hardware/ReserveTable.java new file mode 100644 index 00000000..6ef829dd --- /dev/null +++ b/src/rars/riscv/hardware/ReserveTable.java @@ -0,0 +1,93 @@ +package rars.riscv.hardware; + +import java.util.ArrayList; + +/* +Copyright (c) 2021, Siva Chowdeswar Nandipati. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class ReserveTable{ + public static ArrayList proc1 = new ArrayList(); + public static ArrayList proc2 = new ArrayList(); + public static ArrayList bool = new ArrayList(); + + public static void ResetReserve(){ + proc1.clear(); + proc2.clear(); + bool.clear(); + } + public static void addproc1(int address){ + proc1.add(Integer.valueOf(address)); + } + public static void addproc2(int address){ + proc1.add(Integer.valueOf(address)); + } + public static void addbool(int address){ + bool.add(Integer.valueOf(address)); + } + public static void lr_w1(int address){ + if(proc1.contains(Integer.valueOf(address))) + return; + addproc1(address); + } + public static void lr_w2(int address){ + if(proc2.contains(Integer.valueOf(address))) + return; + addproc2(address); + } + public static boolean sc_w1(int address){ + if(!proc1.contains(Integer.valueOf(address))){ + return false; // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + } + if(bool.contains(Integer.valueOf(address))){ + proc1.remove(Integer.valueOf(address)); + bool.remove(Integer.valueOf(address)); + return false; + } + if(!proc2.contains(Integer.valueOf(address))){ + proc1.remove(Integer.valueOf(address)); + return true; + } + proc1.remove(Integer.valueOf(address)); + addbool(address); + return true; + } + public static boolean sc_w2(int address){ + if(!proc2.contains(Integer.valueOf(address))){ + return false; // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + } + if(bool.contains(Integer.valueOf(address))){ + proc2.remove(Integer.valueOf(address)); + bool.remove(Integer.valueOf(address)); + return false; + } + if(!proc1.contains(Integer.valueOf(address))){ + proc2.remove(Integer.valueOf(address)); + return true; + } + proc2.remove(Integer.valueOf(address)); + addbool(address); + return true; + } +} \ No newline at end of file From e81c2532ea0849ce778a9346652eba2c4091404f Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Thu, 27 May 2021 21:51:43 +0530 Subject: [PATCH 08/51] General Reserve Table --- src/rars/riscv/hardware/ReserveTable.java | 78 ++++++++++------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/src/rars/riscv/hardware/ReserveTable.java b/src/rars/riscv/hardware/ReserveTable.java index 6ef829dd..be0386e4 100644 --- a/src/rars/riscv/hardware/ReserveTable.java +++ b/src/rars/riscv/hardware/ReserveTable.java @@ -28,66 +28,52 @@ a copy of this software and associated documentation files (the */ public class ReserveTable{ - public static ArrayList proc1 = new ArrayList(); - public static ArrayList proc2 = new ArrayList(); - public static ArrayList bool = new ArrayList(); - + //0 represents Stored value;; + public static ArrayList arrrayProc = new ArrayList(); + public static int procs = 0; public static void ResetReserve(){ - proc1.clear(); - proc2.clear(); - bool.clear(); - } - public static void addproc1(int address){ - proc1.add(Integer.valueOf(address)); + arrayProc = new ArrayList(); } - public static void addproc2(int address){ - proc1.add(Integer.valueOf(address)); + + public static void addproc(int address, int processor){ + arrrayProc.get(processor).get(1).add(Integer.valueOf(address)); } + public static void addbool(int address){ - bool.add(Integer.valueOf(address)); + arrrayProc.get(processor).get(0).add(Integer.valueOf(address)); } - public static void lr_w1(int address){ - if(proc1.contains(Integer.valueOf(address))) + + public static void lr_w(int address, int processor){ + if(arrrayProc.get(processor).get(1).contains(Integer.valueOf(address))) return; - addproc1(address); + addproc(address, processor); } - public static void lr_w2(int address){ - if(proc2.contains(Integer.valueOf(address))) + + private static void addToRest(int address, int processor){ + if(procs = 0) return; - addproc2(address); - } - public static boolean sc_w1(int address){ - if(!proc1.contains(Integer.valueOf(address))){ - return false; // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt + for(int i = 0; i <= processor; i++){ + if(i == processor) + continue; + if(arrrayProc.get(i).get(1).contains(address)){ + arrrayProc.get(i).get(0).add(address) + } } - if(bool.contains(Integer.valueOf(address))){ - proc1.remove(Integer.valueOf(address)); - bool.remove(Integer.valueOf(address)); - return false; - } - if(!proc2.contains(Integer.valueOf(address))){ - proc1.remove(Integer.valueOf(address)); - return true; - } - proc1.remove(Integer.valueOf(address)); - addbool(address); - return true; } - public static boolean sc_w2(int address){ - if(!proc2.contains(Integer.valueOf(address))){ + + public static boolean sc_w(int address, int processor){ + if(!arrrayProc.get(processor).get(1).contains(Integer.valueOf(address))){ return false; // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt } - if(bool.contains(Integer.valueOf(address))){ - proc2.remove(Integer.valueOf(address)); - bool.remove(Integer.valueOf(address)); + if(arrrayProc.get(processor).get(0).contains(Integer.valueOf(address))){ + arrrayProc.get(processor).get(1).remove(Integer.valueOf(address)); + arrrayProc.get(processor).get(0).remove(Integer.valueOf(address)); return false; } - if(!proc1.contains(Integer.valueOf(address))){ - proc2.remove(Integer.valueOf(address)); - return true; - } - proc2.remove(Integer.valueOf(address)); - addbool(address); + addToRest(address, processor); return true; } + public static setProcs(int procces){ + procs = procces; + } } \ No newline at end of file From d37dcf555e8564077b8f6f840cbc147f254550cc Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Thu, 27 May 2021 23:20:51 +0530 Subject: [PATCH 09/51] General Reserve Table 27 May --- src/rars/riscv/hardware/ReserveTable.java | 35 +++++++---------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/rars/riscv/hardware/ReserveTable.java b/src/rars/riscv/hardware/ReserveTable.java index be0386e4..8c012d99 100644 --- a/src/rars/riscv/hardware/ReserveTable.java +++ b/src/rars/riscv/hardware/ReserveTable.java @@ -29,48 +29,33 @@ a copy of this software and associated documentation files (the public class ReserveTable{ //0 represents Stored value;; - public static ArrayList arrrayProc = new ArrayList(); + public static ArrayList arrrayProc = new ArrayList();//Reserve Table for public static int procs = 0; + public static ArrayList oldestReserve = new ArrayList() public static void ResetReserve(){ arrayProc = new ArrayList(); } public static void addproc(int address, int processor){ - arrrayProc.get(processor).get(1).add(Integer.valueOf(address)); - } - public static void addbool(int address){ - arrrayProc.get(processor).get(0).add(Integer.valueOf(address)); + arrrayProc.get(processor).add(Integer.valueOf(address)); } public static void lr_w(int address, int processor){ - if(arrrayProc.get(processor).get(1).contains(Integer.valueOf(address))) + if(arrrayProc.get(processor).contains(Integer.valueOf(address))) return; addproc(address, processor); } - private static void addToRest(int address, int processor){ - if(procs = 0) - return; - for(int i = 0; i <= processor; i++){ - if(i == processor) - continue; - if(arrrayProc.get(i).get(1).contains(address)){ - arrrayProc.get(i).get(0).add(address) - } - } - } - public static boolean sc_w(int address, int processor){ - if(!arrrayProc.get(processor).get(1).contains(Integer.valueOf(address))){ - return false; // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt - } - if(arrrayProc.get(processor).get(0).contains(Integer.valueOf(address))){ - arrrayProc.get(processor).get(1).remove(Integer.valueOf(address)); - arrrayProc.get(processor).get(0).remove(Integer.valueOf(address)); + if(!arrrayProc.get(processor).contains(Integer.valueOf(address))){ return false; } - addToRest(address, processor); + for(int i = 0; i < procs; i++){ + if(arrrayProc.get(i).contains(address)){ + arrrayProc.remove(Integer.valueOf(address)); + } + } return true; } public static setProcs(int procces){ From 7ea28ab132a15df7a4c9dbdaea32d69cf6ae5461 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Thu, 27 May 2021 19:06:19 -0600 Subject: [PATCH 10/51] reservation table and tables --- src/rars/riscv/hardware/ReservationTable.java | 59 ++++++++++++++ .../riscv/hardware/ReservationTables.java | 58 ++++++++++++++ src/rars/riscv/hardware/ReserveTable.java | 79 ------------------- 3 files changed, 117 insertions(+), 79 deletions(-) create mode 100644 src/rars/riscv/hardware/ReservationTable.java create mode 100644 src/rars/riscv/hardware/ReservationTables.java delete mode 100644 src/rars/riscv/hardware/ReserveTable.java diff --git a/src/rars/riscv/hardware/ReservationTable.java b/src/rars/riscv/hardware/ReservationTable.java new file mode 100644 index 00000000..cf90b082 --- /dev/null +++ b/src/rars/riscv/hardware/ReservationTable.java @@ -0,0 +1,59 @@ +package rars.riscv.hardware; + +import java.util.ArrayList; + +/* +Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class ReservationTable { + private ArrayList table; + public final static int capacity = 8; + + public ReservationTable() { + table = new ArrayList(); + } + + public void reserveAddress(int address) { + if (table.size() == capacity) + table.remove(0); + table.add(Integer.valueOf(address)); + } + + public void unreserveAddress(int address) { + table.removeIf(val -> val == address); + } + + public boolean contains(int address) { + return table.contains(Integer.valueOf(address)); + } + + public Integer[] getAddresses() { + Integer[] addresses = new Integer[table.size()]; + for (int i = 0; i < addresses.length; i++) { + addresses[i] = table.get(i); + } + return addresses; + } +} diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java new file mode 100644 index 00000000..a1cfff28 --- /dev/null +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -0,0 +1,58 @@ +package rars.riscv.hardware; + +/* +Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class ReservationTables { + private ReservationTable[] reservationTables; + + public ReservationTables(int processors) { + reservationTables = new ReservationTable[processors]; + } + + public void reserveAddress(int processor, int address) { + reservationTables[processor].reserveAddress(address); + } + + public boolean unreserveAddress(int processor, int address) { + if (reservationTables[processor].contains(address)) { + for (ReservationTable reservationTable : reservationTables) { + reservationTable.unreserveAddress(address); + } + return true; + } + return false; + } + + public Integer[][] allAddresses() { + Integer[][] all = new Integer[reservationTables.length][ReservationTable.capacity]; + for (int i = 0; i < reservationTables.length; i++) { + for (int j = 0; j < ReservationTable.capacity; j++) { + all[i] = reservationTables[i].getAddresses(); + } + } + return all; + } +} diff --git a/src/rars/riscv/hardware/ReserveTable.java b/src/rars/riscv/hardware/ReserveTable.java deleted file mode 100644 index be0386e4..00000000 --- a/src/rars/riscv/hardware/ReserveTable.java +++ /dev/null @@ -1,79 +0,0 @@ -package rars.riscv.hardware; - -import java.util.ArrayList; - -/* -Copyright (c) 2021, Siva Chowdeswar Nandipati. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -(MIT license, http://www.opensource.org/licenses/mit-license.html) - */ - -public class ReserveTable{ - //0 represents Stored value;; - public static ArrayList arrrayProc = new ArrayList(); - public static int procs = 0; - public static void ResetReserve(){ - arrayProc = new ArrayList(); - } - - public static void addproc(int address, int processor){ - arrrayProc.get(processor).get(1).add(Integer.valueOf(address)); - } - - public static void addbool(int address){ - arrrayProc.get(processor).get(0).add(Integer.valueOf(address)); - } - - public static void lr_w(int address, int processor){ - if(arrrayProc.get(processor).get(1).contains(Integer.valueOf(address))) - return; - addproc(address, processor); - } - - private static void addToRest(int address, int processor){ - if(procs = 0) - return; - for(int i = 0; i <= processor; i++){ - if(i == processor) - continue; - if(arrrayProc.get(i).get(1).contains(address)){ - arrrayProc.get(i).get(0).add(address) - } - } - } - - public static boolean sc_w(int address, int processor){ - if(!arrrayProc.get(processor).get(1).contains(Integer.valueOf(address))){ - return false; // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt - } - if(arrrayProc.get(processor).get(0).contains(Integer.valueOf(address))){ - arrrayProc.get(processor).get(1).remove(Integer.valueOf(address)); - arrrayProc.get(processor).get(0).remove(Integer.valueOf(address)); - return false; - } - addToRest(address, processor); - return true; - } - public static setProcs(int procces){ - procs = procces; - } -} \ No newline at end of file From 37680f5cd85bef7ea077699d68d75534938dd67a Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Fri, 28 May 2021 10:25:02 +0530 Subject: [PATCH 11/51] Small change --- src/rars/riscv/hardware/ReservationTable.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rars/riscv/hardware/ReservationTable.java b/src/rars/riscv/hardware/ReservationTable.java index cf90b082..ed771da8 100644 --- a/src/rars/riscv/hardware/ReservationTable.java +++ b/src/rars/riscv/hardware/ReservationTable.java @@ -36,6 +36,8 @@ public ReservationTable() { } public void reserveAddress(int address) { + if(table.contains(Integer.valueOf(address))) + return; if (table.size() == capacity) table.remove(0); table.add(Integer.valueOf(address)); From 815f798a0903d5b37f7f0bcd18a76869369dd0e4 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 28 May 2021 02:41:34 -0600 Subject: [PATCH 12/51] basic tool --- src/rars/tools/ReservationTablesTool.java | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/rars/tools/ReservationTablesTool.java diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java new file mode 100644 index 00000000..dd079344 --- /dev/null +++ b/src/rars/tools/ReservationTablesTool.java @@ -0,0 +1,51 @@ +package rars.tools; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.GridLayout; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura. + +Developed by Giancarlo Pernudi Segura (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class ReservationTablesTool extends AbstractToolAndApplication { + private static String heading = "Reservation Table Tool"; + private static String version = "Version 1.0"; + + public ReservationTablesTool() { + super(heading + ", " + version, heading); + } + + protected JComponent buildMainDisplayArea() { + JPanel panelTools = new JPanel(new GridLayout(1, 2)); + return panelTools; + } + + @Override + public String getName() { + return heading; + } +} From f555edb5f4de364fec27e03a522d42568ff124b0 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Fri, 28 May 2021 22:07:47 +0530 Subject: [PATCH 13/51] 28 May --- src/images/Shared.png | Bin 0 -> 3124 bytes src/rars/api/Program.java | 2 -- src/rars/riscv/instructions/LR_W.java | 4 +--- src/rars/riscv/instructions/SC_W.java | 6 +----- 4 files changed, 2 insertions(+), 10 deletions(-) create mode 100644 src/images/Shared.png diff --git a/src/images/Shared.png b/src/images/Shared.png new file mode 100644 index 0000000000000000000000000000000000000000..320a5b1bef0ad16a7b438b6b5a21a823b532e942 GIT binary patch literal 3124 zcmZ`+2|Sc*7k}-HU1Uiag9tN&WEo5`*2+wH49&Fn9=v@MFH;M;rY+EaEFkhhC=Ok zXj!yf*LFo&|BBbC(2{za683nd55wDLH~tdmS$S}{t|hA}ptXPMNIag zld5aZv;wQDR26jb$y{B}ODYvXZjTz~j~a%mq-QHosuq^!R4u)-HCX z%EpW(`990u4C>#B8+WjFlP%QNo%frqMx&j-(mbT$Bv5`}_qYKL;KXe4`@ zs4A7G?NBF^xt8QMUD&xuZzj|AkKFnF5TxIvPpcx&O72N({HK`vCNBc0lkwJ<>(rt| zXV{uHuPGCAW-ka8*)L3ylkdTBbzMTcmi8&gF>Qh^Z8y19sp=_%FycYEx7~LmN@0){!5O2T0L)* zKQz7E>&qIo3dQ0OhM4G^`u-#yB=8-V*Y>PmZ}fH`Qx7ne~{Z=uwf>qD_`e)@wH; zRqXnuzGLkPVXws0&g?PH01M(GUC-Ps14+^SZqRT0-S{v@do|N>=;IF1Xy?DvyFwpP zGb-Jcdox_#vF2wl_mD3-%&#J3n8!C*ZdBa@Zjl-PK^l^^pe8AM6P&5ocN(3B9zh%z zIMR~?A)((r7#R&?k+Ut*PJNh44>j!G!J@Cz>W8|H7ikMk3{4CLJkA~`cp#z(j;SrC z4n-|bNy}t;tdu{L-1~gAfH<_<;kh(k?YX4w!neZ}%@(sV>Ckv&MRULb6xAH$N;P|D zV1-8BhT7x3>TZ@eA92`bmFWkf9#C4iv7D}-7qL7GQRAsFAUD7K;W!=-+qjsh_oQjd9^J|CMtO)Z7au!D=A&G%4 z;R&xdO3y`~FnE6Nd^c$wug~Ef=^3es6g}Dz94|SO`p2nP>!ZZw+J1q#G+aS_L*Cyh zoqY@Q-k^IL%6s`1+lrM|n&~alBc%cj*ZdZN>Ie;;jv$MjFXEG7w=tw5PMyz+dRs2{ zbp>gaY{Q@Y`n6)Q^Q~(@C9;&VX-iS0de5-xjKz1hJ6cN(RmiMtxKaoT)4)VztHqHIyb<@|G6$M58SL+pwV3q>Lb90cr_O}RyXKiN1W&NJGYJ3$ zy_l2b&e1X)0I=%d?3~C>mM0NDL4hzYbdWa&MhOgNvH*Pwf}sXt$X;MdAf7-%Pz)en z5eSCPG{Yg_uMl#80mRAD28;?KV!&E3HJBO%2?B$``b4xZ!q(XIJDu@l0P!P}gAs6e zXlN)b^e`-lh=r@`>gvMPG~gNnNOc|kuUY=(_*v&KM5mub4Xs~^zc_v&GV4HC6LA(rkf(-L;$>A>=l_%3^#TJ--=r_&}K+O`|Hn`*_w?&ppXwXP)Kq z5lN(sC*okScN5FYNl0DcxCCC8So5Bd!Du}z_1MPN_&LEDpLa{1)w^Tj6OTf8H^RTX zDkV+V4=kWrN>o#|$UGm{d6V}co^xK1Re?6jv^TgdhOx+7yl3wfPnno>GsV{KyELg? z(?0IQugJIX2`Qgb;p}-JF1cj4N8#7A#$E6zr~*^94WTYb+ig6dRLm77xN zuWY9G@^v)OBffj2mJ=vpave_veY9&j?ta+Qa?9RP; z(YTLqp>6m&Nb*ohLgcjR0KRRQ*UmA%b-3EIceZt_sEvx=jua~Tvm!9i5aN0zxbtlB z#%)@&`ao1&>P*gxgp5s1{bFLJ8C2|J$_0oU`JH9SP{#`{70PRV-r(};@jB5|8r7+a z_u`Vp`f&w(%%(2n4=#KAQ&Z34-w*yqZ`}r&CSh`nOm;I;3JtS!mEJh-3SZ>lCL4|3 z=&_6I9iHUQ?3az0e`3RiQ0x%s3y_K7?%HyjcmxMK!a6T6C&Q{bb6ex+6dsY5DpQ3V zWA7yA(R~U^#5m2Umz7|tBdG2}(Qtdbw9b*M;^G+wN^;XTJ0EY$T59q0zY}vi_)hEy>l6Xb$La zSUzRzg_jbX*Enp*`w8Xyg>x*u--EBp%#YaJ=Fc4HloZBx^6DiAXVVN1$}g-hoAT55 zy9MP|&s*FXeKhyi?$Rpk;c<@e2))`0UWw(;+*v-jUY9~FHIdLekYsWyyf6PG&mPWn z&Egg1)y|&9vhLyE?bc6waVa@^ogMN2h%EGx6wT%eSlCvy%j%ES5E)Z8Et0%28C=us z&~Y#HZ;2PSHTM-qIc|mR%`d-T`PNE};wTf5qK^kDZN67B4RXWc+U_6U&!-(OOPO{x7WtcWS65_>FBK z{8Mv>P{9%vgmp}gWHphNS3l`LCWRGWRPIAB%09+xsHm_%QOmdLJhvm(hJut#mBC$v zRoHc33sK5?HfLpc?+gyzw6dA7Z@MW*4?nxNRP1O;s7L;=h1qG+er;L;e`NZ6glF{r zsRiAlnB_5=)>T^1-DhV=Q3g{h2!YG-Gn!WYD~@vp?ReCaN{NQi^J7ijlj|C3SE75p z%|{>)C#xYN6-$StceS@dL{3OHea1qBdI}Ea%{`TONgmL_eW($~^Efjzr}M=}%lUEY`yDGy~>; O0bpTbWn5)+Chk9du~w7- literal 0 HcmV?d00001 diff --git a/src/rars/api/Program.java b/src/rars/api/Program.java index a5c8b589..f0b0f0db 100644 --- a/src/rars/api/Program.java +++ b/src/rars/api/Program.java @@ -54,7 +54,6 @@ public Program() { public Program(Options set){ Globals.initialize(false); - ReserveTable.ResetReserve(); this.set = set; code = new RISCVprogram(); assembled = new Memory(); @@ -131,7 +130,6 @@ private ErrorList assemble(ArrayList programs) throws AssemblyExce */ public void setup(ArrayList args, String STDIN){ RegisterFile.resetRegisters(); - ReserveTable.ResetReserve(); FloatingPointRegisterFile.resetRegisters(); ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LR_W.java index 849e2326..95717e9a 100644 --- a/src/rars/riscv/instructions/LR_W.java +++ b/src/rars/riscv/instructions/LR_W.java @@ -5,7 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; -import rars.riscv.hardware.ReserveTable; +import rars.riscv.hardware.ReservationTable; public class LR_W extends Atomic { @@ -23,9 +23,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long load(int address) throws AddressErrorException { - // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt - ReserveTable.lr_w1(address); return Globals.memory.getWord(address); } } diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SC_W.java index 1157de44..5248fd41 100644 --- a/src/rars/riscv/instructions/SC_W.java +++ b/src/rars/riscv/instructions/SC_W.java @@ -5,7 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; -import rars.riscv.hardware.ReserveTable; +import rars.riscv.hardware.ReservationTable; public class SC_W extends Atomic { public SC_W() { @@ -23,11 +23,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private int store(int address, int value) throws AddressErrorException { - // -------------------------------------------------> Doubt Doubt Doubt Doubt Doubt Doubt Doubt Doubt - if(ReserveTable.sc_w1(address)){ Globals.memory.setWord(address, value); return 0; - } - return -1; } } From c8bdb742ad8873c344ae0519d2a98aae7688e045 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Fri, 28 May 2021 22:32:57 +0530 Subject: [PATCH 14/51] 28 May --- src/rars/riscv/hardware/ReservationTables.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index a1cfff28..b860c72d 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -27,8 +27,13 @@ a copy of this software and associated documentation files (the public class ReservationTables { private ReservationTable[] reservationTables; - + private int processors; public ReservationTables(int processors) { + this.processors = processors; + reset(); + } + + public void reset(){ reservationTables = new ReservationTable[processors]; } From a6000a0093db6e765b3b9dd9eb409e8fc909f55e Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 28 May 2021 17:54:55 -0600 Subject: [PATCH 15/51] integrate reservation table with lr.w and sc.w --- src/rars/Globals.java | 8 +++++++- src/rars/api/Program.java | 1 + src/rars/riscv/hardware/ReservationTables.java | 3 +++ src/rars/riscv/instructions/LR_W.java | 3 +-- src/rars/riscv/instructions/SC_W.java | 4 +++- src/rars/tools/ReservationTablesTool.java | 5 ++++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/rars/Globals.java b/src/rars/Globals.java index 1696930d..4dbaf00d 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -2,6 +2,7 @@ import rars.assembler.SymbolTable; import rars.riscv.hardware.Memory; +import rars.riscv.hardware.ReservationTables; import rars.riscv.InstructionSet; import rars.riscv.SyscallNumberOverride; import rars.util.PropertiesFile; @@ -68,6 +69,10 @@ public class Globals { * Simulated memory component. **/ public static Memory memory; + /** + * Simulated reservation tables component. + **/ + public static ReservationTables reservationTables; /** * Lock variable used at head of synchronized block to guard memory and registers **/ @@ -166,7 +171,8 @@ public static Settings getSettings() { public static void initialize(boolean gui) { if (!initialized) { - memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory + memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory + reservationTables = new ReservationTables(1); symbolTable = new SymbolTable("global"); settings = new Settings(gui); instructionSet = new InstructionSet(); diff --git a/src/rars/api/Program.java b/src/rars/api/Program.java index f0b0f0db..26897876 100644 --- a/src/rars/api/Program.java +++ b/src/rars/api/Program.java @@ -130,6 +130,7 @@ private ErrorList assemble(ArrayList programs) throws AssemblyExce */ public void setup(ArrayList args, String STDIN){ RegisterFile.resetRegisters(); + Globals.reservationTables.reset(); FloatingPointRegisterFile.resetRegisters(); ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index b860c72d..6b7a3cd2 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -35,6 +35,9 @@ public ReservationTables(int processors) { public void reset(){ reservationTables = new ReservationTable[processors]; + for (int i = 0; i < reservationTables.length; i++) { + reservationTables[i] = new ReservationTable(); + } } public void reserveAddress(int processor, int address) { diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LR_W.java index 95717e9a..98aafd4d 100644 --- a/src/rars/riscv/instructions/LR_W.java +++ b/src/rars/riscv/instructions/LR_W.java @@ -5,7 +5,6 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; -import rars.riscv.hardware.ReservationTable; public class LR_W extends Atomic { @@ -23,7 +22,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long load(int address) throws AddressErrorException { - + Globals.reservationTables.reserveAddress(0, address); return Globals.memory.getWord(address); } } diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SC_W.java index 5248fd41..8e6d8952 100644 --- a/src/rars/riscv/instructions/SC_W.java +++ b/src/rars/riscv/instructions/SC_W.java @@ -5,7 +5,6 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; -import rars.riscv.hardware.ReservationTable; public class SC_W extends Atomic { public SC_W() { @@ -23,7 +22,10 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private int store(int address, int value) throws AddressErrorException { + if (Globals.reservationTables.unreserveAddress(0, address)) { Globals.memory.setWord(address, value); return 0; + } + return -1; } } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index dd079344..a5358116 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -3,6 +3,7 @@ import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.GridLayout; +import javax.swing.JTable; /* Copyright (c) 2021, Giancarlo Pernudi Segura. @@ -40,7 +41,9 @@ public ReservationTablesTool() { } protected JComponent buildMainDisplayArea() { - JPanel panelTools = new JPanel(new GridLayout(1, 2)); + JPanel panelTools = new JPanel(new GridLayout(2, 1)); + JTable reservations = new JTable(); + panelTools.add(reservations); return panelTools; } From f2911f927981d95351eb6049bf9850cdbc7b8a90 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 28 May 2021 22:15:28 -0600 Subject: [PATCH 16/51] show reservation table and help --- src/rars/riscv/hardware/ReservationTable.java | 10 ++-- .../riscv/hardware/ReservationTables.java | 37 ++++++++++++--- src/rars/tools/ReservationTablesTool.java | 47 ++++++++++++++++++- 3 files changed, 82 insertions(+), 12 deletions(-) diff --git a/src/rars/riscv/hardware/ReservationTable.java b/src/rars/riscv/hardware/ReservationTable.java index ed771da8..f7524c9c 100644 --- a/src/rars/riscv/hardware/ReservationTable.java +++ b/src/rars/riscv/hardware/ReservationTable.java @@ -52,9 +52,13 @@ public boolean contains(int address) { } public Integer[] getAddresses() { - Integer[] addresses = new Integer[table.size()]; - for (int i = 0; i < addresses.length; i++) { - addresses[i] = table.get(i); + Integer[] addresses = new Integer[capacity]; + for (int i = 0; i < capacity; i++) { + try { + addresses[i] = table.get(i); + } catch (IndexOutOfBoundsException e) { + addresses[i] = 0; + } } return addresses; } diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index 6b7a3cd2..f8b430b7 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -1,5 +1,10 @@ package rars.riscv.hardware; +import java.util.Collection; +import java.util.Observable; +import java.util.Observer; +import java.util.Vector; + /* Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. @@ -27,13 +32,15 @@ a copy of this software and associated documentation files (the public class ReservationTables { private ReservationTable[] reservationTables; - private int processors; + public int processors; + private Collection observables = new Vector<>(); + public ReservationTables(int processors) { this.processors = processors; reset(); } - public void reset(){ + public void reset() { reservationTables = new ReservationTable[processors]; for (int i = 0; i < reservationTables.length; i++) { reservationTables[i] = new ReservationTable(); @@ -54,13 +61,29 @@ public boolean unreserveAddress(int processor, int address) { return false; } - public Integer[][] allAddresses() { - Integer[][] all = new Integer[reservationTables.length][ReservationTable.capacity]; - for (int i = 0; i < reservationTables.length; i++) { - for (int j = 0; j < ReservationTable.capacity; j++) { - all[i] = reservationTables[i].getAddresses(); + public Integer[][] getAllAddresses() { + Integer[][] all = new Integer[ReservationTable.capacity][processors]; + for (int i = 0; i < ReservationTable.capacity; i++) { + for (int j = 0; j < processors; j++) { + Integer[] addresses = reservationTables[j].getAddresses(); + all[i][j] = addresses[j]; } } return all; } + + public void addObserver(Observer obs) { + observables.add(new ReservationTablesObservable(obs)); + } + + private class ReservationTablesObservable extends Observable { + public ReservationTablesObservable(Observer obs) { + this.addObserver(obs); + } + + public void notifyObserver(MemoryAccessNotice notice) { + this.setChanged(); + this.notifyObservers(notice); + } + } } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index a5358116..5aec0f02 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -1,9 +1,13 @@ package rars.tools; +import java.awt.GridLayout; +import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JOptionPane; import javax.swing.JPanel; -import java.awt.GridLayout; import javax.swing.JTable; +import rars.venus.NumberDisplayBaseChooser; +import rars.Globals; /* Copyright (c) 2021, Giancarlo Pernudi Segura. @@ -36,13 +40,20 @@ public class ReservationTablesTool extends AbstractToolAndApplication { private static String heading = "Reservation Table Tool"; private static String version = "Version 1.0"; + private String[][] addressStrings; + public ReservationTablesTool() { super(heading + ", " + version, heading); } protected JComponent buildMainDisplayArea() { JPanel panelTools = new JPanel(new GridLayout(2, 1)); - JTable reservations = new JTable(); + String[] columns = new String[Globals.reservationTables.processors]; + for (int i = 0; i < columns.length; i++) { + columns[i] = String.format("Processor %d", i); + } + updateDisplay(); + JTable reservations = new JTable(addressStrings, columns); panelTools.add(reservations); return panelTools; } @@ -51,4 +62,36 @@ protected JComponent buildMainDisplayArea() { public String getName() { return heading; } + + protected JComponent getHelpComponent() { + final String helpContent = "Use this tool to simulate atomic operations such as store conditional.\n" + + "While this tool is connected to the program, the table below shows the\n" + + "reservation table for each processor. Addresses reserved by a processor\n" + + "will appear under that processor's column. You can release an address, \n" + + "which will release that address across all the processor's tables in\n" + + "order to simulate some other processor performing a store conditional.\n" + + "(contributed by Giancarlo Pernudi Segura, pernudi@ualberta.ca)"; + JButton help = new JButton("Help"); + help.addActionListener(l -> { + JOptionPane.showMessageDialog(theWindow, helpContent); + }); + return help; + } + + @Override + protected void updateDisplay() { + Integer[][] addresses = Globals.reservationTables.getAllAddresses(); + addressStrings = new String[addresses.length][addresses[0].length]; + for (int i = 0; i < addressStrings.length; i++) { + for (int j = 0; j < addressStrings[i].length; j++) { + addressStrings[i][j] = NumberDisplayBaseChooser.formatNumber(addresses[i][j], 16); + } + } + } + + @Override + protected void reset() { + Globals.reservationTables.reset(); + updateDisplay(); + } } From af791d77133fef05c8f2b09e53c913515428c50c Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 28 May 2021 23:01:31 -0600 Subject: [PATCH 17/51] fix duplication of first cell --- .../riscv/hardware/ReservationTables.java | 2 +- src/rars/tools/ReservationTablesTool.java | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index f8b430b7..78a4f2a9 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -66,7 +66,7 @@ public Integer[][] getAllAddresses() { for (int i = 0; i < ReservationTable.capacity; i++) { for (int j = 0; j < processors; j++) { Integer[] addresses = reservationTables[j].getAddresses(); - all[i][j] = addresses[j]; + all[i][j] = addresses[i]; } } return all; diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 5aec0f02..0d2a3fcb 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -8,6 +8,7 @@ import javax.swing.JTable; import rars.venus.NumberDisplayBaseChooser; import rars.Globals; +import rars.riscv.hardware.ReservationTable; /* Copyright (c) 2021, Giancarlo Pernudi Segura. @@ -40,7 +41,7 @@ public class ReservationTablesTool extends AbstractToolAndApplication { private static String heading = "Reservation Table Tool"; private static String version = "Version 1.0"; - private String[][] addressStrings; + JTable reservations; public ReservationTablesTool() { super(heading + ", " + version, heading); @@ -48,12 +49,12 @@ public ReservationTablesTool() { protected JComponent buildMainDisplayArea() { JPanel panelTools = new JPanel(new GridLayout(2, 1)); - String[] columns = new String[Globals.reservationTables.processors]; - for (int i = 0; i < columns.length; i++) { - columns[i] = String.format("Processor %d", i); - } + reservations = new JTable(ReservationTable.capacity, Globals.reservationTables.processors); + // String[] columns = new String[Globals.reservationTables.processors]; + // for (int i = 0; i < columns.length; i++) { + // columns[i] = String.format("Processor %d", i); + // } updateDisplay(); - JTable reservations = new JTable(addressStrings, columns); panelTools.add(reservations); return panelTools; } @@ -81,10 +82,10 @@ protected JComponent getHelpComponent() { @Override protected void updateDisplay() { Integer[][] addresses = Globals.reservationTables.getAllAddresses(); - addressStrings = new String[addresses.length][addresses[0].length]; - for (int i = 0; i < addressStrings.length; i++) { - for (int j = 0; j < addressStrings[i].length; j++) { - addressStrings[i][j] = NumberDisplayBaseChooser.formatNumber(addresses[i][j], 16); + for (int i = 0; i < addresses.length; i++) { + for (int j = 0; j < addresses[i].length; j++) { + System.out.println(addresses[i][j]); + reservations.setValueAt(NumberDisplayBaseChooser.formatNumber(addresses[i][j], 16), i, j); } } } From 2d3e687728d29c5b0e449bcf06c17fd926a39812 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Sat, 29 May 2021 00:14:53 -0600 Subject: [PATCH 18/51] add table headers --- .../riscv/hardware/ReservationTables.java | 11 +++++++ src/rars/tools/ReservationTablesTool.java | 32 ++++++++++--------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index 78a4f2a9..16c041eb 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -72,6 +72,17 @@ public Integer[][] getAllAddresses() { return all; } + public String[][] getAllAddressesAsStrings() { + String[][] all = new String[ReservationTable.capacity][processors]; + for (int i = 0; i < ReservationTable.capacity; i++) { + for (int j = 0; j < processors; j++) { + Integer[] addresses = reservationTables[j].getAddresses(); + all[i][j] = String.format("0x%08x", addresses[i]); + } + } + return all; + } + public void addObserver(Observer obs) { observables.add(new ReservationTablesObservable(obs)); } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 0d2a3fcb..f6a7f97a 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -1,14 +1,13 @@ package rars.tools; -import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTable; -import rars.venus.NumberDisplayBaseChooser; + import rars.Globals; -import rars.riscv.hardware.ReservationTable; /* Copyright (c) 2021, Giancarlo Pernudi Segura. @@ -48,14 +47,18 @@ public ReservationTablesTool() { } protected JComponent buildMainDisplayArea() { - JPanel panelTools = new JPanel(new GridLayout(2, 1)); - reservations = new JTable(ReservationTable.capacity, Globals.reservationTables.processors); - // String[] columns = new String[Globals.reservationTables.processors]; - // for (int i = 0; i < columns.length; i++) { - // columns[i] = String.format("Processor %d", i); - // } - updateDisplay(); - panelTools.add(reservations); + JPanel panelTools = new JPanel(); + String[] columns = new String[Globals.reservationTables.processors]; + for (int i = 0; i < columns.length; i++) { + columns[i] = String.format("Processor %d", i); + } + reservations = new JTable(Globals.reservationTables.getAllAddressesAsStrings(), columns) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + panelTools.add(new JScrollPane(reservations)); return panelTools; } @@ -68,7 +71,7 @@ protected JComponent getHelpComponent() { final String helpContent = "Use this tool to simulate atomic operations such as store conditional.\n" + "While this tool is connected to the program, the table below shows the\n" + "reservation table for each processor. Addresses reserved by a processor\n" - + "will appear under that processor's column. You can release an address, \n" + + "will appear under that processor's column. You can release an address,\n" + "which will release that address across all the processor's tables in\n" + "order to simulate some other processor performing a store conditional.\n" + "(contributed by Giancarlo Pernudi Segura, pernudi@ualberta.ca)"; @@ -81,11 +84,10 @@ protected JComponent getHelpComponent() { @Override protected void updateDisplay() { - Integer[][] addresses = Globals.reservationTables.getAllAddresses(); + String[][] addresses = Globals.reservationTables.getAllAddressesAsStrings(); for (int i = 0; i < addresses.length; i++) { for (int j = 0; j < addresses[i].length; j++) { - System.out.println(addresses[i][j]); - reservations.setValueAt(NumberDisplayBaseChooser.formatNumber(addresses[i][j], 16), i, j); + reservations.setValueAt(addresses[i][j], i, j); } } } From 9de9f2eb90a20056ac40752b2126172930e02352 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Sat, 29 May 2021 04:03:40 -0600 Subject: [PATCH 19/51] unreserve selection --- src/rars/tools/ReservationTablesTool.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index f6a7f97a..35a564ab 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -6,6 +6,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.ListSelectionModel; import rars.Globals; @@ -58,7 +59,21 @@ public boolean isCellEditable(int row, int column) { return false; } }; + reservations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); panelTools.add(new JScrollPane(reservations)); + JButton clearButton = new JButton("Clear Selected"); + clearButton.addActionListener(l -> { + if (connectButton.isConnected()) { + int row = reservations.getSelectedRow(); + int col = reservations.getSelectedColumn(); + int address = Integer.parseInt(reservations.getValueAt(row, col) + .toString().substring(2), 16); + Globals.reservationTables.unreserveAddress(col, address); + } + reservations.clearSelection(); + updateDisplay(); + }); + panelTools.add(clearButton); return panelTools; } @@ -94,7 +109,9 @@ protected void updateDisplay() { @Override protected void reset() { - Globals.reservationTables.reset(); - updateDisplay(); + if (connectButton.isConnected()) { + Globals.reservationTables.reset(); + updateDisplay(); + } } } From 735c061a2e0cde659408f2824a808c7a22a2a26c Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Sat, 29 May 2021 17:34:16 +0530 Subject: [PATCH 20/51] Moved Clear to button area --- .../tools/AbstractToolAndApplication.java | 4 +-- src/rars/tools/ReservationTablesTool.java | 30 ++++++++++--------- src/rars/venus/run/RunAssembleAction.java | 1 + 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/rars/tools/AbstractToolAndApplication.java b/src/rars/tools/AbstractToolAndApplication.java index 2ef1518c..43784c12 100644 --- a/src/rars/tools/AbstractToolAndApplication.java +++ b/src/rars/tools/AbstractToolAndApplication.java @@ -68,7 +68,7 @@ public abstract class AbstractToolAndApplication extends JFrame implements Tool, protected boolean isBeingUsedAsATool = false; // can use to determine whether invoked as Tool or stand-alone. private JDialog dialog; // used only for Tool use. This is the pop-up dialog that appears when menu item selected. protected Window theWindow; // highest level GUI component (a JFrame for app, a JDialog for Tool) - + protected Box buttonArea; // Major GUI components private JLabel headingLabel; private String title; // descriptive title for title bar provided to constructor. @@ -262,7 +262,7 @@ protected JComponent buildHeadingArea() { * attach or detach simulator to memory, a button to reset the cache, and one to close the tool. */ protected JComponent buildButtonAreaForTool() { - Box buttonArea = Box.createHorizontalBox(); + buttonArea = Box.createHorizontalBox(); TitledBorder tc = new TitledBorder("Tool Control"); tc.setTitleJustification(TitledBorder.CENTER); buttonArea.setBorder(tc); diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 35a564ab..e0f0ad88 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -1,14 +1,8 @@ package rars.tools; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; - +import java.awt.GridLayout; import rars.Globals; +import javax.swing.*; /* Copyright (c) 2021, Giancarlo Pernudi Segura. @@ -48,7 +42,7 @@ public ReservationTablesTool() { } protected JComponent buildMainDisplayArea() { - JPanel panelTools = new JPanel(); + JPanel panelTools = new JPanel(new GridLayout()); String[] columns = new String[Globals.reservationTables.processors]; for (int i = 0; i < columns.length; i++) { columns[i] = String.format("Processor %d", i); @@ -60,8 +54,15 @@ public boolean isCellEditable(int row, int column) { } }; reservations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - panelTools.add(new JScrollPane(reservations)); + panelTools.add(reservations); + return panelTools; + } + + @Override + protected JComponent buildButtonAreaForTool(){ + super.buildButtonAreaForTool(); JButton clearButton = new JButton("Clear Selected"); + clearButton.setToolTipText("Clear the Selected from the Reserve Table"); clearButton.addActionListener(l -> { if (connectButton.isConnected()) { int row = reservations.getSelectedRow(); @@ -73,8 +74,11 @@ public boolean isCellEditable(int row, int column) { reservations.clearSelection(); updateDisplay(); }); - panelTools.add(clearButton); - return panelTools; + clearButton.addKeyListener(new EnterKeyListener(clearButton)); + buttonArea.add(clearButton); + buttonArea.add(Box.createHorizontalGlue()); + return buttonArea; + } @Override @@ -109,9 +113,7 @@ protected void updateDisplay() { @Override protected void reset() { - if (connectButton.isConnected()) { Globals.reservationTables.reset(); updateDisplay(); - } } } diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index 5e5bec6c..7f6b2395 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -124,6 +124,7 @@ public void actionPerformed(ActionEvent e) { FloatingPointRegisterFile.resetRegisters(); ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); + Globals.reservationTables.reset(); executePane.getTextSegmentWindow().setupTable(); executePane.getDataSegmentWindow().setupTable(); From a4183fefc8c0fcf93a5a83065e82da3d07921750 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Sat, 29 May 2021 17:45:02 +0530 Subject: [PATCH 21/51] Modified Clear Selected --- src/rars/tools/ReservationTablesTool.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index e0f0ad88..8728e32c 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -67,6 +67,8 @@ protected JComponent buildButtonAreaForTool(){ if (connectButton.isConnected()) { int row = reservations.getSelectedRow(); int col = reservations.getSelectedColumn(); + if(row < 0 || col < 0) + return; int address = Integer.parseInt(reservations.getValueAt(row, col) .toString().substring(2), 16); Globals.reservationTables.unreserveAddress(col, address); From 92cefca0f054eee9154d3918ff938c3f8b1d261a Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Sat, 29 May 2021 17:46:46 +0530 Subject: [PATCH 22/51] May 29 --- src/rars/tools/ReservationTablesTool.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 8728e32c..7d912650 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -5,9 +5,9 @@ import javax.swing.*; /* -Copyright (c) 2021, Giancarlo Pernudi Segura. +Copyright (c) 2021, Giancarlo Pernudi Segura & Siva Chowdeswar Nandipati. -Developed by Giancarlo Pernudi Segura (pernudi@ualberta.ca) +Developed by Giancarlo Pernudi Segura (pernudi@ualberta.ca) & Siva Chowdeswar Nandipati (sivachow@ualberta.ca). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From d60dfb56f0a45792fc47e9812981127316384231 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Sat, 29 May 2021 18:42:40 +0530 Subject: [PATCH 23/51] Reserve Table Layout --- src/rars/tools/ReservationTablesTool.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 7d912650..5f4f66cc 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -3,6 +3,7 @@ import java.awt.GridLayout; import rars.Globals; import javax.swing.*; +import java.awt.*; /* Copyright (c) 2021, Giancarlo Pernudi Segura & Siva Chowdeswar Nandipati. @@ -42,10 +43,10 @@ public ReservationTablesTool() { } protected JComponent buildMainDisplayArea() { - JPanel panelTools = new JPanel(new GridLayout()); + JPanel panelTools = new JPanel(new BorderLayout()); String[] columns = new String[Globals.reservationTables.processors]; for (int i = 0; i < columns.length; i++) { - columns[i] = String.format("Processor %d", i); + columns[i] = String.format("Processor %d", i + 1); } reservations = new JTable(Globals.reservationTables.getAllAddressesAsStrings(), columns) { @Override @@ -53,6 +54,7 @@ public boolean isCellEditable(int row, int column) { return false; } }; + panelTools.add(reservations.getTableHeader(), BorderLayout.NORTH); reservations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); panelTools.add(reservations); return panelTools; From 56deb618daff18eb2215f27bb505c777c40e8535 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Sat, 29 May 2021 19:19:38 +0530 Subject: [PATCH 24/51] Reserve Table Tool --- src/rars/tools/ReservationTablesTool.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 5f4f66cc..10b9252d 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -55,7 +55,8 @@ public boolean isCellEditable(int row, int column) { } }; panelTools.add(reservations.getTableHeader(), BorderLayout.NORTH); - reservations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + reservations.setCellSelectionEnabled(true); + reservations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); panelTools.add(reservations); return panelTools; } @@ -97,7 +98,8 @@ protected JComponent getHelpComponent() { + "will appear under that processor's column. You can release an address,\n" + "which will release that address across all the processor's tables in\n" + "order to simulate some other processor performing a store conditional.\n" - + "(contributed by Giancarlo Pernudi Segura, pernudi@ualberta.ca)"; + + "(contributed by Giancarlo Pernudi Segura, pernudi@ualberta.ca) &" + + "\n Siva Chowdeswar Nandipati (sivachow@ualberta.ca)"; JButton help = new JButton("Help"); help.addActionListener(l -> { JOptionPane.showMessageDialog(theWindow, helpContent); From 87d0808b70bedb200b219a1b7cfb4fc7fd2a1091 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Mon, 31 May 2021 23:30:52 +0530 Subject: [PATCH 25/51] Changed 'Processor' to Hart' --- .../riscv/hardware/ReservationTables.java | 24 +++++++++---------- src/rars/tools/ReservationTablesTool.java | 12 +++++----- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index 16c041eb..a1e3bea4 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -32,27 +32,27 @@ a copy of this software and associated documentation files (the public class ReservationTables { private ReservationTable[] reservationTables; - public int processors; + public int harts; private Collection observables = new Vector<>(); - public ReservationTables(int processors) { - this.processors = processors; + public ReservationTables(int harts) { + this.harts = harts; reset(); } public void reset() { - reservationTables = new ReservationTable[processors]; + reservationTables = new ReservationTable[harts]; for (int i = 0; i < reservationTables.length; i++) { reservationTables[i] = new ReservationTable(); } } - public void reserveAddress(int processor, int address) { - reservationTables[processor].reserveAddress(address); + public void reserveAddress(int hart, int address) { + reservationTables[hart].reserveAddress(address); } - public boolean unreserveAddress(int processor, int address) { - if (reservationTables[processor].contains(address)) { + public boolean unreserveAddress(int hart, int address) { + if (reservationTables[hart].contains(address)) { for (ReservationTable reservationTable : reservationTables) { reservationTable.unreserveAddress(address); } @@ -62,9 +62,9 @@ public boolean unreserveAddress(int processor, int address) { } public Integer[][] getAllAddresses() { - Integer[][] all = new Integer[ReservationTable.capacity][processors]; + Integer[][] all = new Integer[ReservationTable.capacity][harts]; for (int i = 0; i < ReservationTable.capacity; i++) { - for (int j = 0; j < processors; j++) { + for (int j = 0; j < harts; j++) { Integer[] addresses = reservationTables[j].getAddresses(); all[i][j] = addresses[i]; } @@ -73,9 +73,9 @@ public Integer[][] getAllAddresses() { } public String[][] getAllAddressesAsStrings() { - String[][] all = new String[ReservationTable.capacity][processors]; + String[][] all = new String[ReservationTable.capacity][harts]; for (int i = 0; i < ReservationTable.capacity; i++) { - for (int j = 0; j < processors; j++) { + for (int j = 0; j < harts; j++) { Integer[] addresses = reservationTables[j].getAddresses(); all[i][j] = String.format("0x%08x", addresses[i]); } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 10b9252d..798c8281 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -44,9 +44,9 @@ public ReservationTablesTool() { protected JComponent buildMainDisplayArea() { JPanel panelTools = new JPanel(new BorderLayout()); - String[] columns = new String[Globals.reservationTables.processors]; + String[] columns = new String[Globals.reservationTables.harts]; for (int i = 0; i < columns.length; i++) { - columns[i] = String.format("Processor %d", i + 1); + columns[i] = String.format("Hart %d", i); } reservations = new JTable(Globals.reservationTables.getAllAddressesAsStrings(), columns) { @Override @@ -94,10 +94,10 @@ public String getName() { protected JComponent getHelpComponent() { final String helpContent = "Use this tool to simulate atomic operations such as store conditional.\n" + "While this tool is connected to the program, the table below shows the\n" - + "reservation table for each processor. Addresses reserved by a processor\n" - + "will appear under that processor's column. You can release an address,\n" - + "which will release that address across all the processor's tables in\n" - + "order to simulate some other processor performing a store conditional.\n" + + "reservation table for each Hart. Addresses reserved by a Hart\n" + + "will appear under that Hart's column. You can release an address,\n" + + "which will release that address across all the Hart's tables in\n" + + "order to simulate some other Hart performing a store conditional.\n" + "(contributed by Giancarlo Pernudi Segura, pernudi@ualberta.ca) &" + "\n Siva Chowdeswar Nandipati (sivachow@ualberta.ca)"; JButton help = new JButton("Help"); From 60d1341ce03faed2619d1dc6208d0a86a4d415c6 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Tue, 1 Jun 2021 10:20:53 -0600 Subject: [PATCH 26/51] change hart in help window to lowercase --- src/rars/tools/ReservationTablesTool.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 798c8281..bbb07475 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -94,10 +94,10 @@ public String getName() { protected JComponent getHelpComponent() { final String helpContent = "Use this tool to simulate atomic operations such as store conditional.\n" + "While this tool is connected to the program, the table below shows the\n" - + "reservation table for each Hart. Addresses reserved by a Hart\n" - + "will appear under that Hart's column. You can release an address,\n" - + "which will release that address across all the Hart's tables in\n" - + "order to simulate some other Hart performing a store conditional.\n" + + "reservation table for each hart. Addresses reserved by a hart\n" + + "will appear under that hart's column. You can release an address,\n" + + "which will release that address across all the hart's tables in\n" + + "order to simulate some other hart performing a store conditional.\n" + "(contributed by Giancarlo Pernudi Segura, pernudi@ualberta.ca) &" + "\n Siva Chowdeswar Nandipati (sivachow@ualberta.ca)"; JButton help = new JButton("Help"); From 22c1477439cdc066590d259c2e240fad5f9a7ead Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Wed, 2 Jun 2021 12:49:24 -0600 Subject: [PATCH 27/51] add atomic instructions example --- examples/atomic.s | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/atomic.s diff --git a/examples/atomic.s b/examples/atomic.s new file mode 100644 index 00000000..01757c14 --- /dev/null +++ b/examples/atomic.s @@ -0,0 +1,15 @@ +.globl main +.data +num: + .word 0x12345678 + +.text +main: + la t0, num +retry: + lr.w t1, (t0) + # increment by 1 + addi t1, t1, 1 + sc.w t2, t1, (t0) + # if save fails; retry operations again + bne zero, t2, retry From 21ef508647bd6cb571c023f53b1b2fc567608bb6 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Wed, 2 Jun 2021 16:33:42 -0600 Subject: [PATCH 28/51] redefine all atomic instructions to be R type --- src/rars/riscv/BasicInstructionFormat.java | 1 - src/rars/riscv/instructions/Atomic.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rars/riscv/BasicInstructionFormat.java b/src/rars/riscv/BasicInstructionFormat.java index a037566a..fce2261f 100644 --- a/src/rars/riscv/BasicInstructionFormat.java +++ b/src/rars/riscv/BasicInstructionFormat.java @@ -42,5 +42,4 @@ public enum BasicInstructionFormat { B_FORMAT, // 2 src registers + small immediate shifted left U_FORMAT, // 1 dst register + large immediate J_FORMAT, // 1 dst register + large immediate for jumping - A_FORMAT, // 1 dst and 1 or 2 src register } diff --git a/src/rars/riscv/instructions/Atomic.java b/src/rars/riscv/instructions/Atomic.java index 335a9af9..5a8b8ffb 100644 --- a/src/rars/riscv/instructions/Atomic.java +++ b/src/rars/riscv/instructions/Atomic.java @@ -38,7 +38,7 @@ a copy of this software and associated documentation files (the */ public abstract class Atomic extends BasicInstruction { public Atomic(String usage, String description, String funct3, String funct5) { - super(usage, description, BasicInstructionFormat.A_FORMAT, + super(usage, description, BasicInstructionFormat.R_FORMAT, funct5 + " 00sssss ttttt " + funct3 + " fffff 0101111"); } } From ba9fd8ed7fd7e826ad56359af403689377b93d2d Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Wed, 2 Jun 2021 17:44:09 -0600 Subject: [PATCH 29/51] parent AMO class --- .../instructions/AtomicMemoryOperation.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/rars/riscv/instructions/AtomicMemoryOperation.java diff --git a/src/rars/riscv/instructions/AtomicMemoryOperation.java b/src/rars/riscv/instructions/AtomicMemoryOperation.java new file mode 100644 index 00000000..358543c5 --- /dev/null +++ b/src/rars/riscv/instructions/AtomicMemoryOperation.java @@ -0,0 +1,61 @@ +package rars.riscv.instructions; + +import rars.Globals; +import rars.ProgramStatement; +import rars.SimulationException; +import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.RegisterFile; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +/** + * Base class for all Atomic instructions + * + * @author Giancarlo Pernudi Segura + * @version May 2017 + */ +public abstract class AtomicMemoryOperation extends Atomic { + public AtomicMemoryOperation(String usage, String description, String funct3, String funct5) { + super(usage, description, funct5, funct3); + } + + public void simulate(ProgramStatement statement) throws SimulationException { + int[] operands = statement.getOperands(); + try { + int rs1Data = Globals.memory.getWord(RegisterFile.getValue(operands[1])); + int rs2Value = RegisterFile.getValue(operands[2]); + RegisterFile.updateRegister(operands[0], rs1Data); + rs1Data = binaryOperation(rs1Data, rs2Value); + Globals.memory.setWord(RegisterFile.getValue(operands[1]), rs1Data); + } catch (AddressErrorException e) { + throw new SimulationException(statement, e); + } + } + + protected abstract int binaryOperation(int value1, int value2); +} From 7a66fa1f4aacdb8808b1a10eb04cc7955276949d Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Thu, 3 Jun 2021 21:54:34 +0530 Subject: [PATCH 30/51] Fixing the glue before clearselect --- src/rars/Globals.java | 2 +- src/rars/tools/ReservationTablesTool.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rars/Globals.java b/src/rars/Globals.java index 4dbaf00d..c0d8ad81 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -172,7 +172,7 @@ public static Settings getSettings() { public static void initialize(boolean gui) { if (!initialized) { memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory - reservationTables = new ReservationTables(1); + reservationTables = new ReservationTables(2); symbolTable = new SymbolTable("global"); settings = new Settings(gui); instructionSet = new InstructionSet(); diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 798c8281..5f06f76a 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -80,6 +80,7 @@ protected JComponent buildButtonAreaForTool(){ updateDisplay(); }); clearButton.addKeyListener(new EnterKeyListener(clearButton)); + buttonArea.add(Box.createHorizontalGlue()); buttonArea.add(clearButton); buttonArea.add(Box.createHorizontalGlue()); return buttonArea; From 888a5614d0eeda1e7fe585eba6d903d3b1fa714f Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Sat, 5 Jun 2021 18:21:30 -0600 Subject: [PATCH 31/51] unreserve address on regular store --- src/PseudoOps.txt | 4 --- src/rars/Globals.java | 2 +- .../riscv/hardware/ReservationTables.java | 28 +++++++++++++++++-- .../instructions/{LR_W.java => LRW.java} | 4 +-- src/rars/riscv/instructions/SB.java | 4 +-- .../instructions/{SC_W.java => SCW.java} | 4 +-- src/rars/riscv/instructions/SH.java | 4 +-- src/rars/riscv/instructions/SW.java | 4 +-- src/rars/tools/ReservationTablesTool.java | 11 ++++++-- 9 files changed, 42 insertions(+), 23 deletions(-) rename src/rars/riscv/instructions/{LR_W.java => LRW.java} (94%) rename src/rars/riscv/instructions/{SC_W.java => SCW.java} (95%) diff --git a/src/PseudoOps.txt b/src/PseudoOps.txt index dcb8a6de..d9870286 100644 --- a/src/PseudoOps.txt +++ b/src/PseudoOps.txt @@ -265,7 +265,3 @@ fgt.s t1, f2, f3 ;fle.s RG1, RG2, RG3 ;#Floating Greater Than: if f1 > f2, fge.s t1, f2, f3 ;flt.s RG1, RG2, RG3 ;#Floating Greater Than or Equal: if f1 >= f2, set t1 to 1, else set t1 to 0 fgt.d t1, f2, f3 ;fle.d RG1, RG2, RG3 ;#Floating Greater Than (64 bit): if f1 > f2, set t1 to 1, else set t1 to 0 fge.d t1, f2, f3 ;flt.d RG1, RG2, RG3 ;#Floating Greater Than or Equal (64 bit): if f1 >= f2, set t1 to 1, else set t1 to 0 - -######################### atomic pseudo-ops ########################## -lr.w t1,(t2) ;lr.w RG1,(RG3) ;#Load Reserved Word : Set t1 to contents of effective memory word address and reserves memory word address -sc.w t1,t2,(t3) ;sc.w RG1,RG2,(RG3) ;#Store Conditional Word : Tries to store t2 contents into effective memory word address and returns store result in t1 diff --git a/src/rars/Globals.java b/src/rars/Globals.java index c0d8ad81..4dbaf00d 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -172,7 +172,7 @@ public static Settings getSettings() { public static void initialize(boolean gui) { if (!initialized) { memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory - reservationTables = new ReservationTables(2); + reservationTables = new ReservationTables(1); symbolTable = new SymbolTable("global"); settings = new Settings(gui); instructionSet = new InstructionSet(); diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index a1e3bea4..724410e2 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -5,6 +5,8 @@ import java.util.Observer; import java.util.Vector; +import rars.SimulationException; + /* Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. @@ -30,7 +32,7 @@ a copy of this software and associated documentation files (the (MIT license, http://www.opensource.org/licenses/mit-license.html) */ -public class ReservationTables { +public class ReservationTables extends Observable { private ReservationTable[] reservationTables; public int harts; private Collection observables = new Vector<>(); @@ -51,7 +53,10 @@ public void reserveAddress(int hart, int address) { reservationTables[hart].reserveAddress(address); } - public boolean unreserveAddress(int hart, int address) { + public boolean unreserveAddress(int hart, int address) throws AddressErrorException { + if (address % 4 != 0) { + throw new AddressErrorException("Reservation address not aligned to word boundary ", SimulationException.STORE_ADDRESS_MISALIGNED, address); + } if (reservationTables[hart].contains(address)) { for (ReservationTable reservationTable : reservationTables) { reservationTable.unreserveAddress(address); @@ -87,6 +92,25 @@ public void addObserver(Observer obs) { observables.add(new ReservationTablesObservable(obs)); } + /** + * Remove specified reservation tables observer + * + * @param obs Observer to be removed + */ + public void deleteObserver(Observer obs) { + for (ReservationTablesObservable o : observables) { + o.deleteObserver(obs); + } + } + + /** + * Remove all reservation tables observers + */ + public void deleteObservers() { + // just drop the collection + observables = new Vector<>(); + } + private class ReservationTablesObservable extends Observable { public ReservationTablesObservable(Observer obs) { this.addObserver(obs); diff --git a/src/rars/riscv/instructions/LR_W.java b/src/rars/riscv/instructions/LRW.java similarity index 94% rename from src/rars/riscv/instructions/LR_W.java rename to src/rars/riscv/instructions/LRW.java index 98aafd4d..17bb7c95 100644 --- a/src/rars/riscv/instructions/LR_W.java +++ b/src/rars/riscv/instructions/LRW.java @@ -7,8 +7,8 @@ import rars.riscv.hardware.RegisterFile; -public class LR_W extends Atomic { - public LR_W() { +public class LRW extends Atomic { + public LRW() { super("lr.w t1, (t2)", "Set t1 to contents of effective memory word address and reserve", "010", "00010"); } diff --git a/src/rars/riscv/instructions/SB.java b/src/rars/riscv/instructions/SB.java index bc8f3446..125f4bc0 100644 --- a/src/rars/riscv/instructions/SB.java +++ b/src/rars/riscv/instructions/SB.java @@ -36,9 +36,7 @@ public SB() { } public void store(int address, long data) throws AddressErrorException { + Globals.reservationTables.unreserveAddress(0, address & ~0b11); Globals.memory.setByte(address, (int)data & 0x000000FF); } } - - - diff --git a/src/rars/riscv/instructions/SC_W.java b/src/rars/riscv/instructions/SCW.java similarity index 95% rename from src/rars/riscv/instructions/SC_W.java rename to src/rars/riscv/instructions/SCW.java index 8e6d8952..8628db84 100644 --- a/src/rars/riscv/instructions/SC_W.java +++ b/src/rars/riscv/instructions/SCW.java @@ -6,8 +6,8 @@ import rars.SimulationException; import rars.riscv.hardware.RegisterFile; -public class SC_W extends Atomic { - public SC_W() { +public class SCW extends Atomic { + public SCW() { super("sc.w t0, t1, (t2)", "Try to store t1 to contents of effective memory word address, sets t0 to store attempt result", "010", "00011"); } diff --git a/src/rars/riscv/instructions/SH.java b/src/rars/riscv/instructions/SH.java index 829b6cba..99e00741 100644 --- a/src/rars/riscv/instructions/SH.java +++ b/src/rars/riscv/instructions/SH.java @@ -36,9 +36,7 @@ public SH() { } public void store(int address, long data) throws AddressErrorException { + Globals.reservationTables.unreserveAddress(0, address & ~0b11); Globals.memory.setHalf(address, (int)data & 0x0000FFFF); } } - - - diff --git a/src/rars/riscv/instructions/SW.java b/src/rars/riscv/instructions/SW.java index 73b3ca65..4ab55821 100644 --- a/src/rars/riscv/instructions/SW.java +++ b/src/rars/riscv/instructions/SW.java @@ -36,9 +36,7 @@ public SW() { } public void store(int address, long data) throws AddressErrorException { + Globals.reservationTables.unreserveAddress(0, address); Globals.memory.setWord(address, (int) data); } } - - - diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index da863ef2..369281dc 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -1,7 +1,8 @@ package rars.tools; -import java.awt.GridLayout; import rars.Globals; +import rars.riscv.hardware.AddressErrorException; + import javax.swing.*; import java.awt.*; @@ -40,6 +41,7 @@ public class ReservationTablesTool extends AbstractToolAndApplication { public ReservationTablesTool() { super(heading + ", " + version, heading); + Globals.reservationTables.addObserver(this); } protected JComponent buildMainDisplayArea() { @@ -74,7 +76,11 @@ protected JComponent buildButtonAreaForTool(){ return; int address = Integer.parseInt(reservations.getValueAt(row, col) .toString().substring(2), 16); - Globals.reservationTables.unreserveAddress(col, address); + try { + Globals.reservationTables.unreserveAddress(col, address); + } catch (AddressErrorException e) { + e.printStackTrace(); + } } reservations.clearSelection(); updateDisplay(); @@ -82,7 +88,6 @@ protected JComponent buildButtonAreaForTool(){ clearButton.addKeyListener(new EnterKeyListener(clearButton)); buttonArea.add(Box.createHorizontalGlue()); buttonArea.add(clearButton); - buttonArea.add(Box.createHorizontalGlue()); return buttonArea; } From 1cf1ea4d91280dc4c08193385f98de74e0e77d28 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Sat, 5 Jun 2021 18:22:16 -0600 Subject: [PATCH 32/51] implement rest of 32-bit atomic instructions --- src/rars/riscv/instructions/AMOADDW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOANDW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMAXUW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMAXW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMINUW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMINW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOORW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOSWAPW.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOXORW.java | 39 +++++++++++++++++++ .../instructions/AtomicMemoryOperation.java | 10 +++-- 10 files changed, 357 insertions(+), 4 deletions(-) create mode 100644 src/rars/riscv/instructions/AMOADDW.java create mode 100644 src/rars/riscv/instructions/AMOANDW.java create mode 100644 src/rars/riscv/instructions/AMOMAXUW.java create mode 100644 src/rars/riscv/instructions/AMOMAXW.java create mode 100644 src/rars/riscv/instructions/AMOMINUW.java create mode 100644 src/rars/riscv/instructions/AMOMINW.java create mode 100644 src/rars/riscv/instructions/AMOORW.java create mode 100644 src/rars/riscv/instructions/AMOSWAPW.java create mode 100644 src/rars/riscv/instructions/AMOXORW.java diff --git a/src/rars/riscv/instructions/AMOADDW.java b/src/rars/riscv/instructions/AMOADDW.java new file mode 100644 index 00000000..ab966d64 --- /dev/null +++ b/src/rars/riscv/instructions/AMOADDW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOADDW extends AtomicMemoryOperation { + public AMOADDW() { + super("amoadd.w t0, t1, (t2)", "Loads value at t2 and places it into t0, adds value t1 and t0 (new), and saves at memory location t2.", "010", "00000"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return value1 + value2; + } +} diff --git a/src/rars/riscv/instructions/AMOANDW.java b/src/rars/riscv/instructions/AMOANDW.java new file mode 100644 index 00000000..a781e417 --- /dev/null +++ b/src/rars/riscv/instructions/AMOANDW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOANDW extends AtomicMemoryOperation { + public AMOANDW() { + super("amoand.w t0, t1, (t2)", "Loads value at t2 and places it into t0, ANDS value t1 and t0 (new), and saves at memory location t2.", "010", "01100"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return value1 & value2; + } +} diff --git a/src/rars/riscv/instructions/AMOMAXUW.java b/src/rars/riscv/instructions/AMOMAXUW.java new file mode 100644 index 00000000..33087e06 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMAXUW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMAXUW extends AtomicMemoryOperation { + public AMOMAXUW() { + super("amomaxu.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest unsigned value between value t1 and t0 (new).", "010", "11100"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return Integer.compareUnsigned(value1, value2) > 0 ? value1 : value2; + } +} diff --git a/src/rars/riscv/instructions/AMOMAXW.java b/src/rars/riscv/instructions/AMOMAXW.java new file mode 100644 index 00000000..4dcb3e17 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMAXW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMAXW extends AtomicMemoryOperation { + public AMOMAXW() { + super("amomax.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest value between value t1 and t0 (new).", "010", "10100"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return Integer.max(value1, value2); + } +} diff --git a/src/rars/riscv/instructions/AMOMINUW.java b/src/rars/riscv/instructions/AMOMINUW.java new file mode 100644 index 00000000..cd4f6689 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMINUW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMINUW extends AtomicMemoryOperation { + public AMOMINUW() { + super("amominu.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest unsigned value between value t1 and t0 (new).", "010", "11000"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return Integer.compareUnsigned(value1, value2) < 0 ? value1 : value2; + } +} diff --git a/src/rars/riscv/instructions/AMOMINW.java b/src/rars/riscv/instructions/AMOMINW.java new file mode 100644 index 00000000..635ac8fd --- /dev/null +++ b/src/rars/riscv/instructions/AMOMINW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMINW extends AtomicMemoryOperation { + public AMOMINW() { + super("amomin.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest value between value t1 and t0 (new).", "010", "10000"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return Integer.min(value1, value2); + } +} diff --git a/src/rars/riscv/instructions/AMOORW.java b/src/rars/riscv/instructions/AMOORW.java new file mode 100644 index 00000000..b574a0f4 --- /dev/null +++ b/src/rars/riscv/instructions/AMOORW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOORW extends AtomicMemoryOperation { + public AMOORW() { + super("amoor.w t0, t1, (t2)", "Loads value at t2 and places it into t0, ORS value t1 and t0 (new), and saves at memory location t2.", "010", "01000"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return value1 | value2; + } +} diff --git a/src/rars/riscv/instructions/AMOSWAPW.java b/src/rars/riscv/instructions/AMOSWAPW.java new file mode 100644 index 00000000..f836f30c --- /dev/null +++ b/src/rars/riscv/instructions/AMOSWAPW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOSWAPW extends AtomicMemoryOperation { + public AMOSWAPW() { + super("amoswap.w t0, t1, (t2)", "Loads value at t2 and places it into t0, saves value t1 at memory location t2.", "010", "00001"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return value2; + } +} diff --git a/src/rars/riscv/instructions/AMOXORW.java b/src/rars/riscv/instructions/AMOXORW.java new file mode 100644 index 00000000..6a43df30 --- /dev/null +++ b/src/rars/riscv/instructions/AMOXORW.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOXORW extends AtomicMemoryOperation { + public AMOXORW() { + super("amoxor.w t0, t1, (t2)", "Loads value at t2 and places it into t0, XORS value t1 and t0 (new), and saves at memory location t2.", "010", "00100"); + } + + @Override + protected int binaryOperation(int value1, int value2) { + return value1 ^ value2; + } +} diff --git a/src/rars/riscv/instructions/AtomicMemoryOperation.java b/src/rars/riscv/instructions/AtomicMemoryOperation.java index 358543c5..03cf2f20 100644 --- a/src/rars/riscv/instructions/AtomicMemoryOperation.java +++ b/src/rars/riscv/instructions/AtomicMemoryOperation.java @@ -41,17 +41,19 @@ a copy of this software and associated documentation files (the */ public abstract class AtomicMemoryOperation extends Atomic { public AtomicMemoryOperation(String usage, String description, String funct3, String funct5) { - super(usage, description, funct5, funct3); + super(usage, description, funct3, funct5); } public void simulate(ProgramStatement statement) throws SimulationException { int[] operands = statement.getOperands(); try { - int rs1Data = Globals.memory.getWord(RegisterFile.getValue(operands[1])); - int rs2Value = RegisterFile.getValue(operands[2]); + int rs1Loc = RegisterFile.getValue(operands[2]); + Globals.reservationTables.unreserveAddress(0, rs1Loc); + int rs1Data = Globals.memory.getWord(rs1Loc); + int rs2Value = RegisterFile.getValue(operands[1]); RegisterFile.updateRegister(operands[0], rs1Data); rs1Data = binaryOperation(rs1Data, rs2Value); - Globals.memory.setWord(RegisterFile.getValue(operands[1]), rs1Data); + Globals.memory.setWord(rs1Loc, rs1Data); } catch (AddressErrorException e) { throw new SimulationException(statement, e); } From 8b0ce6ed3b1a5e0637b1aa602368c154e6827bb1 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Mon, 7 Jun 2021 15:21:30 +0530 Subject: [PATCH 33/51] Added To GUI --- src/rars/Globals.java | 7 ++- .../tools/AbstractToolAndApplication.java | 3 +- src/rars/tools/ReservationTablesTool.java | 60 +++++++++++++++---- 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/rars/Globals.java b/src/rars/Globals.java index 4dbaf00d..efcb36f6 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -145,6 +145,11 @@ public class Globals { public static boolean runSpeedPanelExists = false; + private static int harts = 1; + + public static int getHarts() { + return harts; + } private static String getCopyrightYears() { return "2003-2019"; } @@ -172,7 +177,7 @@ public static Settings getSettings() { public static void initialize(boolean gui) { if (!initialized) { memory = Memory.getInstance(); //clients can use Memory.getInstance instead of Globals.memory - reservationTables = new ReservationTables(1); + reservationTables = new ReservationTables(harts); symbolTable = new SymbolTable("global"); settings = new Settings(gui); instructionSet = new InstructionSet(); diff --git a/src/rars/tools/AbstractToolAndApplication.java b/src/rars/tools/AbstractToolAndApplication.java index 43784c12..f5fca64a 100644 --- a/src/rars/tools/AbstractToolAndApplication.java +++ b/src/rars/tools/AbstractToolAndApplication.java @@ -68,7 +68,6 @@ public abstract class AbstractToolAndApplication extends JFrame implements Tool, protected boolean isBeingUsedAsATool = false; // can use to determine whether invoked as Tool or stand-alone. private JDialog dialog; // used only for Tool use. This is the pop-up dialog that appears when menu item selected. protected Window theWindow; // highest level GUI component (a JFrame for app, a JDialog for Tool) - protected Box buttonArea; // Major GUI components private JLabel headingLabel; private String title; // descriptive title for title bar provided to constructor. @@ -262,7 +261,7 @@ protected JComponent buildHeadingArea() { * attach or detach simulator to memory, a button to reset the cache, and one to close the tool. */ protected JComponent buildButtonAreaForTool() { - buttonArea = Box.createHorizontalBox(); + Box buttonArea = Box.createHorizontalBox(); TitledBorder tc = new TitledBorder("Tool Control"); tc.setTitleJustification(TitledBorder.CENTER); buttonArea.setBorder(tc); diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 369281dc..102cfae4 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -2,9 +2,15 @@ import rars.Globals; import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.*; +import rars.util.Binary; +import rars.venus.*; import javax.swing.*; import java.awt.*; +import java.util.*; +import java.awt.event.*; +import javax.swing.border.TitledBorder; /* Copyright (c) 2021, Giancarlo Pernudi Segura & Siva Chowdeswar Nandipati. @@ -36,8 +42,19 @@ a copy of this software and associated documentation files (the public class ReservationTablesTool extends AbstractToolAndApplication { private static String heading = "Reservation Table Tool"; private static String version = "Version 1.0"; - - JTable reservations; + private static String displayPanelTitle; + private JPanel displayOptions, hartPanel; + private JComboBox hartWindow; + + private Integer[] SelectHartWindow(){ + Integer hartChoser[]; + hartChoser = new Integer[(Integer) Globals.getHarts()]; + for(int i = 0; i < Globals.getHarts(); i ++){ + hartChoser[i] = i; + } + return hartChoser; + } + private JTable reservations; public ReservationTablesTool() { super(heading + ", " + version, heading); @@ -46,6 +63,7 @@ public ReservationTablesTool() { protected JComponent buildMainDisplayArea() { JPanel panelTools = new JPanel(new BorderLayout()); + hartPanel = new JPanel(new BorderLayout()); String[] columns = new String[Globals.reservationTables.harts]; for (int i = 0; i < columns.length; i++) { columns[i] = String.format("Hart %d", i); @@ -56,16 +74,26 @@ public boolean isCellEditable(int row, int column) { return false; } }; - panelTools.add(reservations.getTableHeader(), BorderLayout.NORTH); + + hartPanel.add(reservations.getTableHeader(), BorderLayout.NORTH); reservations.setCellSelectionEnabled(true); reservations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - panelTools.add(reservations); - return panelTools; - } + hartPanel.add(reservations); + + TitledBorder tb = new TitledBorder(displayPanelTitle); + tb.setTitleJustification(TitledBorder.CENTER); + panelTools.setBorder(tb); + + Box displayOptions = Box.createHorizontalBox(); + hartWindow = new JComboBox<>(SelectHartWindow()); + hartWindow.setToolTipText("Technique for determining simulated transmitter device processing delay"); + //ToDo----------- + hartWindow.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + } + }); - @Override - protected JComponent buildButtonAreaForTool(){ - super.buildButtonAreaForTool(); JButton clearButton = new JButton("Clear Selected"); clearButton.setToolTipText("Clear the Selected from the Reserve Table"); clearButton.addActionListener(l -> { @@ -85,13 +113,21 @@ protected JComponent buildButtonAreaForTool(){ reservations.clearSelection(); updateDisplay(); }); + + displayOptions.add(Box.createHorizontalGlue()); + displayOptions.add(hartWindow); clearButton.addKeyListener(new EnterKeyListener(clearButton)); - buttonArea.add(Box.createHorizontalGlue()); - buttonArea.add(clearButton); - return buttonArea; + displayOptions.add(Box.createHorizontalGlue()); + displayOptions.add(clearButton); + displayOptions.add(Box.createHorizontalGlue()); + JSplitPane both = new JSplitPane(JSplitPane.VERTICAL_SPLIT, hartPanel, displayOptions); + both.setResizeWeight(0.5); + panelTools.add(both); + return panelTools; } + @Override public String getName() { return heading; From 3a5ab653a77c4a2a44dd3ab8e7db4031747bdd06 Mon Sep 17 00:00:00 2001 From: giancarlopernudisegura Date: Mon, 7 Jun 2021 17:06:21 -0600 Subject: [PATCH 34/51] atomic 64-bit support --- .../riscv/hardware/ReservationTables.java | 10 ++++- src/rars/riscv/instructions/AMOADDD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOADDW.java | 4 +- src/rars/riscv/instructions/AMOANDD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOANDW.java | 4 +- src/rars/riscv/instructions/AMOMAXD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMAXUD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMAXUW.java | 6 +-- src/rars/riscv/instructions/AMOMAXW.java | 6 +-- src/rars/riscv/instructions/AMOMIND.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMINUD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOMINUW.java | 6 +-- src/rars/riscv/instructions/AMOMINW.java | 6 +-- src/rars/riscv/instructions/AMOORD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOORW.java | 4 +- src/rars/riscv/instructions/AMOSWAPD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOSWAPW.java | 4 +- src/rars/riscv/instructions/AMOXORD.java | 39 +++++++++++++++++++ src/rars/riscv/instructions/AMOXORW.java | 4 +- src/rars/riscv/instructions/Atomic.java | 5 +++ .../instructions/AtomicMemoryOperation.java | 21 +++++++--- src/rars/riscv/instructions/LRD.java | 27 +++++++++++++ src/rars/riscv/instructions/LRW.java | 1 - src/rars/riscv/instructions/SCD.java | 31 +++++++++++++++ 24 files changed, 459 insertions(+), 31 deletions(-) create mode 100644 src/rars/riscv/instructions/AMOADDD.java create mode 100644 src/rars/riscv/instructions/AMOANDD.java create mode 100644 src/rars/riscv/instructions/AMOMAXD.java create mode 100644 src/rars/riscv/instructions/AMOMAXUD.java create mode 100644 src/rars/riscv/instructions/AMOMIND.java create mode 100644 src/rars/riscv/instructions/AMOMINUD.java create mode 100644 src/rars/riscv/instructions/AMOORD.java create mode 100644 src/rars/riscv/instructions/AMOSWAPD.java create mode 100644 src/rars/riscv/instructions/AMOXORD.java create mode 100644 src/rars/riscv/instructions/LRD.java create mode 100644 src/rars/riscv/instructions/SCD.java diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index 724410e2..b7646e51 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -6,6 +6,7 @@ import java.util.Vector; import rars.SimulationException; +import rars.riscv.InstructionSet; /* Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. @@ -49,12 +50,17 @@ public void reset() { } } - public void reserveAddress(int hart, int address) { + public void reserveAddress(int hart, int address) throws AddressErrorException { + int modulo = InstructionSet.rv64 ? 8 : 4; + if (address % modulo != 0) { + throw new AddressErrorException("Reservation address not aligned to word boundary ", SimulationException.LOAD_ADDRESS_MISALIGNED, address); + } reservationTables[hart].reserveAddress(address); } public boolean unreserveAddress(int hart, int address) throws AddressErrorException { - if (address % 4 != 0) { + int modulo = InstructionSet.rv64 ? 8 : 4; + if (address % modulo != 0) { throw new AddressErrorException("Reservation address not aligned to word boundary ", SimulationException.STORE_ADDRESS_MISALIGNED, address); } if (reservationTables[hart].contains(address)) { diff --git a/src/rars/riscv/instructions/AMOADDD.java b/src/rars/riscv/instructions/AMOADDD.java new file mode 100644 index 00000000..cef47d85 --- /dev/null +++ b/src/rars/riscv/instructions/AMOADDD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOADDD extends AtomicMemoryOperation { + public AMOADDD() { + super("amoadd.d t0, t1, (t2)", "Loads value at t2 and places it into t0, adds value t1 and t0 (new), and saves at memory location t2.", "00000", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return value1 + value2; + } +} diff --git a/src/rars/riscv/instructions/AMOADDW.java b/src/rars/riscv/instructions/AMOADDW.java index ab966d64..8cad4e46 100644 --- a/src/rars/riscv/instructions/AMOADDW.java +++ b/src/rars/riscv/instructions/AMOADDW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOADDW extends AtomicMemoryOperation { public AMOADDW() { - super("amoadd.w t0, t1, (t2)", "Loads value at t2 and places it into t0, adds value t1 and t0 (new), and saves at memory location t2.", "010", "00000"); + super("amoadd.w t0, t1, (t2)", "Loads value at t2 and places it into t0, adds value t1 and t0 (new), and saves at memory location t2.", "00000"); } @Override - protected int binaryOperation(int value1, int value2) { + protected long binaryOperation(long value1, long value2) { return value1 + value2; } } diff --git a/src/rars/riscv/instructions/AMOANDD.java b/src/rars/riscv/instructions/AMOANDD.java new file mode 100644 index 00000000..ca9b07af --- /dev/null +++ b/src/rars/riscv/instructions/AMOANDD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOANDD extends AtomicMemoryOperation { + public AMOANDD() { + super("amoand.d t0, t1, (t2)", "Loads value at t2 and places it into t0, ANDS value t1 and t0 (new), and saves at memory location t2.", "01100", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return value1 & value2; + } +} diff --git a/src/rars/riscv/instructions/AMOANDW.java b/src/rars/riscv/instructions/AMOANDW.java index a781e417..ade22070 100644 --- a/src/rars/riscv/instructions/AMOANDW.java +++ b/src/rars/riscv/instructions/AMOANDW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOANDW extends AtomicMemoryOperation { public AMOANDW() { - super("amoand.w t0, t1, (t2)", "Loads value at t2 and places it into t0, ANDS value t1 and t0 (new), and saves at memory location t2.", "010", "01100"); + super("amoand.w t0, t1, (t2)", "Loads value at t2 and places it into t0, ANDS value t1 and t0 (new), and saves at memory location t2.", "01100"); } @Override - protected int binaryOperation(int value1, int value2) { + protected long binaryOperation(long value1, long value2) { return value1 & value2; } } diff --git a/src/rars/riscv/instructions/AMOMAXD.java b/src/rars/riscv/instructions/AMOMAXD.java new file mode 100644 index 00000000..7f6de467 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMAXD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMAXD extends AtomicMemoryOperation { + public AMOMAXD() { + super("amomax.d t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest value between value t1 and t0 (new).", "10100", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return Long.max(value1, value2); + } +} diff --git a/src/rars/riscv/instructions/AMOMAXUD.java b/src/rars/riscv/instructions/AMOMAXUD.java new file mode 100644 index 00000000..eee095e9 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMAXUD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMAXUD extends AtomicMemoryOperation { + public AMOMAXUD() { + super("amomaxu.d t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest unsigned value between value t1 and t0 (new).", "11100", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return Long.compareUnsigned(value1, value2) > 0 ? value1 : value2; + } +} diff --git a/src/rars/riscv/instructions/AMOMAXUW.java b/src/rars/riscv/instructions/AMOMAXUW.java index 33087e06..e9a13139 100644 --- a/src/rars/riscv/instructions/AMOMAXUW.java +++ b/src/rars/riscv/instructions/AMOMAXUW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOMAXUW extends AtomicMemoryOperation { public AMOMAXUW() { - super("amomaxu.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest unsigned value between value t1 and t0 (new).", "010", "11100"); + super("amomaxu.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest unsigned value between value t1 and t0 (new).", "11100"); } @Override - protected int binaryOperation(int value1, int value2) { - return Integer.compareUnsigned(value1, value2) > 0 ? value1 : value2; + protected long binaryOperation(long value1, long value2) { + return Long.compareUnsigned(value1, value2) > 0 ? value1 : value2; } } diff --git a/src/rars/riscv/instructions/AMOMAXW.java b/src/rars/riscv/instructions/AMOMAXW.java index 4dcb3e17..fe20615f 100644 --- a/src/rars/riscv/instructions/AMOMAXW.java +++ b/src/rars/riscv/instructions/AMOMAXW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOMAXW extends AtomicMemoryOperation { public AMOMAXW() { - super("amomax.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest value between value t1 and t0 (new).", "010", "10100"); + super("amomax.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the greatest value between value t1 and t0 (new).", "10100"); } @Override - protected int binaryOperation(int value1, int value2) { - return Integer.max(value1, value2); + protected long binaryOperation(long value1, long value2) { + return Long.max(value1, value2); } } diff --git a/src/rars/riscv/instructions/AMOMIND.java b/src/rars/riscv/instructions/AMOMIND.java new file mode 100644 index 00000000..a339e477 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMIND.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMIND extends AtomicMemoryOperation { + public AMOMIND() { + super("amomin.d t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest value between value t1 and t0 (new).", "10000", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return Long.min(value1, value2); + } +} diff --git a/src/rars/riscv/instructions/AMOMINUD.java b/src/rars/riscv/instructions/AMOMINUD.java new file mode 100644 index 00000000..3f4e5348 --- /dev/null +++ b/src/rars/riscv/instructions/AMOMINUD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOMINUD extends AtomicMemoryOperation { + public AMOMINUD() { + super("amominu.d t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest unsigned value between value t1 and t0 (new).", "11000", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return Long.compareUnsigned(value1, value2) < 0 ? value1 : value2; + } +} diff --git a/src/rars/riscv/instructions/AMOMINUW.java b/src/rars/riscv/instructions/AMOMINUW.java index cd4f6689..c9ed5836 100644 --- a/src/rars/riscv/instructions/AMOMINUW.java +++ b/src/rars/riscv/instructions/AMOMINUW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOMINUW extends AtomicMemoryOperation { public AMOMINUW() { - super("amominu.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest unsigned value between value t1 and t0 (new).", "010", "11000"); + super("amominu.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest unsigned value between value t1 and t0 (new).", "11000"); } @Override - protected int binaryOperation(int value1, int value2) { - return Integer.compareUnsigned(value1, value2) < 0 ? value1 : value2; + protected long binaryOperation(long value1, long value2) { + return Long.compareUnsigned(value1, value2) < 0 ? value1 : value2; } } diff --git a/src/rars/riscv/instructions/AMOMINW.java b/src/rars/riscv/instructions/AMOMINW.java index 635ac8fd..f2f6d153 100644 --- a/src/rars/riscv/instructions/AMOMINW.java +++ b/src/rars/riscv/instructions/AMOMINW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOMINW extends AtomicMemoryOperation { public AMOMINW() { - super("amomin.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest value between value t1 and t0 (new).", "010", "10000"); + super("amomin.w t0, t1, (t2)", "Loads value at t2 and places it into t0, and saves at memory location t2, the lowest value between value t1 and t0 (new).", "10000"); } @Override - protected int binaryOperation(int value1, int value2) { - return Integer.min(value1, value2); + protected long binaryOperation(long value1, long value2) { + return Long.min(value1, value2); } } diff --git a/src/rars/riscv/instructions/AMOORD.java b/src/rars/riscv/instructions/AMOORD.java new file mode 100644 index 00000000..31a820ab --- /dev/null +++ b/src/rars/riscv/instructions/AMOORD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOORD extends AtomicMemoryOperation { + public AMOORD() { + super("amoor.d t0, t1, (t2)", "Loads value at t2 and places it into t0, ORS value t1 and t0 (new), and saves at memory location t2.", "01000", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return value1 | value2; + } +} diff --git a/src/rars/riscv/instructions/AMOORW.java b/src/rars/riscv/instructions/AMOORW.java index b574a0f4..8b97511a 100644 --- a/src/rars/riscv/instructions/AMOORW.java +++ b/src/rars/riscv/instructions/AMOORW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOORW extends AtomicMemoryOperation { public AMOORW() { - super("amoor.w t0, t1, (t2)", "Loads value at t2 and places it into t0, ORS value t1 and t0 (new), and saves at memory location t2.", "010", "01000"); + super("amoor.w t0, t1, (t2)", "Loads value at t2 and places it into t0, ORS value t1 and t0 (new), and saves at memory location t2.", "01000"); } @Override - protected int binaryOperation(int value1, int value2) { + protected long binaryOperation(long value1, long value2) { return value1 | value2; } } diff --git a/src/rars/riscv/instructions/AMOSWAPD.java b/src/rars/riscv/instructions/AMOSWAPD.java new file mode 100644 index 00000000..0cdccb0b --- /dev/null +++ b/src/rars/riscv/instructions/AMOSWAPD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOSWAPD extends AtomicMemoryOperation { + public AMOSWAPD() { + super("amoswap.d t0, t1, (t2)", "Loads value at t2 and places it into t0, saves value t1 at memory location t2.", "00001", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return value2; + } +} diff --git a/src/rars/riscv/instructions/AMOSWAPW.java b/src/rars/riscv/instructions/AMOSWAPW.java index f836f30c..f2522a29 100644 --- a/src/rars/riscv/instructions/AMOSWAPW.java +++ b/src/rars/riscv/instructions/AMOSWAPW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOSWAPW extends AtomicMemoryOperation { public AMOSWAPW() { - super("amoswap.w t0, t1, (t2)", "Loads value at t2 and places it into t0, saves value t1 at memory location t2.", "010", "00001"); + super("amoswap.w t0, t1, (t2)", "Loads value at t2 and places it into t0, saves value t1 at memory location t2.", "00001"); } @Override - protected int binaryOperation(int value1, int value2) { + protected long binaryOperation(long value1, long value2) { return value2; } } diff --git a/src/rars/riscv/instructions/AMOXORD.java b/src/rars/riscv/instructions/AMOXORD.java new file mode 100644 index 00000000..5e558c75 --- /dev/null +++ b/src/rars/riscv/instructions/AMOXORD.java @@ -0,0 +1,39 @@ +package rars.riscv.instructions; + +/* +Copyright (c) 2021, Giancarlo Pernudi Segura + +Developed by Giancarlo Pernudi Segura at the University of Alberta (pernudi@ualberta.ca) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +public class AMOXORD extends AtomicMemoryOperation { + public AMOXORD() { + super("amoxor.d t0, t1, (t2)", "Loads value at t2 and places it into t0, XORS value t1 and t0 (new), and saves at memory location t2.", "00100", true); + } + + @Override + protected long binaryOperation(long value1, long value2) { + return value1 ^ value2; + } +} diff --git a/src/rars/riscv/instructions/AMOXORW.java b/src/rars/riscv/instructions/AMOXORW.java index 6a43df30..10dc0759 100644 --- a/src/rars/riscv/instructions/AMOXORW.java +++ b/src/rars/riscv/instructions/AMOXORW.java @@ -29,11 +29,11 @@ a copy of this software and associated documentation files (the public class AMOXORW extends AtomicMemoryOperation { public AMOXORW() { - super("amoxor.w t0, t1, (t2)", "Loads value at t2 and places it into t0, XORS value t1 and t0 (new), and saves at memory location t2.", "010", "00100"); + super("amoxor.w t0, t1, (t2)", "Loads value at t2 and places it into t0, XORS value t1 and t0 (new), and saves at memory location t2.", "00100"); } @Override - protected int binaryOperation(int value1, int value2) { + protected long binaryOperation(long value1, long value2) { return value1 ^ value2; } } diff --git a/src/rars/riscv/instructions/Atomic.java b/src/rars/riscv/instructions/Atomic.java index 5a8b8ffb..8cd2cf2b 100644 --- a/src/rars/riscv/instructions/Atomic.java +++ b/src/rars/riscv/instructions/Atomic.java @@ -41,4 +41,9 @@ public Atomic(String usage, String description, String funct3, String funct5) { super(usage, description, BasicInstructionFormat.R_FORMAT, funct5 + " 00sssss ttttt " + funct3 + " fffff 0101111"); } + + public Atomic(String usage, String description, String funct3, String funct5, boolean rv64) { + super(usage, description, BasicInstructionFormat.R_FORMAT, + funct5 + " 00sssss ttttt " + funct3 + " fffff 0101111", rv64); + } } diff --git a/src/rars/riscv/instructions/AtomicMemoryOperation.java b/src/rars/riscv/instructions/AtomicMemoryOperation.java index 03cf2f20..88ab194a 100644 --- a/src/rars/riscv/instructions/AtomicMemoryOperation.java +++ b/src/rars/riscv/instructions/AtomicMemoryOperation.java @@ -3,6 +3,7 @@ import rars.Globals; import rars.ProgramStatement; import rars.SimulationException; +import rars.riscv.InstructionSet; import rars.riscv.hardware.AddressErrorException; import rars.riscv.hardware.RegisterFile; @@ -40,8 +41,12 @@ a copy of this software and associated documentation files (the * @version May 2017 */ public abstract class AtomicMemoryOperation extends Atomic { - public AtomicMemoryOperation(String usage, String description, String funct3, String funct5) { - super(usage, description, funct3, funct5); + public AtomicMemoryOperation(String usage, String description, String funct5) { + super(usage, description, "010", funct5); + } + + public AtomicMemoryOperation(String usage, String description, String funct5, boolean rv64) { + super(usage, description, rv64 ? "011" : "010", funct5, rv64); } public void simulate(ProgramStatement statement) throws SimulationException { @@ -49,15 +54,19 @@ public void simulate(ProgramStatement statement) throws SimulationException { try { int rs1Loc = RegisterFile.getValue(operands[2]); Globals.reservationTables.unreserveAddress(0, rs1Loc); - int rs1Data = Globals.memory.getWord(rs1Loc); - int rs2Value = RegisterFile.getValue(operands[1]); + long rs1Data = InstructionSet.rv64 ? Globals.memory.getDoubleWord(rs1Loc) : Globals.memory.getWord(rs1Loc); + long rs2Value = RegisterFile.getValueLong(operands[1]); RegisterFile.updateRegister(operands[0], rs1Data); rs1Data = binaryOperation(rs1Data, rs2Value); - Globals.memory.setWord(rs1Loc, rs1Data); + if (InstructionSet.rv64) { + Globals.memory.setDoubleWord(rs1Loc, rs1Data); + } else { + Globals.memory.setWord(rs1Loc, (int) rs1Data); + } } catch (AddressErrorException e) { throw new SimulationException(statement, e); } } - protected abstract int binaryOperation(int value1, int value2); + protected abstract long binaryOperation(long value1, long value2); } diff --git a/src/rars/riscv/instructions/LRD.java b/src/rars/riscv/instructions/LRD.java new file mode 100644 index 00000000..89ded3c5 --- /dev/null +++ b/src/rars/riscv/instructions/LRD.java @@ -0,0 +1,27 @@ +package rars.riscv.instructions; + +import rars.Globals; +import rars.riscv.hardware.AddressErrorException; +import rars.ProgramStatement; +import rars.SimulationException; +import rars.riscv.hardware.RegisterFile; + +public class LRD extends Atomic { + public LRD() { + super("lr.d t1, (t2)", "Set t1 to contents of effective memory word address and reserve", "011", "00010", true); + } + + public void simulate(ProgramStatement statement) throws SimulationException { + int[] operands = statement.getOperands(); + try { + RegisterFile.updateRegister(operands[0], load(RegisterFile.getValue(operands[1]))); + } catch (AddressErrorException e) { + throw new SimulationException(statement, e); + } + } + + private long load(int address) throws AddressErrorException { + Globals.reservationTables.reserveAddress(0, address); + return Globals.memory.getDoubleWord(address); + } +} diff --git a/src/rars/riscv/instructions/LRW.java b/src/rars/riscv/instructions/LRW.java index 17bb7c95..27731971 100644 --- a/src/rars/riscv/instructions/LRW.java +++ b/src/rars/riscv/instructions/LRW.java @@ -6,7 +6,6 @@ import rars.SimulationException; import rars.riscv.hardware.RegisterFile; - public class LRW extends Atomic { public LRW() { super("lr.w t1, (t2)", "Set t1 to contents of effective memory word address and reserve", "010", "00010"); diff --git a/src/rars/riscv/instructions/SCD.java b/src/rars/riscv/instructions/SCD.java new file mode 100644 index 00000000..2ebef073 --- /dev/null +++ b/src/rars/riscv/instructions/SCD.java @@ -0,0 +1,31 @@ +package rars.riscv.instructions; + +import rars.Globals; +import rars.riscv.hardware.AddressErrorException; +import rars.ProgramStatement; +import rars.SimulationException; +import rars.riscv.hardware.RegisterFile; + +public class SCD extends Atomic { + public SCD() { + super("sc.d t0, t1, (t2)", "Try to store t1 to contents of effective memory word address, sets t0 to store attempt result", "011", "00011", true); + } + + public void simulate(ProgramStatement statement) throws SimulationException { + int[] operands = statement.getOperands(); + try { + long result = store(RegisterFile.getValue(operands[2]), RegisterFile.getValue(operands[1])); + RegisterFile.updateRegister(operands[0], result); + } catch (AddressErrorException e) { + throw new SimulationException(statement, e); + } + } + + private long store(int address, int value) throws AddressErrorException { + if (Globals.reservationTables.unreserveAddress(0, address)) { + Globals.memory.setDoubleWord(address, value); + return 0; + } + return -1; + } +} From 665ec73218f98ff8af036380e1dbd7a2cd2bc303 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Tue, 8 Jun 2021 18:22:02 +0530 Subject: [PATCH 35/51] GUI for Harts --- src/rars/Globals.java | 10 + src/rars/tools/ReservationTablesTool.java | 19 +- src/rars/venus/GeneralExecutePane.java | 252 ++++++++++++++++++ src/rars/venus/GeneralMainPane.java | 113 ++++++++ src/rars/venus/GeneralVenusUI.java | 221 +++++++++++++++ .../venus/registers/GeneralRegistersPane.java | 97 +++++++ src/rars/venus/run/RunAssembleAction.java | 19 ++ 7 files changed, 726 insertions(+), 5 deletions(-) create mode 100644 src/rars/venus/GeneralExecutePane.java create mode 100644 src/rars/venus/GeneralMainPane.java create mode 100644 src/rars/venus/GeneralVenusUI.java create mode 100644 src/rars/venus/registers/GeneralRegistersPane.java diff --git a/src/rars/Globals.java b/src/rars/Globals.java index efcb36f6..332d70da 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -7,6 +7,7 @@ import rars.riscv.SyscallNumberOverride; import rars.util.PropertiesFile; import rars.venus.VenusUI; +import rars.venus.GeneralVenusUI; import java.util.ArrayList; import java.util.Enumeration; @@ -147,6 +148,15 @@ public class Globals { private static int harts = 1; + private static ArrayList hartWindows = new ArrayList(); + + + public static ArrayList getHartWindows(){ + GeneralVenusUI temp= new GeneralVenusUI("Window "+0); + hartWindows.add(temp); + return hartWindows; + } + public static int getHarts() { return harts; } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 102cfae4..234ce10a 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -44,7 +44,8 @@ public class ReservationTablesTool extends AbstractToolAndApplication { private static String version = "Version 1.0"; private static String displayPanelTitle; private JPanel displayOptions, hartPanel; - private JComboBox hartWindow; + private JComboBox hartWindowSelector; + protected ArrayList hartWindows = Globals.getHartWindows(); private Integer[] SelectHartWindow(){ Integer hartChoser[]; @@ -59,6 +60,11 @@ private Integer[] SelectHartWindow(){ public ReservationTablesTool() { super(heading + ", " + version, heading); Globals.reservationTables.addObserver(this); + + for(int i = 1; i < Globals.getHarts(); i++){ + GeneralVenusUI temp= new GeneralVenusUI("Window "+i); + hartWindows.add(temp); + } } protected JComponent buildMainDisplayArea() { @@ -85,12 +91,13 @@ public boolean isCellEditable(int row, int column) { panelTools.setBorder(tb); Box displayOptions = Box.createHorizontalBox(); - hartWindow = new JComboBox<>(SelectHartWindow()); - hartWindow.setToolTipText("Technique for determining simulated transmitter device processing delay"); + hartWindowSelector = new JComboBox<>(SelectHartWindow()); + hartWindowSelector.setToolTipText("Technique for determining simulated transmitter device processing delay"); //ToDo----------- - hartWindow.addActionListener( + hartWindowSelector.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { + hartWindows.get(0).setVisible(true); } }); @@ -115,7 +122,7 @@ public void actionPerformed(ActionEvent e) { }); displayOptions.add(Box.createHorizontalGlue()); - displayOptions.add(hartWindow); + displayOptions.add(hartWindowSelector); clearButton.addKeyListener(new EnterKeyListener(clearButton)); displayOptions.add(Box.createHorizontalGlue()); displayOptions.add(clearButton); @@ -165,3 +172,5 @@ protected void reset() { updateDisplay(); } } + + diff --git a/src/rars/venus/GeneralExecutePane.java b/src/rars/venus/GeneralExecutePane.java new file mode 100644 index 00000000..0a53e6d4 --- /dev/null +++ b/src/rars/venus/GeneralExecutePane.java @@ -0,0 +1,252 @@ +package rars.venus; + +import rars.Globals; +import rars.Settings; +import rars.venus.registers.ControlAndStatusWindow; +import rars.venus.registers.FloatingPointWindow; +import rars.venus.registers.RegistersWindow; + +import javax.swing.*; +import java.awt.*; + +/* +Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar + +Developed by Pete Sanderson (psanderson@otterbein.edu) +and Kenneth Vollmar (kenvollmar@missouristate.edu) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +/** + * Container for the execution-related windows. Currently displayed as a tabbed pane. + * + * @author Sanderson and Team JSpim + **/ + +public class GeneralExecutePane extends JDesktopPane { + private RegistersWindow registerValues; + private FloatingPointWindow fpRegValues; + private ControlAndStatusWindow csrValues; + private DataSegmentWindow dataSegment; + private TextSegmentWindow textSegment; + private LabelsWindow labelValues; + private GeneralVenusUI mainUI; + private NumberDisplayBaseChooser valueDisplayBase; + private NumberDisplayBaseChooser addressDisplayBase; + private boolean labelWindowVisible; + + /** + * initialize the Execute pane with major components + * + * @param mainUI the parent GUI + * @param regs window containing integer register set + * @param fpRegs window containing floating point register set + * @param csrRegs window containing the CSR set + */ + + public GeneralExecutePane(GeneralVenusUI mainUI, RegistersWindow regs, FloatingPointWindow fpRegs, ControlAndStatusWindow csrRegs) { + this.mainUI = mainUI; + // Although these are displayed in Data Segment, they apply to all three internal + // windows within the Execute pane. So they will be housed here. + addressDisplayBase = new NumberDisplayBaseChooser("Hexadecimal Addresses", + Globals.getSettings().getBooleanSetting(Settings.Bool.DISPLAY_ADDRESSES_IN_HEX)); + valueDisplayBase = new NumberDisplayBaseChooser("Hexadecimal Values", + Globals.getSettings().getBooleanSetting(Settings.Bool.DISPLAY_VALUES_IN_HEX));//VenusUI.DEFAULT_NUMBER_BASE); + addressDisplayBase.setToolTipText("If checked, displays all memory addresses in hexadecimal. Otherwise, decimal."); + valueDisplayBase.setToolTipText("If checked, displays all memory and register contents in hexadecimal. Otherwise, decimal."); + registerValues = regs; + fpRegValues = fpRegs; + csrValues = csrRegs; + textSegment = new TextSegmentWindow(); + labelValues = new LabelsWindow(); + labelWindowVisible = Globals.getSettings().getBooleanSetting(Settings.Bool.LABEL_WINDOW_VISIBILITY); + this.add(textSegment); // these 3 LOC moved up. DPS 3-Sept-2014 + this.add(labelValues); + textSegment.pack(); // these 3 LOC added. DPS 3-Sept-2014 + labelValues.pack(); + textSegment.setVisible(true); + labelValues.setVisible(labelWindowVisible); + + } + + /** + * This method will set the bounds of this JDesktopPane's internal windows + * relative to the current size of this JDesktopPane. Such an operation + * cannot be adequately done at constructor time because the actual + * size of the desktop pane window is not yet established. Layout manager + * is not a good option here because JDesktopPane does not work well with + * them (the whole idea of using JDesktopPane with internal frames is to + * have mini-frames that you can resize, move around, minimize, etc). This + * method should be invoked only once: the first time the Execute tab is + * selected (a change listener invokes it). We do not want it invoked + * on subsequent tab selections; otherwise, user manipulations of the + * internal frames would be lost the next time execute tab is selected. + */ + public void setWindowBounds() { + + int fullWidth = this.getSize().width - this.getInsets().left - this.getInsets().right; + int fullHeight = this.getSize().height - this.getInsets().top - this.getInsets().bottom; + int halfHeight = fullHeight / 2; + Dimension textDim = new Dimension((int) (fullWidth * .75), halfHeight); + Dimension lablDim = new Dimension((int) (fullWidth * .25), halfHeight); + Dimension textFullDim = new Dimension((int) (fullWidth), halfHeight); + if (labelWindowVisible) { + textSegment.setBounds(0, 0, textDim.width, textDim.height); + labelValues.setBounds(textDim.width + 1, 0, lablDim.width, lablDim.height); + } else { + textSegment.setBounds(0, 0, textFullDim.width, textFullDim.height); + labelValues.setBounds(0, 0, 0, 0); + } + } + + /** + * Show or hide the label window (symbol table). If visible, it is displayed + * to the right of the text segment and the latter is shrunk accordingly. + * + * @param visibility set to true or false + */ + + public void setLabelWindowVisibility(boolean visibility) { + if (!visibility && labelWindowVisible) { + labelWindowVisible = false; + textSegment.setVisible(false); + labelValues.setVisible(false); + setWindowBounds(); + textSegment.setVisible(true); + } else if (visibility && !labelWindowVisible) { + labelWindowVisible = true; + textSegment.setVisible(false); + setWindowBounds(); + textSegment.setVisible(true); + labelValues.setVisible(true); + } + } + + /** + * Clears out all components of the Execute tab: text segment + * display, data segment display, label display and register display. + * This will typically be done upon File->Close, Open, New. + */ + + public void clearPane() { + this.getTextSegmentWindow().clearWindow(); + this.getRegistersWindow().clearWindow(); + this.getFloatingPointWindow().clearWindow(); + this.getControlAndStatusWindow().clearWindow(); + this.getLabelsWindow().clearWindow(); + // seems to be required, to display cleared Execute tab contents... + if (mainUI.getMainPane().getSelectedComponent() == this) { + mainUI.getMainPane().setSelectedComponent(mainUI.getMainPane().getEditTabbedPane()); + mainUI.getMainPane().setSelectedComponent(this); + } + } + + /** + * Access the text segment window. + */ + public TextSegmentWindow getTextSegmentWindow() { + return textSegment; + } + + /** + * Access the register values window. + */ + public RegistersWindow getRegistersWindow() { + return registerValues; + } + + /** + * Access the floating point values window. + */ + public FloatingPointWindow getFloatingPointWindow() { + return fpRegValues; + } + + /** + * Access the Control and Status values window. + */ + public ControlAndStatusWindow getControlAndStatusWindow() { + return csrValues; + } + + /** + * Access the label values window. + */ + public LabelsWindow getLabelsWindow() { + return labelValues; + } + + /** + * Retrieve the number system base for displaying values (mem/register contents) + */ + public int getValueDisplayBase() { + return valueDisplayBase.getBase(); + } + + /** + * Retrieve the number system base for displaying memory addresses + */ + public int getAddressDisplayBase() { + return addressDisplayBase.getBase(); + } + + /** + * Retrieve component used to set numerical base (10 or 16) of data value display. + * + * @return the chooser + */ + public NumberDisplayBaseChooser getValueDisplayBaseChooser() { + return valueDisplayBase; + } + + /** + * Retrieve component used to set numerical base (10 or 16) of address display. + * + * @return the chooser + */ + public NumberDisplayBaseChooser getAddressDisplayBaseChooser() { + return addressDisplayBase; + } + + /** + * Update display of columns based on state of given chooser. Normally + * called only by the chooser's ItemListener. + * + * @param chooser the GUI object manipulated by the user to change number base + */ + public void numberDisplayBaseChanged(NumberDisplayBaseChooser chooser) { + if (chooser == valueDisplayBase) { + // Have all internal windows update their value columns + registerValues.updateRegisters(); + fpRegValues.updateRegisters(); + csrValues.updateRegisters(); + textSegment.updateBasicStatements(); + } else { // addressDisplayBase + // Have all internal windows update their address columns + labelValues.updateLabelAddresses(); + textSegment.updateCodeAddresses(); + textSegment.updateBasicStatements(); + } + } + +} \ No newline at end of file diff --git a/src/rars/venus/GeneralMainPane.java b/src/rars/venus/GeneralMainPane.java new file mode 100644 index 00000000..bab0ddae --- /dev/null +++ b/src/rars/venus/GeneralMainPane.java @@ -0,0 +1,113 @@ +package rars.venus; + +import rars.Globals; +import rars.venus.registers.ControlAndStatusWindow; +import rars.venus.registers.FloatingPointWindow; +import rars.venus.registers.RegistersWindow; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicTabbedPaneUI; +import java.awt.*; + + + /* +Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar + +Developed by Pete Sanderson (psanderson@otterbein.edu) +and Kenneth Vollmar (kenvollmar@missouristate.edu) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +/** + * Creates the tabbed areas in the UI and also created the internal windows that + * exist in them. + * + * @author Sanderson and Bumgarner + **/ + +public class GeneralMainPane extends JTabbedPane { + GeneralExecutePane executeTab; + EditTabbedPane editTabbedPane; + + private GeneralVenusUI mainUI; + + /** + * Constructor for the MainPane class. + **/ + + public GeneralMainPane(GeneralVenusUI appFrame, RegistersWindow regs, + FloatingPointWindow cop1Regs, ControlAndStatusWindow cop0Regs) { + super(); + this.mainUI = appFrame; + this.setTabPlacement(JTabbedPane.TOP); //LEFT); + if (this.getUI() instanceof BasicTabbedPaneUI) { + BasicTabbedPaneUI ui = (BasicTabbedPaneUI) this.getUI(); + } + + executeTab = new GeneralExecutePane(appFrame, regs, cop1Regs, cop0Regs); + String executeTabTitle = "Execute"; //"
 
E
x
e
c
u
t
e
 
"; + Icon executeTabIcon = null;//new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath+"Execute_tab.jpg"))); + + // this.addTab("
 
P
r
o
j
 
1", null, new JTabbedPane()); + // this.addTab("
 
P
r
o
j
 
2", null, new JTabbedPane()); + // this.addTab("
 
P
r
o
j
 
3", null, new JTabbedPane()); + // this.addTab("
 
P
r
o
j
 
4", null, new JTabbedPane()); + + this.addTab(executeTabTitle, executeTabIcon, executeTab); + + this.setToolTipTextAt(0, "View and control assembly language program execution. Enabled upon successful assemble."); + + } + + + /** + * Returns component containing editor display + * + * @return the editor tabbed pane + */ + public JComponent getEditTabbedPane() { + return editTabbedPane; + } + + /** + * returns component containing execution-time display + * + * @return the execute pane + */ + public GeneralExecutePane getExecutePane() { + return executeTab; + } + + /** + * returns component containing execution-time display. + * Same as getExecutePane(). + * + * @return the execute pane + */ + public GeneralExecutePane getExecuteTab() { + return executeTab; + } + +} \ No newline at end of file diff --git a/src/rars/venus/GeneralVenusUI.java b/src/rars/venus/GeneralVenusUI.java new file mode 100644 index 00000000..876c916f --- /dev/null +++ b/src/rars/venus/GeneralVenusUI.java @@ -0,0 +1,221 @@ +package rars.venus; + +import rars.Globals; +import rars.Settings; +import rars.riscv.InstructionSet; +import rars.riscv.dump.DumpFormatLoader; +import rars.simulator.Simulator; +import rars.venus.registers.*; +import rars.venus.run.*; +import rars.venus.settings.*; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.net.URL; + +/* +Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar + +Developed by Pete Sanderson (psanderson@otterbein.edu) +and Kenneth Vollmar (kenvollmar@missouristate.edu) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +/** + * Top level container for Venus GUI. + * + * @author Sanderson and Team JSpim + **/ + + /* Heavily modified by Pete Sanderson, July 2004, to incorporate JSPIMMenu and JSPIMToolbar + * not as subclasses of JMenuBar and JToolBar, but as instances of them. They are both + * here primarily so both can share the Action objects. + */ + +public class GeneralVenusUI extends JFrame { + GeneralVenusUI mainUI; + + private GeneralMainPane mainPane; + private GeneralRegistersPane registersPane; + private RegistersWindow registersTab; + private FloatingPointWindow fpTab; + private ControlAndStatusWindow csrTab; + private JSplitPane splitter, horizonSplitter; + JPanel north; + + private int frameState; // see windowActivated() and windowDeactivated() + + // PLEASE PUT THESE TWO (& THEIR METHODS) SOMEWHERE THEY BELONG, NOT HERE + private boolean reset = true; // registers/memory reset for execution + private boolean started = false; // started execution + + /** + * Constructor for the Class. Sets up a window object for the UI + * + * @param s Name of the window to be created. + **/ + + public GeneralVenusUI(String s) { + super(s); + mainUI = this; + + double screenWidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); + double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); + double mainWidthPct = (screenWidth < 1000.0) ? 0.67 : 0.73; + double mainHeightPct = (screenWidth < 1000.0) ? 0.60 : 0.65; + double registersWidthPct = (screenWidth < 1000.0) ? 0.18 : 0.22; + double registersHeightPct = (screenWidth < 1000.0) ? 0.72 : 0.80; + Dimension mainPanePreferredSize = new Dimension((int) (screenWidth * mainWidthPct), (int) (screenHeight * mainHeightPct)); + Dimension registersPanePreferredSize = new Dimension((int) (screenWidth * registersWidthPct), (int) (screenHeight * registersHeightPct)); + + + Globals.initialize(true); + + // image courtesy of NASA/JPL. + URL im = this.getClass().getResource(Globals.imagesPath + "RISC-V.png"); + if (im == null) { + System.out.println("Internal Error: images folder or file not found"); + System.exit(0); + } + Image mars = Toolkit.getDefaultToolkit().getImage(im); + this.setIconImage(mars); + // Everything in frame will be arranged on JPanel "center", which is only frame component. + // "center" has BorderLayout and 2 major components: + // -- panel (jp) on North with 2 components + // 1. toolbar + // 2. run speed slider. + // -- split pane (horizonSplitter) in center with 2 components side-by-side + // 1. split pane (splitter) with 2 components stacked + // a. main pane, with 2 tabs (edit, execute) + // b. messages pane with 2 tabs (rars, run I/O) + // 2. registers pane with 3 tabs (register file, coproc 0, coproc 1) + // I should probably run this breakdown out to full detail. The components are created + // roughly in bottom-up order; some are created in component constructors and thus are + // not visible here. + + registersTab = new RegistersWindow(); + fpTab = new FloatingPointWindow(); + csrTab = new ControlAndStatusWindow(); + registersPane = new GeneralRegistersPane(mainUI, registersTab, fpTab, csrTab); + registersPane.setPreferredSize(registersPanePreferredSize); + + //Insets defaultTabInsets = (Insets)UIManager.get("TabbedPane.tabInsets"); + //UIManager.put("TabbedPane.tabInsets", new Insets(1, 1, 1, 1)); + mainPane = new GeneralMainPane(mainUI, registersTab, fpTab, csrTab); + mainPane.remove(0); + //UIManager.put("TabbedPane.tabInsets", defaultTabInsets); + + mainPane.setPreferredSize(mainPanePreferredSize); + + horizonSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitter, registersPane); + horizonSplitter.setOneTouchExpandable(true); + horizonSplitter.resetToPreferredSizes(); + + JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel center = new JPanel(new BorderLayout()); + center.add(jp, BorderLayout.NORTH); + center.add(horizonSplitter); + + + // This is invoked when opening the app. It will set the app to + // appear at full screen size. + this.addWindowListener( + new WindowAdapter() { + public void windowOpened(WindowEvent e) { + mainUI.setExtendedState(JFrame.MAXIMIZED_BOTH); + } + }); + + this.pack(); + } + + + /** + * To set whether the register values are reset. + * + * @param b Boolean true if the register values have been reset. + **/ + + public void setReset(boolean b) { + reset = b; + } + + /** + * To set whether MIPS program execution has started. + * + * @param b true if the MIPS program execution has started. + **/ + + public void setStarted(boolean b) { + started = b; + } + + /** + * To find out whether the register values are reset. + * + * @return Boolean true if the register values have been reset. + **/ + + public boolean getReset() { + return reset; + } + + /** + * To find out whether MIPS program is currently executing. + * + * @return true if MIPS program is currently executing. + **/ + public boolean getStarted() { + return started; + } + + /** + * Get reference to messages pane associated with this GUI. + * + * @return MessagesPane object associated with the GUI. + **/ + + public GeneralMainPane getMainPane() { + return mainPane; + } + + /** + * Get reference to registers pane associated with this GUI. + * + * @return RegistersPane object associated with the GUI. + **/ + + public GeneralRegistersPane getRegistersPane() { + return registersPane; + } + + + private ImageIcon loadIcon(String name) { + return new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath + name))); + } + + private KeyStroke makeShortcut(int key) { + return KeyStroke.getKeyStroke(key, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); + } +} \ No newline at end of file diff --git a/src/rars/venus/registers/GeneralRegistersPane.java b/src/rars/venus/registers/GeneralRegistersPane.java new file mode 100644 index 00000000..c2f96dc9 --- /dev/null +++ b/src/rars/venus/registers/GeneralRegistersPane.java @@ -0,0 +1,97 @@ +package rars.venus.registers; + +import rars.venus.GeneralVenusUI; + +import javax.swing.*; + +/* +Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar + +Developed by Pete Sanderson (psanderson@otterbein.edu) +and Kenneth Vollmar (kenvollmar@missouristate.edu) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject +to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +(MIT license, http://www.opensource.org/licenses/mit-license.html) + */ + +/** + * Contains tabbed areas in the UI to display register contents + * + * @author Sanderson + * @version August 2005 + **/ + +public class GeneralRegistersPane extends JTabbedPane { + private RegistersWindow regsTab; + private FloatingPointWindow fpTab; + private ControlAndStatusWindow csrTab; + + private GeneralVenusUI mainUI; + + /** + * Constructor for the RegistersPane class. + **/ + + public GeneralRegistersPane(GeneralVenusUI appFrame, RegistersWindow regs, FloatingPointWindow cop1, + ControlAndStatusWindow cop0) { + super(); + this.mainUI = appFrame; + regsTab = regs; + fpTab = cop1; + csrTab = cop0; + regsTab.setVisible(true); + fpTab.setVisible(true); + csrTab.setVisible(true); + this.addTab("Registers", regsTab); + this.addTab("Floating Point", fpTab); + this.addTab("Control and Status", csrTab); + this.setToolTipTextAt(0, "CPU registers"); + this.setToolTipTextAt(1, "Floating point unit registers"); + this.setToolTipTextAt(2, "Control and Status registers"); + } + + /** + * Return component containing integer register set. + * + * @return integer register window + */ + public RegistersWindow getRegistersWindow() { + return regsTab; + } + + /** + * Return component containing floating point register set. + * + * @return floating point register window + */ + public FloatingPointWindow getFloatingPointWindow() { + return fpTab; + } + + /** + * Return component containing Control and Status register set. + * + * @return exceptions register window + */ + public ControlAndStatusWindow getControlAndStatusWindow() { + return csrTab; + } +} \ No newline at end of file diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index 7f6b2395..bf3a910f 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -1,11 +1,13 @@ package rars.venus.run; import rars.*; +import rars.Globals; import rars.riscv.hardware.*; import rars.util.FilenameFinder; import rars.util.SystemIO; import rars.venus.*; import rars.venus.registers.RegistersPane; +import rars.venus.registers.GeneralRegistersPane; import javax.swing.*; import java.awt.event.ActionEvent; @@ -51,10 +53,12 @@ public class RunAssembleAction extends GuiAction { // Threshold for adding filename to printed message of files being assembled. private static final int LINE_LENGTH_LIMIT = 60; private VenusUI mainUI; + private GeneralVenusUI gmainUI; public RunAssembleAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); + gmainUI = Globals.getHartWindows().get(0); mainUI = gui; } @@ -76,6 +80,10 @@ public void actionPerformed(ActionEvent e) { MessagesPane messagesPane = mainUI.getMessagesPane(); ExecutePane executePane = mainUI.getMainPane().getExecutePane(); RegistersPane registersPane = mainUI.getRegistersPane(); + + GeneralExecutePane gexecutePane = gmainUI.getMainPane().getExecutePane(); + GeneralRegistersPane gregistersPane = gmainUI.getRegistersPane(); + extendedAssemblerEnabled = Globals.getSettings().getBooleanSetting(Settings.Bool.EXTENDED_ASSEMBLER_ENABLED); warningsAreErrors = Globals.getSettings().getBooleanSetting(Settings.Bool.WARNINGS_ARE_ERRORS); if (FileStatus.getFile() != null) { @@ -126,6 +134,9 @@ public void actionPerformed(ActionEvent e) { InterruptController.reset(); Globals.reservationTables.reset(); + gexecutePane.getTextSegmentWindow().setupTable(); + gexecutePane.getLabelsWindow().setupTable(); + executePane.getTextSegmentWindow().setupTable(); executePane.getDataSegmentWindow().setupTable(); executePane.getDataSegmentWindow().highlightCellForAddress(Memory.dataBaseAddress); @@ -136,10 +147,18 @@ public void actionPerformed(ActionEvent e) { registersPane.getRegistersWindow().clearWindow(); registersPane.getFloatingPointWindow().clearWindow(); registersPane.getControlAndStatusWindow().clearWindow(); + + gregistersPane.getRegistersWindow().clearWindow(); + gregistersPane.getFloatingPointWindow().clearWindow(); + gregistersPane.getControlAndStatusWindow().clearWindow(); + mainUI.setReset(true); mainUI.setStarted(false); mainUI.getMainPane().setSelectedComponent(executePane); + gmainUI.setReset(true); + gmainUI.setStarted(false); + // Aug. 24, 2005 Ken Vollmar SystemIO.resetFiles(); // Ensure that I/O "file descriptors" are initialized for a new program run From 4fd92f599d16bd9bbfadfb61fc4f62eab1854458 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Tue, 8 Jun 2021 19:50:51 +0530 Subject: [PATCH 36/51] Added the GUI for Harts --- src/rars/venus/GeneralExecutePane.java | 15 +++------------ src/rars/venus/GeneralMainPane.java | 11 ----------- src/rars/venus/GeneralVenusUI.java | 12 ++++-------- src/rars/venus/run/RunAssembleAction.java | 3 +++ 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/rars/venus/GeneralExecutePane.java b/src/rars/venus/GeneralExecutePane.java index 0a53e6d4..d46da445 100644 --- a/src/rars/venus/GeneralExecutePane.java +++ b/src/rars/venus/GeneralExecutePane.java @@ -47,7 +47,6 @@ public class GeneralExecutePane extends JDesktopPane { private RegistersWindow registerValues; private FloatingPointWindow fpRegValues; private ControlAndStatusWindow csrValues; - private DataSegmentWindow dataSegment; private TextSegmentWindow textSegment; private LabelsWindow labelValues; private GeneralVenusUI mainUI; @@ -68,12 +67,6 @@ public GeneralExecutePane(GeneralVenusUI mainUI, RegistersWindow regs, FloatingP this.mainUI = mainUI; // Although these are displayed in Data Segment, they apply to all three internal // windows within the Execute pane. So they will be housed here. - addressDisplayBase = new NumberDisplayBaseChooser("Hexadecimal Addresses", - Globals.getSettings().getBooleanSetting(Settings.Bool.DISPLAY_ADDRESSES_IN_HEX)); - valueDisplayBase = new NumberDisplayBaseChooser("Hexadecimal Values", - Globals.getSettings().getBooleanSetting(Settings.Bool.DISPLAY_VALUES_IN_HEX));//VenusUI.DEFAULT_NUMBER_BASE); - addressDisplayBase.setToolTipText("If checked, displays all memory addresses in hexadecimal. Otherwise, decimal."); - valueDisplayBase.setToolTipText("If checked, displays all memory and register contents in hexadecimal. Otherwise, decimal."); registerValues = regs; fpRegValues = fpRegs; csrValues = csrRegs; @@ -81,9 +74,7 @@ public GeneralExecutePane(GeneralVenusUI mainUI, RegistersWindow regs, FloatingP labelValues = new LabelsWindow(); labelWindowVisible = Globals.getSettings().getBooleanSetting(Settings.Bool.LABEL_WINDOW_VISIBILITY); this.add(textSegment); // these 3 LOC moved up. DPS 3-Sept-2014 - this.add(labelValues); textSegment.pack(); // these 3 LOC added. DPS 3-Sept-2014 - labelValues.pack(); textSegment.setVisible(true); labelValues.setVisible(labelWindowVisible); @@ -105,11 +96,12 @@ public GeneralExecutePane(GeneralVenusUI mainUI, RegistersWindow regs, FloatingP public void setWindowBounds() { int fullWidth = this.getSize().width - this.getInsets().left - this.getInsets().right; - int fullHeight = this.getSize().height - this.getInsets().top - this.getInsets().bottom; + int fullHeight = this.getSize().height; int halfHeight = fullHeight / 2; Dimension textDim = new Dimension((int) (fullWidth * .75), halfHeight); Dimension lablDim = new Dimension((int) (fullWidth * .25), halfHeight); Dimension textFullDim = new Dimension((int) (fullWidth), halfHeight); + if (labelWindowVisible) { textSegment.setBounds(0, 0, textDim.width, textDim.height); labelValues.setBounds(textDim.width + 1, 0, lablDim.width, lablDim.height); @@ -138,7 +130,7 @@ public void setLabelWindowVisibility(boolean visibility) { textSegment.setVisible(false); setWindowBounds(); textSegment.setVisible(true); - labelValues.setVisible(true); + labelValues.setVisible(false); } } @@ -156,7 +148,6 @@ public void clearPane() { this.getLabelsWindow().clearWindow(); // seems to be required, to display cleared Execute tab contents... if (mainUI.getMainPane().getSelectedComponent() == this) { - mainUI.getMainPane().setSelectedComponent(mainUI.getMainPane().getEditTabbedPane()); mainUI.getMainPane().setSelectedComponent(this); } } diff --git a/src/rars/venus/GeneralMainPane.java b/src/rars/venus/GeneralMainPane.java index bab0ddae..37915826 100644 --- a/src/rars/venus/GeneralMainPane.java +++ b/src/rars/venus/GeneralMainPane.java @@ -49,7 +49,6 @@ a copy of this software and associated documentation files (the public class GeneralMainPane extends JTabbedPane { GeneralExecutePane executeTab; - EditTabbedPane editTabbedPane; private GeneralVenusUI mainUI; @@ -81,16 +80,6 @@ public GeneralMainPane(GeneralVenusUI appFrame, RegistersWindow regs, } - - /** - * Returns component containing editor display - * - * @return the editor tabbed pane - */ - public JComponent getEditTabbedPane() { - return editTabbedPane; - } - /** * returns component containing execution-time display * diff --git a/src/rars/venus/GeneralVenusUI.java b/src/rars/venus/GeneralVenusUI.java index 876c916f..8fa90537 100644 --- a/src/rars/venus/GeneralVenusUI.java +++ b/src/rars/venus/GeneralVenusUI.java @@ -79,7 +79,6 @@ public class GeneralVenusUI extends JFrame { public GeneralVenusUI(String s) { super(s); mainUI = this; - double screenWidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); double mainWidthPct = (screenWidth < 1000.0) ? 0.67 : 0.73; @@ -120,15 +119,12 @@ public GeneralVenusUI(String s) { registersPane = new GeneralRegistersPane(mainUI, registersTab, fpTab, csrTab); registersPane.setPreferredSize(registersPanePreferredSize); - //Insets defaultTabInsets = (Insets)UIManager.get("TabbedPane.tabInsets"); - //UIManager.put("TabbedPane.tabInsets", new Insets(1, 1, 1, 1)); mainPane = new GeneralMainPane(mainUI, registersTab, fpTab, csrTab); - mainPane.remove(0); - //UIManager.put("TabbedPane.tabInsets", defaultTabInsets); + mainPane.setPreferredSize(mainPanePreferredSize); - horizonSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitter, registersPane); + horizonSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainPane, registersPane); horizonSplitter.setOneTouchExpandable(true); horizonSplitter.resetToPreferredSizes(); @@ -136,14 +132,14 @@ public GeneralVenusUI(String s) { JPanel center = new JPanel(new BorderLayout()); center.add(jp, BorderLayout.NORTH); center.add(horizonSplitter); - + this.add(center); // This is invoked when opening the app. It will set the app to // appear at full screen size. this.addWindowListener( new WindowAdapter() { public void windowOpened(WindowEvent e) { - mainUI.setExtendedState(JFrame.MAXIMIZED_BOTH); + mainUI.pack(); } }); diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index bf3a910f..c45e5b90 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -137,6 +137,9 @@ public void actionPerformed(ActionEvent e) { gexecutePane.getTextSegmentWindow().setupTable(); gexecutePane.getLabelsWindow().setupTable(); + gexecutePane.getTextSegmentWindow().setCodeHighlighting(true); + gexecutePane.getTextSegmentWindow().highlightStepAtPC(); + executePane.getTextSegmentWindow().setupTable(); executePane.getDataSegmentWindow().setupTable(); executePane.getDataSegmentWindow().highlightCellForAddress(Memory.dataBaseAddress); From 58c3f0520a981753b0758cfdce5c55c0b8f17d93 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Wed, 9 Jun 2021 08:38:41 +0530 Subject: [PATCH 37/51] Bug fix for Window GUI --- src/rars/Globals.java | 2 -- src/rars/tools/ReservationTablesTool.java | 9 +++++++-- src/rars/venus/run/RunAssembleAction.java | 24 +++++++++++++---------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/rars/Globals.java b/src/rars/Globals.java index 332d70da..c5dd8f3e 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -152,8 +152,6 @@ public class Globals { public static ArrayList getHartWindows(){ - GeneralVenusUI temp= new GeneralVenusUI("Window "+0); - hartWindows.add(temp); return hartWindows; } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 234ce10a..843871bf 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -93,11 +93,16 @@ public boolean isCellEditable(int row, int column) { Box displayOptions = Box.createHorizontalBox(); hartWindowSelector = new JComboBox<>(SelectHartWindow()); hartWindowSelector.setToolTipText("Technique for determining simulated transmitter device processing delay"); - //ToDo----------- hartWindowSelector.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { - hartWindows.get(0).setVisible(true); + int i = hartWindowSelector.getSelectedIndex(); + if(i == 0) + return; + else{ + hartWindows.get(i-1).setVisible(true); + } + } }); diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index c45e5b90..858907d4 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -58,7 +58,8 @@ public class RunAssembleAction extends GuiAction { public RunAssembleAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); - gmainUI = Globals.getHartWindows().get(0); + if(Globals.getHarts() > 1) + gmainUI = Globals.getHartWindows().get(0); mainUI = gui; } @@ -80,9 +81,12 @@ public void actionPerformed(ActionEvent e) { MessagesPane messagesPane = mainUI.getMessagesPane(); ExecutePane executePane = mainUI.getMainPane().getExecutePane(); RegistersPane registersPane = mainUI.getRegistersPane(); - - GeneralExecutePane gexecutePane = gmainUI.getMainPane().getExecutePane(); - GeneralRegistersPane gregistersPane = gmainUI.getRegistersPane(); + GeneralExecutePane gexecutePane = null; + GeneralRegistersPane gregistersPane = null; + if(Globals.getHarts() > 1){ + gexecutePane = gmainUI.getMainPane().getExecutePane(); + gregistersPane = gmainUI.getRegistersPane(); + } extendedAssemblerEnabled = Globals.getSettings().getBooleanSetting(Settings.Bool.EXTENDED_ASSEMBLER_ENABLED); warningsAreErrors = Globals.getSettings().getBooleanSetting(Settings.Bool.WARNINGS_ARE_ERRORS); @@ -133,13 +137,13 @@ public void actionPerformed(ActionEvent e) { ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); Globals.reservationTables.reset(); - + if(Globals.getHarts() > 1){ gexecutePane.getTextSegmentWindow().setupTable(); gexecutePane.getLabelsWindow().setupTable(); gexecutePane.getTextSegmentWindow().setCodeHighlighting(true); gexecutePane.getTextSegmentWindow().highlightStepAtPC(); - + } executePane.getTextSegmentWindow().setupTable(); executePane.getDataSegmentWindow().setupTable(); executePane.getDataSegmentWindow().highlightCellForAddress(Memory.dataBaseAddress); @@ -150,17 +154,17 @@ public void actionPerformed(ActionEvent e) { registersPane.getRegistersWindow().clearWindow(); registersPane.getFloatingPointWindow().clearWindow(); registersPane.getControlAndStatusWindow().clearWindow(); - + if(Globals.getHarts() > 1){ gregistersPane.getRegistersWindow().clearWindow(); gregistersPane.getFloatingPointWindow().clearWindow(); gregistersPane.getControlAndStatusWindow().clearWindow(); - + gmainUI.setReset(true); + gmainUI.setStarted(false); + } mainUI.setReset(true); mainUI.setStarted(false); mainUI.getMainPane().setSelectedComponent(executePane); - gmainUI.setReset(true); - gmainUI.setStarted(false); // Aug. 24, 2005 Ken Vollmar SystemIO.resetFiles(); // Ensure that I/O "file descriptors" are initialized for a new program run From 4875de96774c54c0ae85c0c6060d54779958d973 Mon Sep 17 00:00:00 2001 From: giancarlopernudisegura Date: Wed, 9 Jun 2021 09:00:30 -0600 Subject: [PATCH 38/51] categorize atomic instructions in statistics tool --- src/rars/tools/InstructionStatistics.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rars/tools/InstructionStatistics.java b/src/rars/tools/InstructionStatistics.java index ef96d88d..1f63d9c9 100644 --- a/src/rars/tools/InstructionStatistics.java +++ b/src/rars/tools/InstructionStatistics.java @@ -259,6 +259,8 @@ protected int getInstructionCategory(Instruction instruction) { return InstructionStatistics.CATEGORY_MEM; // lb, lh, lwl, lw, lbu, lhu, lwr if (instruction instanceof Store) return InstructionStatistics.CATEGORY_MEM; // sb, sh, swl, sw, swr + if (instruction instanceof Atomic) + return InstructionStatistics.CATEGORY_MEM; // a extension return InstructionStatistics.CATEGORY_OTHER; } From 095b7158517a2fabc70eac0466a374a9281692f4 Mon Sep 17 00:00:00 2001 From: giancarlopernudisegura Date: Wed, 9 Jun 2021 13:08:54 -0600 Subject: [PATCH 39/51] update getInstructionCategory description for instruction support --- src/rars/tools/InstructionStatistics.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rars/tools/InstructionStatistics.java b/src/rars/tools/InstructionStatistics.java index 1f63d9c9..dde83937 100644 --- a/src/rars/tools/InstructionStatistics.java +++ b/src/rars/tools/InstructionStatistics.java @@ -226,7 +226,7 @@ protected void addAsObserver() { * decodes the instruction and determines the category of the instruction. *

* The instruction is decoded by checking the java instance of the instruction. - * Only the most relevant instructions are decoded and categorized. + * Supported instructions are RV32I, RV64I, M, and A extensions. * * @param instruction the instruction to decode * @return the category of the instruction From 9cf6d0a623246d535dd099a5851a3423b85dac7c Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Wed, 9 Jun 2021 15:33:41 -0600 Subject: [PATCH 40/51] add mhartid csr --- src/rars/riscv/hardware/ControlAndStatusRegisterFile.java | 4 +++- src/rars/venus/registers/ControlAndStatusWindow.java | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rars/riscv/hardware/ControlAndStatusRegisterFile.java b/src/rars/riscv/hardware/ControlAndStatusRegisterFile.java index bf1d88dc..0b4bfc66 100644 --- a/src/rars/riscv/hardware/ControlAndStatusRegisterFile.java +++ b/src/rars/riscv/hardware/ControlAndStatusRegisterFile.java @@ -70,13 +70,15 @@ public class ControlAndStatusRegisterFile { null, // cycleh null, // timeh null, // instreth + null, // mhartid }; tmp[1] = new LinkedRegister("fflags", 0x001, tmp[3], 0x1F); tmp[2] = new LinkedRegister("frm", 0x002, tmp[3], 0xE0); tmp[14] = new LinkedRegister("cycleh", 0xC80,tmp[11], 0xFFFFFFFF_00000000L); tmp[15] = new LinkedRegister("timeh", 0xC81, tmp[12],0xFFFFFFFF_00000000L); - tmp[16] = new LinkedRegister("instreth",0xC82, tmp[13],0xFFFFFFFF_00000000L); + tmp[16] = new LinkedRegister("instreth", 0xC82, tmp[13], 0xFFFFFFFF_00000000L); + tmp[17] = new ReadOnlyRegister("mhartid", 0xF10, 0); instance = new RegisterBlock('_', tmp); // prefix not used } diff --git a/src/rars/venus/registers/ControlAndStatusWindow.java b/src/rars/venus/registers/ControlAndStatusWindow.java index 3fb21358..743ad022 100644 --- a/src/rars/venus/registers/ControlAndStatusWindow.java +++ b/src/rars/venus/registers/ControlAndStatusWindow.java @@ -28,7 +28,8 @@ public class ControlAndStatusWindow extends RegisterBlockWindow { /*instret*/"Instructions retired (same as cycle in RARS)", /*cycleh*/ "High 32 bits of cycle", /*timeh*/ "High 32 bits of time", - /*instreth*/ "High 32 bits of instret" + /*instreth*/ "High 32 bits of instret", + /*mhartid*/"ID of the hardware thread running the code" }; public ControlAndStatusWindow() { @@ -54,4 +55,4 @@ protected void endObserving() { public void resetRegisters() { ControlAndStatusRegisterFile.resetRegisters(); } -} \ No newline at end of file +} From a72d74e92a1f46d83b53b76e7ff5c8704cd655bd Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Wed, 9 Jun 2021 16:28:38 -0600 Subject: [PATCH 41/51] sc.w/d returns unspecified failiure --- src/rars/riscv/instructions/SCD.java | 2 +- src/rars/riscv/instructions/SCW.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rars/riscv/instructions/SCD.java b/src/rars/riscv/instructions/SCD.java index 2ebef073..a70b30b7 100644 --- a/src/rars/riscv/instructions/SCD.java +++ b/src/rars/riscv/instructions/SCD.java @@ -26,6 +26,6 @@ private long store(int address, int value) throws AddressErrorException { Globals.memory.setDoubleWord(address, value); return 0; } - return -1; + return 1; } } diff --git a/src/rars/riscv/instructions/SCW.java b/src/rars/riscv/instructions/SCW.java index 8628db84..d87760c0 100644 --- a/src/rars/riscv/instructions/SCW.java +++ b/src/rars/riscv/instructions/SCW.java @@ -26,6 +26,6 @@ private int store(int address, int value) throws AddressErrorException { Globals.memory.setWord(address, value); return 0; } - return -1; + return 1; } } From d3c92b3de039285ad6e80b98eaeb1773327dab28 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Thu, 10 Jun 2021 07:19:11 +0530 Subject: [PATCH 42/51] Moving the Harts to Globals --- src/rars/tools/ReservationTablesTool.java | 5 +---- src/rars/venus/run/RunAssembleAction.java | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 843871bf..0ec04ffc 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -61,10 +61,7 @@ public ReservationTablesTool() { super(heading + ", " + version, heading); Globals.reservationTables.addObserver(this); - for(int i = 1; i < Globals.getHarts(); i++){ - GeneralVenusUI temp= new GeneralVenusUI("Window "+i); - hartWindows.add(temp); - } + } protected JComponent buildMainDisplayArea() { diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index 858907d4..f483a0af 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -54,10 +54,15 @@ public class RunAssembleAction extends GuiAction { private static final int LINE_LENGTH_LIMIT = 60; private VenusUI mainUI; private GeneralVenusUI gmainUI; + protected ArrayList hartWindows = Globals.getHartWindows(); public RunAssembleAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); + for(int i = 1; i < Globals.getHarts(); i++){ + GeneralVenusUI temp= new GeneralVenusUI("Window "+i); + hartWindows.add(temp); + } if(Globals.getHarts() > 1) gmainUI = Globals.getHartWindows().get(0); mainUI = gui; From 0e171706ba60476960410fd22659047ac9ff1476 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Thu, 10 Jun 2021 18:37:15 +0530 Subject: [PATCH 43/51] Documentation --- src/rars/venus/GeneralExecutePane.java | 5 ++--- src/rars/venus/GeneralMainPane.java | 7 +++---- src/rars/venus/GeneralVenusUI.java | 5 ++--- src/rars/venus/registers/GeneralRegistersPane.java | 5 ++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/rars/venus/GeneralExecutePane.java b/src/rars/venus/GeneralExecutePane.java index d46da445..a2d167c1 100644 --- a/src/rars/venus/GeneralExecutePane.java +++ b/src/rars/venus/GeneralExecutePane.java @@ -10,10 +10,9 @@ import java.awt.*; /* -Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar +Copyright (c) 2003-2006, Siva Chowdeswar Nandipati -Developed by Pete Sanderson (psanderson@otterbein.edu) -and Kenneth Vollmar (kenvollmar@missouristate.edu) +Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/src/rars/venus/GeneralMainPane.java b/src/rars/venus/GeneralMainPane.java index 37915826..d8a08056 100644 --- a/src/rars/venus/GeneralMainPane.java +++ b/src/rars/venus/GeneralMainPane.java @@ -12,11 +12,10 @@ import java.awt.*; - /* -Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar +/* +Copyright (c) 2003-2006, Siva Chowdeswar Nandipati -Developed by Pete Sanderson (psanderson@otterbein.edu) -and Kenneth Vollmar (kenvollmar@missouristate.edu) +Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/src/rars/venus/GeneralVenusUI.java b/src/rars/venus/GeneralVenusUI.java index 8fa90537..ebc0293a 100644 --- a/src/rars/venus/GeneralVenusUI.java +++ b/src/rars/venus/GeneralVenusUI.java @@ -15,10 +15,9 @@ import java.net.URL; /* -Copyright (c) 2003-2013, Pete Sanderson and Kenneth Vollmar +Copyright (c) 2003-2006, Siva Chowdeswar Nandipati -Developed by Pete Sanderson (psanderson@otterbein.edu) -and Kenneth Vollmar (kenvollmar@missouristate.edu) +Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/src/rars/venus/registers/GeneralRegistersPane.java b/src/rars/venus/registers/GeneralRegistersPane.java index c2f96dc9..fe10dccb 100644 --- a/src/rars/venus/registers/GeneralRegistersPane.java +++ b/src/rars/venus/registers/GeneralRegistersPane.java @@ -5,10 +5,9 @@ import javax.swing.*; /* -Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar +Copyright (c) 2003-2006, Siva Chowdeswar Nandipati -Developed by Pete Sanderson (psanderson@otterbein.edu) -and Kenneth Vollmar (kenvollmar@missouristate.edu) +Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 0cc38158f6e05ba97db99c86f07a79fa1fb096c3 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Thu, 10 Jun 2021 18:46:48 -0600 Subject: [PATCH 44/51] add rv32a unit tests --- test/riscv-tests/amoaddw.s | 55 ++++++++++++++++++++++ test/riscv-tests/amoandw.s | 54 +++++++++++++++++++++ test/riscv-tests/amomaxuw.s | 55 ++++++++++++++++++++++ test/riscv-tests/amomaxw.s | 55 ++++++++++++++++++++++ test/riscv-tests/amominuw.s | 55 ++++++++++++++++++++++ test/riscv-tests/amominw.s | 55 ++++++++++++++++++++++ test/riscv-tests/amoorw.s | 54 +++++++++++++++++++++ test/riscv-tests/amoswapw.s | 54 +++++++++++++++++++++ test/riscv-tests/amoxorw.s | 54 +++++++++++++++++++++ test/riscv-tests/lrsc.s | 93 +++++++++++++++++++++++++++++++++++++ 10 files changed, 584 insertions(+) create mode 100644 test/riscv-tests/amoaddw.s create mode 100644 test/riscv-tests/amoandw.s create mode 100644 test/riscv-tests/amomaxuw.s create mode 100644 test/riscv-tests/amomaxw.s create mode 100644 test/riscv-tests/amominuw.s create mode 100644 test/riscv-tests/amominw.s create mode 100644 test/riscv-tests/amoorw.s create mode 100644 test/riscv-tests/amoswapw.s create mode 100644 test/riscv-tests/amoxorw.s create mode 100644 test/riscv-tests/lrsc.s diff --git a/test/riscv-tests/amoaddw.s b/test/riscv-tests/amoaddw.s new file mode 100644 index 00000000..4bafdd15 --- /dev/null +++ b/test/riscv-tests/amoaddw.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amoadd.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0x000000007ffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + lui a1, 0x80000 + amoadd.w a4, a1, (a3) + lui t2, 0x80000 + addi t2, t2, -2048 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, -2048 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amoandw.s b/test/riscv-tests/amoandw.s new file mode 100644 index 00000000..3ec5def6 --- /dev/null +++ b/test/riscv-tests/amoandw.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amoand.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0x80000000 + amoand.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amomaxuw.s b/test/riscv-tests/amomaxuw.s new file mode 100644 index 00000000..d0df56e2 --- /dev/null +++ b/test/riscv-tests/amomaxuw.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amomaxu.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xffffffffffffffff + sw zero, 0(a3) + amomaxu.w a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0xffffffffffffffff + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amomaxw.s b/test/riscv-tests/amomaxw.s new file mode 100644 index 00000000..5761a67d --- /dev/null +++ b/test/riscv-tests/amomaxw.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amomax.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 1 + sw zero, 0(a3) + amomax.w a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 1 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amominuw.s b/test/riscv-tests/amominuw.s new file mode 100644 index 00000000..fdadf1a6 --- /dev/null +++ b/test/riscv-tests/amominuw.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amominu.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xffffffffffffffff + sw zero, 0(a3) + amominu.w a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amominw.s b/test/riscv-tests/amominw.s new file mode 100644 index 00000000..82f786a1 --- /dev/null +++ b/test/riscv-tests/amominw.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amomin.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xffffffffffffffff + sw zero, 0(a3) + amomin.w a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0xffffffffffffffff + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amoorw.s b/test/riscv-tests/amoorw.s new file mode 100644 index 00000000..8d8e0951 --- /dev/null +++ b/test/riscv-tests/amoorw.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amoor.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 1 + amoor.w a4, a1, (a3) + li t2, 0xfffffffffffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0xfffffffffffff801 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amoswapw.s b/test/riscv-tests/amoswapw.s new file mode 100644 index 00000000..8afbd968 --- /dev/null +++ b/test/riscv-tests/amoswapw.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amoswap.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0x80000000 + amoswap.w a4, a1, (a3) + li t2, 0xfffffffffffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/amoxorw.s b/test/riscv-tests/amoxorw.s new file mode 100644 index 00000000..8078f06b --- /dev/null +++ b/test/riscv-tests/amoxorw.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sw a0, 0(a3) + amoxor.w a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a5, 0(a3) + li t2, 0x7ffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xc0000001 + amoxor.w a4, a1, (a3) + li t2, 0x7ffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + lw a5, 0(a3) + li t2, 0xffffffffbffff801 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests/lrsc.s b/test/riscv-tests/lrsc.s new file mode 100644 index 00000000..029af77b --- /dev/null +++ b/test/riscv-tests/lrsc.s @@ -0,0 +1,93 @@ +.data +coreid: .word 0 +barrier: .word 0 +foo: .word 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +# get a unique core id +la a0, coreid +li a1, 1 +amoadd.w a2, a1, (a0) + +# for now, only run this on core 0 +lbl_1: +li a3, 1 +bgeu a2, a3, lbl_1 + +lbl_2: +lw a1, (a0) +bltu a1, a3, lbl_2 + +test_2: + la a0, foo + li a5, 0xdeadbeef + sc.w a4, a5, (a0) + li t2, 1 + li gp, 2 + bne a4, t2, fail + +test_3: + lw a4, foo + li t2, 0 + li gp, 3 + bne a4, t2, fail + +# have each core add its coreid+1 to foo 128 times +la a0, foo +li a1, 0x80 +addi a2, a2, 1 +lbl_3: lr.w a4, (a0) +add a4, a4, a2 +sc.w a4, a4, (a0) +bnez a4, lbl_3 +addi a1, a1, -1 +bnez a1, lbl_3 + +# wait for all cores to finish +la a0, barrier +li a1, 1 +amoadd.w x0, a1, (a0) +lbl_4: lw a1, (a0) +blt a1, a3, lbl_4 +fence 1, 1 + +test_5: + lw a0, foo + slli a1, a3, 6 + lbl_5: sub a0, a0, a1 + addi a3, a3, -1 + bgez a3, lbl_5 + li t2, 0 + li gp, 5 + bne a0, t2, fail + +test_6: + la a0, foo + lbl_6: lr.w a1, (a0) + sc.w a1, x0, (a0) + bnez a1, lbl_6 + sc.w a1, x0 (a0) + li t2, 1 + li gp, 6 + bne a1, t2, fail + +bne zero, gp, pass +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall From 895bfb7ee5d472a682ddb5d2dcc66f55c6e00815 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Fri, 11 Jun 2021 23:44:54 +0530 Subject: [PATCH 45/51] Fixed bugs for more than One Hart --- src/rars/Globals.java | 8 +- src/rars/venus/GeneralVenusUI.java | 4 +- .../venus/registers/RegisterBlockWindow.java | 9 +- src/rars/venus/registers/RegistersWindow.java | 4 + src/rars/venus/run/RunAssembleAction.java | 96 +++++++++---------- src/rars/venus/run/RunGoAction.java | 42 +++++++- 6 files changed, 109 insertions(+), 54 deletions(-) diff --git a/src/rars/Globals.java b/src/rars/Globals.java index c5dd8f3e..e64a0f52 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -146,10 +146,16 @@ public class Globals { public static boolean runSpeedPanelExists = false; - private static int harts = 1; + private static int harts = 2; private static ArrayList hartWindows = new ArrayList(); + public static void setHartWindows(){ + for(int i = 1; i < Globals.getHarts(); i++){ + GeneralVenusUI temp= new GeneralVenusUI("Window "+i); + hartWindows.add(temp); + } + } public static ArrayList getHartWindows(){ return hartWindows; diff --git a/src/rars/venus/GeneralVenusUI.java b/src/rars/venus/GeneralVenusUI.java index ebc0293a..048ee64e 100644 --- a/src/rars/venus/GeneralVenusUI.java +++ b/src/rars/venus/GeneralVenusUI.java @@ -86,8 +86,6 @@ public GeneralVenusUI(String s) { double registersHeightPct = (screenWidth < 1000.0) ? 0.72 : 0.80; Dimension mainPanePreferredSize = new Dimension((int) (screenWidth * mainWidthPct), (int) (screenHeight * mainHeightPct)); Dimension registersPanePreferredSize = new Dimension((int) (screenWidth * registersWidthPct), (int) (screenHeight * registersHeightPct)); - - Globals.initialize(true); // image courtesy of NASA/JPL. @@ -112,7 +110,7 @@ public GeneralVenusUI(String s) { // roughly in bottom-up order; some are created in component constructors and thus are // not visible here. - registersTab = new RegistersWindow(); + registersTab = new RegistersWindow("Not GUI"); fpTab = new FloatingPointWindow(); csrTab = new ControlAndStatusWindow(); registersPane = new GeneralRegistersPane(mainUI, registersTab, fpTab, csrTab); diff --git a/src/rars/venus/registers/RegisterBlockWindow.java b/src/rars/venus/registers/RegisterBlockWindow.java index 7c94713e..0550261f 100644 --- a/src/rars/venus/registers/RegisterBlockWindow.java +++ b/src/rars/venus/registers/RegisterBlockWindow.java @@ -61,6 +61,7 @@ public abstract class RegisterBlockWindow extends JPanel implements Observer { private boolean highlighting; private int highlightRow; private Register[] registers; + private boolean notMainUI = true; private static final int NAME_COLUMN = 0; private static final int NUMBER_COLUMN = 1; @@ -93,6 +94,11 @@ public RegisterBlockWindow(Register[] registers, String[] registerDescriptions, this.add(new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); } + public RegisterBlockWindow(Register[] registers2, String[] regtooltips, String string, String string2) { + this(registers2, regtooltips, string); + notMainUI = false; + } + protected abstract String formatRegister(Register value, int base); protected abstract void beginObserving(); @@ -203,7 +209,8 @@ public void update(Observable observable, Object obj) { // AddressCellRenderer class in DataSegmentWindow.java. this.highlighting = true; this.highlightCellForRegister((Register) observable); - Globals.getGui().getRegistersPane().setSelectedComponent(this); + if(notMainUI) + Globals.getGui().getRegistersPane().setSelectedComponent(this); } } } diff --git a/src/rars/venus/registers/RegistersWindow.java b/src/rars/venus/registers/RegistersWindow.java index 694cb4b4..eb5b5282 100644 --- a/src/rars/venus/registers/RegistersWindow.java +++ b/src/rars/venus/registers/RegistersWindow.java @@ -52,6 +52,10 @@ public RegistersWindow() { super(getRegisters(), regToolTips, "Current 32 bit value"); } + public RegistersWindow(String s){ + super(getRegisters(), regToolTips, "Current 32 bit value", "GeneralGUI"); + } + /* * A simple wrapper to add pc into the Registers array */ diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index f483a0af..9ba147be 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -13,8 +13,8 @@ import java.awt.event.ActionEvent; import java.io.File; import java.util.ArrayList; - - /* + +/* Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar Developed by Pete Sanderson (psanderson@otterbein.edu) @@ -40,7 +40,7 @@ a copy of this software and associated documentation files (the WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (MIT license, http://www.opensource.org/licenses/mit-license.html) - */ +*/ /** * Action class for the Run -> Assemble menu item (and toolbar icon) @@ -53,22 +53,16 @@ public class RunAssembleAction extends GuiAction { // Threshold for adding filename to printed message of files being assembled. private static final int LINE_LENGTH_LIMIT = 60; private VenusUI mainUI; - private GeneralVenusUI gmainUI; protected ArrayList hartWindows = Globals.getHartWindows(); - public RunAssembleAction(String name, Icon icon, String descrip, - Integer mnemonic, KeyStroke accel, VenusUI gui) { + public RunAssembleAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); - for(int i = 1; i < Globals.getHarts(); i++){ - GeneralVenusUI temp= new GeneralVenusUI("Window "+i); - hartWindows.add(temp); - } - if(Globals.getHarts() > 1) - gmainUI = Globals.getHartWindows().get(0); + Globals.setHartWindows(); mainUI = gui; } - // These are both used by RunResetAction to re-assemble under identical conditions. + // These are both used by RunResetAction to re-assemble under identical + // conditions. public static ArrayList getProgramsToAssemble() { return programsToAssemble; } @@ -86,11 +80,12 @@ public void actionPerformed(ActionEvent e) { MessagesPane messagesPane = mainUI.getMessagesPane(); ExecutePane executePane = mainUI.getMainPane().getExecutePane(); RegistersPane registersPane = mainUI.getRegistersPane(); - GeneralExecutePane gexecutePane = null; - GeneralRegistersPane gregistersPane = null; - if(Globals.getHarts() > 1){ - gexecutePane = gmainUI.getMainPane().getExecutePane(); - gregistersPane = gmainUI.getRegistersPane(); + ArrayList gexecutePanes = new ArrayList<>(); + ArrayList gregistersPanes = new ArrayList<>(); + + for (int i = 0; i < hartWindows.size(); i++) { + gexecutePanes.add(hartWindows.get(i).getMainPane().getExecutePane()); + gregistersPanes.add(hartWindows.get(i).getRegistersPane()); } extendedAssemblerEnabled = Globals.getSettings().getBooleanSetting(Settings.Bool.EXTENDED_ASSEMBLER_ENABLED); @@ -102,9 +97,10 @@ public void actionPerformed(ActionEvent e) { try { Globals.program = new RISCVprogram(); ArrayList filesToAssemble; - if (Globals.getSettings().getBooleanSetting(Settings.Bool.ASSEMBLE_ALL)) {// setting calls for multiple file assembly - filesToAssemble = FilenameFinder.getFilenameList( - new File(FileStatus.getName()).getParent(), Globals.fileExtensions); + if (Globals.getSettings().getBooleanSetting(Settings.Bool.ASSEMBLE_ALL)) {// setting calls for multiple + // file assembly + filesToAssemble = FilenameFinder.getFilenameList(new File(FileStatus.getName()).getParent(), + Globals.fileExtensions); } else { filesToAssemble = new ArrayList<>(); filesToAssemble.add(FileStatus.getName()); @@ -119,12 +115,13 @@ public void actionPerformed(ActionEvent e) { } } String exceptionHandler = null; - if (Globals.getSettings().getBooleanSetting(Settings.Bool.EXCEPTION_HANDLER_ENABLED) && - Globals.getSettings().getExceptionHandler() != null && - Globals.getSettings().getExceptionHandler().length() > 0) { + if (Globals.getSettings().getBooleanSetting(Settings.Bool.EXCEPTION_HANDLER_ENABLED) + && Globals.getSettings().getExceptionHandler() != null + && Globals.getSettings().getExceptionHandler().length() > 0) { exceptionHandler = Globals.getSettings().getExceptionHandler(); } - programsToAssemble = Globals.program.prepareFilesForAssembly(filesToAssemble, FileStatus.getFile().getPath(), exceptionHandler); + programsToAssemble = Globals.program.prepareFilesForAssembly(filesToAssemble, + FileStatus.getFile().getPath(), exceptionHandler); messagesPane.postMessage(buildFileNameList(name + ": assembling ", programsToAssemble)); // added logic to receive any warnings and output them.... DPS 11/28/06 ErrorList warnings = Globals.program.assemble(programsToAssemble, extendedAssemblerEnabled, @@ -132,8 +129,7 @@ public void actionPerformed(ActionEvent e) { if (warnings.warningsOccurred()) { messagesPane.postMessage(warnings.generateWarningReport()); } - messagesPane.postMessage( - name + ": operation completed successfully.\n\n"); + messagesPane.postMessage(name + ": operation completed successfully.\n\n"); FileStatus.setAssembled(true); FileStatus.set(FileStatus.RUNNABLE); @@ -142,12 +138,12 @@ public void actionPerformed(ActionEvent e) { ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); Globals.reservationTables.reset(); - if(Globals.getHarts() > 1){ - gexecutePane.getTextSegmentWindow().setupTable(); - gexecutePane.getLabelsWindow().setupTable(); + for (int i = 0; i < hartWindows.size(); i++) { + gexecutePanes.get(i).getTextSegmentWindow().setupTable(); + gexecutePanes.get(i).getLabelsWindow().setupTable(); - gexecutePane.getTextSegmentWindow().setCodeHighlighting(true); - gexecutePane.getTextSegmentWindow().highlightStepAtPC(); + gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); + gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); } executePane.getTextSegmentWindow().setupTable(); executePane.getDataSegmentWindow().setupTable(); @@ -159,42 +155,46 @@ public void actionPerformed(ActionEvent e) { registersPane.getRegistersWindow().clearWindow(); registersPane.getFloatingPointWindow().clearWindow(); registersPane.getControlAndStatusWindow().clearWindow(); - if(Globals.getHarts() > 1){ - gregistersPane.getRegistersWindow().clearWindow(); - gregistersPane.getFloatingPointWindow().clearWindow(); - gregistersPane.getControlAndStatusWindow().clearWindow(); - gmainUI.setReset(true); - gmainUI.setStarted(false); + for(int i = 0; i < hartWindows.size(); i++){ + gregistersPanes.get(i).getRegistersWindow().clearWindow(); + gregistersPanes.get(i).getFloatingPointWindow().clearWindow(); + gregistersPanes.get(i).getControlAndStatusWindow().clearWindow(); + hartWindows.get(i).setReset(true); + hartWindows.get(i).setStarted(false); } mainUI.setReset(true); mainUI.setStarted(false); mainUI.getMainPane().setSelectedComponent(executePane); - // Aug. 24, 2005 Ken Vollmar - SystemIO.resetFiles(); // Ensure that I/O "file descriptors" are initialized for a new program run + SystemIO.resetFiles(); // Ensure that I/O "file descriptors" are initialized for a new program run } catch (AssemblyException pe) { String errorReport = pe.errors().generateErrorAndWarningReport(); messagesPane.postMessage(errorReport); - messagesPane.postMessage( - name + ": operation completed with errors.\n\n"); + messagesPane.postMessage(name + ": operation completed with errors.\n\n"); // Select editor line containing first error, and corresponding error message. ArrayList errorMessages = pe.errors().getErrorMessages(); for (ErrorMessage em : errorMessages) { - // No line or position may mean File Not Found (e.g. exception file). Don't try to open. DPS 3-Oct-2010 + // No line or position may mean File Not Found (e.g. exception file). Don't try + // to open. DPS 3-Oct-2010 if (em.getLine() == 0 && em.getPosition() == 0) { continue; } if (!em.isWarning() || warningsAreErrors) { - Globals.getGui().getMessagesPane().selectErrorMessage(em.getFilename(), em.getLine(), em.getPosition()); - // Bug workaround: Line selection does not work correctly for the JEditTextArea editor - // when the file is opened then automatically assembled (assemble-on-open setting). + Globals.getGui().getMessagesPane().selectErrorMessage(em.getFilename(), em.getLine(), + em.getPosition()); + // Bug workaround: Line selection does not work correctly for the JEditTextArea + // editor + // when the file is opened then automatically assembled (assemble-on-open + // setting). // Automatic assemble happens in EditTabbedPane's openFile() method, by invoking - // this method (actionPerformed) explicitly with null argument. Thus e!=null test. + // this method (actionPerformed) explicitly with null argument. Thus e!=null + // test. // DPS 9-Aug-2010 if (e != null) { - Globals.getGui().getMessagesPane().selectEditorTextLine(em.getFilename(), em.getLine(), em.getPosition()); + Globals.getGui().getMessagesPane().selectEditorTextLine(em.getFilename(), em.getLine(), + em.getPosition()); } break; } diff --git a/src/rars/venus/run/RunGoAction.java b/src/rars/venus/run/RunGoAction.java index d4c152dc..3d5bd5b1 100644 --- a/src/rars/venus/run/RunGoAction.java +++ b/src/rars/venus/run/RunGoAction.java @@ -10,12 +10,15 @@ import rars.util.SystemIO; import rars.venus.ExecutePane; import rars.venus.FileStatus; +import rars.venus.GeneralExecutePane; +import rars.venus.GeneralVenusUI; import rars.venus.GuiAction; import rars.venus.VenusUI; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; +import java.util.ArrayList; import java.util.Observable; import java.util.Observer; @@ -56,7 +59,9 @@ public class RunGoAction extends GuiAction { public static int maxSteps = defaultMaxSteps; private String name; private ExecutePane executePane; + private ArrayList gexecutePanes = new ArrayList<>(); private VenusUI mainUI; + protected ArrayList hartWindows = Globals.getHartWindows(); public RunGoAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { @@ -70,6 +75,9 @@ public RunGoAction(String name, Icon icon, String descrip, public void actionPerformed(ActionEvent e) { name = this.getValue(Action.NAME).toString(); executePane = mainUI.getMainPane().getExecutePane(); + for(int i = 0; i < hartWindows.size(); i++){ + gexecutePanes.add(hartWindows.get(i).getMainPane().getExecutePane()); + } if (FileStatus.isAssembled()) { if (!mainUI.getStarted()) { processProgramArgumentsIfAny(); // DPS 17-July-2008 @@ -77,12 +85,18 @@ public void actionPerformed(ActionEvent e) { if (mainUI.getReset() || mainUI.getStarted()) { mainUI.setStarted(true); // added 8/27/05 - + for(int i = 0; i < hartWindows.size(); i++){ + hartWindows.get(i).setStarted(true); + } mainUI.getMessagesPane().postMessage( name + ": running " + FileStatus.getFile().getName() + "\n\n"); mainUI.getMessagesPane().selectRunMessageTab(); executePane.getTextSegmentWindow().setCodeHighlighting(false); executePane.getTextSegmentWindow().unhighlightAllSteps(); + for(int i = 0; i < hartWindows.size(); i++){ + gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(false); + gexecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); + } //FileStatus.set(FileStatus.RUNNING); mainUI.setMenuState(FileStatus.RUNNING); @@ -142,6 +156,15 @@ public void paused(boolean done, Simulator.Reason pauseReason, SimulationExcepti executePane.getFloatingPointWindow().updateRegisters(); executePane.getControlAndStatusWindow().updateRegisters(); executePane.getDataSegmentWindow().updateValues(); + for(int i = 0; i < hartWindows.size(); i++){ + gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); + gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); + gexecutePanes.get(i).getRegistersWindow().updateRegisters(); + gexecutePanes.get(i).getFloatingPointWindow().updateRegisters(); + gexecutePanes.get(i).getControlAndStatusWindow().updateRegisters(); + hartWindows.get(i).setReset(false); + + } FileStatus.set(FileStatus.RUNNABLE); mainUI.setReset(false); } @@ -159,14 +182,26 @@ public void stopped(SimulationException pe, Simulator.Reason reason) { executePane.getFloatingPointWindow().updateRegisters(); executePane.getControlAndStatusWindow().updateRegisters(); executePane.getDataSegmentWindow().updateValues(); + for(int i = 0; i < hartWindows.size(); i++){ + gexecutePanes.get(i).getRegistersWindow().updateRegisters(); + gexecutePanes.get(i).getFloatingPointWindow().updateRegisters(); + gexecutePanes.get(i).getControlAndStatusWindow().updateRegisters(); + } FileStatus.set(FileStatus.TERMINATED); SystemIO.resetFiles(); // close any files opened in MIPS program // Bring CSRs to the front if terminated due to exception. if (pe != null) { + mainUI.getRegistersPane().setSelectedComponent(executePane.getControlAndStatusWindow()); executePane.getTextSegmentWindow().setCodeHighlighting(true); executePane.getTextSegmentWindow().unhighlightAllSteps(); executePane.getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); + for(int i = 0; i < hartWindows.size(); i++){ + hartWindows.get(i).getRegistersPane().setSelectedComponent(executePane.getControlAndStatusWindow()); + gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); + gexecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); + gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); + } } switch (reason) { case NORMAL_TERMINATION: @@ -204,6 +239,11 @@ public void stopped(SimulationException pe, Simulator.Reason reason) { } RunGoAction.resetMaxSteps(); mainUI.setReset(false); + for(int i = 0; i < hartWindows.size(); i++){ + hartWindows.get(i).setReset(false); + } + + } /** From 988346a2bb7a9eb364f6e238a9646fa84b0e183e Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Fri, 11 Jun 2021 14:02:38 -0600 Subject: [PATCH 46/51] add rv64a unit tests --- test/riscv-tests-64/amoaddd.s | 53 ++++++++++++++++++++++++++++++++ test/riscv-tests-64/amoandd.s | 54 +++++++++++++++++++++++++++++++++ test/riscv-tests-64/amomaxd.s | 55 ++++++++++++++++++++++++++++++++++ test/riscv-tests-64/amomaxud.s | 55 ++++++++++++++++++++++++++++++++++ test/riscv-tests-64/amomind.s | 55 ++++++++++++++++++++++++++++++++++ test/riscv-tests-64/amominud.s | 55 ++++++++++++++++++++++++++++++++++ test/riscv-tests-64/amoord.s | 54 +++++++++++++++++++++++++++++++++ test/riscv-tests-64/amoswapd.s | 54 +++++++++++++++++++++++++++++++++ test/riscv-tests-64/amoxord.s | 54 +++++++++++++++++++++++++++++++++ 9 files changed, 489 insertions(+) create mode 100644 test/riscv-tests-64/amoaddd.s create mode 100644 test/riscv-tests-64/amoandd.s create mode 100644 test/riscv-tests-64/amomaxd.s create mode 100644 test/riscv-tests-64/amomaxud.s create mode 100644 test/riscv-tests-64/amomind.s create mode 100644 test/riscv-tests-64/amominud.s create mode 100644 test/riscv-tests-64/amoord.s create mode 100644 test/riscv-tests-64/amoswapd.s create mode 100644 test/riscv-tests-64/amoxord.s diff --git a/test/riscv-tests-64/amoaddd.s b/test/riscv-tests-64/amoaddd.s new file mode 100644 index 00000000..bb6f25ab --- /dev/null +++ b/test/riscv-tests-64/amoaddd.s @@ -0,0 +1,53 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amoadd.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xffffffff7ffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + amoadd.d a4, a1, (a3) + li t2, 0xffffffff7ffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0xffffffff7ffff000 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amoandd.s b/test/riscv-tests-64/amoandd.s new file mode 100644 index 00000000..b5182ce7 --- /dev/null +++ b/test/riscv-tests-64/amoandd.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amoand.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0x0000000080000000 + amoand.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0x0000000080000000 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amomaxd.s b/test/riscv-tests-64/amomaxd.s new file mode 100644 index 00000000..8ff48a4f --- /dev/null +++ b/test/riscv-tests-64/amomaxd.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amomax.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 1 + sd x0, 0(a3) + amomax.d a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 1 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amomaxud.s b/test/riscv-tests-64/amomaxud.s new file mode 100644 index 00000000..a8a3281c --- /dev/null +++ b/test/riscv-tests-64/amomaxud.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amomaxu.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xffffffffffffffff + sd x0, 0(a3) + amomaxu.d a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0xffffffffffffffff + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amomind.s b/test/riscv-tests-64/amomind.s new file mode 100644 index 00000000..142aa1ff --- /dev/null +++ b/test/riscv-tests-64/amomind.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amomin.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xffffffffffffffff + sd x0, 0(a3) + amomin.d a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0xffffffffffffffff + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amominud.s b/test/riscv-tests-64/amominud.s new file mode 100644 index 00000000..59e674b8 --- /dev/null +++ b/test/riscv-tests-64/amominud.s @@ -0,0 +1,55 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amominu.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xffffffff80000000 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0xffffffffffffffff + sd x0, 0(a3) + amominu.d a4, a1, (a3) + li t2, 0 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amoord.s b/test/riscv-tests-64/amoord.s new file mode 100644 index 00000000..cc376e46 --- /dev/null +++ b/test/riscv-tests-64/amoord.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amoor.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 1 + amoor.d a4, a1, (a3) + li t2, 0xfffffffffffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0xfffffffffffff801 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amoswapd.s b/test/riscv-tests-64/amoswapd.s new file mode 100644 index 00000000..d6060d99 --- /dev/null +++ b/test/riscv-tests-64/amoswapd.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amoswap.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0xfffffffffffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 0x0000000080000000 + amoswap.d a4, a1, (a3) + li t2, 0xfffffffffffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0x0000000080000000 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall diff --git a/test/riscv-tests-64/amoxord.s b/test/riscv-tests-64/amoxord.s new file mode 100644 index 00000000..6dfc27d2 --- /dev/null +++ b/test/riscv-tests-64/amoxord.s @@ -0,0 +1,54 @@ +.data +.align 3 +amo_operand: .dword 0 + +.text +main: + #------------------------------------------------------------- + # Atomic tests + #------------------------------------------------------------- + +test_2: + li a0, 0xffffffff80000000 + li a1, 0xfffffffffffff800 + la a3, amo_operand + sd a0, 0(a3) + amoxor.d a4, a1, (a3) + li t2, 0xffffffff80000000 + li gp, 2 + bne a4, t2, fail + +test_3: + ld a5, 0(a3) + li t2, 0x000000007ffff800 + li gp, 3 + bne a5, t2, fail + +test_4: + li a1, 1 + amoxor.d a4, a1, (a3) + li t2, 0x000000007ffff800 + li gp, 4 + bne a4, t2, fail + +test_5: + ld a5, 0(a3) + li t2, 0x000000007ffff801 + li gp, 5 + bne a5, t2, fail + bne zero, gp, pass + +fail: + fence 1, 1 + slli gp, gp, 0x1 + ori gp, gp, 1 + li a7, 93 + mv a0, gp + ecall + +pass: + fence 1, 1 + li gp, 1 + li a7, 93 + li a0, 42 + ecall From fc77595b423c391889ea6d4d29e0c96e4a68e178 Mon Sep 17 00:00:00 2001 From: Siva Chowdeswar Nandipati Date: Wed, 16 Jun 2021 16:53:43 +0530 Subject: [PATCH 47/51] All Harts work alike --- src/rars/Globals.java | 2 ++ src/rars/venus/run/RunAssembleAction.java | 8 +++-- src/rars/venus/run/RunStepAction.java | 44 ++++++++++++++++++++++- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/rars/Globals.java b/src/rars/Globals.java index e64a0f52..862ebb6e 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -62,6 +62,8 @@ public class Globals { * the program currently being worked with. Used by GUI only, not command line. **/ public static RISCVprogram program; + + public static ArrayList gPrograms; /** * Symbol table for file currently being assembled. **/ diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index 9ba147be..74ef9aa4 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -48,6 +48,7 @@ a copy of this software and associated documentation files (the public class RunAssembleAction extends GuiAction { private static ArrayList programsToAssemble; + private static ArrayList> gProgramsToAssemble; private static boolean extendedAssemblerEnabled; private static boolean warningsAreErrors; // Threshold for adding filename to printed message of files being assembled. @@ -96,6 +97,10 @@ public void actionPerformed(ActionEvent e) { } try { Globals.program = new RISCVprogram(); + Globals.gPrograms = new ArrayList<>(); + for (int i = 0; i < hartWindows.size(); i++){ + Globals.gPrograms.add(new RISCVprogram()); + } ArrayList filesToAssemble; if (Globals.getSettings().getBooleanSetting(Settings.Bool.ASSEMBLE_ALL)) {// setting calls for multiple // file assembly @@ -132,7 +137,7 @@ public void actionPerformed(ActionEvent e) { messagesPane.postMessage(name + ": operation completed successfully.\n\n"); FileStatus.setAssembled(true); FileStatus.set(FileStatus.RUNNABLE); - + //TODO RegisterFile.resetRegisters(); FloatingPointRegisterFile.resetRegisters(); ControlAndStatusRegisterFile.resetRegisters(); @@ -141,7 +146,6 @@ public void actionPerformed(ActionEvent e) { for (int i = 0; i < hartWindows.size(); i++) { gexecutePanes.get(i).getTextSegmentWindow().setupTable(); gexecutePanes.get(i).getLabelsWindow().setupTable(); - gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); } diff --git a/src/rars/venus/run/RunStepAction.java b/src/rars/venus/run/RunStepAction.java index 96b86bae..1a0ad7fc 100644 --- a/src/rars/venus/run/RunStepAction.java +++ b/src/rars/venus/run/RunStepAction.java @@ -11,10 +11,13 @@ import rars.venus.FileStatus; import rars.venus.GuiAction; import rars.venus.VenusUI; +import rars.venus.GeneralVenusUI; +import rars.venus.GeneralExecutePane; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; +import java.util.ArrayList; import java.util.Observable; import java.util.Observer; @@ -53,12 +56,14 @@ public class RunStepAction extends GuiAction { private String name; private ExecutePane executePane; + private ArrayList gExecutePanes; private VenusUI mainUI; - + private ArrayList hartWindows; public RunStepAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); mainUI = gui; + hartWindows = Globals.getHartWindows(); } /** @@ -67,6 +72,10 @@ public RunStepAction(String name, Icon icon, String descrip, public void actionPerformed(ActionEvent e) { name = this.getValue(Action.NAME).toString(); executePane = mainUI.getMainPane().getExecutePane(); + gExecutePanes = new ArrayList<>(); + for(int i = 0; i < hartWindows.size(); i++){ + gExecutePanes.add(hartWindows.get(i).getMainPane().getExecutePane()); + } if (FileStatus.isAssembled()) { if (!mainUI.getStarted()) { // DPS 17-July-2008 processProgramArgumentsIfAny(); @@ -74,6 +83,10 @@ public void actionPerformed(ActionEvent e) { mainUI.setStarted(true); mainUI.getMessagesPane().selectRunMessageTab(); executePane.getTextSegmentWindow().setCodeHighlighting(true); + for(int i = 0; i < hartWindows.size(); i++){ + hartWindows.get(i).setStarted(true); + gExecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); + } // Setup callback for after step finishes final Observer stopListener = @@ -88,6 +101,9 @@ public void update(Observable o, Object simulator) { Simulator.getInstance().addObserver(stopListener); Globals.program.startSimulation(1, null); + for(int i = 0; i < hartWindows.size(); i++){ + Globals.gPrograms.get(i).startSimulation(1, null); + } } else { // note: this should never occur since "Step" is only enabled after successful assembly. JOptionPane.showMessageDialog(mainUI, "The program must be assembled before it can be run."); @@ -101,13 +117,25 @@ public void stepped(boolean done, Simulator.Reason reason, SimulationException p executePane.getFloatingPointWindow().updateRegisters(); executePane.getControlAndStatusWindow().updateRegisters(); executePane.getDataSegmentWindow().updateValues(); + + for(int i = 0; i < hartWindows.size(); i++){ + gExecutePanes.get(i).getRegistersWindow().updateRegisters(); + gExecutePanes.get(i).getFloatingPointWindow().updateRegisters(); + gExecutePanes.get(i).getControlAndStatusWindow().updateRegisters(); + } if (!done) { + for(int i = 0; i < hartWindows.size(); i++){ + gExecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); + } executePane.getTextSegmentWindow().highlightStepAtPC(); FileStatus.set(FileStatus.RUNNABLE); } if (done) { RunGoAction.resetMaxSteps(); executePane.getTextSegmentWindow().unhighlightAllSteps(); + for(int i = 0; i < hartWindows.size(); i++){ + gExecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); + } FileStatus.set(FileStatus.TERMINATED); } if (done && pe == null) { @@ -131,8 +159,17 @@ public void stepped(boolean done, Simulator.Reason reason, SimulationException p executePane.getTextSegmentWindow().setCodeHighlighting(true); executePane.getTextSegmentWindow().unhighlightAllSteps(); executePane.getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); + for(int i = 0; i < hartWindows.size(); i++){ + hartWindows.get(i).getRegistersPane().setSelectedComponent(executePane.getControlAndStatusWindow()); + gExecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); + gExecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); + gExecutePanes.get(i).getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); + } } mainUI.setReset(false); + for(int i = 0; i < hartWindows.size(); i++){ + hartWindows.get(i).setReset(false); + } } //////////////////////////////////////////////////////////////////////////////////// @@ -142,6 +179,11 @@ public void stepped(boolean done, Simulator.Reason reason, SimulationException p // $a0 gets argument count (argc), $a1 gets stack address of first arg pointer (argv). private void processProgramArgumentsIfAny() { String programArguments = executePane.getTextSegmentWindow().getProgramArguments(); + ArrayList gProgramArgumentsArrayList = new ArrayList<>(); + for(int i = 0; i < hartWindows.size(); i++){ + gProgramArgumentsArrayList.add(gExecutePanes.get(i).getTextSegmentWindow().getProgramArguments()); + } + //TODO if (programArguments == null || programArguments.length() == 0 || !Globals.getSettings().getBooleanSetting(Settings.Bool.PROGRAM_ARGUMENTS)) { return; From 35cda7621dab5030686810219daf3ac1db6261b2 Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Thu, 17 Jun 2021 19:30:36 -0600 Subject: [PATCH 48/51] fix sc on 64-bit mode --- src/rars/riscv/hardware/ReservationTable.java | 63 ++++++++++++++++--- .../riscv/hardware/ReservationTables.java | 41 ++++++------ .../instructions/AtomicMemoryOperation.java | 7 ++- src/rars/riscv/instructions/LRD.java | 3 +- src/rars/riscv/instructions/LRW.java | 3 +- src/rars/riscv/instructions/SB.java | 3 +- src/rars/riscv/instructions/SCD.java | 3 +- src/rars/riscv/instructions/SCW.java | 3 +- src/rars/riscv/instructions/SD.java | 5 +- src/rars/riscv/instructions/SH.java | 3 +- src/rars/riscv/instructions/SW.java | 3 +- src/rars/tools/ReservationTablesTool.java | 29 ++++----- 12 files changed, 108 insertions(+), 58 deletions(-) diff --git a/src/rars/riscv/hardware/ReservationTable.java b/src/rars/riscv/hardware/ReservationTable.java index f7524c9c..1bee1ae8 100644 --- a/src/rars/riscv/hardware/ReservationTable.java +++ b/src/rars/riscv/hardware/ReservationTable.java @@ -1,6 +1,7 @@ package rars.riscv.hardware; import java.util.ArrayList; +import java.util.function.Predicate; /* Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. @@ -28,38 +29,80 @@ a copy of this software and associated documentation files (the */ public class ReservationTable { - private ArrayList table; + private ArrayList table; public final static int capacity = 8; + private final static int doubleAlignMask = ~0x7; + + public enum bitWidth { + word, + doubleWord + } + + protected class ReservationTableEntry { + protected Integer address; + protected bitWidth width; + + public ReservationTableEntry(Integer address, bitWidth width) { + this.address = address; + this.width = width; + } + + public boolean equals(Object o) { + ReservationTableEntry other = (ReservationTableEntry) o; + return address.equals(other.address) && width.equals(other.width); + } + } public ReservationTable() { - table = new ArrayList(); + table = new ArrayList(); } - public void reserveAddress(int address) { - if(table.contains(Integer.valueOf(address))) + public void reserveAddress(int address, bitWidth width) { + ReservationTableEntry newEntry = new ReservationTableEntry(address, width); + if(table.contains(newEntry)) return; if (table.size() == capacity) table.remove(0); - table.add(Integer.valueOf(address)); + table.add(newEntry); } - public void unreserveAddress(int address) { - table.removeIf(val -> val == address); + public void unreserveAddress(int address, bitWidth width) { + Predicate filter = entry -> + (entry.address == address && entry.width == width) + || ((address & doubleAlignMask) == entry.address && entry.width == bitWidth.doubleWord); + table.removeIf(filter); } - public boolean contains(int address) { - return table.contains(Integer.valueOf(address)); + public boolean contains(int address, bitWidth width) { + for (ReservationTableEntry entry : table) { + if ((entry.address == address && entry.width == width) + || ((address & doubleAlignMask) == entry.address && entry.width == bitWidth.doubleWord)) + return true; + } + return false; } public Integer[] getAddresses() { Integer[] addresses = new Integer[capacity]; for (int i = 0; i < capacity; i++) { try { - addresses[i] = table.get(i); + addresses[i] = this.table.get(i).address; } catch (IndexOutOfBoundsException e) { addresses[i] = 0; } } return addresses; } + + public bitWidth[] getWidths() { + bitWidth[] addresses = new bitWidth[capacity]; + for (int i = 0; i < capacity; i++) { + try { + addresses[i] = this.table.get(i).width; + } catch (IndexOutOfBoundsException e) { + addresses[i] = null; + } + } + return addresses; + } } diff --git a/src/rars/riscv/hardware/ReservationTables.java b/src/rars/riscv/hardware/ReservationTables.java index b7646e51..398b0494 100644 --- a/src/rars/riscv/hardware/ReservationTables.java +++ b/src/rars/riscv/hardware/ReservationTables.java @@ -6,7 +6,7 @@ import java.util.Vector; import rars.SimulationException; -import rars.riscv.InstructionSet; +import rars.riscv.hardware.ReservationTable.bitWidth; /* Copyright (c) 2021, Siva Chowdeswar Nandipati & Giancarlo Pernudi Segura. @@ -50,45 +50,44 @@ public void reset() { } } - public void reserveAddress(int hart, int address) throws AddressErrorException { - int modulo = InstructionSet.rv64 ? 8 : 4; + public void reserveAddress(int hart, int address, bitWidth width) throws AddressErrorException { + int modulo = width == bitWidth.doubleWord ? 8 : 4; if (address % modulo != 0) { throw new AddressErrorException("Reservation address not aligned to word boundary ", SimulationException.LOAD_ADDRESS_MISALIGNED, address); } - reservationTables[hart].reserveAddress(address); + reservationTables[hart].reserveAddress(address, width); } - public boolean unreserveAddress(int hart, int address) throws AddressErrorException { - int modulo = InstructionSet.rv64 ? 8 : 4; + public boolean unreserveAddress(int hart, int address, bitWidth width) throws AddressErrorException { + int modulo = width == bitWidth.doubleWord ? 8 : 4; if (address % modulo != 0) { throw new AddressErrorException("Reservation address not aligned to word boundary ", SimulationException.STORE_ADDRESS_MISALIGNED, address); } - if (reservationTables[hart].contains(address)) { + if (reservationTables[hart].contains(address, width)) { for (ReservationTable reservationTable : reservationTables) { - reservationTable.unreserveAddress(address); + reservationTable.unreserveAddress(address, width); } return true; } return false; } - public Integer[][] getAllAddresses() { - Integer[][] all = new Integer[ReservationTable.capacity][harts]; - for (int i = 0; i < ReservationTable.capacity; i++) { - for (int j = 0; j < harts; j++) { - Integer[] addresses = reservationTables[j].getAddresses(); - all[i][j] = addresses[i]; - } - } - return all; - } - public String[][] getAllAddressesAsStrings() { - String[][] all = new String[ReservationTable.capacity][harts]; + String[][] all = new String[ReservationTable.capacity][harts * 2]; + char width = '0'; for (int i = 0; i < ReservationTable.capacity; i++) { for (int j = 0; j < harts; j++) { Integer[] addresses = reservationTables[j].getAddresses(); - all[i][j] = String.format("0x%08x", addresses[i]); + ReservationTable.bitWidth[] widths = reservationTables[j].getWidths(); + if (widths[i] == ReservationTable.bitWidth.word) { + width = 'w'; + } else if (widths[i] == ReservationTable.bitWidth.doubleWord) { + width = 'd'; + } else { + width = ' '; + } + all[i][j * 2] = String.format("0x%08x", addresses[i]); + all[i][j * 2 + 1] = String.format("%c", width); } } return all; diff --git a/src/rars/riscv/instructions/AtomicMemoryOperation.java b/src/rars/riscv/instructions/AtomicMemoryOperation.java index 88ab194a..655cfac8 100644 --- a/src/rars/riscv/instructions/AtomicMemoryOperation.java +++ b/src/rars/riscv/instructions/AtomicMemoryOperation.java @@ -6,6 +6,7 @@ import rars.riscv.InstructionSet; import rars.riscv.hardware.AddressErrorException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReservationTable.bitWidth; /* Copyright (c) 2021, Giancarlo Pernudi Segura @@ -41,19 +42,23 @@ a copy of this software and associated documentation files (the * @version May 2017 */ public abstract class AtomicMemoryOperation extends Atomic { + private bitWidth width; + public AtomicMemoryOperation(String usage, String description, String funct5) { super(usage, description, "010", funct5); + width = bitWidth.word; } public AtomicMemoryOperation(String usage, String description, String funct5, boolean rv64) { super(usage, description, rv64 ? "011" : "010", funct5, rv64); + width = rv64 ? bitWidth.doubleWord : bitWidth.word; } public void simulate(ProgramStatement statement) throws SimulationException { int[] operands = statement.getOperands(); try { int rs1Loc = RegisterFile.getValue(operands[2]); - Globals.reservationTables.unreserveAddress(0, rs1Loc); + Globals.reservationTables.unreserveAddress(0, rs1Loc, width); long rs1Data = InstructionSet.rv64 ? Globals.memory.getDoubleWord(rs1Loc) : Globals.memory.getWord(rs1Loc); long rs2Value = RegisterFile.getValueLong(operands[1]); RegisterFile.updateRegister(operands[0], rs1Data); diff --git a/src/rars/riscv/instructions/LRD.java b/src/rars/riscv/instructions/LRD.java index 89ded3c5..16d702e0 100644 --- a/src/rars/riscv/instructions/LRD.java +++ b/src/rars/riscv/instructions/LRD.java @@ -5,6 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReservationTable.bitWidth; public class LRD extends Atomic { public LRD() { @@ -21,7 +22,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long load(int address) throws AddressErrorException { - Globals.reservationTables.reserveAddress(0, address); + Globals.reservationTables.reserveAddress(0, address, bitWidth.doubleWord); return Globals.memory.getDoubleWord(address); } } diff --git a/src/rars/riscv/instructions/LRW.java b/src/rars/riscv/instructions/LRW.java index 27731971..0d433abc 100644 --- a/src/rars/riscv/instructions/LRW.java +++ b/src/rars/riscv/instructions/LRW.java @@ -5,6 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReservationTable.bitWidth; public class LRW extends Atomic { public LRW() { @@ -21,7 +22,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long load(int address) throws AddressErrorException { - Globals.reservationTables.reserveAddress(0, address); + Globals.reservationTables.reserveAddress(0, address, bitWidth.word); return Globals.memory.getWord(address); } } diff --git a/src/rars/riscv/instructions/SB.java b/src/rars/riscv/instructions/SB.java index 125f4bc0..9768ff64 100644 --- a/src/rars/riscv/instructions/SB.java +++ b/src/rars/riscv/instructions/SB.java @@ -2,6 +2,7 @@ import rars.Globals; import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.ReservationTable.bitWidth; /* Copyright (c) 2017, Benjamin Landers @@ -36,7 +37,7 @@ public SB() { } public void store(int address, long data) throws AddressErrorException { - Globals.reservationTables.unreserveAddress(0, address & ~0b11); + Globals.reservationTables.unreserveAddress(0, address & ~0b11, bitWidth.word); Globals.memory.setByte(address, (int)data & 0x000000FF); } } diff --git a/src/rars/riscv/instructions/SCD.java b/src/rars/riscv/instructions/SCD.java index a70b30b7..dba28da1 100644 --- a/src/rars/riscv/instructions/SCD.java +++ b/src/rars/riscv/instructions/SCD.java @@ -5,6 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReservationTable.bitWidth; public class SCD extends Atomic { public SCD() { @@ -22,7 +23,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private long store(int address, int value) throws AddressErrorException { - if (Globals.reservationTables.unreserveAddress(0, address)) { + if (Globals.reservationTables.unreserveAddress(0, address, bitWidth.doubleWord)) { Globals.memory.setDoubleWord(address, value); return 0; } diff --git a/src/rars/riscv/instructions/SCW.java b/src/rars/riscv/instructions/SCW.java index d87760c0..80ad716c 100644 --- a/src/rars/riscv/instructions/SCW.java +++ b/src/rars/riscv/instructions/SCW.java @@ -5,6 +5,7 @@ import rars.ProgramStatement; import rars.SimulationException; import rars.riscv.hardware.RegisterFile; +import rars.riscv.hardware.ReservationTable.bitWidth; public class SCW extends Atomic { public SCW() { @@ -22,7 +23,7 @@ public void simulate(ProgramStatement statement) throws SimulationException { } private int store(int address, int value) throws AddressErrorException { - if (Globals.reservationTables.unreserveAddress(0, address)) { + if (Globals.reservationTables.unreserveAddress(0, address, bitWidth.word)) { Globals.memory.setWord(address, value); return 0; } diff --git a/src/rars/riscv/instructions/SD.java b/src/rars/riscv/instructions/SD.java index 20228068..4b901d8d 100644 --- a/src/rars/riscv/instructions/SD.java +++ b/src/rars/riscv/instructions/SD.java @@ -2,6 +2,7 @@ import rars.Globals; import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.ReservationTable.bitWidth; public class SD extends Store { public SD() { @@ -9,9 +10,7 @@ public SD() { } public void store(int address, long data) throws AddressErrorException { + Globals.reservationTables.unreserveAddress(0, address, bitWidth.doubleWord); Globals.memory.setDoubleWord(address, data); } } - - - diff --git a/src/rars/riscv/instructions/SH.java b/src/rars/riscv/instructions/SH.java index 99e00741..a640e1f5 100644 --- a/src/rars/riscv/instructions/SH.java +++ b/src/rars/riscv/instructions/SH.java @@ -2,6 +2,7 @@ import rars.Globals; import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.ReservationTable.bitWidth; /* Copyright (c) 2017, Benjamin Landers @@ -36,7 +37,7 @@ public SH() { } public void store(int address, long data) throws AddressErrorException { - Globals.reservationTables.unreserveAddress(0, address & ~0b11); + Globals.reservationTables.unreserveAddress(0, address & ~0b11, bitWidth.word); Globals.memory.setHalf(address, (int)data & 0x0000FFFF); } } diff --git a/src/rars/riscv/instructions/SW.java b/src/rars/riscv/instructions/SW.java index 4ab55821..9c1720cf 100644 --- a/src/rars/riscv/instructions/SW.java +++ b/src/rars/riscv/instructions/SW.java @@ -2,6 +2,7 @@ import rars.Globals; import rars.riscv.hardware.AddressErrorException; +import rars.riscv.hardware.ReservationTable.bitWidth; /* Copyright (c) 2017, Benjamin Landers @@ -36,7 +37,7 @@ public SW() { } public void store(int address, long data) throws AddressErrorException { - Globals.reservationTables.unreserveAddress(0, address); + Globals.reservationTables.unreserveAddress(0, address, bitWidth.word); Globals.memory.setWord(address, (int) data); } } diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 0ec04ffc..1d885d0e 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -2,8 +2,7 @@ import rars.Globals; import rars.riscv.hardware.AddressErrorException; -import rars.riscv.hardware.*; -import rars.util.Binary; +import rars.riscv.hardware.ReservationTable.bitWidth; import rars.venus.*; import javax.swing.*; @@ -60,16 +59,15 @@ private Integer[] SelectHartWindow(){ public ReservationTablesTool() { super(heading + ", " + version, heading); Globals.reservationTables.addObserver(this); - - } protected JComponent buildMainDisplayArea() { JPanel panelTools = new JPanel(new BorderLayout()); hartPanel = new JPanel(new BorderLayout()); - String[] columns = new String[Globals.reservationTables.harts]; - for (int i = 0; i < columns.length; i++) { - columns[i] = String.format("Hart %d", i); + String[] columns = new String[Globals.reservationTables.harts * 2]; + for (int i = 0; i < Globals.reservationTables.harts; i++) { + columns[i * 2] = String.format("Hart %d", i); + columns[i * 2 + 1] = "Length"; } reservations = new JTable(Globals.reservationTables.getAllAddressesAsStrings(), columns) { @Override @@ -80,7 +78,8 @@ public boolean isCellEditable(int row, int column) { hartPanel.add(reservations.getTableHeader(), BorderLayout.NORTH); reservations.setCellSelectionEnabled(true); - reservations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + reservations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + reservations.getTableHeader().setReorderingAllowed(false); hartPanel.add(reservations); TitledBorder tb = new TitledBorder(displayPanelTitle); @@ -94,12 +93,10 @@ public boolean isCellEditable(int row, int column) { new ActionListener() { public void actionPerformed(ActionEvent e) { int i = hartWindowSelector.getSelectedIndex(); - if(i == 0) + if (i == 0) return; - else{ - hartWindows.get(i-1).setVisible(true); - } - + else + hartWindows.get(i-1).setVisible(true); } }); @@ -111,10 +108,12 @@ public void actionPerformed(ActionEvent e) { int col = reservations.getSelectedColumn(); if(row < 0 || col < 0) return; + if (col % 2 == 1) + col--; int address = Integer.parseInt(reservations.getValueAt(row, col) .toString().substring(2), 16); try { - Globals.reservationTables.unreserveAddress(col, address); + Globals.reservationTables.unreserveAddress(col, address, bitWidth.word); } catch (AddressErrorException e) { e.printStackTrace(); } @@ -174,5 +173,3 @@ protected void reset() { updateDisplay(); } } - - From f703297f1de73d1b84e8a19af0d149896ca13c2b Mon Sep 17 00:00:00 2001 From: Giancarlo Pernudi Segura Date: Thu, 17 Jun 2021 22:58:07 -0600 Subject: [PATCH 49/51] rename atomic example --- examples/{atomic.s => atomic_increment.s} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{atomic.s => atomic_increment.s} (100%) diff --git a/examples/atomic.s b/examples/atomic_increment.s similarity index 100% rename from examples/atomic.s rename to examples/atomic_increment.s From 66ef86168d1c5843a4a0dfac279987bd8501463b Mon Sep 17 00:00:00 2001 From: giancarlopernudisegura Date: Fri, 16 Jul 2021 11:54:14 -0600 Subject: [PATCH 50/51] disable multithreading code for PR --- src/rars/Globals.java | 18 +- src/rars/tools/ReservationTablesTool.java | 1 - src/rars/venus/GeneralExecutePane.java | 242 ------------------ src/rars/venus/GeneralMainPane.java | 101 -------- src/rars/venus/GeneralVenusUI.java | 214 ---------------- .../venus/registers/GeneralRegistersPane.java | 96 ------- src/rars/venus/run/RunAssembleAction.java | 28 -- src/rars/venus/run/RunGoAction.java | 41 +-- src/rars/venus/run/RunStepAction.java | 44 +--- 9 files changed, 4 insertions(+), 781 deletions(-) delete mode 100644 src/rars/venus/GeneralExecutePane.java delete mode 100644 src/rars/venus/GeneralMainPane.java delete mode 100644 src/rars/venus/GeneralVenusUI.java delete mode 100644 src/rars/venus/registers/GeneralRegistersPane.java diff --git a/src/rars/Globals.java b/src/rars/Globals.java index 862ebb6e..efcb36f6 100644 --- a/src/rars/Globals.java +++ b/src/rars/Globals.java @@ -7,7 +7,6 @@ import rars.riscv.SyscallNumberOverride; import rars.util.PropertiesFile; import rars.venus.VenusUI; -import rars.venus.GeneralVenusUI; import java.util.ArrayList; import java.util.Enumeration; @@ -62,8 +61,6 @@ public class Globals { * the program currently being worked with. Used by GUI only, not command line. **/ public static RISCVprogram program; - - public static ArrayList gPrograms; /** * Symbol table for file currently being assembled. **/ @@ -148,20 +145,7 @@ public class Globals { public static boolean runSpeedPanelExists = false; - private static int harts = 2; - - private static ArrayList hartWindows = new ArrayList(); - - public static void setHartWindows(){ - for(int i = 1; i < Globals.getHarts(); i++){ - GeneralVenusUI temp= new GeneralVenusUI("Window "+i); - hartWindows.add(temp); - } - } - - public static ArrayList getHartWindows(){ - return hartWindows; - } + private static int harts = 1; public static int getHarts() { return harts; diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 1d885d0e..7fd5798d 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -44,7 +44,6 @@ public class ReservationTablesTool extends AbstractToolAndApplication { private static String displayPanelTitle; private JPanel displayOptions, hartPanel; private JComboBox hartWindowSelector; - protected ArrayList hartWindows = Globals.getHartWindows(); private Integer[] SelectHartWindow(){ Integer hartChoser[]; diff --git a/src/rars/venus/GeneralExecutePane.java b/src/rars/venus/GeneralExecutePane.java deleted file mode 100644 index a2d167c1..00000000 --- a/src/rars/venus/GeneralExecutePane.java +++ /dev/null @@ -1,242 +0,0 @@ -package rars.venus; - -import rars.Globals; -import rars.Settings; -import rars.venus.registers.ControlAndStatusWindow; -import rars.venus.registers.FloatingPointWindow; -import rars.venus.registers.RegistersWindow; - -import javax.swing.*; -import java.awt.*; - -/* -Copyright (c) 2003-2006, Siva Chowdeswar Nandipati - -Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -(MIT license, http://www.opensource.org/licenses/mit-license.html) - */ - -/** - * Container for the execution-related windows. Currently displayed as a tabbed pane. - * - * @author Sanderson and Team JSpim - **/ - -public class GeneralExecutePane extends JDesktopPane { - private RegistersWindow registerValues; - private FloatingPointWindow fpRegValues; - private ControlAndStatusWindow csrValues; - private TextSegmentWindow textSegment; - private LabelsWindow labelValues; - private GeneralVenusUI mainUI; - private NumberDisplayBaseChooser valueDisplayBase; - private NumberDisplayBaseChooser addressDisplayBase; - private boolean labelWindowVisible; - - /** - * initialize the Execute pane with major components - * - * @param mainUI the parent GUI - * @param regs window containing integer register set - * @param fpRegs window containing floating point register set - * @param csrRegs window containing the CSR set - */ - - public GeneralExecutePane(GeneralVenusUI mainUI, RegistersWindow regs, FloatingPointWindow fpRegs, ControlAndStatusWindow csrRegs) { - this.mainUI = mainUI; - // Although these are displayed in Data Segment, they apply to all three internal - // windows within the Execute pane. So they will be housed here. - registerValues = regs; - fpRegValues = fpRegs; - csrValues = csrRegs; - textSegment = new TextSegmentWindow(); - labelValues = new LabelsWindow(); - labelWindowVisible = Globals.getSettings().getBooleanSetting(Settings.Bool.LABEL_WINDOW_VISIBILITY); - this.add(textSegment); // these 3 LOC moved up. DPS 3-Sept-2014 - textSegment.pack(); // these 3 LOC added. DPS 3-Sept-2014 - textSegment.setVisible(true); - labelValues.setVisible(labelWindowVisible); - - } - - /** - * This method will set the bounds of this JDesktopPane's internal windows - * relative to the current size of this JDesktopPane. Such an operation - * cannot be adequately done at constructor time because the actual - * size of the desktop pane window is not yet established. Layout manager - * is not a good option here because JDesktopPane does not work well with - * them (the whole idea of using JDesktopPane with internal frames is to - * have mini-frames that you can resize, move around, minimize, etc). This - * method should be invoked only once: the first time the Execute tab is - * selected (a change listener invokes it). We do not want it invoked - * on subsequent tab selections; otherwise, user manipulations of the - * internal frames would be lost the next time execute tab is selected. - */ - public void setWindowBounds() { - - int fullWidth = this.getSize().width - this.getInsets().left - this.getInsets().right; - int fullHeight = this.getSize().height; - int halfHeight = fullHeight / 2; - Dimension textDim = new Dimension((int) (fullWidth * .75), halfHeight); - Dimension lablDim = new Dimension((int) (fullWidth * .25), halfHeight); - Dimension textFullDim = new Dimension((int) (fullWidth), halfHeight); - - if (labelWindowVisible) { - textSegment.setBounds(0, 0, textDim.width, textDim.height); - labelValues.setBounds(textDim.width + 1, 0, lablDim.width, lablDim.height); - } else { - textSegment.setBounds(0, 0, textFullDim.width, textFullDim.height); - labelValues.setBounds(0, 0, 0, 0); - } - } - - /** - * Show or hide the label window (symbol table). If visible, it is displayed - * to the right of the text segment and the latter is shrunk accordingly. - * - * @param visibility set to true or false - */ - - public void setLabelWindowVisibility(boolean visibility) { - if (!visibility && labelWindowVisible) { - labelWindowVisible = false; - textSegment.setVisible(false); - labelValues.setVisible(false); - setWindowBounds(); - textSegment.setVisible(true); - } else if (visibility && !labelWindowVisible) { - labelWindowVisible = true; - textSegment.setVisible(false); - setWindowBounds(); - textSegment.setVisible(true); - labelValues.setVisible(false); - } - } - - /** - * Clears out all components of the Execute tab: text segment - * display, data segment display, label display and register display. - * This will typically be done upon File->Close, Open, New. - */ - - public void clearPane() { - this.getTextSegmentWindow().clearWindow(); - this.getRegistersWindow().clearWindow(); - this.getFloatingPointWindow().clearWindow(); - this.getControlAndStatusWindow().clearWindow(); - this.getLabelsWindow().clearWindow(); - // seems to be required, to display cleared Execute tab contents... - if (mainUI.getMainPane().getSelectedComponent() == this) { - mainUI.getMainPane().setSelectedComponent(this); - } - } - - /** - * Access the text segment window. - */ - public TextSegmentWindow getTextSegmentWindow() { - return textSegment; - } - - /** - * Access the register values window. - */ - public RegistersWindow getRegistersWindow() { - return registerValues; - } - - /** - * Access the floating point values window. - */ - public FloatingPointWindow getFloatingPointWindow() { - return fpRegValues; - } - - /** - * Access the Control and Status values window. - */ - public ControlAndStatusWindow getControlAndStatusWindow() { - return csrValues; - } - - /** - * Access the label values window. - */ - public LabelsWindow getLabelsWindow() { - return labelValues; - } - - /** - * Retrieve the number system base for displaying values (mem/register contents) - */ - public int getValueDisplayBase() { - return valueDisplayBase.getBase(); - } - - /** - * Retrieve the number system base for displaying memory addresses - */ - public int getAddressDisplayBase() { - return addressDisplayBase.getBase(); - } - - /** - * Retrieve component used to set numerical base (10 or 16) of data value display. - * - * @return the chooser - */ - public NumberDisplayBaseChooser getValueDisplayBaseChooser() { - return valueDisplayBase; - } - - /** - * Retrieve component used to set numerical base (10 or 16) of address display. - * - * @return the chooser - */ - public NumberDisplayBaseChooser getAddressDisplayBaseChooser() { - return addressDisplayBase; - } - - /** - * Update display of columns based on state of given chooser. Normally - * called only by the chooser's ItemListener. - * - * @param chooser the GUI object manipulated by the user to change number base - */ - public void numberDisplayBaseChanged(NumberDisplayBaseChooser chooser) { - if (chooser == valueDisplayBase) { - // Have all internal windows update their value columns - registerValues.updateRegisters(); - fpRegValues.updateRegisters(); - csrValues.updateRegisters(); - textSegment.updateBasicStatements(); - } else { // addressDisplayBase - // Have all internal windows update their address columns - labelValues.updateLabelAddresses(); - textSegment.updateCodeAddresses(); - textSegment.updateBasicStatements(); - } - } - -} \ No newline at end of file diff --git a/src/rars/venus/GeneralMainPane.java b/src/rars/venus/GeneralMainPane.java deleted file mode 100644 index d8a08056..00000000 --- a/src/rars/venus/GeneralMainPane.java +++ /dev/null @@ -1,101 +0,0 @@ -package rars.venus; - -import rars.Globals; -import rars.venus.registers.ControlAndStatusWindow; -import rars.venus.registers.FloatingPointWindow; -import rars.venus.registers.RegistersWindow; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.basic.BasicTabbedPaneUI; -import java.awt.*; - - -/* -Copyright (c) 2003-2006, Siva Chowdeswar Nandipati - -Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -(MIT license, http://www.opensource.org/licenses/mit-license.html) - */ - -/** - * Creates the tabbed areas in the UI and also created the internal windows that - * exist in them. - * - * @author Sanderson and Bumgarner - **/ - -public class GeneralMainPane extends JTabbedPane { - GeneralExecutePane executeTab; - - private GeneralVenusUI mainUI; - - /** - * Constructor for the MainPane class. - **/ - - public GeneralMainPane(GeneralVenusUI appFrame, RegistersWindow regs, - FloatingPointWindow cop1Regs, ControlAndStatusWindow cop0Regs) { - super(); - this.mainUI = appFrame; - this.setTabPlacement(JTabbedPane.TOP); //LEFT); - if (this.getUI() instanceof BasicTabbedPaneUI) { - BasicTabbedPaneUI ui = (BasicTabbedPaneUI) this.getUI(); - } - - executeTab = new GeneralExecutePane(appFrame, regs, cop1Regs, cop0Regs); - String executeTabTitle = "Execute"; //"

 
E
x
e
c
u
t
e
 
"; - Icon executeTabIcon = null;//new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath+"Execute_tab.jpg"))); - - // this.addTab("
 
P
r
o
j
 
1", null, new JTabbedPane()); - // this.addTab("
 
P
r
o
j
 
2", null, new JTabbedPane()); - // this.addTab("
 
P
r
o
j
 
3", null, new JTabbedPane()); - // this.addTab("
 
P
r
o
j
 
4", null, new JTabbedPane()); - - this.addTab(executeTabTitle, executeTabIcon, executeTab); - - this.setToolTipTextAt(0, "View and control assembly language program execution. Enabled upon successful assemble."); - - } - - /** - * returns component containing execution-time display - * - * @return the execute pane - */ - public GeneralExecutePane getExecutePane() { - return executeTab; - } - - /** - * returns component containing execution-time display. - * Same as getExecutePane(). - * - * @return the execute pane - */ - public GeneralExecutePane getExecuteTab() { - return executeTab; - } - -} \ No newline at end of file diff --git a/src/rars/venus/GeneralVenusUI.java b/src/rars/venus/GeneralVenusUI.java deleted file mode 100644 index 048ee64e..00000000 --- a/src/rars/venus/GeneralVenusUI.java +++ /dev/null @@ -1,214 +0,0 @@ -package rars.venus; - -import rars.Globals; -import rars.Settings; -import rars.riscv.InstructionSet; -import rars.riscv.dump.DumpFormatLoader; -import rars.simulator.Simulator; -import rars.venus.registers.*; -import rars.venus.run.*; -import rars.venus.settings.*; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.net.URL; - -/* -Copyright (c) 2003-2006, Siva Chowdeswar Nandipati - -Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -(MIT license, http://www.opensource.org/licenses/mit-license.html) - */ - -/** - * Top level container for Venus GUI. - * - * @author Sanderson and Team JSpim - **/ - - /* Heavily modified by Pete Sanderson, July 2004, to incorporate JSPIMMenu and JSPIMToolbar - * not as subclasses of JMenuBar and JToolBar, but as instances of them. They are both - * here primarily so both can share the Action objects. - */ - -public class GeneralVenusUI extends JFrame { - GeneralVenusUI mainUI; - - private GeneralMainPane mainPane; - private GeneralRegistersPane registersPane; - private RegistersWindow registersTab; - private FloatingPointWindow fpTab; - private ControlAndStatusWindow csrTab; - private JSplitPane splitter, horizonSplitter; - JPanel north; - - private int frameState; // see windowActivated() and windowDeactivated() - - // PLEASE PUT THESE TWO (& THEIR METHODS) SOMEWHERE THEY BELONG, NOT HERE - private boolean reset = true; // registers/memory reset for execution - private boolean started = false; // started execution - - /** - * Constructor for the Class. Sets up a window object for the UI - * - * @param s Name of the window to be created. - **/ - - public GeneralVenusUI(String s) { - super(s); - mainUI = this; - double screenWidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); - double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight(); - double mainWidthPct = (screenWidth < 1000.0) ? 0.67 : 0.73; - double mainHeightPct = (screenWidth < 1000.0) ? 0.60 : 0.65; - double registersWidthPct = (screenWidth < 1000.0) ? 0.18 : 0.22; - double registersHeightPct = (screenWidth < 1000.0) ? 0.72 : 0.80; - Dimension mainPanePreferredSize = new Dimension((int) (screenWidth * mainWidthPct), (int) (screenHeight * mainHeightPct)); - Dimension registersPanePreferredSize = new Dimension((int) (screenWidth * registersWidthPct), (int) (screenHeight * registersHeightPct)); - Globals.initialize(true); - - // image courtesy of NASA/JPL. - URL im = this.getClass().getResource(Globals.imagesPath + "RISC-V.png"); - if (im == null) { - System.out.println("Internal Error: images folder or file not found"); - System.exit(0); - } - Image mars = Toolkit.getDefaultToolkit().getImage(im); - this.setIconImage(mars); - // Everything in frame will be arranged on JPanel "center", which is only frame component. - // "center" has BorderLayout and 2 major components: - // -- panel (jp) on North with 2 components - // 1. toolbar - // 2. run speed slider. - // -- split pane (horizonSplitter) in center with 2 components side-by-side - // 1. split pane (splitter) with 2 components stacked - // a. main pane, with 2 tabs (edit, execute) - // b. messages pane with 2 tabs (rars, run I/O) - // 2. registers pane with 3 tabs (register file, coproc 0, coproc 1) - // I should probably run this breakdown out to full detail. The components are created - // roughly in bottom-up order; some are created in component constructors and thus are - // not visible here. - - registersTab = new RegistersWindow("Not GUI"); - fpTab = new FloatingPointWindow(); - csrTab = new ControlAndStatusWindow(); - registersPane = new GeneralRegistersPane(mainUI, registersTab, fpTab, csrTab); - registersPane.setPreferredSize(registersPanePreferredSize); - - mainPane = new GeneralMainPane(mainUI, registersTab, fpTab, csrTab); - - - mainPane.setPreferredSize(mainPanePreferredSize); - - horizonSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainPane, registersPane); - horizonSplitter.setOneTouchExpandable(true); - horizonSplitter.resetToPreferredSizes(); - - JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT)); - JPanel center = new JPanel(new BorderLayout()); - center.add(jp, BorderLayout.NORTH); - center.add(horizonSplitter); - this.add(center); - - // This is invoked when opening the app. It will set the app to - // appear at full screen size. - this.addWindowListener( - new WindowAdapter() { - public void windowOpened(WindowEvent e) { - mainUI.pack(); - } - }); - - this.pack(); - } - - - /** - * To set whether the register values are reset. - * - * @param b Boolean true if the register values have been reset. - **/ - - public void setReset(boolean b) { - reset = b; - } - - /** - * To set whether MIPS program execution has started. - * - * @param b true if the MIPS program execution has started. - **/ - - public void setStarted(boolean b) { - started = b; - } - - /** - * To find out whether the register values are reset. - * - * @return Boolean true if the register values have been reset. - **/ - - public boolean getReset() { - return reset; - } - - /** - * To find out whether MIPS program is currently executing. - * - * @return true if MIPS program is currently executing. - **/ - public boolean getStarted() { - return started; - } - - /** - * Get reference to messages pane associated with this GUI. - * - * @return MessagesPane object associated with the GUI. - **/ - - public GeneralMainPane getMainPane() { - return mainPane; - } - - /** - * Get reference to registers pane associated with this GUI. - * - * @return RegistersPane object associated with the GUI. - **/ - - public GeneralRegistersPane getRegistersPane() { - return registersPane; - } - - - private ImageIcon loadIcon(String name) { - return new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath + name))); - } - - private KeyStroke makeShortcut(int key) { - return KeyStroke.getKeyStroke(key, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); - } -} \ No newline at end of file diff --git a/src/rars/venus/registers/GeneralRegistersPane.java b/src/rars/venus/registers/GeneralRegistersPane.java deleted file mode 100644 index fe10dccb..00000000 --- a/src/rars/venus/registers/GeneralRegistersPane.java +++ /dev/null @@ -1,96 +0,0 @@ -package rars.venus.registers; - -import rars.venus.GeneralVenusUI; - -import javax.swing.*; - -/* -Copyright (c) 2003-2006, Siva Chowdeswar Nandipati - -Developed by Siva Chowdeswar Nandipati (sivachow@ualberta.ca) - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject -to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -(MIT license, http://www.opensource.org/licenses/mit-license.html) - */ - -/** - * Contains tabbed areas in the UI to display register contents - * - * @author Sanderson - * @version August 2005 - **/ - -public class GeneralRegistersPane extends JTabbedPane { - private RegistersWindow regsTab; - private FloatingPointWindow fpTab; - private ControlAndStatusWindow csrTab; - - private GeneralVenusUI mainUI; - - /** - * Constructor for the RegistersPane class. - **/ - - public GeneralRegistersPane(GeneralVenusUI appFrame, RegistersWindow regs, FloatingPointWindow cop1, - ControlAndStatusWindow cop0) { - super(); - this.mainUI = appFrame; - regsTab = regs; - fpTab = cop1; - csrTab = cop0; - regsTab.setVisible(true); - fpTab.setVisible(true); - csrTab.setVisible(true); - this.addTab("Registers", regsTab); - this.addTab("Floating Point", fpTab); - this.addTab("Control and Status", csrTab); - this.setToolTipTextAt(0, "CPU registers"); - this.setToolTipTextAt(1, "Floating point unit registers"); - this.setToolTipTextAt(2, "Control and Status registers"); - } - - /** - * Return component containing integer register set. - * - * @return integer register window - */ - public RegistersWindow getRegistersWindow() { - return regsTab; - } - - /** - * Return component containing floating point register set. - * - * @return floating point register window - */ - public FloatingPointWindow getFloatingPointWindow() { - return fpTab; - } - - /** - * Return component containing Control and Status register set. - * - * @return exceptions register window - */ - public ControlAndStatusWindow getControlAndStatusWindow() { - return csrTab; - } -} \ No newline at end of file diff --git a/src/rars/venus/run/RunAssembleAction.java b/src/rars/venus/run/RunAssembleAction.java index 74ef9aa4..ead1eeed 100644 --- a/src/rars/venus/run/RunAssembleAction.java +++ b/src/rars/venus/run/RunAssembleAction.java @@ -7,7 +7,6 @@ import rars.util.SystemIO; import rars.venus.*; import rars.venus.registers.RegistersPane; -import rars.venus.registers.GeneralRegistersPane; import javax.swing.*; import java.awt.event.ActionEvent; @@ -48,17 +47,14 @@ a copy of this software and associated documentation files (the public class RunAssembleAction extends GuiAction { private static ArrayList programsToAssemble; - private static ArrayList> gProgramsToAssemble; private static boolean extendedAssemblerEnabled; private static boolean warningsAreErrors; // Threshold for adding filename to printed message of files being assembled. private static final int LINE_LENGTH_LIMIT = 60; private VenusUI mainUI; - protected ArrayList hartWindows = Globals.getHartWindows(); public RunAssembleAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); - Globals.setHartWindows(); mainUI = gui; } @@ -81,13 +77,6 @@ public void actionPerformed(ActionEvent e) { MessagesPane messagesPane = mainUI.getMessagesPane(); ExecutePane executePane = mainUI.getMainPane().getExecutePane(); RegistersPane registersPane = mainUI.getRegistersPane(); - ArrayList gexecutePanes = new ArrayList<>(); - ArrayList gregistersPanes = new ArrayList<>(); - - for (int i = 0; i < hartWindows.size(); i++) { - gexecutePanes.add(hartWindows.get(i).getMainPane().getExecutePane()); - gregistersPanes.add(hartWindows.get(i).getRegistersPane()); - } extendedAssemblerEnabled = Globals.getSettings().getBooleanSetting(Settings.Bool.EXTENDED_ASSEMBLER_ENABLED); warningsAreErrors = Globals.getSettings().getBooleanSetting(Settings.Bool.WARNINGS_ARE_ERRORS); @@ -97,10 +86,6 @@ public void actionPerformed(ActionEvent e) { } try { Globals.program = new RISCVprogram(); - Globals.gPrograms = new ArrayList<>(); - for (int i = 0; i < hartWindows.size(); i++){ - Globals.gPrograms.add(new RISCVprogram()); - } ArrayList filesToAssemble; if (Globals.getSettings().getBooleanSetting(Settings.Bool.ASSEMBLE_ALL)) {// setting calls for multiple // file assembly @@ -143,12 +128,6 @@ public void actionPerformed(ActionEvent e) { ControlAndStatusRegisterFile.resetRegisters(); InterruptController.reset(); Globals.reservationTables.reset(); - for (int i = 0; i < hartWindows.size(); i++) { - gexecutePanes.get(i).getTextSegmentWindow().setupTable(); - gexecutePanes.get(i).getLabelsWindow().setupTable(); - gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); - gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); - } executePane.getTextSegmentWindow().setupTable(); executePane.getDataSegmentWindow().setupTable(); executePane.getDataSegmentWindow().highlightCellForAddress(Memory.dataBaseAddress); @@ -159,13 +138,6 @@ public void actionPerformed(ActionEvent e) { registersPane.getRegistersWindow().clearWindow(); registersPane.getFloatingPointWindow().clearWindow(); registersPane.getControlAndStatusWindow().clearWindow(); - for(int i = 0; i < hartWindows.size(); i++){ - gregistersPanes.get(i).getRegistersWindow().clearWindow(); - gregistersPanes.get(i).getFloatingPointWindow().clearWindow(); - gregistersPanes.get(i).getControlAndStatusWindow().clearWindow(); - hartWindows.get(i).setReset(true); - hartWindows.get(i).setStarted(false); - } mainUI.setReset(true); mainUI.setStarted(false); mainUI.getMainPane().setSelectedComponent(executePane); diff --git a/src/rars/venus/run/RunGoAction.java b/src/rars/venus/run/RunGoAction.java index 3d5bd5b1..218a3df3 100644 --- a/src/rars/venus/run/RunGoAction.java +++ b/src/rars/venus/run/RunGoAction.java @@ -10,8 +10,6 @@ import rars.util.SystemIO; import rars.venus.ExecutePane; import rars.venus.FileStatus; -import rars.venus.GeneralExecutePane; -import rars.venus.GeneralVenusUI; import rars.venus.GuiAction; import rars.venus.VenusUI; @@ -59,9 +57,7 @@ public class RunGoAction extends GuiAction { public static int maxSteps = defaultMaxSteps; private String name; private ExecutePane executePane; - private ArrayList gexecutePanes = new ArrayList<>(); private VenusUI mainUI; - protected ArrayList hartWindows = Globals.getHartWindows(); public RunGoAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { @@ -75,9 +71,6 @@ public RunGoAction(String name, Icon icon, String descrip, public void actionPerformed(ActionEvent e) { name = this.getValue(Action.NAME).toString(); executePane = mainUI.getMainPane().getExecutePane(); - for(int i = 0; i < hartWindows.size(); i++){ - gexecutePanes.add(hartWindows.get(i).getMainPane().getExecutePane()); - } if (FileStatus.isAssembled()) { if (!mainUI.getStarted()) { processProgramArgumentsIfAny(); // DPS 17-July-2008 @@ -85,18 +78,11 @@ public void actionPerformed(ActionEvent e) { if (mainUI.getReset() || mainUI.getStarted()) { mainUI.setStarted(true); // added 8/27/05 - for(int i = 0; i < hartWindows.size(); i++){ - hartWindows.get(i).setStarted(true); - } mainUI.getMessagesPane().postMessage( name + ": running " + FileStatus.getFile().getName() + "\n\n"); mainUI.getMessagesPane().selectRunMessageTab(); executePane.getTextSegmentWindow().setCodeHighlighting(false); executePane.getTextSegmentWindow().unhighlightAllSteps(); - for(int i = 0; i < hartWindows.size(); i++){ - gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(false); - gexecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); - } //FileStatus.set(FileStatus.RUNNING); mainUI.setMenuState(FileStatus.RUNNING); @@ -156,15 +142,6 @@ public void paused(boolean done, Simulator.Reason pauseReason, SimulationExcepti executePane.getFloatingPointWindow().updateRegisters(); executePane.getControlAndStatusWindow().updateRegisters(); executePane.getDataSegmentWindow().updateValues(); - for(int i = 0; i < hartWindows.size(); i++){ - gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); - gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); - gexecutePanes.get(i).getRegistersWindow().updateRegisters(); - gexecutePanes.get(i).getFloatingPointWindow().updateRegisters(); - gexecutePanes.get(i).getControlAndStatusWindow().updateRegisters(); - hartWindows.get(i).setReset(false); - - } FileStatus.set(FileStatus.RUNNABLE); mainUI.setReset(false); } @@ -182,11 +159,6 @@ public void stopped(SimulationException pe, Simulator.Reason reason) { executePane.getFloatingPointWindow().updateRegisters(); executePane.getControlAndStatusWindow().updateRegisters(); executePane.getDataSegmentWindow().updateValues(); - for(int i = 0; i < hartWindows.size(); i++){ - gexecutePanes.get(i).getRegistersWindow().updateRegisters(); - gexecutePanes.get(i).getFloatingPointWindow().updateRegisters(); - gexecutePanes.get(i).getControlAndStatusWindow().updateRegisters(); - } FileStatus.set(FileStatus.TERMINATED); SystemIO.resetFiles(); // close any files opened in MIPS program // Bring CSRs to the front if terminated due to exception. @@ -196,12 +168,6 @@ public void stopped(SimulationException pe, Simulator.Reason reason) { executePane.getTextSegmentWindow().setCodeHighlighting(true); executePane.getTextSegmentWindow().unhighlightAllSteps(); executePane.getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); - for(int i = 0; i < hartWindows.size(); i++){ - hartWindows.get(i).getRegistersPane().setSelectedComponent(executePane.getControlAndStatusWindow()); - gexecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); - gexecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); - gexecutePanes.get(i).getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); - } } switch (reason) { case NORMAL_TERMINATION: @@ -239,11 +205,6 @@ public void stopped(SimulationException pe, Simulator.Reason reason) { } RunGoAction.resetMaxSteps(); mainUI.setReset(false); - for(int i = 0; i < hartWindows.size(); i++){ - hartWindows.get(i).setReset(false); - } - - } /** @@ -269,4 +230,4 @@ private void processProgramArgumentsIfAny() { } -} \ No newline at end of file +} diff --git a/src/rars/venus/run/RunStepAction.java b/src/rars/venus/run/RunStepAction.java index 1a0ad7fc..bbc2faf0 100644 --- a/src/rars/venus/run/RunStepAction.java +++ b/src/rars/venus/run/RunStepAction.java @@ -11,8 +11,6 @@ import rars.venus.FileStatus; import rars.venus.GuiAction; import rars.venus.VenusUI; -import rars.venus.GeneralVenusUI; -import rars.venus.GeneralExecutePane; import javax.swing.*; import java.awt.*; @@ -56,14 +54,12 @@ public class RunStepAction extends GuiAction { private String name; private ExecutePane executePane; - private ArrayList gExecutePanes; private VenusUI mainUI; - private ArrayList hartWindows; + public RunStepAction(String name, Icon icon, String descrip, Integer mnemonic, KeyStroke accel, VenusUI gui) { super(name, icon, descrip, mnemonic, accel); mainUI = gui; - hartWindows = Globals.getHartWindows(); } /** @@ -72,10 +68,6 @@ public RunStepAction(String name, Icon icon, String descrip, public void actionPerformed(ActionEvent e) { name = this.getValue(Action.NAME).toString(); executePane = mainUI.getMainPane().getExecutePane(); - gExecutePanes = new ArrayList<>(); - for(int i = 0; i < hartWindows.size(); i++){ - gExecutePanes.add(hartWindows.get(i).getMainPane().getExecutePane()); - } if (FileStatus.isAssembled()) { if (!mainUI.getStarted()) { // DPS 17-July-2008 processProgramArgumentsIfAny(); @@ -83,10 +75,6 @@ public void actionPerformed(ActionEvent e) { mainUI.setStarted(true); mainUI.getMessagesPane().selectRunMessageTab(); executePane.getTextSegmentWindow().setCodeHighlighting(true); - for(int i = 0; i < hartWindows.size(); i++){ - hartWindows.get(i).setStarted(true); - gExecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); - } // Setup callback for after step finishes final Observer stopListener = @@ -101,9 +89,6 @@ public void update(Observable o, Object simulator) { Simulator.getInstance().addObserver(stopListener); Globals.program.startSimulation(1, null); - for(int i = 0; i < hartWindows.size(); i++){ - Globals.gPrograms.get(i).startSimulation(1, null); - } } else { // note: this should never occur since "Step" is only enabled after successful assembly. JOptionPane.showMessageDialog(mainUI, "The program must be assembled before it can be run."); @@ -118,24 +103,13 @@ public void stepped(boolean done, Simulator.Reason reason, SimulationException p executePane.getControlAndStatusWindow().updateRegisters(); executePane.getDataSegmentWindow().updateValues(); - for(int i = 0; i < hartWindows.size(); i++){ - gExecutePanes.get(i).getRegistersWindow().updateRegisters(); - gExecutePanes.get(i).getFloatingPointWindow().updateRegisters(); - gExecutePanes.get(i).getControlAndStatusWindow().updateRegisters(); - } if (!done) { - for(int i = 0; i < hartWindows.size(); i++){ - gExecutePanes.get(i).getTextSegmentWindow().highlightStepAtPC(); - } executePane.getTextSegmentWindow().highlightStepAtPC(); FileStatus.set(FileStatus.RUNNABLE); } if (done) { RunGoAction.resetMaxSteps(); executePane.getTextSegmentWindow().unhighlightAllSteps(); - for(int i = 0; i < hartWindows.size(); i++){ - gExecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); - } FileStatus.set(FileStatus.TERMINATED); } if (done && pe == null) { @@ -159,17 +133,8 @@ public void stepped(boolean done, Simulator.Reason reason, SimulationException p executePane.getTextSegmentWindow().setCodeHighlighting(true); executePane.getTextSegmentWindow().unhighlightAllSteps(); executePane.getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); - for(int i = 0; i < hartWindows.size(); i++){ - hartWindows.get(i).getRegistersPane().setSelectedComponent(executePane.getControlAndStatusWindow()); - gExecutePanes.get(i).getTextSegmentWindow().setCodeHighlighting(true); - gExecutePanes.get(i).getTextSegmentWindow().unhighlightAllSteps(); - gExecutePanes.get(i).getTextSegmentWindow().highlightStepAtAddress(RegisterFile.getProgramCounter() - 4); - } } mainUI.setReset(false); - for(int i = 0; i < hartWindows.size(); i++){ - hartWindows.get(i).setReset(false); - } } //////////////////////////////////////////////////////////////////////////////////// @@ -179,15 +144,10 @@ public void stepped(boolean done, Simulator.Reason reason, SimulationException p // $a0 gets argument count (argc), $a1 gets stack address of first arg pointer (argv). private void processProgramArgumentsIfAny() { String programArguments = executePane.getTextSegmentWindow().getProgramArguments(); - ArrayList gProgramArgumentsArrayList = new ArrayList<>(); - for(int i = 0; i < hartWindows.size(); i++){ - gProgramArgumentsArrayList.add(gExecutePanes.get(i).getTextSegmentWindow().getProgramArguments()); - } - //TODO if (programArguments == null || programArguments.length() == 0 || !Globals.getSettings().getBooleanSetting(Settings.Bool.PROGRAM_ARGUMENTS)) { return; } new ProgramArgumentList(programArguments).storeProgramArguments(); } -} \ No newline at end of file +} From c83a9ed6fbe91f472586608da7a419dff3f62404 Mon Sep 17 00:00:00 2001 From: giancarlopernudisegura Date: Fri, 16 Jul 2021 13:28:35 -0600 Subject: [PATCH 51/51] disable extra harts on reservation table tool --- src/rars/tools/ReservationTablesTool.java | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/rars/tools/ReservationTablesTool.java b/src/rars/tools/ReservationTablesTool.java index 7fd5798d..0c29b6b2 100644 --- a/src/rars/tools/ReservationTablesTool.java +++ b/src/rars/tools/ReservationTablesTool.java @@ -43,16 +43,7 @@ public class ReservationTablesTool extends AbstractToolAndApplication { private static String version = "Version 1.0"; private static String displayPanelTitle; private JPanel displayOptions, hartPanel; - private JComboBox hartWindowSelector; - private Integer[] SelectHartWindow(){ - Integer hartChoser[]; - hartChoser = new Integer[(Integer) Globals.getHarts()]; - for(int i = 0; i < Globals.getHarts(); i ++){ - hartChoser[i] = i; - } - return hartChoser; - } private JTable reservations; public ReservationTablesTool() { @@ -86,18 +77,6 @@ public boolean isCellEditable(int row, int column) { panelTools.setBorder(tb); Box displayOptions = Box.createHorizontalBox(); - hartWindowSelector = new JComboBox<>(SelectHartWindow()); - hartWindowSelector.setToolTipText("Technique for determining simulated transmitter device processing delay"); - hartWindowSelector.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - int i = hartWindowSelector.getSelectedIndex(); - if (i == 0) - return; - else - hartWindows.get(i-1).setVisible(true); - } - }); JButton clearButton = new JButton("Clear Selected"); clearButton.setToolTipText("Clear the Selected from the Reserve Table"); @@ -121,8 +100,6 @@ public void actionPerformed(ActionEvent e) { updateDisplay(); }); - displayOptions.add(Box.createHorizontalGlue()); - displayOptions.add(hartWindowSelector); clearButton.addKeyListener(new EnterKeyListener(clearButton)); displayOptions.add(Box.createHorizontalGlue()); displayOptions.add(clearButton);