ExecutionTime Multiplier, Hex Format

This commit is contained in:
2024-06-02 21:41:00 +02:00
parent 8bc6d5cfd0
commit 0ed167f822
6 changed files with 37 additions and 20 deletions

View File

@ -18,7 +18,7 @@ public class Commands {
}
public static long getTotalExecutionTime() {
return totalExecutionTime;
return (long) (totalExecutionTime * Controller_Frontend.getExecutionTimeMultiplier());
}
public static void resetTotalExecutionTime() {

View File

@ -32,13 +32,19 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import static java.lang.Math.max;
public class Controller_Frontend {
private int [] prog;
private int [][] read;
private int [] ind;
private double executionTimeMultiplier = 1;
private static double executionTimeMultiplier = 1;
public static double getExecutionTimeMultiplier(){
return executionTimeMultiplier;
}
@ -240,8 +246,7 @@ public class Controller_Frontend {
IOPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
long totalExecutionTime = Commands.getTotalExecutionTime();
double adjustedTotalExecutionTime = totalExecutionTime * executionTimeMultiplier;
totalExecutionTimeLabel.setText("Total Execution Time: " + adjustedTotalExecutionTime + "µs");
totalExecutionTimeLabel.setText("Total Execution Time: " + totalExecutionTime + "µs");
}
private void markSelectedRow(int currentIndex, String selectedRowStyle) {
@ -268,6 +273,7 @@ public class Controller_Frontend {
File selectedFile = chooseLSTFile();
stopAutoRun(null);
if(selectedFile != null){
String fileAddress = selectedFile.getAbsolutePath();
DataRegister.initDataRegister();
DataRegister.resetPC();
initialize();
@ -285,13 +291,23 @@ public class Controller_Frontend {
WatchdogTimer.reset();
wdtCheck.setSelected(false);
Table.refresh();
read = ParseFile.parseDatei(selectedFile.getAbsolutePath());
read = ParseFile.parseDatei(fileAddress);
prog = read [0];
ind = read[1];
System.out.println(Arrays.toString(Arrays.stream(prog).toArray()));
displayLSTFileContent(selectedFile);
markSelectedRow(0, "-fx-background-color: red; -fx-text-fill: white;");
initializeBreakpoints();
int lastSlash = max (fileAddress.lastIndexOf('/'), fileAddress.lastIndexOf('\\'));
int lastDot = fileAddress.lastIndexOf('.');
String stageTitle;
if (lastDot > lastSlash)
stageTitle = "Simulator - " + fileAddress.substring(lastSlash + 1, lastDot);
else {
stageTitle = "Simulator - " + fileAddress.substring(lastSlash + 1);
}
Stage stage = (Stage) stepintoButton.getScene().getWindow();
stage.setTitle(stageTitle);
}
@ -345,7 +361,6 @@ public class Controller_Frontend {
private File chooseLSTFile() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open LST File");
fileChooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("LST Files", "*.lst", "*.LST"),
new FileChooser.ExtensionFilter("All Files", "*.*"));

View File

@ -83,7 +83,7 @@ public class EEPROM {
public static void registerTime(boolean reset) {
if (reset)
startTime = getTotalExecutionTime();
else if ((getTotalExecutionTime() >= (startTime + 1)) && writeControl) {
else if ((getTotalExecutionTime() >= (startTime + 1000)) && writeControl) {
eecon2stages = new boolean[]{false, false};
DataRegister.setDirectBit(EECON1, EEIF, 1);
DataRegister.setDirectBit(EECON1, WR, 0);

View File

@ -26,11 +26,11 @@ public class PreScaler {
scaler = getFactor();
}
public static void decrement() {
public static void decrement(boolean manual) {
scaler--;
if (scaler == 0) {
scaler = getFactor();
Timer.increment(false);
Timer.increment(manual);
}
}
}

View File

@ -25,6 +25,9 @@ public class Table {
private static final double TABLE_WIDTH = 400; // Breite der TableView
private static final double TABLE_HEIGHT = 650; // Höhe der TableView
private static String format (String s) {
return (s.length() == 1) ? "0" + s : s;
}
public static VBox refresh(){
@ -60,8 +63,8 @@ public class Table {
for (int col = 0; col < NUM_COLUMNS; col++) {
int index = row * NUM_COLUMNS + col;
if (index < DataRegister.getDataRegister().length) {
String address = "0x" + Integer.toHexString(index).toUpperCase();
String value = "0x" + Integer.toHexString(DataRegister.getDataRegister()[index]).toUpperCase();
String address = "0x" + format(Integer.toHexString(index).toUpperCase());
String value = "0x" + format(Integer.toHexString(DataRegister.getDataRegister()[index]).toUpperCase());
rowData[col] = new DataEntry(address, value);
} else {
rowData[col] = new DataEntry("", "");
@ -71,11 +74,11 @@ public class Table {
}
// Erstelle Labels für die Spezialregister
Label pclLabel = new Label("PCL: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getPCL())).toUpperCase());
Label statusLabel = new Label("STATUS: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getSTATUS())).toUpperCase());
Label fsrLabel = new Label("FSR: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getFSR())).toUpperCase());
Label pclathLabel = new Label("PCLATH: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getPCLATH())).toUpperCase());
Label intconLabel = new Label("INTCON: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getINTCON())).toUpperCase());
Label pclLabel = new Label("PCL: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getPCL())).toUpperCase()));
Label statusLabel = new Label("STATUS: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getSTATUS())).toUpperCase()));
Label fsrLabel = new Label("FSR: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getFSR())).toUpperCase()));
Label pclathLabel = new Label("PCLATH: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getPCLATH())).toUpperCase()));
Label intconLabel = new Label("INTCON: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getINTCON())).toUpperCase()));

View File

@ -13,7 +13,7 @@ public class Timer {
if (DataRegister.getDirectBit(OPTION, T0CS) == 0){
if (PreScaler.isPrescalerOnTimer()){
for (int i = 0; i < cycles; i++){
PreScaler.decrement();
PreScaler.decrement(false);
}
} else {
increment(false);
@ -26,12 +26,11 @@ public class Timer {
if ((DataRegister.getDirectBit(OPTION, T0CS) == 1) && !Controller_Frontend.isSleeping()){
int newpin = (register >> 4) & 1;
if (newpin != oldpin) {
System.out.println(newpin + " " + oldpin);
if (DataRegister.getDirectBit(OPTION, T0SE) == 0) {
// Low to high
if (newpin == 1 && oldpin == 0) {
if (PreScaler.isPrescalerOnTimer())
PreScaler.decrement();
PreScaler.decrement(true);
else
increment(true);
}
@ -39,7 +38,7 @@ public class Timer {
// High to low
if (newpin == 0 && oldpin == 1) {
if (PreScaler.isPrescalerOnTimer())
PreScaler.decrement();
PreScaler.decrement(true);
else
increment(true);
}