diff --git a/bin/Backend/Microcontroller/PIC.class b/bin/Backend/Microcontroller/PIC.class index 6f9de97..e41de5d 100644 Binary files a/bin/Backend/Microcontroller/PIC.class and b/bin/Backend/Microcontroller/PIC.class differ diff --git a/bin/Backend/Microcontroller/RAM.class b/bin/Backend/Microcontroller/RAM.class index f8ec01b..57b1752 100644 Binary files a/bin/Backend/Microcontroller/RAM.class and b/bin/Backend/Microcontroller/RAM.class differ diff --git a/bin/Backend/Runtime/Environment.class b/bin/Backend/Runtime/Environment.class index a6fd8ff..8b51cd9 100644 Binary files a/bin/Backend/Runtime/Environment.class and b/bin/Backend/Runtime/Environment.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class index 11cc457..2402591 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class index 49fcb28..020859a 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class index 6d75bd0..d1acb2d 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegistersDetailed.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegistersDetailed.class new file mode 100644 index 0000000..d84d5e1 Binary files /dev/null and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegistersDetailed.class differ diff --git a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class index dd8ed34..107a049 100644 Binary files a/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class and b/bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.class differ diff --git a/src/Backend/Microcontroller/PIC.java b/src/Backend/Microcontroller/PIC.java index dece17e..698d528 100755 --- a/src/Backend/Microcontroller/PIC.java +++ b/src/Backend/Microcontroller/PIC.java @@ -26,8 +26,7 @@ public class PIC { WRegister = 0; } - public synchronized void resetPIC() - { + public synchronized void resetPIC() { Ram = new RAM(); Stack = new STACK(); WRegister = 0; @@ -59,13 +58,11 @@ public class PIC { int bitMaskClearBitArray[] = { bitMaskClearBit0, bitMaskClearBit1, bitMaskClearBit2, bitMaskClearBit3, bitMaskClearBit4, bitMaskClearBit5, bitMaskClearBit6, bitMaskClearBit7}; - public synchronized void setWRegister(int value) - { + public synchronized void setWRegister(int value) { WRegister = value; } - public synchronized int get_WRegister() - { + public synchronized int get_WRegister() { return WRegister; } @@ -88,40 +85,34 @@ public class PIC { * added to the eight bit literal ’k’ and the * result is placed in the W register. */ - public void ADDLW(int eightK) - { + public void ADDLW(int eightK) { int wRegValue = get_WRegister(); int result = wRegValue + eightK; //If result is zero. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero. - else - { + else { Ram.set_Zeroflag(false); } //If result is greater than 255. - if (result > 255) - { + if (result > 255) { result = result & 255; Ram.set_Carryflag(true); } //If result is smaller than 0. - else if (result < 0) - { + else if (result < 0) { result = result & 255; Ram.set_Carryflag(true); } //If result is greater than or equal to 0 and smaller than or equal to 255. - else - { + else { Ram.set_Carryflag(false); } @@ -129,21 +120,22 @@ public class PIC { int dcResult = (wRegValue & 15) + (eightK & 15); //If the result is greater than 15, DC-Flag is set true. - if (dcResult > 15) - { + if (dcResult > 15) { Ram.set_Digitcarryflag(true); } //If the result is smaller or equal to 15, DC-Flag is set false. - else - { + else { Ram.set_Digitcarryflag(false); } setWRegister(result); + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); - //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. + //Each Instruction has to split Programmcounter to PCL and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); } @@ -174,8 +166,10 @@ public class PIC { //Write result into setWRegister(result); - //Increment programcounter + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -257,8 +251,10 @@ public class PIC { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - //Increment programcounter + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -306,8 +302,10 @@ public class PIC { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - //Increment programcounter + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -332,8 +330,10 @@ public class PIC { //Write result back into fileregister. Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); - //Increment programcounter + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -359,15 +359,19 @@ public class PIC { //If bit at bitaddress is 1, next instruction is executed. if ((bitMask & regFileAddrValue) == bitMask) { - //Increment programcounter by one. + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); } //If bit at bitaddress is 0, next instruction will be replaced by a NOP. else { - //Increment programcounter by one. + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Execute NOP. NOP(); } @@ -381,8 +385,7 @@ public class PIC { * * Bit ’b’ in register ’f’ is set. */ - public void BSF(int bitaddress, int registerFileAddress) - { + public void BSF(int bitaddress, int registerFileAddress) { //Get bitmask to OR with fileaddress to set bit. int bitMask = bitMaskSetBitArray[bitaddress]; //Get Value of RAM-Bank-RP0Bit Address. @@ -394,8 +397,10 @@ public class PIC { //Write result into file-register. Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); - //Increment programcounter + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -410,25 +415,26 @@ public class PIC { * discarded and a NOP is executed * instead, making this a 2TCY instruction. */ - public void BTFSS(int bitaddress, int registerFileAddress) - { + public void BTFSS(int bitaddress, int registerFileAddress) { //Get bitmask to AND with fileaddress to get bit. int bitMask = bitMaskSetBitArray[bitaddress]; //Get Value of RAM-Bank-RP0Bit Address. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //If bit at bitaddress is 0, next instruction is executed. - if ((bitMask & regFileAddrValue) != bitMask) - { - //Increment programcounter by one. + if ((bitMask & regFileAddrValue) != bitMask) { + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); } //If bit at bitaddress is 1, next instruction will be replaced by a NOP. - else - { - //Increment programcounter by one. + else { + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Execute NOP. NOP(); } @@ -447,8 +453,7 @@ public class PIC { * the PC are loaded from PCLATH. CALL * is a two cycle instruction. */ - public void CALL(int elevenK) - { + public void CALL(int elevenK) { //Push next instruction on STACK. Stack.pushReturnAdressOnStack(Ram.get_Programcounter() + 1); @@ -460,6 +465,9 @@ public class PIC { //Set Programmcounter to new address. Ram.set_Programcounter(newPC); + //Increment TMR0 if interbnal instruction cycle assigned to TMR0. + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. @@ -472,14 +480,15 @@ public class PIC { * The contents of register ’f’ are cleared * and the Z bit is set. */ - public void CLRF(int registerFileAddress) - { + public void CLRF(int registerFileAddress) { //Value at fileregisteraddress is set to zero. Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), 0); //Zeroflag is set. Ram.set_Zeroflag(true); - //Increment programcounter by 1. + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -491,14 +500,15 @@ public class PIC { * W register is cleared. Zero bit (Z) is * set. */ - public void CLRW() - { + public void CLRW() { //Set to zero. setWRegister(0); //Zeroflag is set. Ram.set_Zeroflag(true); - //Increment programcounter by 1. + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -512,8 +522,7 @@ public class PIC { * of the WDT. Status bits TO and PD are * set. */ - public void CLRWDT() - { + public void CLRWDT() { Ram.set_TimeOutFlag(true); Ram.set_PowerDownFlag(true); Ram.set_PS0(false); @@ -521,8 +530,10 @@ public class PIC { Ram.set_PS2(false); //Programcounter will be incremented by 1. - //Increment programcounter by 1. + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -536,8 +547,7 @@ public class PIC { * W. If ’d’ is 1 the result is stored back in * register ’f’. */ - public void COMF(int destinationBit, int registerFileAddress) - { + public void COMF(int destinationBit, int registerFileAddress) { //Get value at registerFileAddress int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); @@ -545,33 +555,31 @@ public class PIC { int result = (~regFileAddrValue); //If result is zero, zeroflag is set true. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero, zeroflag is set false. - else - { + else { Ram.set_Zeroflag(false); } result &= 255; //If destinationbit is zero, result will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is one, result will be written into fileRegister. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - //Increment programcounter by 1. + //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -589,35 +597,36 @@ public class PIC { * executed instead making it a 2T CY instruc- * tion. */ - public void DECFSZ(int destinationBit, int registerFileAddress) - { + public void DECFSZ(int destinationBit, int registerFileAddress) { //Get value of fileregisteraddress. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //Decrement value by one. regFileAddrValue--; //If the destinationbit is 0, the decremented value is written into the - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(regFileAddrValue); } //If the destinationbit is 1, the decremented value is written bach into the fileregister. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), regFileAddrValue); } //If the dekremented value doesn't equal zero, the next instruction is executed. - if (regFileAddrValue != 0) - { - Ram.inkrement_Programcounter(1, 0); + if (regFileAddrValue != 0) { + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); } //If the dekremented value equals zero, a NOP is executed and the other instruction will be dismissed. - else - { - Ram.inkrement_Programcounter(1, 0); + else { + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); NOP(); } @@ -632,45 +641,41 @@ public class PIC { * result is stored in the W register. If ’d’ is * 1 the result is stored back in register ’f’ . */ - public void DECF(int destinationBit, int registerFileAddress) - { + public void DECF(int destinationBit, int registerFileAddress) { //Get value of fileregisteraddress. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //Decrement value by one. regFileAddrValue--; //If dekremented value equals zero, zeroflag is set true. - if (regFileAddrValue == 0) - { + if (regFileAddrValue == 0) { Ram.set_Zeroflag(true); } //If dekremented value doesn't equal zero, zeroflag is set false. - else - { + else { Ram.set_Zeroflag(false); } //If value gets smaller than zero it is AND with 255 to become positive, because only values between 0 and 255 are allowed. - if (regFileAddrValue < 0) - { + if (regFileAddrValue < 0) { regFileAddrValue = regFileAddrValue & 255; } //If destinationbit equals zero, value is written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(regFileAddrValue); } //If destinationbit doesn't equal zero, value is written into fileregister. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), regFileAddrValue); } - //Inkrement Ram by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -685,12 +690,14 @@ public class PIC { * PC are loaded from PCLATH<4:3>. * GOTO is a two cycle instruction. */ - public void GOTO(int elevenK) - { + public void GOTO(int elevenK) { //elevenK OR ((PCLATH AND 0b11000) << 8) int result = elevenK | ((Ram.get_PCLATH() & 0b11000) << 8); Ram.set_Programcounter(result); + //Increment TMR0 if internal instruction cycle assigned to TMR0. + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -704,45 +711,41 @@ public class PIC { * the W register. If ’d’ is 1 the result is * placed back in register ’f’. */ - public void INCF(int destinationBit, int registerFileAddress) - { + public void INCF(int destinationBit, int registerFileAddress) { //Get value of fileregisteraddress. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //Increment value by one. regFileAddrValue++; //If value becomes zero, zeroflag is set true. - if (regFileAddrValue == 0) - { + if (regFileAddrValue == 0) { Ram.set_Zeroflag(true); } //If value doesn't become zero, zeroflag is set false. - else - { + else { Ram.set_Zeroflag(false); } //If value becomes greater than 255, it will be set to a value between 0 and 255. - if (regFileAddrValue > 255) - { + if (regFileAddrValue > 255) { regFileAddrValue &= 255; } //If destinationbit is set 0, value will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(regFileAddrValue); } //If destinationbit is not 0, value will be written back to RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), regFileAddrValue); } - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -760,43 +763,41 @@ public class PIC { * cuted instead making it a 2TCY instruc- * tion . */ - public void INCFSZ(int destinationBit, int registerFileAddress) - { + public void INCFSZ(int destinationBit, int registerFileAddress) { //Get value of fileregisteraddress. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //Increment value by one. regFileAddrValue++; //If value increases over uper line, it is set to a value between 0 and 255. - if (regFileAddrValue > 255) - { + if (regFileAddrValue > 255) { regFileAddrValue &= 255; } //If destinationbit is zero, the value is written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(regFileAddrValue); } //If destinationbit is one, the value is written into RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), regFileAddrValue); } //If value is not zero, next instruction will be executed. - if (regFileAddrValue != 0) - { - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + if (regFileAddrValue != 0) { + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); } //If value is zero, next instruction will not be executed and NOP is executed instead. - else - { - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + else { + ///Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Call NOP. NOP(); @@ -813,28 +814,27 @@ public class PIC { * OR’ed with the eight bit literal 'k'. The * result is placed in the W register . */ - public void IORLW(int eightK) - { + public void IORLW(int eightK) { //and eightK are OR'ed and result is written into result. int result = get_WRegister() | eightK; //If result is zero, zeroflag is set true. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero, zeroflag is set false. - else - { + else { Ram.set_Zeroflag(false); } //Set to result. setWRegister(result); - //Increment programcounter. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -848,37 +848,34 @@ public class PIC { * W register. If ’d’ is 1 the result is placed * back in register ’f’. */ - public void IORWF(int destinationBit, int registerFileAddress) - { + public void IORWF(int destinationBit, int registerFileAddress) { //Result is value OR fileregister-value. int result = get_WRegister() | Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //If result is zero, zeroflag is set true. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero, zeroflag is set false. - else - { + else { Ram.set_Zeroflag(false); } //If destinationbit is zero, result is written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is not zero, result is written into fileregister. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -891,13 +888,14 @@ public class PIC { * register . The don’t cares will assemble * as 0’s. */ - public void MOVLW(int eightK) - { + public void MOVLW(int eightK) { //is set to eightK bit literal. setWRegister(eightK); - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -914,30 +912,28 @@ public class PIC { * itself. d = 1 is useful to test a file regis- * ter since status flag Z is affected. */ - public void MOVF(int destinationBit, int registerFileAddress) - { + public void MOVF(int destinationBit, int registerFileAddress) { //If destinationbit is zero, the value from fileregister is written to - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress)); } //If destinationbit is one, value will still be in fileregister. //If value in fileregister is zero, zeroflag is set true. - if (Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress) == 0) - { + if (Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress) == 0) { Ram.set_Zeroflag(true); } //If value in fileregister is not zero, zeroflag is set false. - else - { + else { Ram.set_Zeroflag(false); } - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -948,13 +944,14 @@ public class PIC { * * Move data from W register to file register */ - public void MOVWF(int registerFileAddress) - { + public void MOVWF(int registerFileAddress) { //Data from is moved to fileregister. Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), get_WRegister()); - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -965,10 +962,11 @@ public class PIC { * * No operation */ - public void NOP() - { - //Increment programcounter by one. - Ram.inkrement_Programcounter(1, 0); + public void NOP() { + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -984,8 +982,7 @@ public class PIC { * (INTCON<7>). This is a two cycle * instruction. */ - public void RETFIE() - { + public void RETFIE() { //Set Global Interrupt Enable Bit true. Ram.set_GIE(true); @@ -994,6 +991,9 @@ public class PIC { //Write returnAddress into programcounter. Ram.set_Programcounter(returnAddress); + //Increment TMR0 if assigned to TMR0. + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1002,11 +1002,13 @@ public class PIC { /**OPTION * Datasheet Page 65 */ - public void OPTION() - { + public void OPTION() { //Nothing happens, only programmcounter gets incremented by 1. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1022,8 +1024,7 @@ public class PIC { * return address). This is a two cycle * instruction. */ - public void RETLW(int eightK) - { + public void RETLW(int eightK) { //Load with eight bit literal. setWRegister(eightK); @@ -1032,6 +1033,9 @@ public class PIC { //Write returnAddress into programcounter. Ram.set_Programcounter(returnAddress); + //Increment TMR0 if assigned to TMR0. + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1045,13 +1049,15 @@ public class PIC { * is loaded into the program counter. This * is a two cycle instruction. */ - public void RETURN() - { + public void RETURN() { //Pop address from STACK. int returnAddress = Stack.popReturnAdressFromStack(); //Write returnAddress into programcounter. Ram.set_Programcounter(returnAddress); + //Increment TMR0 if assigned to TMR0. + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1066,8 +1072,7 @@ public class PIC { * W register. If ’d’ is 1 the result is stored * back in register ’f’. */ - public void RLF(int destinationBit, int registerFileAddress) - { + public void RLF(int destinationBit, int registerFileAddress) { //Get value at fileaddress. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //Shift result to left by one bit. @@ -1076,42 +1081,39 @@ public class PIC { boolean set_Carryflag = false; //If the first bit which will be shifted is 1, the Carryflag will be set at the end to true. - if ((0b10000000 & regFileAddrValue) == 0b10000000) - { + if ((0b10000000 & regFileAddrValue) == 0b10000000) { set_Carryflag = true; } //If carryflag is true, last bit is set 1. - if (Ram.get_Carryflag() == true) - { + if (Ram.get_Carryflag() == true) { result |= 0b00000001; } //If carryflag is false, last bit is set 0. - else - { + else { result &= 0b11111110; } result &= 255; //If destinationbit is zero, result will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is one, result will be written into RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } //Set value of carryflag. Ram.set_Carryflag(set_Carryflag); - //Increment Ram by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1136,20 +1138,17 @@ public class PIC { boolean set_Carryflag = false; //If the first bit which will be shifted is 1, the Carryflag will be set at the end to true. - if ((0b00000001 & regFileAddrValue) == 0b00000001) - { + if ((0b00000001 & regFileAddrValue) == 0b00000001) { set_Carryflag = true; } //If carryflag is true, first bit is set 1. - if (Ram.get_Carryflag() == true) - { + if (Ram.get_Carryflag() == true) { result |= 0b10000000; } //If carryflag is false, first bit is set 0. - else - { + else { result &= 0b01111111; } @@ -1157,19 +1156,19 @@ public class PIC { Ram.set_Carryflag(set_Carryflag); //If destinationbit is zero, result will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is one, result will be written into RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - //Increment Ram by one. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1177,7 +1176,7 @@ public class PIC { /** * Datasheet Page 68 - * + * TODO * The power-down status bit, PD is * cleared. Time-out status bit, TO is * set. Watchdog Timer and its pres- @@ -1186,10 +1185,13 @@ public class PIC { * mode with the oscillator stopped. See * Section 14.8 for more details. */ - public void SLEEP() - { - //Not implemented - Ram.inkrement_Programcounter(1, 0); + public void SLEEP() { + //TODO pause running (no Thread.sleep()!!!) + //Not implemented + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1202,8 +1204,7 @@ public class PIC { * ment method) from the eight bit literal 'k'. * The result is placed in the W register. */ - public void SUBLW(int eightK) - { + public void SUBLW(int eightK) { int wRegValue = get_WRegister(); //Build Two's complement @@ -1221,34 +1222,24 @@ public class PIC { int dcResult = (eightK & 15) + (wRegValue & 15) + 1; //If the result is greater than 15, DC-Flag is set true. - if (dcResult > 15) - { + if (dcResult > 15) { Ram.set_Digitcarryflag(true); } //If the result is smaller or equal to 15, DC-Flag is set false. - else - { + else { Ram.set_Digitcarryflag(false); } - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); - } - - else - { + } else { Ram.set_Zeroflag(false); } - if (carry == 1) - { + if (carry == 1) { Ram.set_Carryflag(true); - } - - else - { + } else { Ram.set_Carryflag(false); } @@ -1256,7 +1247,10 @@ public class PIC { setWRegister(result); - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1270,8 +1264,8 @@ public class PIC { * result is stored in the W register. If 'd' is 1 the * result is stored back in register 'f'. */ - public void SUBWF(int destinationBit, int registerFileAddress) - { + public void SUBWF(int destinationBit, int registerFileAddress) { + int wRegValue = get_WRegister(); //Get value at fileaddress. @@ -1298,46 +1292,40 @@ public class PIC { } //If the result is smaller or equal to 15, DC-Flag is set false. - else - { + else { Ram.set_Digitcarryflag(false); } - if (result == 0) - { + //Set/clear zeroflag + if (result == 0) { Ram.set_Zeroflag(true); - } - - else - { + } else { Ram.set_Zeroflag(false); } - if (carry == 1) - { + //Set/clear carryflag + if (carry == 1) { Ram.set_Carryflag(true); - } - - else - { + } else { Ram.set_Carryflag(false); } result &= 255; //If destinationbit is zero, result will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is one, result will be written into RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1351,8 +1339,7 @@ public class PIC { * is placed in W register. If 'd' is 1 the result * is placed in register 'f'. */ - public void SWAPF(int destinationBit, int registerFileAddress) - { + public void SWAPF(int destinationBit, int registerFileAddress) { //Get value at fileaddress. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); @@ -1363,18 +1350,19 @@ public class PIC { int result = (lowerNibble << 4) | higherNibble; //If destinationbit is zero, result will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is one, result will be written into RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1393,11 +1381,13 @@ public class PIC { * with future PIC16CXX products, * do not use this instruction! */ - public void TRIS() - { + public void TRIS() { //Nothing happens, only programcounter will be incremented by 1. - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1410,25 +1400,25 @@ public class PIC { * XOR’ed with the eight bit literal 'k'. * The result is placed in the W register. */ - public void XORLW(int eightK) - { + public void XORLW(int eightK) { int wRegValue = get_WRegister(); int result = wRegValue ^ eightK; - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } - else - { + else { Ram.set_Zeroflag(false); } setWRegister(result); - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1442,8 +1432,7 @@ public class PIC { * 0 the result is stored in the W register. If 'd' is * 1 the result is stored back in register 'f'. */ - public void XORWF(int destinationBit, int registerFileAddress) - { + public void XORWF(int destinationBit, int registerFileAddress) { int wRegValue = get_WRegister(); //Get value at fileaddress. @@ -1451,29 +1440,28 @@ public class PIC { int result = wRegValue ^ regFileAddrValue; - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } - else - { + else { Ram.set_Zeroflag(false); } //If destinationbit is zero, result will be written into - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If destinationbit is one, result will be written into RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } - Ram.inkrement_Programcounter(1, 0); + //Increment programcounter and TMR0 if assigned to TMR0. + Ram.inkrement_Programcounter(1, 0); //Kind of call + if (Ram.get_T0CS() == false) + Ram.increment_TMR0(); //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); diff --git a/src/Backend/Microcontroller/RAM.java b/src/Backend/Microcontroller/RAM.java index 5955907..4d591c0 100755 --- a/src/Backend/Microcontroller/RAM.java +++ b/src/Backend/Microcontroller/RAM.java @@ -214,7 +214,7 @@ public class RAM { //Check for overflow and set bit and timer if ((iValTMR0 + iValIncr) > 255) { set_T0IF(true); - set_TMR0((iValTMR0 + iValIncr) & 255); //TODO 0 or &255 + set_TMR0((iValTMR0 + iValIncr) & 255); //TODO 0 or &255 (Question to Prof) } else { set_T0IF(false); set_TMR0(iValTMR0 + iValIncr); @@ -281,34 +281,12 @@ public class RAM { * @param value */ public synchronized void set_PORTA(int value) { - //Check if PORT A RA4 was set/cleared - boolean bActualRA4 = get_RA4_T0CKI(); - boolean bNewRA4 = ((value & 0b00010000) == 0b00010000); - - //Increment TMR0 if RA4 was set/cleared - if (bActualRA4 != bNewRA4) { - if (bNewRA4) { //rising edge - if (!get_T0SE()) { //rising edge increments TMR0 - increment_TMR0(); - } - } else { //falling edge - if (get_T0SE()) { //falling edge increments TMR0 - increment_TMR0(); - } - } - } - //Set PORT A - bank0[5] = value; - } - - public synchronized void set_PORTA_Bit_X_To_Y(int x, int y) { //TODO - //Increment TMR0 if RA4 was set/cleared - if ((x == 4)) { + if (get_T0CS()) { + //Check if PORT A RA4 was set/cleared boolean bActualRA4 = get_RA4_T0CKI(); - boolean bNewRA4 = false; - if (y == 1) - bNewRA4 = true; - + boolean bNewRA4 = ((value & 0b00010000) == 0b00010000); + + //Increment TMR0 if RA4 was set/cleared if (bActualRA4 != bNewRA4) { if (bNewRA4) { //rising edge if (!get_T0SE()) { //rising edge increments TMR0 @@ -321,6 +299,35 @@ public class RAM { } } } + + //Set PORT A + bank0[5] = value; + } + + public synchronized void set_PORTA_Bit_X_To_Y(int x, int y) { + + //Increment TMR0 if RA4 was set/cleared + if ((x == 4)) { + //Check T0CS + if (get_T0CS()) { + boolean bActualRA4 = get_RA4_T0CKI(); + boolean bNewRA4 = false; + if (y == 1) + bNewRA4 = true; + + if (bActualRA4 != bNewRA4) { + if (bNewRA4) { //rising edge + if (!get_T0SE()) { //rising edge increments TMR0 + increment_TMR0(); + } + } else { //falling edge + if (get_T0SE()) { //falling edge increments TMR0 + increment_TMR0(); + } + } + } + } + } //Clear bit x if (y == 0) { @@ -595,71 +602,65 @@ public class RAM { set_STATUS(status); } - public synchronized boolean get_Interruptflag() - { + public synchronized boolean get_Interruptflag() { return (get_STATUS() & 0b10000000) == 128; } //Bank0 PCL - public synchronized int get_Programcounter() - { + public synchronized int get_Programcounter() { return (bank0[2]); } - public synchronized int get_LastProgramcounter() - { + public synchronized int get_LastProgramcounter() { return lastProgramcounter; } - public synchronized void inkrement_Programcounter(int value, int kindOfCall) //0 at Fetchzycle, 1 at Jumpcommand, 2 at ... - { - if (bank0[2] >= 0 && bank0[2] <= 255) - { + /** + * + * @param value + * @param kindOfCall 0 at normal instruction, 1 at Fetchzycle,... 2 at Jumpcommand, 3 at ... + */ + public synchronized void inkrement_Programcounter(int value, int kindOfCall) { + if (bank0[2] >= 0 && bank0[2] <= 255) { lastProgramcounter = bank0[2]; bank0[2] += value; - } - - else - { - if (kindOfCall == 0) - { + } else { + if (kindOfCall == 0) { //Nothing happens } - if (kindOfCall == 1) - { + if (kindOfCall == 1) { bank0[2] = 0; //Wrap-Around at fetchcycle } } } - public synchronized void dekrement_Programcounter(int value) - { - if (bank0[2] > 0 && bank0[2] <= 255) - { + /** + * Decrements PC by value. + * @param value to decrement PC by. + */ + public synchronized void dekrement_Programcounter(int value) { + if (bank0[2] > 0 && bank0[2] <= 255) { lastProgramcounter = bank0[2]; bank0[2] -= value; - } - - else - { + } else { throw new IndexOutOfBoundsException(); } } - public synchronized boolean set_Programcounter(int value) - { + /** + * Sets PC to value. + * @param value to set PC to. + * @returns true if set worked, else false if set didn't work. + */ + public synchronized boolean set_Programcounter(int value) { boolean setWorked = false; - if (value >= 0 && value <= 255) - { + if (value >= 0 && value <= 255) { lastProgramcounter = bank0[2]; bank0[2] = value; setWorked = true; - } - - else - { + } else { throw new IndexOutOfBoundsException(); } @@ -667,85 +668,84 @@ public class RAM { } //Bank0 PORTA - public synchronized void set_RA0(boolean value) - { + /** + * + * @param value + */ + public synchronized void set_RA0(boolean value) { int portA = get_PORTA(); - if (value) - { + if (value) { portA |= 0b00000001; - } - - else - { + } else { portA &= 0b11111110; } set_PORTA(portA); } - public synchronized boolean get_RA0() - { - { - return (get_PORTA() & 0b00000001) == 1; - } + /** + * + * @return + */ + public synchronized boolean get_RA0() { + return (get_PORTA() & 0b00000001) == 1; } - public synchronized void set_RA1(boolean value) - { + /** + * + * @param value + */ + public synchronized void set_RA1(boolean value) { int portA = get_PORTA(); - if (value) - { + if (value) { portA |= 0b00000010; - } - - else - { + } else { portA &= 0b11111101; } set_PORTA(portA); } - public synchronized boolean get_RA1() - { - { - return (get_PORTA() & 0b00000010) == 2; - } + /** + * + * @return + */ + public synchronized boolean get_RA1() { + return (get_PORTA() & 0b00000010) == 2; } - public synchronized void set_RA2(boolean value) - { + /** + * + * @param value + */ + public synchronized void set_RA2(boolean value) { int portA = get_PORTA(); - if (value) - { + if (value) { portA |= 0b00000100; - } - - else - { + } else { portA &= 0b11111011; } set_PORTA(portA); } - public synchronized boolean get_RA2() - { - { - return (get_PORTA() & 0b00000100) == 4; - } + /** + * + * @return + */ + public synchronized boolean get_RA2() { + return (get_PORTA() & 0b00000100) == 4; } - public synchronized void set_RA3(boolean value) - { + /** + * + * @param value + */ + public synchronized void set_RA3(boolean value) { int portA = get_PORTA(); - if (value) - { + if (value) { portA |= 0b00001000; - } - - else - { + } else { portA &= 0b11110111; } diff --git a/src/Backend/Runtime/Environment.java b/src/Backend/Runtime/Environment.java index db2b9fa..5c53d25 100755 --- a/src/Backend/Runtime/Environment.java +++ b/src/Backend/Runtime/Environment.java @@ -31,13 +31,15 @@ public class Environment { public Environment() { + oPIC = new PIC(); + oPIC.setWRegister(4); GUIMainFrame oMainFrame = new GUIMainFrame(this); watchdog = new WATCHDOG(); - oPIC = new PIC(); + sEepromDataFile = ""; sActualCommand = ""; diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java index 10c26e0..f74a056 100755 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java @@ -3,6 +3,7 @@ package Frontend.PIC_SIMULATOR_GUI_JAVA; import java.awt.Color; import java.awt.Dimension; import java.awt.Insets; +import java.util.ArrayList; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; @@ -10,6 +11,7 @@ import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JPanel; import javax.swing.border.Border; import Backend.EepromLoader.ReadEepromFile; @@ -17,27 +19,72 @@ import Backend.Runtime.Environment; public class GUIMainFrame extends JFrame { + /** + * Color oWhite = new Color(255, 253, 250); + * Color oDarkGray = new Color(76, 78, 82); + * Color oDarkGrayB = new Color(47, 47, 47); + * Color oLightBlue = new Color(173, 216, 230); + * Color oOrangeDM = new Color(255, 170, 0); + * Color oLightBlueDM = new Color(0, 213, 255); + * Color oOrangeDMB = new Color(255, 85, 0); + * First Color == TextColor + * Second Color == BackgroundColor + * Third Color == BorderColor + * Fourth Color == TextColor Marked + * Fifth Color == BackgroundColor Marked + * Sixth Color == BorderColor Marked + */ + Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)}; + Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)}; + GUITestFileTable oGUITestFileTable; GUIMenuBar oGUIMenuBar; + + JPanel oMainPanel; + JPanel oPanelRegisterInformation; + + ArrayList oPanels = new ArrayList(); /** * Constructor */ public GUIMainFrame(Environment env) { - + oMainPanel = new JPanel(); this.setTitle("PIC-Simulator GUI"); // sets title of frame this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if x is pressed, exit application (HIDE_ON_CLOSE-hides application, DO_NOTHING_ON_CLOSE-prevents user from closing application) //this.setResizable(false); // prevent frame from beeing resized this.setSize(1400, 800); //sets x and y dimension of frame //this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); - this.setLayout(new GridBagLayout()); + oMainPanel.setLayout(new GridBagLayout()); oGUITestFileTable = new GUITestFileTable(); - int[] aiTestRegisters = {1, 2, 3, 4, 5, 6, 7, 8 ,9}; + oPanelRegisterInformation = new JPanel(); + oPanelRegisterInformation.setLayout(new GridBagLayout()); + GridBagConstraints oConstraintsRegisterInformation = new GridBagConstraints(); + int iPrescaler; + if (env.getPIC().getRam().get_PSA()) + iPrescaler = env.getPIC().getRam().get_WDT_PrescalerRate(); + else + iPrescaler = env.getPIC().getRam().get_TMR0_PrescalerRate(); + int[] aiRegisters = {env.getPIC().getRam().get_PCL(), env.getPIC().getRam().get_PCLATH(), + env.getPIC().getRam().get_Programcounter(), env.getPIC().getRam().get_STATUS(), + env.getPIC().getRam().get_FSR(), env.getPIC().getRam().get_OPTION(), + iPrescaler, env.getPIC().getRam().get_TMR0(), + env.getPIC().get_WRegister()}; GUIRegisters oGUIRegisters = new GUIRegisters(); + oGUIRegisters.setRegisters(aiRegisters); + GUIRegistersDetailed oGuiRegistersDetailed = new GUIRegistersDetailed(); + oConstraintsRegisterInformation.anchor = GridBagConstraints.WEST; + oConstraintsRegisterInformation.gridx = 0; + oConstraintsRegisterInformation.gridy = 0; + oPanelRegisterInformation.add(oGUIRegisters, oConstraintsRegisterInformation); + oConstraintsRegisterInformation.gridy = 1; + oConstraintsRegisterInformation.anchor = GridBagConstraints.WEST; + oPanelRegisterInformation.add(oGuiRegistersDetailed, oConstraintsRegisterInformation); + this.setJMenuBar(new GUIMenuBar(env, this, oGUITestFileTable, oGUIRegisters)); this.setVisible(true); //make frame visible - this.setBackground(new Color(76, 78, 82)); - ImageIcon guiLogo = new ImageIcon("./images/gui_logo.png"); // create an ImageIcon + + ImageIcon guiLogo = new ImageIcon("./pictures/gui_logo.png"); // create an ImageIcon this.setIconImage(guiLogo.getImage()); // change icon of frame //this.getContentPane().setBackground(Color.green); //change color of background @@ -64,14 +111,16 @@ public class GUIMainFrame extends JFrame { //getContentPane().setLayout(new BorderLayout()); //this.add(new GUITestFileTable("./testfiles/TPicSim1.LST")); GridBagConstraints c = new GridBagConstraints(); + c.anchor = GridBagConstraints.WEST; + c.insets = new Insets(2,5,2,5); c.gridx = 0; //next added element will be in column 1 c.gridy = 0; //next added element will be in row 1 - c.insets = new Insets(10,10,10,10); - this.add(oGUITestFileTable, c); - + oMainPanel.add(oGUITestFileTable, c); c.gridx = 1; - this.add(oGUIRegisters); - + oMainPanel.add(oPanelRegisterInformation, c); + oPanels.add(oPanelRegisterInformation); + oPanels.add(oMainPanel); + this.add(oMainPanel); updateWindow(); } @@ -79,4 +128,21 @@ public class GUIMainFrame extends JFrame { this.revalidate(); this.repaint(); } + + public void setTheme(int iThemeNr) { + switch (iThemeNr) { + case 0: { + for (JPanel oPanel : oPanels) { + oPanel.setForeground(aoLightTheme[0]); + oPanel.setBackground(aoLightTheme[1]); + } + }break; + case 1: { + for (JPanel oPanel : oPanels) { + oPanel.setForeground(aoDarkTheme[0]); + oPanel.setBackground(aoDarkTheme[1]); + } + }break; + } + } } \ No newline at end of file diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java index 6f925b8..b19299f 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMenuBar.java @@ -14,6 +14,8 @@ import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; +import javax.swing.JPanel; + import Backend.EepromLoader.ReadEepromFile; import Backend.Runtime.Environment; @@ -367,7 +369,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { setTheme(aoDarkTheme[0], aoDarkTheme[1]); oGUITestFileTable.setTheme(1); oGUIRegisters.setTheme(1); - oGUIMainFrame.setBackground(aoDarkTheme[1]); + oGUIMainFrame.setTheme(1); } //Change to light theme if (e.getSource() == oLightTheme) { @@ -375,7 +377,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener { setTheme(aoLightTheme[0], aoLightTheme[1]); oGUITestFileTable.setTheme(0); oGUIRegisters.setTheme(0); - oGUIMainFrame.setBackground(aoLightTheme[1]); + oGUIMainFrame.setTheme(0); } //Microcontroller diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java index 395e9d0..818743a 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegisters.java @@ -14,11 +14,20 @@ public class GUIRegisters extends JPanel { /** * Color oWhite = new Color(255, 253, 250); * Color oDarkGray = new Color(76, 78, 82); + * Color oDarkGrayB = new Color(47, 47, 47); + * Color oLightBlue = new Color(173, 216, 230); + * Color oOrangeDM = new Color(255, 170, 0); + * Color oLightBlueDM = new Color(0, 213, 255); + * Color oOrangeDMB = new Color(255, 85, 0); * First Color == TextColor * Second Color == BackgroundColor + * Third Color == BorderColor + * Fourth Color == TextColor Marked + * Fifth Color == BackgroundColor Marked + * Sixth Color == BorderColor Marked */ - Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82)}; - Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250)}; + Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)}; + Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)}; ArrayList oTextfields = new ArrayList(); ArrayList oPanels = new ArrayList(); @@ -26,61 +35,55 @@ public class GUIRegisters extends JPanel { JPanel oLeftComponentPanel = new JPanel(); JPanel oRightComponentPanel = new JPanel(); - JTextField oTextSFR = new JTextField("SFR", 22); + int iTextFieldSize = 15; - JTextField oTextPCL = new JTextField("PCL", 22); - JTextField oTextPCLATH = new JTextField("PCLATH", 22); - JTextField oTextPCIntern = new JTextField("PC intern", 22); - JTextField oTextStatus = new JTextField("STATUS", 22); - JTextField oTextFileSelectionRegister = new JTextField("FileSelectionRegister", 22); - JTextField oTextOption = new JTextField("OPTION", 22); - JTextField oTextPrescaler = new JTextField("Prescaler", 22); - JTextField oTextTMR0 = new JTextField("TMR0", 22); + JTextField oTextSFR = new JTextField("SFR", iTextFieldSize); + + JTextField oTextPCL = new JTextField("PCL", iTextFieldSize); + JTextField oTextPCLATH = new JTextField("PCLATH", iTextFieldSize); + JTextField oTextPCIntern = new JTextField("PC intern", iTextFieldSize); + JTextField oTextStatus = new JTextField("STATUS", iTextFieldSize); + JTextField oTextFileSelectionRegister = new JTextField("FileSelectionRegister", iTextFieldSize); + JTextField oTextOption = new JTextField("OPTION", iTextFieldSize); + JTextField oTextPrescaler = new JTextField("Prescaler", iTextFieldSize); + JTextField oTextTMR0 = new JTextField("TMR0", iTextFieldSize); JTextField oValuePCL = new JTextField("00", 2); JTextField oValuePCLATH = new JTextField("00", 2); JTextField oValuePCIntern = new JTextField("00", 2); JTextField oValueStatus = new JTextField("00", 2); - JTextField oValueFileSearchRegister = new JTextField("00", 2); + JTextField oValueFileSelectionRegister = new JTextField("00", 2); JTextField oValueOption = new JTextField("00", 2); JTextField oValuePrescaler = new JTextField("00", 2); JTextField oValueTMR0 = new JTextField("00", 2); - JTextField oFillTextField1 = new JTextField("", 22); + JTextField oFillTextField1 = new JTextField("", iTextFieldSize); JTextField oFillValueField1 = new JTextField("", 2); - JTextField oFillTextField2 = new JTextField("", 22); + JTextField oFillTextField2 = new JTextField("", iTextFieldSize); JTextField oFillValueField2 = new JTextField("", 2); - JTextField oFillTextField3 = new JTextField("", 22); + JTextField oFillTextField3 = new JTextField("", iTextFieldSize); JTextField oFillValueField3 = new JTextField("", 2); JTextField oFillValueField4 = new JTextField("", 2); JTextField oFillValueField5 = new JTextField("", 2); - JTextField oTextW = new JTextField("W", 22); - - JTextField oTextWRegister = new JTextField("W-Register", 22); - + JTextField oTextW = new JTextField("W", iTextFieldSize); + JTextField oTextWRegister = new JTextField("W-Register", iTextFieldSize); JTextField oValueWRegister = new JTextField("00", 2); + /** + * Constructor of register-table-class, adds components to list, sets components uneditable, + * builds register-table and colors according to theme. + */ public GUIRegisters() { - //9 - /** - * [0] W-Register - * [1] PCL - * [2] PCLATH - * [3] PC intern - * [4] Status - * [5] FSR FileSelectionRegister - * [6] Option - * [7] Vorteiler - * [8] TMR0 - */ addComponentsToLists(); setEditFalse(); buildGUIRegisters(); setTheme(0); - this.setBorder(BorderFactory.createLineBorder(new Color(173, 216, 230))); } + /** + * Builds register-panel by actually setting the positions of the fields and adding them to the panels. + */ private void buildGUIRegisters() { GridBagConstraints oConstraints = new GridBagConstraints(); @@ -95,7 +98,7 @@ public class GUIRegisters extends JPanel { oConstraints.anchor = GridBagConstraints.WEST; oLeftComponentPanel.add(oTextSFR, oConstraints); oConstraints.gridx = 1; - oLeftComponentPanel.add(oFillValueField1); + oLeftComponentPanel.add(oFillValueField1, oConstraints); //Fill left side of left component panel oConstraints.gridx = 0; @@ -135,14 +138,16 @@ public class GUIRegisters extends JPanel { oRightComponentPanel.add(oTextTMR0, oConstraints); oConstraints.gridy = 5; oRightComponentPanel.add(oFillTextField2, oConstraints); + oConstraints.gridy = 6; + oRightComponentPanel.add(oFillTextField3, oConstraints); //Fill right side of right component panel oConstraints.gridx = 1; oConstraints.gridy = 0; oConstraints.anchor = GridBagConstraints.EAST; - oRightComponentPanel.add(oFillValueField1, oConstraints); + oRightComponentPanel.add(oFillValueField2, oConstraints); oConstraints.gridy = 1; - oRightComponentPanel.add(oValueFileSearchRegister, oConstraints); + oRightComponentPanel.add(oValueFileSelectionRegister, oConstraints); oConstraints.gridy = 2; oRightComponentPanel.add(oValueOption, oConstraints); oConstraints.gridy = 3; @@ -150,7 +155,9 @@ public class GUIRegisters extends JPanel { oConstraints.gridy = 4; oRightComponentPanel.add(oValueTMR0, oConstraints); oConstraints.gridy = 5; - oRightComponentPanel.add(oFillValueField2); + oRightComponentPanel.add(oFillValueField3, oConstraints); + oConstraints.gridy = 6; + oRightComponentPanel.add(oFillValueField4, oConstraints); //Fill footer of left component panel oConstraints.anchor = GridBagConstraints.WEST; @@ -159,8 +166,9 @@ public class GUIRegisters extends JPanel { oLeftComponentPanel.add(oTextW, oConstraints); oConstraints.anchor = GridBagConstraints.EAST; oConstraints.gridx = 1; - oLeftComponentPanel.add(oFillValueField2, oConstraints); + oLeftComponentPanel.add(oFillValueField5, oConstraints); oConstraints.gridx = 0; + oConstraints.gridy = 6; oLeftComponentPanel.add(oTextWRegister, oConstraints); oConstraints.anchor = GridBagConstraints.EAST; oConstraints.gridx = 1; @@ -171,6 +179,7 @@ public class GUIRegisters extends JPanel { oConstraints.gridx = 0; oConstraints.gridy = 0; this.add(oLeftComponentPanel, oConstraints); + oConstraints.gridx = 1; this.add(oRightComponentPanel, oConstraints); } @@ -189,24 +198,31 @@ public class GUIRegisters extends JPanel { oTextfields.add(oTextTMR0); oTextfields.add(oTextW); oTextfields.add(oTextWRegister); + oTextfields.add(oFillTextField1); + oTextfields.add(oFillTextField2); + oTextfields.add(oFillTextField3); oTextfields.add(oValuePCL); oTextfields.add(oValuePCLATH); oTextfields.add(oValuePCIntern); oTextfields.add(oValueStatus); - oTextfields.add(oValueFileSearchRegister); + oTextfields.add(oValueFileSelectionRegister); oTextfields.add(oValueOption); oTextfields.add(oValuePrescaler); oTextfields.add(oValueTMR0); oTextfields.add(oValueWRegister); + oTextfields.add(oFillValueField1); + oTextfields.add(oFillValueField2); + oTextfields.add(oFillValueField3); + oTextfields.add(oFillValueField4); + oTextfields.add(oFillValueField5); - oPanels.add(this); oPanels.add(oLeftComponentPanel); oPanels.add(oRightComponentPanel); } /** - * + * Set edit all textfields to false. */ private void setEditFalse() { for (JTextField oTextfield : oTextfields) { @@ -215,16 +231,28 @@ public class GUIRegisters extends JPanel { } /** - * + * Sets textfields of registervalues. * @param aiRegisters */ public void setRegisters(int[] aiRegisters) { - //TODO + oValuePCL.setText(aiRegisters[0] + ""); + oValuePCLATH.setText(aiRegisters[1] + ""); + oValuePCIntern.setText(aiRegisters[2] + ""); + oValueStatus.setText(aiRegisters[3] + ""); + oValueFileSelectionRegister.setText(aiRegisters[4] + ""); + oValueOption.setText(aiRegisters[5] + ""); + oValuePrescaler.setText(aiRegisters[6] + ""); + oValueTMR0.setText(aiRegisters[7] + ""); + oValueWRegister.setText(aiRegisters[8] + ""); } + /** + * Set theme of RegisterTable + * @param iThemeNr 0 == light theme, 1 == dark theme + */ public void setTheme(int iThemeNr) { switch (iThemeNr) { - case 0: { + case 0: { //light theme for (JPanel oPanel : oPanels) { oPanel.setForeground(aoLightTheme[0]); oPanel.setBackground(aoLightTheme[1]); @@ -233,12 +261,12 @@ public class GUIRegisters extends JPanel { for (JTextField oTextfield : oTextfields) { oTextfield.setForeground(aoLightTheme[0]); oTextfield.setBackground(aoLightTheme[1]); - oTextfield.setBorder(BorderFactory.createLineBorder(aoLightTheme[1])); + oTextfield.setBorder(BorderFactory.createLineBorder(aoLightTheme[2])); } + this.setBorder(BorderFactory.createLineBorder(aoLightTheme[2], 3)); }break; - case 1: { - System.out.println("Test"); + case 1: { //dark theme for (JPanel oPanel : oPanels) { oPanel.setForeground(aoDarkTheme[0]); oPanel.setBackground(aoDarkTheme[1]); @@ -247,8 +275,9 @@ public class GUIRegisters extends JPanel { for (JTextField oTextfield : oTextfields) { oTextfield.setForeground(aoDarkTheme[0]); oTextfield.setBackground(aoDarkTheme[1]); - oTextfield.setBorder(BorderFactory.createLineBorder(aoDarkTheme[1])); + oTextfield.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2])); } + this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[2], 3)); }break; } } diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegistersDetailed.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegistersDetailed.java new file mode 100644 index 0000000..83894a3 --- /dev/null +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIRegistersDetailed.java @@ -0,0 +1,103 @@ +package Frontend.PIC_SIMULATOR_GUI_JAVA; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Color; + +public class GUIRegistersDetailed extends JPanel { + + JTable oStatusTable; + JTable oOptionTable = new JTable(); + JTable oIntconTable = new JTable(); + + JPanel oStatusPanel = new JPanel(); + JPanel oOptionPanel = new JPanel(); + JPanel oIntconPanel = new JPanel(); + + JLabel oStatusLabel = new JLabel("STATUS"); + JLabel oOptionLabel = new JLabel("OPTION"); + JLabel oIntconLabel = new JLabel("INTCON"); + + public GUIRegistersDetailed() { + buildGUIRegistersDetailed(); + } + + private void buildGUIRegistersDetailed() { + this.setLayout(new GridBagLayout()); + + oStatusPanel.setLayout(new GridBagLayout()); + oOptionPanel.setLayout(new GridBagLayout()); + oIntconPanel.setLayout(new GridBagLayout()); + + String[][] asDataStatus = {{"IRP", "RP1", "RP0", "TO", "PD", "Z", "DC", "C"}, {"0", "0", "0", "0", "0", "0", "0", "0"}}; + String[] asHeadersStatus = {"0", "1", "2", "3", "4", "5", "6", "7"}; + oStatusTable = new JTable(asDataStatus, asHeadersStatus); + oStatusTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + GridBagConstraints oConstraintsStatus = new GridBagConstraints(); + oConstraintsStatus.anchor = GridBagConstraints.WEST; + oConstraintsStatus.gridx = 0; + oConstraintsStatus.gridy = 0; + oStatusPanel.add(oStatusLabel, oConstraintsStatus); + oConstraintsStatus.gridy = 1; + oStatusPanel.add(oStatusTable, oConstraintsStatus); + + for (int i = 0; i < 8; i++) { + oStatusTable.getColumn(i + "").setMaxWidth(50); + } + oStatusTable.setEnabled(false); + + String[][] asDataOption = {{"RBPU", "INTEDG", "T0CS", "T0SE", "PSA", "PS2", "PS1", "PS0"}, {"0", "0", "0", "0", "0", "0", "0", "0"}}; + String[] asHeadersOption = {"0", "1", "2", "3", "4", "5", "6", "7"}; + oOptionTable = new JTable(asDataOption, asHeadersOption); + oOptionTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + GridBagConstraints oConstraintsOption = new GridBagConstraints(); + oConstraintsOption.anchor = GridBagConstraints.WEST; + oConstraintsOption.gridx = 0; + oConstraintsOption.gridy = 0; + oOptionPanel.add(oOptionLabel, oConstraintsOption); + oConstraintsOption.gridy = 1; + oOptionPanel.add(oOptionTable, oConstraintsOption); + + for (int i = 0; i < 8; i++) { + oOptionTable.getColumn(i + "").setMaxWidth(50); + } + oOptionTable.setEnabled(false); + + String[][] asDataIntcon = {{"GIE", "EEIE", "T0IE", "INTE", "RBIE", "T0IF", "INTF", "RBIF"}, {"0", "0", "0", "0", "0", "0", "0", "0"}}; + String[] asHeadersIntcon = {"0", "1", "2", "3", "4", "5", "6", "7"}; + oIntconTable = new JTable(asDataIntcon, asHeadersIntcon); + oIntconTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + GridBagConstraints oConstraintsIntcon = new GridBagConstraints(); + oConstraintsIntcon.anchor = GridBagConstraints.WEST; + oConstraintsIntcon.gridx = 0; + oConstraintsIntcon.gridy = 0; + oIntconPanel.add(oIntconLabel, oConstraintsIntcon); + oConstraintsIntcon.gridy = 1; + oIntconPanel.add(oIntconTable, oConstraintsIntcon); + + for (int i = 0; i < 8; i++) { + oIntconTable.getColumn(i + "").setMaxWidth(50); + } + oIntconTable.setEnabled(false); + + GridBagConstraints oConstraints = new GridBagConstraints(); + oConstraints.anchor = GridBagConstraints.WEST; + oConstraints.gridx = 0; + oConstraints.gridy = 0; + this.add(oStatusPanel, oConstraints); + oConstraints.gridy = 1; + this.add(oOptionPanel, oConstraints); + oConstraints.gridy = 2; + this.add(oIntconPanel, oConstraints); + + this.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + } +} \ No newline at end of file diff --git a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java index 525e88e..02bfa0f 100644 --- a/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java +++ b/src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUITestFileTable.java @@ -46,13 +46,13 @@ public class GUITestFileTable extends JScrollPane { */ public GUITestFileTable() { oTable = new JPanel(); - oPanels.add(oTable); + + JPanel oTestPanel = new JPanel(); + JTextField oFill = new JTextField("0"); oLineInformation.add(oFill); oFill.setEditable(false); - JPanel oTestPanel = new JPanel(); - oPanels.add(oTestPanel); oTestPanel.setLayout(new GridLayout(1, 3)); oTestPanel.add(oFill); @@ -170,19 +170,19 @@ public class GUITestFileTable extends JScrollPane { public void setTheme(int iThemeNr) { iTheme = iThemeNr; - for (int i = 0; i < oLineInformation.size(); i++) { - oLineInformation.get(i).setForeground(getThemeColor()[0]); - oLineInformation.get(i).setBackground(getThemeColor()[1]); - oLineInformation.get(i).setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); + for (JTextField oTextfield : oLineInformation) { + oTextfield.setForeground(getThemeColor()[0]); + oTextfield.setBackground(getThemeColor()[1]); + oTextfield.setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); } - for (int i = 0; i < oCheckboxes.size(); i++) { - oCheckboxes.get(i).setForeground(getThemeColor()[0]); - oCheckboxes.get(i).setBackground(getThemeColor()[1]); - oCheckboxes.get(i).setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); + for (JCheckBox oCheckbox : oCheckboxes) { + oCheckbox.setForeground(getThemeColor()[0]); + oCheckbox.setBackground(getThemeColor()[1]); + oCheckbox.setBorder(BorderFactory.createLineBorder(getThemeColor()[2])); } - for (int i = 0; i < oPanels.size(); i++) { - oPanels.get(i).setForeground(getThemeColor()[0]); - oPanels.get(i).setBackground(getThemeColor()[1]); + for (JPanel oPanel : oPanels) { + oPanel.setForeground(getThemeColor()[0]); + oPanel.setBackground(getThemeColor()[1]); } oTable.setForeground(getThemeColor()[0]);