Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Extension, Reservation Table, and Multi-threading Support #121

Draft
wants to merge 93 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
d96aa80
ignore build files
giancarlopernudisegura May 14, 2021
e846a9d
lr.w and sc.w syntax support
giancarlopernudisegura May 14, 2021
7363378
fix sc.w instructions
giancarlopernudisegura May 15, 2021
fd13240
ReserveTable for 2 processors with shared memory
Sivachow May 25, 2021
2514a83
macOS .DS_Store
Sivachow May 25, 2021
fcac477
ReserveTable for 2 processors with shared memory
Sivachow May 25, 2021
7a12061
Merge branch 'ReservationTable' of https://github.com/giancarlopernud…
Sivachow May 25, 2021
e9022e0
Reserve Table
Sivachow May 25, 2021
e81c253
General Reserve Table
Sivachow May 27, 2021
d37dcf5
General Reserve Table 27 May
Sivachow May 27, 2021
7ea28ab
reservation table and tables
giancarlopernudisegura May 28, 2021
31a24b6
Commit
Sivachow May 28, 2021
37680f5
Small change
Sivachow May 28, 2021
815f798
basic tool
giancarlopernudisegura May 28, 2021
f555edb
28 May
Sivachow May 28, 2021
b5d07df
Merge branch 'ReservationTable' of https://github.com/giancarlopernud…
Sivachow May 28, 2021
c8bdb74
28 May
Sivachow May 28, 2021
a6000a0
integrate reservation table with lr.w and sc.w
giancarlopernudisegura May 28, 2021
f2911f9
show reservation table and help
giancarlopernudisegura May 29, 2021
af791d7
fix duplication of first cell
giancarlopernudisegura May 29, 2021
2d3e687
add table headers
giancarlopernudisegura May 29, 2021
9de9f2e
unreserve selection
giancarlopernudisegura May 29, 2021
735c061
Moved Clear to button area
Sivachow May 29, 2021
a4183fe
Modified Clear Selected
Sivachow May 29, 2021
92cefca
May 29
Sivachow May 29, 2021
d60dfb5
Reserve Table Layout
Sivachow May 29, 2021
56deb61
Reserve Table Tool
Sivachow May 29, 2021
87d0808
Changed 'Processor' to Hart'
Sivachow May 31, 2021
60d1341
change hart in help window to lowercase
giancarlopernudisegura Jun 1, 2021
22c1477
add atomic instructions example
giancarlopernudisegura Jun 2, 2021
21ef508
redefine all atomic instructions to be R type
giancarlopernudisegura Jun 2, 2021
ba9fd8e
parent AMO class
giancarlopernudisegura Jun 2, 2021
7a66fa1
Fixing the glue before clearselect
Sivachow Jun 3, 2021
ce33c92
Merge branch 'master' of https://github.com/giancarlopernudisegura/rars
Sivachow Jun 3, 2021
888a561
unreserve address on regular store
giancarlopernudisegura Jun 6, 2021
1cf1ea4
implement rest of 32-bit atomic instructions
giancarlopernudisegura Jun 6, 2021
8b0ce6e
Added To GUI
Sivachow Jun 7, 2021
3a5ab65
atomic 64-bit support
giancarlopernudisegura Jun 7, 2021
665ec73
GUI for Harts
Sivachow Jun 8, 2021
4fd92f5
Added the GUI for Harts
Sivachow Jun 8, 2021
58c3f05
Bug fix for Window GUI
Sivachow Jun 9, 2021
30d37fd
Merge branch 'TheThirdOne:master' into master
giancarlopernudisegura Jun 9, 2021
4875de9
categorize atomic instructions in statistics tool
giancarlopernudisegura Jun 9, 2021
095b715
update getInstructionCategory description for instruction support
giancarlopernudisegura Jun 9, 2021
9cf6d0a
add mhartid csr
giancarlopernudisegura Jun 9, 2021
a72d74e
sc.w/d returns unspecified failiure
giancarlopernudisegura Jun 9, 2021
d3c92b3
Moving the Harts to Globals
Sivachow Jun 10, 2021
9970c10
Merge branch 'master' of https://github.com/giancarlopernudisegura/rars
Sivachow Jun 10, 2021
0e17170
Documentation
Sivachow Jun 10, 2021
0cc3815
add rv32a unit tests
giancarlopernudisegura Jun 11, 2021
895bfb7
Fixed bugs for more than One Hart
Sivachow Jun 11, 2021
988346a
add rv64a unit tests
giancarlopernudisegura Jun 11, 2021
fc77595
All Harts work alike
Sivachow Jun 16, 2021
35cda76
fix sc on 64-bit mode
giancarlopernudisegura Jun 18, 2021
f703297
rename atomic example
giancarlopernudisegura Jun 18, 2021
85c7e75
Mannual Harts selection
Sivachow Jun 23, 2021
75d834b
MultiThreading Works except LR.W and SC.W
Sivachow Jun 23, 2021
2020e7a
reopen reservation table tool on hart update
giancarlopernudisegura Jun 23, 2021
cb52a90
add hart variable to ProgramStatement
giancarlopernudisegura Jun 24, 2021
85a9631
maximise text segment on extra hart windows
giancarlopernudisegura Jun 24, 2021
a795b31
add harts cli argument
giancarlopernudisegura Jul 8, 2021
c4feba9
Hart -1 independent, needs bug fixes
Sivachow Jul 9, 2021
6d4ae4f
Merge branch 'master' of https://github.com/giancarlopernudisegura/rars
Sivachow Jul 9, 2021
54661e8
Immediate and Arithmatic support
Sivachow Jul 13, 2021
2f6992d
add run buttons to secondary hart windows
giancarlopernudisegura Jul 13, 2021
1b33010
Harts works dependent with main Hart
Sivachow Jul 20, 2021
d606cf1
Updating registers work
Sivachow Jul 20, 2021
566200f
Highlightung works with few bugs
Sivachow Jul 22, 2021
7534aed
sync action buttons with main window
giancarlopernudisegura Jul 22, 2021
ff2c506
set terminal state independent
giancarlopernudisegura Jul 23, 2021
5509ea0
extend Zicsr for multithread support
giancarlopernudisegura Jul 26, 2021
01262f3
update cycle, instret, time csr on secondary harts
giancarlopernudisegura Jul 29, 2021
91a945a
fix component not found error
giancarlopernudisegura Aug 3, 2021
cc5db18
enable multithreaded branching
giancarlopernudisegura Aug 5, 2021
44ed41c
reset pc on reassemble for secondary harts
giancarlopernudisegura Aug 5, 2021
4da0506
add per hart execution setting
giancarlopernudisegura Aug 6, 2021
aeb5dc8
extend traps and interuptions to multithread
giancarlopernudisegura Aug 12, 2021
3b535d6
extend all but float instructions to multithread
giancarlopernudisegura Aug 13, 2021
3249da4
extend store instructions to multithread
giancarlopernudisegura Aug 13, 2021
1895866
multithread f+d extensions
giancarlopernudisegura Aug 17, 2021
0b3453d
fix negative references on secondary harts
giancarlopernudisegura Aug 17, 2021
6682000
PC register Fix
Sivachow Aug 20, 2021
5c4f453
fix (but not completely) highlighting on secondary harts
giancarlopernudisegura Aug 24, 2021
b3d1cfd
set menu state terminated general venus ui
giancarlopernudisegura Aug 24, 2021
f4c4a7c
Ecall Fixed 💀
Sivachow Aug 24, 2021
e97482d
multithread getting null strings
giancarlopernudisegura Aug 26, 2021
6818d53
fix GeneralVenusUI constructor
giancarlopernudisegura Aug 26, 2021
7451ae9
fix reservation table update call
giancarlopernudisegura Aug 26, 2021
39e59a6
fix syscall open and read multithreading
giancarlopernudisegura Aug 26, 2021
2e3a5db
Sys call Fixes :)
Sivachow Aug 26, 2021
eddb11b
Sys call Update
Sivachow Aug 30, 2021
c8a6dce
fix opening hart 2+
giancarlopernudisegura Aug 31, 2021
6371a8f
remove unnecessary syscall import
giancarlopernudisegura Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ out
.classpath
.project
examples/riscv

# RARS build
build/
rars.jar

# macOS
.DS_Store
15 changes: 15 additions & 0 deletions examples/atomic_increment.s
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/Settings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ DataSegmentHighlightBackground = 0x0099ccff
DataSegmentHighlightForeground = 0
RegisterHighlightBackground = 0x0099cc55
RegisterHighlightForeground = 0

PerHartExecution = false
Binary file added src/images/Shared.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 38 additions & 1 deletion src/rars/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

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;
import rars.venus.VenusUI;
import rars.venus.GeneralVenusUI;

import java.util.ArrayList;
import java.util.Enumeration;
Expand Down Expand Up @@ -60,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<RISCVprogram> gPrograms;
/**
* Symbol table for file currently being assembled.
**/
Expand All @@ -68,6 +72,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
**/
Expand Down Expand Up @@ -140,6 +148,34 @@ public class Globals {

public static boolean runSpeedPanelExists = false;

private static int harts = 1;

private static ArrayList<GeneralVenusUI> hartWindows = new ArrayList<>();

public static void setHartWindows() {
for (int i = 1; i < Globals.getHarts(); i++) {
hartWindows.add(new GeneralVenusUI(i - 1));
}
}

public static ArrayList<GeneralVenusUI> getHartWindows(){
return hartWindows;
}

public static int getHarts() {
return harts;
}

public static void setHarts(int i) {
if ((harts == 1 && i < 0) || (harts == 7 && i > 0)) {
return;
} if (i > 0) {
reservationTables = new ReservationTables(++harts);
} else {
reservationTables = new ReservationTables(--harts);
}
}

private static String getCopyrightYears() {
return "2003-2019";
}
Expand All @@ -166,7 +202,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(harts);
symbolTable = new SymbolTable("global");
settings = new Settings(gui);
instructionSet = new InstructionSet();
Expand Down
8 changes: 6 additions & 2 deletions src/rars/Launch.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class Launch {
* segments are <tt>.text</tt> and <tt>.data</tt>. Current supported dump formats <br>
* are <tt>Binary</tt>, <tt>HexText</tt>, <tt>BinaryText</tt>.<br>
* h -- display help. Use by itself and with no filename</br>
* harts <n> -- the amount of harts to use for running RARS with<br>
* hex -- display memory or register contents in hexadecimal (default)<br>
* ic -- display count of basic instructions 'executed'");
* mc -- set memory configuration. Option has 1 argument, e.g.<br>
Expand Down Expand Up @@ -384,6 +385,10 @@ private boolean parseCommandArgs(String[] args) {
countInstructions = true;
continue;
}
if (args[i].toLowerCase().equals("harts")) {
Globals.setHarts(Integer.valueOf(args[++i]));
continue;
}

if (new File(args[i]).exists()) { // is it a file name?
filenameList.add(args[i]);
Expand Down Expand Up @@ -713,6 +718,7 @@ private void displayHelp() {
out.println(" <segment> = " + segments+", or a range like 0x400000-0x10000000");
out.println(" <format> = " + formats);
out.println(" h -- display this help. Use by itself with no filename.");
out.println(" harts <n> -- the amount of harts to use for running RARS with");
out.println(" hex -- display memory or register contents in hexadecimal (default)");
out.println(" ic -- display count of basic instructions 'executed'");
out.println(" mc <config> -- set memory configuration. Argument <config> is");
Expand Down Expand Up @@ -749,5 +755,3 @@ private void displayHelp() {
}

}


20 changes: 19 additions & 1 deletion src/rars/ProgramStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class ProgramStatement implements Comparable<ProgramStatement> {
private int textAddress;
private int sourceLine;
private int binaryStatement;
private int currrentHart;
private boolean altered;
private static final String invalidOperator = "<INVALID>";

Expand Down Expand Up @@ -517,6 +518,15 @@ public void setSource(String src) {
source = src;
}

/**
* Set the current hart for this program statement.
*
* @param hart the new current hart
*/
public void setCurrentHart(int hart) {
currrentHart = hart;
}


/**
* Produces RISCVprogram object representing the source file containing this statement.
Expand Down Expand Up @@ -645,6 +655,15 @@ public int[] getOperands() {
return operands;
}

/**
* Produces current hart that will simulate this statement.
*
* @return curent hart.
*/
public int getCurrentHart() {
return currrentHart;
}

/**
* Produces operand value from given array position (first operand is position 0).
*
Expand Down Expand Up @@ -873,5 +892,4 @@ private class ListElement {
}
}
}

}
4 changes: 4 additions & 0 deletions src/rars/RISCVprogram.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ public void startSimulation(int maxSteps, int[] breakPoints) {
sim.startSimulation(RegisterFile.getProgramCounter(), maxSteps, breakPoints);
}

public void startSimulation(int maxSteps, int[] breakPoints, int hart) {
Simulator sim = Simulator.getInstance(hart);
sim.startSimulation(RegisterFile.getProgramCounter(hart), maxSteps, breakPoints, hart);
}
/**
* Instantiates a new {@link MacroPool} and sends reference of this
* {@link RISCVprogram} to it
Expand Down
8 changes: 6 additions & 2 deletions src/rars/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ public enum Bool {
/**
* Flag to determine whether a program uses rv64i instead of rv32i
*/
RV64_ENABLED("rv64Enabled", false);;
RV64_ENABLED("rv64Enabled", false),
/**
* Flag to determine if the step buttons should run for all harts or just indivdual hart
*/
PER_HART_EXECUTION("PerHartExecution", false);;

// TODO: add option for turning off user trap handling and interrupts
private String name;
Expand Down Expand Up @@ -1320,4 +1324,4 @@ private int[] getTextSegmentColumnOrder(String stringOfColumnIndexes) {
return list;
}

}
}
1 change: 1 addition & 0 deletions src/rars/api/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private ErrorList assemble(ArrayList<RISCVprogram> programs) throws AssemblyExce
*/
public void setup(ArrayList<String> args, String STDIN){
RegisterFile.resetRegisters();
Globals.reservationTables.reset();
FloatingPointRegisterFile.resetRegisters();
ControlAndStatusRegisterFile.resetRegisters();
InterruptController.reset();
Expand Down
2 changes: 1 addition & 1 deletion src/rars/riscv/BasicInstructionFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ 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
}
13 changes: 10 additions & 3 deletions src/rars/riscv/InstructionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ public static void processBranch(int displacement) {
// Decrement needed because PC has already been incremented
RegisterFile.setProgramCounter(RegisterFile.getProgramCounter() + displacement - Instruction.INSTRUCTION_LENGTH);
}
public static void processBranch(int displacement, int hart) {
// Decrement needed because PC has already been incremented
RegisterFile.setProgramCounter(RegisterFile.getProgramCounter(hart) + displacement - Instruction.INSTRUCTION_LENGTH, hart);
}

/*
* Method to process a jump. DO NOT USE WITH BRANCH INSTRUCTIONS!
Expand All @@ -322,7 +326,9 @@ public static void processBranch(int displacement) {
public static void processJump(int targetAddress) {
RegisterFile.setProgramCounter(targetAddress);
}

public static void processJump(int targetAddress, int hart) {
RegisterFile.setProgramCounter(targetAddress, hart);
}
/*
* Method to process storing of a return address in the given
* register. This is used only by the "and link"
Expand All @@ -333,7 +339,9 @@ public static void processJump(int targetAddress) {
public static void processReturnAddress(int register) {
RegisterFile.updateRegister(register, RegisterFile.getProgramCounter());
}

public static void processReturnAddress(int register, int hart){
RegisterFile.updateRegister(register, RegisterFile.getProgramCounter(hart), hart);
}
private static class MatchMap implements Comparable<MatchMap> {
private int mask;
private int maskLength; // number of 1 bits in mask
Expand Down Expand Up @@ -368,4 +376,3 @@ public BasicInstruction find(int instr) {
}
}
}

Loading