This commit is contained in:
2024-06-03 12:59:23 +02:00
parent 6aab534dad
commit 648bb58030
6 changed files with 86 additions and 48 deletions

View File

@ -72,27 +72,6 @@ public class Controller_Frontend {
@FXML
private ListView<String> lstContentListView;
@FXML
private Label pclLabel;
@FXML
private Label PrescalerLabel;
@FXML
private Label statusLabel;
@FXML
private Label fsrLabel;
@FXML
private Label pclathLabel;
@FXML
private Label intconLabel;
@FXML
private Button stepButton;
@FXML
private Button autoRunGUI;
@ -109,6 +88,7 @@ public class Controller_Frontend {
private static volatile boolean isAutoRunActive = false;
private static volatile boolean isSleeping = false;
@ -208,7 +188,7 @@ public class Controller_Frontend {
}
@FXML
private void stepintoButton(ActionEvent event) throws IOException {
public void stepintoButton(ActionEvent event) throws IOException {
if (lstContentListView.getItems().isEmpty()) {
// Datei ist nicht geladen oder leer
return;
@ -318,6 +298,7 @@ public class Controller_Frontend {
IOPorts.setPORTfromUI(toggleButtonGroup);
} catch (NullPointerException ignored) {}
}
ProgramStack.reset();
wakeUpFromSleep();
breakpoints.clear();
IOPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
@ -337,18 +318,14 @@ public class Controller_Frontend {
int lastDot = fileAddress.lastIndexOf('.');
String stageTitle;
if (lastDot > lastSlash)
stageTitle = "Simulator - " + fileAddress.substring(lastSlash + 1, lastDot);
stageTitle = "Simulator " + fileAddress.substring(lastSlash + 1, lastDot);
else {
stageTitle = "Simulator - " + fileAddress.substring(lastSlash + 1);
stageTitle = "Simulator " + fileAddress.substring(lastSlash + 1);
}
Stage stage = (Stage) stepintoButton.getScene().getWindow();
stage.setTitle(stageTitle);
}
}
}
private void initializeBreakpoints() {
lstContentListView.setCellFactory(createBreakpointCell());
@ -601,6 +578,15 @@ public class Controller_Frontend {
stackVisual.setItems(observedList);
}
//
// @FXML
// private static Label dummyLabel;
//
// public static void triggerTableRefresh(){
// dummyLabel.setText(" ");
// CreateWindow.refreshTable((Stage) dummyLabel.getScene().getWindow());
// }
private void updateWatchdog (){
wdtCheck.setText("Watchdog-Timer: " + WatchdogTimer.get() + "µs");
}

View File

@ -31,7 +31,7 @@ public class CreateWindow extends Application {
grid.relocate(0, 0);
grid.getStylesheets().add(Objects.requireNonNull(getClass().getResource("styles.css")).toExternalForm());
Scene scene = new Scene(grid, 1800, 800);
Scene scene = new Scene(grid, 1845, 800);
primaryStage.setScene(scene);
primaryStage.setTitle("Simulator");
primaryStage.show();

View File

@ -239,6 +239,10 @@ public class DataRegister {
}
}
public static int getZeroFlag(){
return zeroFlag;
}
private static int carryFlag = 0;
public static void setCarryFlag(int value){
@ -323,6 +327,7 @@ public class DataRegister {
public static int getDirectRegister(int address) {
return dataRegister[address];
}
}

View File

@ -32,6 +32,11 @@ public class ProgramStack {
return returnStack.get(stackIndex)-1;
}
public static void reset (){
returnStack.clear();
stackIndex = 0;
}
public static int getStackPointer(){
return stackIndex;
}

View File

@ -3,16 +3,16 @@ package fabrik.simulator.pic16f84;
import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.Insets;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import java.io.IOException;
import static javafx.application.Application.launch;
public class Table {
@ -22,13 +22,25 @@ public class Table {
//Tabelle aktualisieren
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten
private static final double TABLE_WIDTH = 400; // Breite der TableView
private static final double TABLE_HEIGHT = 650; // Höhe der TableView
private static final double TABLE_WIDTH = 420; // Breite der TableView
private static final double TABLE_HEIGHT = 600; // Höhe der TableView
private static String format (String s) {
private static String formatHex(String s) {
return (s.length() == 1) ? "0" + s : s;
}
private static String formatBin (String s){
int l = s.length();
if (l < 8){
StringBuilder sBuilder = new StringBuilder(s);
for (int i = 0; i < 8 - l; i++){
sBuilder.insert(0, "0");
}
s = sBuilder.toString();
}
return s;
}
public static VBox refresh(){
// Erstelle eine Instanz der DataRegister-Klasse
@ -63,8 +75,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" + format(Integer.toHexString(index).toUpperCase());
String value = "0x" + format(Integer.toHexString(DataRegister.getDataRegister()[index]).toUpperCase());
String address = "0x" + formatHex(Integer.toHexString(index).toUpperCase());
String value = "0x" + formatHex(Integer.toHexString(DataRegister.getDataRegister()[index]).toUpperCase());
rowData[col] = new DataEntry(address, value);
} else {
rowData[col] = new DataEntry("", "");
@ -73,28 +85,57 @@ public class Table {
tableView.getItems().add(rowData);
}
// Erstelle Labels für die Spezialregister
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()));
Label wRegisterLabel = new Label("W-Register: 0x" + format(Integer.toHexString(Commands.get_wRegister()).toUpperCase()));
Label PCLabel = new Label("PC: 0x" + format(Integer.toHexString(DataRegister.getPC()).toUpperCase()));
Label Prescaler = new Label("Prescaler: 0x" + format(Integer.toHexString(PreScaler.getScaler())).toUpperCase());
// Erstelle Labels für die Spezialregister;
Label spacing = new Label(" ");
Label spacing2 = new Label(" ");
Label wRegisterLabel = new Label("W-Register: 0x" + formatHex(Integer.toHexString(Commands.get_wRegister()).toUpperCase()));
Label cLabel = new Label("Carry: 0x" + formatHex(Integer.toHexString(DataRegister.getCarryFlag())));
Label dcLabel = new Label("Digit-Carry: 0x" + formatHex(Integer.toHexString(DataRegister.getDigitCarryFlag())));
Label zLabel = new Label("Zero-Flag: 0x" + formatHex(Integer.toHexString(DataRegister.getZeroFlag())));
Label pcLabel = new Label("PC: 0x" + formatHex(Integer.toHexString(DataRegister.getPC()).toUpperCase()));
Label pclLabel = new Label("PCL: 0x" + formatHex(Integer.toHexString(DataRegister.getRegister(DataRegister.getPCL())).toUpperCase()));
Label pclathLabel = new Label("PCLATH: 0x" + formatHex(Integer.toHexString(DataRegister.getRegister(DataRegister.getPCLATH())).toUpperCase()));
Label statusLabel = new Label("STATUS: 0b" + formatBin(Integer.toBinaryString(DataRegister.getRegister(DataRegister.getSTATUS())))+ " (0x" + formatHex(Integer.toHexString(DataRegister.getRegister(DataRegister.getSTATUS())).toUpperCase()) + ")");
Label fsrLabel = new Label("FSR: 0x" + formatHex(Integer.toHexString(DataRegister.getRegister(DataRegister.getFSR())).toUpperCase()));
Label prescalerLabel = new Label("Prescaler: 0x" + formatHex(Integer.toHexString(PreScaler.getScaler())).toUpperCase());
Label intconLabel = new Label("INTCON: 0b" + formatBin(Integer.toBinaryString(DataRegister.getRegister(DataRegister.getINTCON()))) + " (0x" + formatHex(Integer.toHexString(DataRegister.getRegister(DataRegister.getINTCON())).toUpperCase()) + ")");
wRegisterLabel.setStyle("-fx-font-weight: bold");
pcLabel.setStyle("-fx-font-weight: bold");
statusLabel.setStyle("-fx-font-weight: bold");
intconLabel.setStyle("-fx-font-weight: bold");
HBox labelsAndButton = new HBox();
VBox labels = new VBox();
labels.getChildren().addAll(spacing, pcLabel, pclLabel, pclathLabel, wRegisterLabel, cLabel, dcLabel, zLabel, statusLabel, fsrLabel, prescalerLabel, intconLabel);
VBox button = new VBox();
Button resetButton = new Button("Register reset");
resetButton.setOnAction(e -> {
DataRegister.initDataRegister();
DataRegister.setPC(DataRegister.getPC()-1);
triggerRefresh();
});
button.getChildren().addAll(spacing2, resetButton);
labelsAndButton.getChildren().addAll(labels, button);
// Erstelle einen VBox, um die TableView und Labels anzuzeigen
VBox table = new VBox();
table.getChildren().addAll(tableView, pclLabel, statusLabel, fsrLabel, pclathLabel, intconLabel, wRegisterLabel, PCLabel, Prescaler);
table.getChildren().addAll(tableView, labelsAndButton);
VBox.setMargin(tableView, new Insets(0, 0, 0, 0));
return table;
}
private static void triggerRefresh() {
Controller_Frontend.triggerTableRefresh();
IOPorts.refreshUI(Controller_Frontend.getTRISbuttons(), Controller_Frontend.getPORTbuttons());
}
public static void main(String[] args) {
launch(args);
}

View File

@ -1060,4 +1060,5 @@
<padding>
<Insets right="50.0" />
</padding>
<Label fx:id="dummyLabel" text=" "/>
</AnchorPane>