diff --git a/bin/Control/MyControlModel.class b/bin/Control/MyControlModel.class index 829a535..4991d87 100644 Binary files a/bin/Control/MyControlModel.class and b/bin/Control/MyControlModel.class differ diff --git a/bin/Model/Microcontroller/EEPROM.class b/bin/Model/Microcontroller/EEPROM.class index 4c93019..dc25048 100644 Binary files a/bin/Model/Microcontroller/EEPROM.class and b/bin/Model/Microcontroller/EEPROM.class differ diff --git a/bin/Model/Microcontroller/PIC.class b/bin/Model/Microcontroller/PIC.class index c63deae..524a737 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 900c1b9..829f507 100644 Binary files a/bin/Model/Microcontroller/PROGRAMMEMORY.class and b/bin/Model/Microcontroller/PROGRAMMEMORY.class differ diff --git a/src/Control/MyControlModel.java b/src/Control/MyControlModel.java index c039fe5..01f3ac5 100644 --- a/src/Control/MyControlModel.java +++ b/src/Control/MyControlModel.java @@ -145,7 +145,7 @@ public class MyControlModel implements ActionListener { } } oPIC.getEeprom().setProgramLines(aiProgramLines); - abBreakpoints = new boolean[oPIC.getEeprom().getLengthEEPROM()]; + abBreakpoints = new boolean[oPIC.getEeprom().getLengthProgramMemory()]; } private void controlBreakpoints(ActionEvent e) { diff --git a/src/Model/Microcontroller/EEPROM.java b/src/Model/Microcontroller/EEPROM.java index 6c77176..4114e1e 100644 --- a/src/Model/Microcontroller/EEPROM.java +++ b/src/Model/Microcontroller/EEPROM.java @@ -17,6 +17,18 @@ public class EEPROM { oFile = new File("./eeprom.dat"); } + public void setElementXOfEepromToY(int iX, int iY) { + aiEeprom[iX] = iY; + } + + public void setEeprom(int[] aiNewEeprom) { + aiEeprom = aiNewEeprom; + } + + public int[] getEeprom() { + return aiEeprom; + } + public void changeEepromLocation(String sLocation) { oFile = new File(sLocation + "eeprom.dat"); } diff --git a/src/Model/Microcontroller/PIC.java b/src/Model/Microcontroller/PIC.java index 941183c..7520f5c 100755 --- a/src/Model/Microcontroller/PIC.java +++ b/src/Model/Microcontroller/PIC.java @@ -13,21 +13,24 @@ public class PIC { * Parts of PIC. * Objects are written with a large starting letter. */ - private PROGRAMMEMORY Eeprom; + private PROGRAMMEMORY ProgramMemory; private RAM Ram; private STACK Stack; private int WRegister; private RUNTIMER Runtimer; private ALU ArithmeticLogicUnit; + private EEPROM Eeprom; + private int iStateMachineWriteEeprom = 0; public PIC() { //Initialising objects of PIC. - Eeprom = new PROGRAMMEMORY(); + ProgramMemory = new PROGRAMMEMORY(); Ram = new RAM(); Stack = new STACK(); Runtimer = new RUNTIMER(Ram); WRegister = 0; ArithmeticLogicUnit = new ALU(); + Eeprom = new EEPROM(); } public synchronized void resetPIC() { @@ -76,7 +79,7 @@ public class PIC { } public synchronized PROGRAMMEMORY getEeprom() { - return Eeprom; + return ProgramMemory; } public synchronized STACK getStack() { @@ -352,6 +355,16 @@ public class PIC { * Bit ’b’ in register ’f’ is set. */ public void BSF(int bitaddress, int registerFileAddress) { + //TODO have to check bitaddress and registerFileAddress too + if (iStateMachineWriteEeprom == 3) { + iStateMachineWriteEeprom = 4; + } else if (iStateMachineWriteEeprom == 4) { + if (Ram.get_WREN()) { + Eeprom.writeToFile(); + } + } else { + iStateMachineWriteEeprom = 0; + } //Get bitmask to OR with fileaddress to set bit. int bitMask = bitMaskSetBitArray[bitaddress]; //Get Value of RAM-Bank-RP0Bit Address. @@ -857,6 +870,12 @@ public class PIC { * as 0’s. */ public void MOVLW(int eightK) { + //TODO has to check eightK + if (iStateMachineWriteEeprom == 1) { + iStateMachineWriteEeprom = 2; + } else { + iStateMachineWriteEeprom = 0; + } //is set to eightK bit literal. setWRegister(eightK); @@ -913,6 +932,15 @@ public class PIC { * Move data from W register to file register */ public void MOVWF(int registerFileAddress) { + //TODO has to check registerFileAddress + if (iStateMachineWriteEeprom == 0) { + iStateMachineWriteEeprom = 1; + } else if (iStateMachineWriteEeprom == 2) { + iStateMachineWriteEeprom = 3; + } else { + iStateMachineWriteEeprom = 0; + } + //Data from is moved to fileregister. Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), get_WRegister(), false); @@ -1158,7 +1186,7 @@ public class PIC { public void SLEEP() { //pause running (no Thread.sleep()!!!) //Not implemented - + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1); if (Ram.get_T0CS() == false) { diff --git a/src/Model/Microcontroller/PROGRAMMEMORY.java b/src/Model/Microcontroller/PROGRAMMEMORY.java index 3bd9eca..a1353fa 100644 --- a/src/Model/Microcontroller/PROGRAMMEMORY.java +++ b/src/Model/Microcontroller/PROGRAMMEMORY.java @@ -77,7 +77,7 @@ public class PROGRAMMEMORY /** * Returns length of EEPROM */ - public int getLengthEEPROM() { + public int getLengthProgramMemory() { return eepromLength; }