diff --git a/bin/Control/MyControlModel.class b/bin/Control/MyControlModel.class index c287801..3920d54 100644 Binary files a/bin/Control/MyControlModel.class and b/bin/Control/MyControlModel.class differ diff --git a/bin/Control/MyControlView.class b/bin/Control/MyControlView.class index ec8a98a..1cca0eb 100644 Binary files a/bin/Control/MyControlView.class and b/bin/Control/MyControlView.class differ diff --git a/bin/Model/Microcontroller/EepromThread.class b/bin/Model/Microcontroller/EepromThread.class index 43b01db..0700ceb 100644 Binary files a/bin/Model/Microcontroller/EepromThread.class and b/bin/Model/Microcontroller/EepromThread.class differ diff --git a/bin/Model/Microcontroller/PIC.class b/bin/Model/Microcontroller/PIC.class index 3a66835..347d06a 100644 Binary files a/bin/Model/Microcontroller/PIC.class and b/bin/Model/Microcontroller/PIC.class differ diff --git a/bin/Model/Microcontroller/PROGRAMMEMORY.class b/bin/Model/Microcontroller/PROGRAMMEMORY.class index 8427ac5..8aa1c6f 100644 Binary files a/bin/Model/Microcontroller/PROGRAMMEMORY.class and b/bin/Model/Microcontroller/PROGRAMMEMORY.class differ diff --git a/bin/Model/Microcontroller/RAM.class b/bin/Model/Microcontroller/RAM.class index 7b66774..c5b64d2 100644 Binary files a/bin/Model/Microcontroller/RAM.class and b/bin/Model/Microcontroller/RAM.class differ diff --git a/bin/Model/Microcontroller/STACK.class b/bin/Model/Microcontroller/STACK.class index 1cfbefa..57d7170 100644 Binary files a/bin/Model/Microcontroller/STACK.class and b/bin/Model/Microcontroller/STACK.class differ diff --git a/bin/Model/Microcontroller/TIME.class b/bin/Model/Microcontroller/TIME.class index 2cdb77b..654c905 100644 Binary files a/bin/Model/Microcontroller/TIME.class and b/bin/Model/Microcontroller/TIME.class differ diff --git a/bin/Model/MyModel.class b/bin/Model/MyModel.class index 0933978..c1ac517 100644 Binary files a/bin/Model/MyModel.class and b/bin/Model/MyModel.class differ diff --git a/bin/Model/ProgramLoader/ReadProgramFile.class b/bin/Model/ProgramLoader/ReadProgramFile.class index 961bceb..e3a4fe7 100644 Binary files a/bin/Model/ProgramLoader/ReadProgramFile.class and b/bin/Model/ProgramLoader/ReadProgramFile.class differ diff --git a/documentation/WORD/Dokumentation PIC Simulator Rechnerarchitektur.docx b/documentation/WORD/Dokumentation PIC Simulator Rechnerarchitektur.docx new file mode 100644 index 0000000..8d10056 Binary files /dev/null and b/documentation/WORD/Dokumentation PIC Simulator Rechnerarchitektur.docx differ diff --git a/src/Model/Microcontroller/EepromThread.java b/src/Model/Microcontroller/EepromThread.java index ab31205..dce8dcb 100644 --- a/src/Model/Microcontroller/EepromThread.java +++ b/src/Model/Microcontroller/EepromThread.java @@ -2,12 +2,33 @@ package Model.Microcontroller; public class EepromThread extends Thread { - public EepromThread() { - + private Eeprom oEeprom; + private int iMethodCall = 0; + + public EepromThread(Eeprom oEeprom, int iMethodToCall) { + this.oEeprom = oEeprom; + iMethodCall = iMethodToCall; } @Override public void run() { - + switch (iMethodCall) { + case 1: { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + oEeprom.writeToFile(); + }break; + case 2: { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + oEeprom.readFromFile(); + }break; + } } } diff --git a/src/Model/Microcontroller/PIC.java b/src/Model/Microcontroller/PIC.java index 71bc30e..47a9a4a 100755 --- a/src/Model/Microcontroller/PIC.java +++ b/src/Model/Microcontroller/PIC.java @@ -13,30 +13,30 @@ public class Pic { * Parts of PIC. * Objects are written with a large starting letter. */ - private PROGRAMMEMORY ProgramMemory; - private RAM Ram; - private STACK Stack; + private ProgramMemory ProgramMemory; + private Ram Ram; + private Stack Stack; private int WRegister; - private TIME Runtimer; + private Time Runtimer; private Alu ArithmeticLogicUnit; - private Eeprom Eeprom; + private Eeprom oEeprom; private int iStateMachineWriteEeprom = 0; public Pic() { //Initialising objects of PIC. - ProgramMemory = new PROGRAMMEMORY(); - Ram = new RAM(); - Stack = new STACK(); - Runtimer = new TIME(Ram); + ProgramMemory = new ProgramMemory(); + Ram = new Ram(); + Stack = new Stack(); + Runtimer = new Time(Ram); WRegister = 0; ArithmeticLogicUnit = new Alu(); - Eeprom = new Eeprom(); + oEeprom = new Eeprom(); } public synchronized void resetPIC() { - Ram = new RAM(); - Stack = new STACK(); - Runtimer = new TIME(Ram); + Ram = new Ram(); + Stack = new Stack(); + Runtimer = new Time(Ram); WRegister = 0; } @@ -74,19 +74,19 @@ public class Pic { return WRegister; } - public synchronized RAM getRam() { + public synchronized Ram getRam() { return Ram; } - public synchronized PROGRAMMEMORY getEeprom() { + public synchronized ProgramMemory getEeprom() { return ProgramMemory; } - public synchronized STACK getStack() { + public synchronized Stack getStack() { return Stack; } - public synchronized TIME getRuntimer() { + public synchronized Time getRuntimer() { return Runtimer; } @@ -359,8 +359,8 @@ public class Pic { iStateMachineWriteEeprom = 4; } else if ((iStateMachineWriteEeprom == 4) && (bitaddress == 7) && (registerFileAddress == 0x0B)) { if (Ram.get_WREN()) { - //TODO start thread - Eeprom.writeToFile(); + EepromThread oEepromThread = new EepromThread(oEeprom, 1); + oEepromThread.run(); } } else { iStateMachineWriteEeprom = 0; diff --git a/src/Model/Microcontroller/PROGRAMMEMORY.java b/src/Model/Microcontroller/PROGRAMMEMORY.java index 3c7d2e3..22330b2 100644 --- a/src/Model/Microcontroller/PROGRAMMEMORY.java +++ b/src/Model/Microcontroller/PROGRAMMEMORY.java @@ -7,19 +7,19 @@ package Model.Microcontroller; /** * ProgramMemory of the PIC (Programmspeicher) */ -public class PROGRAMMEMORY +public class ProgramMemory { private int[][] aiiProgramMemory; private int iProgramMemoryLength = 1024; private int[] aiProgramLines; - public PROGRAMMEMORY() + public ProgramMemory() { aiiProgramMemory = new int[iProgramMemoryLength][2]; } - public PROGRAMMEMORY(int iLength) { + public ProgramMemory(int iLength) { aiiProgramMemory = new int[iLength][2]; } diff --git a/src/Model/Microcontroller/RAM.java b/src/Model/Microcontroller/RAM.java index 5dcb300..e570ed9 100755 --- a/src/Model/Microcontroller/RAM.java +++ b/src/Model/Microcontroller/RAM.java @@ -13,7 +13,7 @@ package Model.Microcontroller; * * Page 13 datasheet parts of RAM. */ -public class RAM { +public class Ram { //Bank0 of the PIC-RAM private int[] bank0; @@ -32,7 +32,7 @@ public class RAM { * Constructor of RAM * Initializes two banks as two int arrays of size 128. */ - public RAM() { + public Ram() { //Bank0 of the PIC-RAM bank0 = new int[128]; @@ -206,6 +206,7 @@ public class RAM { * @param value to set TMR0 to. */ public synchronized void set_TMR0(int value) { + iPrescaledTMR0 = 0; value &= 255; bank0[1] = value; } @@ -225,9 +226,9 @@ public class RAM { //Increment TMR0 by 1, set T0IF at overflow. if ((iValTMR0 + 1) > 255) { set_T0IF(true); - set_TMR0((iValTMR0 + 1) & 255); + bank0[1] = (iValTMR0 + 1) & 255; } else { - set_TMR0(iValTMR0 + 1); + bank0[1] = (iValTMR0 + 1) & 255; } //Prescaler assigned to TMR0, increment TMR0 if prescaled TMR0 equals TMR0 prescaler-rate. } else { @@ -238,9 +239,9 @@ public class RAM { //Increment TMR0 by 1, set T0IF at overflow. if ((iValTMR0 + 1) > 255) { set_T0IF(true); - set_TMR0((iValTMR0 + 1) & 255); + bank0[1] = (iValTMR0 + 1) & 255; } else { - set_TMR0(iValTMR0 + 1); + bank0[1] = (iValTMR0 + 1) & 255; } } } diff --git a/src/Model/Microcontroller/STACK.java b/src/Model/Microcontroller/STACK.java index e8ab909..d1f8b56 100755 --- a/src/Model/Microcontroller/STACK.java +++ b/src/Model/Microcontroller/STACK.java @@ -10,7 +10,7 @@ import java.util.EmptyStackException; /** * Datasheet Page 18 */ -public class STACK +public class Stack { private int stackpointer; private int[] stack; @@ -21,7 +21,7 @@ public class STACK /** * Constructor of STACK. */ - public STACK() // + public Stack() // { stackpointer = 0; //Initialize stack with -1 to decide wether the stack is empty or not, because 0 could be a return address. diff --git a/src/Model/Microcontroller/TIME.java b/src/Model/Microcontroller/TIME.java index 2c98da6..c5bd8ab 100644 --- a/src/Model/Microcontroller/TIME.java +++ b/src/Model/Microcontroller/TIME.java @@ -1,6 +1,6 @@ package Model.Microcontroller; -public class TIME { +public class Time { private double dRuntime; private double dMaxWatchdog; private double dOldMaxWatchdog; @@ -9,9 +9,9 @@ public class TIME { private boolean WDTE = false; - private RAM oRam; + private Ram oRam; - public TIME(RAM oRam) { + public Time(Ram oRam) { dWatchdogTimer = dMaxWatchdog = dOldMaxWatchdog = 18000; this.oRam = oRam; }