You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jo...@us...> - 2009-02-25 08:28:42
|
Revision: 462 http://mspsim.svn.sourceforge.net/mspsim/?rev=462&view=rev Author: joxe Date: 2009-02-25 08:28:36 +0000 (Wed, 25 Feb 2009) Log Message: ----------- added rfsource Modified Paths: -------------- mspsim/se/sics/mspsim/chip/RFListener.java Added Paths: ----------- mspsim/se/sics/mspsim/chip/RFSource.java Modified: mspsim/se/sics/mspsim/chip/RFListener.java =================================================================== --- mspsim/se/sics/mspsim/chip/RFListener.java 2009-02-17 15:57:41 UTC (rev 461) +++ mspsim/se/sics/mspsim/chip/RFListener.java 2009-02-25 08:28:36 UTC (rev 462) @@ -1,5 +1,5 @@ /** - * Copyright (c) 2007, Swedish Institute of Computer Science. + * Copyright (c) 2007,2008,2009, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without Added: mspsim/se/sics/mspsim/chip/RFSource.java =================================================================== --- mspsim/se/sics/mspsim/chip/RFSource.java (rev 0) +++ mspsim/se/sics/mspsim/chip/RFSource.java 2009-02-25 08:28:36 UTC (rev 462) @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2007,2008,2009, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: RFListener.java 281 2008-05-13 15:18:14Z joxe$ + * + * ----------------------------------------------------------------- + * + * RFSource + * + * Author : Joakim Eriksson + * Created : Feb 2009 + * + */ +package se.sics.mspsim.chip; + +public interface RFSource { + void setRFListener(RFListener listener); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-17 15:57:46
|
Revision: 461 http://mspsim.svn.sourceforge.net/mspsim/?rev=461&view=rev Author: joxe Date: 2009-02-17 15:57:41 +0000 (Tue, 17 Feb 2009) Log Message: ----------- fixed array out of index bug in CC2420 transmit Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/core/Watchdog.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2009-02-08 18:38:16 UTC (rev 460) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2009-02-17 15:57:41 UTC (rev 461) @@ -779,9 +779,12 @@ private void txNext() { if(txfifoPos <= memory[RAM_TXFIFO]) { + if (txfifoPos > 0x7f) { + log("Warning: packet size too large - repeating packet bytes txfifoPos: " + txfifoPos); + } if (listener != null) { - if (DEBUG) log("transmitting byte: " + Utils.hex8(memory[RAM_TXFIFO + txfifoPos] & 0xFF)); - listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos] & 0xFF)); + if (DEBUG) log("transmitting byte: " + Utils.hex8(memory[RAM_TXFIFO + (txfifoPos & 0x7f)] & 0xFF)); + listener.receivedByte((byte)(memory[RAM_TXFIFO + (txfifoPos & 0x7f)] & 0xFF)); } txfifoPos++; // Two symbol periods to send a byte... Modified: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java 2009-02-08 18:38:16 UTC (rev 460) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2009-02-17 15:57:41 UTC (rev 461) @@ -87,12 +87,10 @@ this.cpu = cpu; } - @Override public String getName() { return "Watchdog"; } - @Override public void interruptServiced(int vector) { cpu.flagInterrupt(RESET_VECTOR, this, false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-08 18:38:18
|
Revision: 460 http://mspsim.svn.sourceforge.net/mspsim/?rev=460&view=rev Author: joxe Date: 2009-02-08 18:38:16 +0000 (Sun, 08 Feb 2009) Log Message: ----------- updated changelog Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2009-02-08 16:12:22 UTC (rev 459) +++ mspsim/CHANGE_LOG.txt 2009-02-08 18:38:16 UTC (rev 460) @@ -1,3 +1,10 @@ +0.97 +- added stack trace for misalignment warnings if MSP430 Core is in log mode +- added MSP430 Core as a loggable +- added emulation of DS2411 for generating MAC addresses +- added warning when UART is transmitting while in LPM3 +- added profiling of events and added event system + 0.96 - added warning on unaligned write/read - fixed bug in timer system causing severe delays when several CCR/Compare This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-08 16:12:33
|
Revision: 459 http://mspsim.svn.sourceforge.net/mspsim/?rev=459&view=rev Author: joxe Date: 2009-02-08 16:12:22 +0000 (Sun, 08 Feb 2009) Log Message: ----------- added stacktrace for misalignmentwarning - when loggin MSP430 Core Modified Paths: -------------- mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2009-02-07 16:32:01 UTC (rev 458) +++ mspsim/se/sics/mspsim/core/Chip.java 2009-02-08 16:12:22 UTC (rev 459) @@ -139,6 +139,10 @@ DEBUG = false; } + public PrintStream getLogStream() { + return log; + } + public void setLogStream(PrintStream out) { log = out; DEBUG = true; Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2009-02-07 16:32:01 UTC (rev 458) +++ mspsim/se/sics/mspsim/core/MSP430.java 2009-02-08 16:12:22 UTC (rev 459) @@ -40,6 +40,8 @@ */ package se.sics.mspsim.core; +import java.io.PrintStream; + import se.sics.mspsim.util.*; public class MSP430 extends MSP430Core { @@ -75,6 +77,7 @@ public MSP430(int type) { super(type); disAsm = new DisAsm(); + addChip(this); } public double getCPUPercent() { @@ -312,6 +315,13 @@ } } + void generateTrace() { + PrintStream out = getLogStream(); + if (profiler != null && out != null) { + profiler.printStackTrace(out); + } + } + public boolean getDebug() { return debug; } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2009-02-07 16:32:01 UTC (rev 458) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2009-02-08 16:12:22 UTC (rev 459) @@ -677,10 +677,15 @@ } else { if (warningMode == WarningMode.PRINT) { System.out.println(message); + generateTrace(); } } } + void generateTrace() { + /* overide if a stack trace or other additional warning info should + * be printed */ + } private int serviceInterrupt(int pc) { int pcBefore = pc; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-07 16:32:02
|
Revision: 458 http://mspsim.svn.sourceforge.net/mspsim/?rev=458&view=rev Author: joxe Date: 2009-02-07 16:32:01 +0000 (Sat, 07 Feb 2009) Log Message: ----------- added possibility to set node id which is used for MAC addresses Modified Paths: -------------- mspsim/se/sics/mspsim/chip/DS2411.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java Modified: mspsim/se/sics/mspsim/chip/DS2411.java =================================================================== --- mspsim/se/sics/mspsim/chip/DS2411.java 2009-02-07 14:36:06 UTC (rev 457) +++ mspsim/se/sics/mspsim/chip/DS2411.java 2009-02-07 16:32:01 UTC (rev 458) @@ -71,6 +71,7 @@ private int writePos = 0; /* max 10 bytes to write back */ private int[] writeBuf = new int[10]; + private int[] macID = new int[]{0, 1, 2, 3, 4, 5}; private TimeEvent stateEvent = new TimeEvent(0) { public void execute(long t) { @@ -137,12 +138,12 @@ if (cmd == CMD_READ_ROM) { /* 48 bits = 6 bytes */ writeBuf[0] = 0x01; /* family */ - writeBuf[1] = 0x01; - writeBuf[2] = 0x02; - writeBuf[3] = 0x03; - writeBuf[4] = 0x04; - writeBuf[5] = 0x05; - writeBuf[6] = 0x06; + writeBuf[1] = macID[0]; + writeBuf[2] = macID[1]; + writeBuf[3] = macID[2]; + writeBuf[4] = macID[3]; + writeBuf[5] = macID[4]; + writeBuf[6] = macID[5]; writeBuf[7] = crc8(writeBuf, 7); /* the crc */ writeLen = 1 + 6 + 1; } @@ -224,4 +225,13 @@ } } } + + public void setMACID(int i, int j, int k, int l, int m, int n) { + macID[0] = i; + macID[1] = j; + macID[2] = k; + macID[3] = l; + macID[4] = m; + macID[5] = n; + } } Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2009-02-07 14:36:06 UTC (rev 457) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2009-02-07 16:32:01 UTC (rev 458) @@ -88,6 +88,10 @@ return elf; } + public void setNodeID(int id) { + ds2411.setMACID(0, 0, 0, (id >> 8) & 0xff, id & 0xff, id & 0xff); + } + public void setupNodePorts() { sht11 = new SHT11(cpu); ds2411 = new DS2411(cpu); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-07 14:36:10
|
Revision: 457 http://mspsim.svn.sourceforge.net/mspsim/?rev=457&view=rev Author: joxe Date: 2009-02-07 14:36:06 +0000 (Sat, 07 Feb 2009) Log Message: ----------- added DS2411 Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java Added Paths: ----------- mspsim/se/sics/mspsim/chip/DS2411.java Added: mspsim/se/sics/mspsim/chip/DS2411.java =================================================================== --- mspsim/se/sics/mspsim/chip/DS2411.java (rev 0) +++ mspsim/se/sics/mspsim/chip/DS2411.java 2009-02-07 14:36:06 UTC (rev 457) @@ -0,0 +1,227 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + * $Id: DS2411.java 177 2008-03-11 15:32:12Z nifi $ + * + * ----------------------------------------------------------------- + * + * DS2411 - MAC Address chip + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2008-03-11 16:32:12 +0100 (ti, 11 mar 2008) $ + * $Revision: 177 $ + */ +package se.sics.mspsim.chip; + + +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.IOPort; +import se.sics.mspsim.core.MSP430Core; +import se.sics.mspsim.core.TimeEvent; +import se.sics.mspsim.util.Utils; + +public class DS2411 extends Chip { + + private static final boolean DEBUG = false; + + private enum STATE { + IDLE, WAIT_FOR_RESET, RESETTING, SIGNAL_READY, READY, WAIT_SENDING, SENDING + } + + private static final int CMD_READ_ROM = 0x33; + private static final int CMD_SEACH_ROM = 0xf0; + + MSP430Core cpu; + private IOPort sdataPort; + private int sdataPin; + private STATE state = STATE.IDLE; + private boolean lastPin; + + private int pos = 0; + private int readByte = 0; + private int writeByte = 0; + private int writeLen = 0; + private int writePos = 0; + /* max 10 bytes to write back */ + private int[] writeBuf = new int[10]; + + private TimeEvent stateEvent = new TimeEvent(0) { + public void execute(long t) { + switch (state) { + case WAIT_FOR_RESET: + if (!lastPin) { + state = STATE.RESETTING; + log("Reseting..."); + } + break; + case SIGNAL_READY: + /* ready! release bus */ + sdataPort.setPinState(sdataPin, IOPort.PIN_HI); + state = STATE.READY; + log("Ready!"); + readByte = 0; + pos = 0; + break; + case READY: + log("Reading: " + (lastPin ? 1 : 0)); + readByte = readByte + (lastPin ? (1 << pos) : 0); + pos++; + if (pos == 8) { + log("Command: " + Utils.hex8(readByte)); + handleCommand(readByte); + state = STATE.WAIT_SENDING; + pos = 0; + writePos = 0; + writeByte = writeBuf[writePos]; + } + break; + } + } + }; + + public DS2411(MSP430Core cpu) { + this.cpu = cpu; + if (DEBUG) { + setLogStream(System.out); + } + } + + private int crcAdd(int acc, int data) { + int i; + acc ^= data; + for (i = 0; i < 8; i++) { + if ((acc & 1) == 1) + acc = (acc >> 1) ^ 0x8c; + else + acc >>= 1; + } + return acc; + } + + private int crc8(int[] buf, int len) { + int acc = 0; + for (int i = 0; i < len; i++) { + acc = crcAdd(acc, buf[i]); + } + return acc; + } + + protected void handleCommand(int cmd) { + if (cmd == CMD_READ_ROM) { + /* 48 bits = 6 bytes */ + writeBuf[0] = 0x01; /* family */ + writeBuf[1] = 0x01; + writeBuf[2] = 0x02; + writeBuf[3] = 0x03; + writeBuf[4] = 0x04; + writeBuf[5] = 0x05; + writeBuf[6] = 0x06; + writeBuf[7] = crc8(writeBuf, 7); /* the crc */ + writeLen = 1 + 6 + 1; + } + } + + public int getModeMax() { + return 0; + } + + public String getName() { + return "DS2411"; + } + + public void setDataPort(IOPort port, int bit) { + sdataPort = port; + sdataPin = bit; + } + + /* Communication pin to the DS2411 */ + /* TODO: we should have a separate reset event so that a low for a long time will + * cause a reset in any state... + */ + public void dataPin(boolean high) { + log(" Data pin high: " + high + " " + cpu.cycles); + if (lastPin == high) return; + lastPin = high; + switch(state) { + case IDLE: + sdataPort.setPinState(sdataPin, IOPort.PIN_HI); + if (!high) { + state = STATE.WAIT_FOR_RESET; + /* reset if low for at least 480uS - we check after 400uS and resets + * then */ + log("Wait for reset..."); + cpu.scheduleTimeEventMillis(stateEvent, 0.400); + } + break; + case RESETTING: + if (high) { + state = STATE.SIGNAL_READY; + log("Signal ready"); + /* reset done - signal with LOW for a while! */ + sdataPort.setPinState(sdataPin, IOPort.PIN_LOW); + cpu.scheduleTimeEventMillis(stateEvent, 0.480); + pos = 0; + } + break; + case READY: + /* we should read a byte during the READY - 60us - 120us time slot*/ + if (!high) { + /* schedule a read after 40us */ + cpu.scheduleTimeEventMillis(stateEvent, 0.040); + } + break; + case WAIT_SENDING: + if (!high) { + state = STATE.SENDING; + } + break; + case SENDING: + if (high) { + if (pos == 0) log("should write next byte: " + writeByte); + + /* went high => we should send another bit */ + sdataPort.setPinState(sdataPin, + ((writeByte & (1 << pos)) > 0) ? IOPort.PIN_HI : IOPort.PIN_LOW); + log(" wrote bit: " + (((writeByte & (1 << pos)) > 0) ? 1 : 0)); + pos++; + if (pos == 8) { + writePos++; + if (writePos == writeLen) { + log("write is over => IDLE!!!!"); + state = STATE.IDLE; + } else { + pos = 0; + writeByte = writeBuf[writePos]; + } + } + } + } + } +} Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2009-02-05 18:35:56 UTC (rev 456) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2009-02-07 14:36:06 UTC (rev 457) @@ -51,6 +51,12 @@ public static final int MISALIGNED_READ = 0; public static final int MISALIGNED_WRITE = 1; + /* memory tags - not used yet*/ + public static final int READ_MONITOR = 0x1000; + public static final int WRITE_MONITOR = 0x2000; + public static final int EXEC_MONITOR = 0x4000; + public static final int MEM_FLASH = 0x100; + public static final int MEM_IO = 0x200; public static final int RESET_PUC = 0; public static final int RESET_POR = 1; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2009-02-05 18:35:56 UTC (rev 456) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2009-02-07 14:36:06 UTC (rev 457) @@ -79,7 +79,7 @@ // For notify read... -> which will happen before actual read! public IOUnit[] memIn = new IOUnit[MAX_MEM_IO]; - private IOUnit[] passiveIOUnits; + private IOUnit[] ioUnits; private SFR sfr; // From the possible interrupt sources - to be able to indicate is serviced. @@ -128,9 +128,9 @@ // Ignore type for now... setModeNames(MODE_NAMES); int passIO = 0; - // Passive IOUnits (no tick) - should likely be placed in a hashtable? + // IOUnits should likely be placed in a hashtable? // Maybe for debugging purposes... - passiveIOUnits = new IOUnit[PORTS + 6]; + ioUnits = new IOUnit[PORTS + 7]; Timer ta = new Timer(this, Timer.TIMER_Ax149, memory, 0x160); Timer tb = new Timer(this, Timer.TIMER_Bx149, memory, 0x180); @@ -179,47 +179,49 @@ // Add port 1,2 with interrupt capability! - passiveIOUnits[0] = new IOPort(this, "1", 4, memory, 0x20); - passiveIOUnits[1] = new IOPort(this, "2", 1, memory, 0x28); + ioUnits[0] = new IOPort(this, "1", 4, memory, 0x20); + ioUnits[1] = new IOPort(this, "2", 1, memory, 0x28); for (int i = 0, n = 8; i < n; i++) { - memOut[0x20 + i] = passiveIOUnits[0]; - memOut[0x28 + i] = passiveIOUnits[1]; + memOut[0x20 + i] = ioUnits[0]; + memOut[0x28 + i] = ioUnits[1]; } // Add port 3,4 & 5,6 for (int i = 0, n = 2; i < n; i++) { - passiveIOUnits[i + 2] = new IOPort(this, "" + (3 + i), 0, + ioUnits[i + 2] = new IOPort(this, "" + (3 + i), 0, memory, 0x18 + i * 4); - memOut[0x18 + i * 4] = passiveIOUnits[i + 2]; - memOut[0x19 + i * 4] = passiveIOUnits[i + 2]; - memOut[0x1a + i * 4] = passiveIOUnits[i + 2]; - memOut[0x1b + i * 4] = passiveIOUnits[i + 2]; + memOut[0x18 + i * 4] = ioUnits[i + 2]; + memOut[0x19 + i * 4] = ioUnits[i + 2]; + memOut[0x1a + i * 4] = ioUnits[i + 2]; + memOut[0x1b + i * 4] = ioUnits[i + 2]; - passiveIOUnits[i + 4] = new IOPort(this, "" + (5 + i), 0, + ioUnits[i + 4] = new IOPort(this, "" + (5 + i), 0, memory, 0x30 + i * 4); - memOut[0x30 + i * 4] = passiveIOUnits[i + 4]; - memOut[0x31 + i * 4] = passiveIOUnits[i + 4]; - memOut[0x32 + i * 4] = passiveIOUnits[i + 4]; - memOut[0x33 + i * 4] = passiveIOUnits[i + 4]; + memOut[0x30 + i * 4] = ioUnits[i + 4]; + memOut[0x31 + i * 4] = ioUnits[i + 4]; + memOut[0x32 + i * 4] = ioUnits[i + 4]; + memOut[0x33 + i * 4] = ioUnits[i + 4]; } passIO = 6; // Basic clock syst. - passiveIOUnits[passIO++] = bcs; + ioUnits[passIO++] = bcs; // Usarts - passiveIOUnits[passIO++] = usart0; - passiveIOUnits[passIO++] = usart1; + ioUnits[passIO++] = usart0; + ioUnits[passIO++] = usart1; // Add the timers - passiveIOUnits[passIO++] = ta; - passiveIOUnits[passIO++] = tb; + ioUnits[passIO++] = ta; + ioUnits[passIO++] = tb; ADC12 adc12 = new ADC12(this); - passiveIOUnits[passIO++] = adc12; + ioUnits[passIO++] = adc12; + ioUnits[passIO++] = sfr; + for (int i = 0, n = 16; i < n; i++) { memOut[0x80 + i] = adc12; memIn[0x80 + i] = adc12; @@ -238,7 +240,7 @@ /* returns port 1 ... 6 */ public IOPort getIOPort(int portID) { if (portID > 0 && portID < 7) { - return (IOPort) passiveIOUnits[portID - 1]; + return (IOPort) ioUnits[portID - 1]; } return null; } @@ -503,17 +505,17 @@ // Should also return active units... public IOUnit getIOUnit(String name) { - for (int i = 0, n = passiveIOUnits.length; i < n; i++) { - if (name.equals(passiveIOUnits[i].getName())) { - return passiveIOUnits[i]; + for (int i = 0, n = ioUnits.length; i < n; i++) { + if (name.equals(ioUnits[i].getName())) { + return ioUnits[i]; } } return null; } private void resetIOUnits() { - for (int i = 0, n = passiveIOUnits.length; i < n; i++) { - passiveIOUnits[i].reset(RESET_POR); + for (int i = 0, n = ioUnits.length; i < n; i++) { + ioUnits[i].reset(RESET_POR); } } @@ -637,6 +639,7 @@ } public void write(int dstAddress, int dst, boolean word) { + // TODO: optimize memory usage by tagging memory's higher bits. if (breakPoints[dstAddress] != null) { breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); } Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2009-02-05 18:35:56 UTC (rev 456) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2009-02-07 14:36:06 UTC (rev 457) @@ -1,6 +1,7 @@ package se.sics.mspsim.platform.sky; import se.sics.mspsim.chip.CC2420; +import se.sics.mspsim.chip.DS2411; import se.sics.mspsim.chip.PacketListener; import se.sics.mspsim.chip.SHT11; import se.sics.mspsim.core.IOPort; @@ -24,6 +25,8 @@ public static final int MODE_LEDS_3 = 3; public static final int MODE_MAX = MODE_LEDS_3; // Port 2. + public static final int DS2411_DATA_PIN = 4; + public static final int DS2411_DATA = 1 << DS2411_DATA_PIN; public static final int BUTTON_PIN = 7; /* P1.0 - Input: FIFOP from CC2420 */ @@ -62,6 +65,7 @@ public CC2420 radio; public SHT11 sht11; + public DS2411 ds2411; public SkyGui gui; public NetworkConnection network; @@ -86,6 +90,7 @@ public void setupNodePorts() { sht11 = new SHT11(cpu); + ds2411 = new DS2411(cpu); IOUnit unit = cpu.getIOUnit("Port 5"); if (unit instanceof IOPort) { @@ -103,6 +108,8 @@ unit = cpu.getIOUnit("Port 2"); if (unit instanceof IOPort) { port2 = (IOPort) unit; + ds2411.setDataPort(port2, DS2411_DATA_PIN); + port2.setPortListener(this); } IOUnit usart0 = cpu.getIOUnit("USART 0"); @@ -211,6 +218,8 @@ } else if (source == port1) { sht11.clockPin((data & SHT11_CLK) != 0); sht11.dataPin((data & SHT11_DATA) != 0); + } else if (source == port2) { + ds2411.dataPin((data & DS2411_DATA) != 0); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-05 18:35:59
|
Revision: 456 http://mspsim.svn.sourceforge.net/mspsim/?rev=456&view=rev Author: joxe Date: 2009-02-05 18:35:56 +0000 (Thu, 05 Feb 2009) Log Message: ----------- fixed update of active channel for chipinfo Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2009-02-05 18:21:07 UTC (rev 455) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2009-02-05 18:35:56 UTC (rev 456) @@ -1066,6 +1066,7 @@ } public String chipinfo() { + updateActiveFrequency(); return " VREG_ON: " + on + " ChipSel: " + chipSelect + "\n OSC_Stable: " + ((status & STATUS_XOSC16M_STABLE) > 0) + "\n RSSI_Valid: " + ((status & STATUS_RSSI_VALID) > 0) + " CCA: " + cca + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-05 18:21:14
|
Revision: 455 http://mspsim.svn.sourceforge.net/mspsim/?rev=455&view=rev Author: joxe Date: 2009-02-05 18:21:07 +0000 (Thu, 05 Feb 2009) Log Message: ----------- added selected channel to chipinfo Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2009-02-02 19:52:26 UTC (rev 454) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2009-02-05 18:21:07 UTC (rev 455) @@ -1074,6 +1074,7 @@ "\n Radio State: " + stateMachine + " rxFifoLen: " + rxfifoLen + " rxFifoWritePos: " + rxfifoWritePos + " rxFifoReadPos: " + rxfifoReadPos + "\n SPI State: " + state + + "\n Channel: " + activeChannel + "\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-02-02 19:52:31
|
Revision: 454 http://mspsim.svn.sourceforge.net/mspsim/?rev=454&view=rev Author: joxe Date: 2009-02-02 19:52:26 +0000 (Mon, 02 Feb 2009) Log Message: ----------- minor fixes of network packet Modified Paths: -------------- mspsim/se/sics/mspsim/util/NetworkPacket.java Modified: mspsim/se/sics/mspsim/util/NetworkPacket.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkPacket.java 2009-01-31 15:57:54 UTC (rev 453) +++ mspsim/se/sics/mspsim/util/NetworkPacket.java 2009-02-02 19:52:26 UTC (rev 454) @@ -40,11 +40,14 @@ */ package se.sics.mspsim.util; +import java.util.Enumeration; import java.util.Hashtable; public class NetworkPacket { byte[] data; - String description = "version:4|trafficClass:8|flowLabel:20" + + String description; + public static final String IPv6 = + "version:4=6|trafficClass:8|flowLabel:20" + "|payloadLength:16|nextHeader:8|hopLimit:8" + "|sourceAddress:128|destinationAddress:128"; @@ -54,6 +57,8 @@ String name; int pos; int size; + int mask = 0; + int value = 0; Field(String name, int pos, int size) { this.name = name; @@ -61,34 +66,79 @@ this.size = size; } + public void setMatchMask(int mask, int value) { + this.mask = mask; + this.value = value; + } + public String toString() { - return name + ":" + pos + "-" + (pos + size - 1); + return name + ":" + pos + "-" + (pos + size - 1) + + (mask != 0 ? "=" + value : ""); } } - public NetworkPacket(byte[] data) { - this.data = data; - parseData(); + + public NetworkPacket(String pattern) { + description = pattern; + String[] parts = description.split("\\|"); + int pos = 0; + for (int i = 0; i < parts.length; i++) { + String field[] = parts[i].split(":"); + String val = field[1]; + String matchVal = null; + if (val.indexOf('=') > 0) { + String[] match = val.split("="); + val = match[0]; + matchVal = match[1]; + } + int size = Integer.parseInt(val); + Field f = new Field(field[0], pos, size); + if (matchVal != null) { + int mask = Integer.parseInt(matchVal); + f.setMatchMask(mask, mask); + } + pos += size; + System.out.println("Adding field: " + f); + fields.put(f.name, f); + } } - private void parseData() { - String[] parts = description.split("\\|"); - int pos = 0; - for (int i = 0; i < parts.length; i++) { - String field[] = parts[i].split(":"); - int size = Integer.parseInt(field[1]); - Field f = new Field(field[0], pos, size); - pos += size; - System.out.println("Adding field: " + f); - fields.put(f.name, f); + + NetworkPacket(String pattern, Hashtable<String, Field> fields) { + this.description = pattern; + this.fields = fields; + } + + public boolean matches(byte[] data) { + for (Enumeration<Field> iterator = fields.elements(); iterator.hasMoreElements();) { + Field f = iterator.nextElement(); + if (f.mask != 0) { + int val = getIntBits(data, f.pos, f.pos + f.size - 1); + if ((val & f.mask) != f.value) { + return false; + } else { + System.out.println("Field: " + f.name + " matches"); + } + } } + return true; } + + /* create a network packet based on a packet with description */ + public NetworkPacket parseData(byte[] data) { + if (matches(data)) { + NetworkPacket np = new NetworkPacket(description, fields); + np.data = data; + return np; + } + return null; + } public int getLength() { return data.length; } - public int getIntBits(int startBit, int endBit) { + public int getIntBits(byte[] data, int startBit, int endBit) { int startByte = startBit >> 8; int endByte = endBit >> 8; startBit = startBit & 7; @@ -112,7 +162,7 @@ public int getInt(String field) { Field f = fields.get(field); - return getIntBits(f.pos, f.pos + f.size - 1); + return getIntBits(data, f.pos, f.pos + f.size - 1); } public static void main(String[] args) { @@ -128,8 +178,9 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - NetworkPacket np = new NetworkPacket(data); - System.out.println("Version: " + np.getIntBits(0, 3)); + NetworkPacket np = new NetworkPacket(IPv6); + np = np.parseData(data); + System.out.println("Version: " + np.getIntBits(np.data, 0, 3)); System.out.println("Version: " + np.getInt("version")); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-31 15:58:02
|
Revision: 453 http://mspsim.svn.sourceforge.net/mspsim/?rev=453&view=rev Author: joxe Date: 2009-01-31 15:57:54 +0000 (Sat, 31 Jan 2009) Log Message: ----------- added warning when USART transmitting when in LPM3 or higher Modified Paths: -------------- mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2009-01-20 22:14:47 UTC (rev 452) +++ mspsim/se/sics/mspsim/core/USART.java 2009-01-31 15:57:54 UTC (rev 453) @@ -335,22 +335,26 @@ cpu.flagInterrupt(vector, this, false); } - private void handleTransmit(long cycles) { - if (listener != null && nextTXByte != -1) { - listener.dataReceived(this, nextTXByte); - nextTXByte = -1; - } + private void handleTransmit(long cycles) { + if (cpu.getMode() >= MSP430Core.MODE_LPM3) { + System.out.println(getName() + " Warning: USART transmission during LPM!!! " + nextTXByte); + } - utctl |= UTCTL_TXEMPTY; - setBitIFG(utxifg); + if (listener != null && nextTXByte != -1) { + listener.dataReceived(this, nextTXByte); + nextTXByte = -1; + } + + utctl |= UTCTL_TXEMPTY; + setBitIFG(utxifg); - if (DEBUG) { - if (isIEBitsSet(utxifg)) { - System.out.println(getName() + " flagging on transmit interrupt"); - } - System.out.println(getName() + " Ready to transmit next at: " + cycles); - } - } + if (DEBUG) { + if (isIEBitsSet(utxifg)) { + System.out.println(getName() + " flagging on transmit interrupt"); + } + System.out.println(getName() + " Ready to transmit next at: " + cycles); + } + } public boolean isReceiveFlagCleared() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-20 22:41:02
|
Revision: 452 http://mspsim.svn.sourceforge.net/mspsim/?rev=452&view=rev Author: joxe Date: 2009-01-20 22:14:47 +0000 (Tue, 20 Jan 2009) Log Message: ----------- added printout of elapsed time when returing from function when logging calls Modified Paths: -------------- mspsim/se/sics/mspsim/util/SimpleProfiler.java Modified: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java 2009-01-20 11:37:32 UTC (rev 451) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2009-01-20 22:14:47 UTC (rev 452) @@ -103,6 +103,12 @@ } ce.cycles += elapsed; ce.calls++; + + if (logger != null) { + printSpace(logger, cSP * 2); + logger.println("return from: " + ce.function + " elapsed time: " + elapsed); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-20 12:22:26
|
Revision: 451 http://mspsim.svn.sourceforge.net/mspsim/?rev=451&view=rev Author: joxe Date: 2009-01-20 11:37:32 +0000 (Tue, 20 Jan 2009) Log Message: ----------- added profiling of events and added event system Modified Paths: -------------- mspsim/README.txt mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/cli/ProfilerCommands.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/Multiplier.java mspsim/se/sics/mspsim/util/SimpleProfiler.java Added Paths: ----------- mspsim/se/sics/mspsim/core/EventListener.java mspsim/se/sics/mspsim/core/EventSource.java Modified: mspsim/README.txt =================================================================== --- mspsim/README.txt 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/README.txt 2009-01-20 11:37:32 UTC (rev 451) @@ -45,6 +45,7 @@ - Emulates some external hardware such as TR1001 and CC2420. - Command Line Interface, CLI, for setting up breakpoints and output to files or windows. +- GDB remote debugging support (initial) * What is emulated of the MSP430 - CPU (instruction level simulation) Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2009-01-20 11:37:32 UTC (rev 451) @@ -628,10 +628,13 @@ if(txfifoFlush) { txCursor = 0; txfifoFlush = false; - } + } if (DEBUG) log("Writing data: " + data + " to tx: " + txCursor); memory[RAM_TXFIFO + txCursor++] = data & 0xff; + if (sendEvents) { + sendEvent("WRITE_TXFIFO", null); + } break; case RAM_ACCESS: if (pos == 0) { @@ -707,6 +710,9 @@ (stateMachine == RadioState.RX_WAIT)) { status |= STATUS_TX_ACTIVE; setState(RadioState.TX_CALIBRATE); + if (sendEvents) { + sendEvent("STXON", null); + } // Starting up TX subsystem - indicate that we are in TX mode! if (DEBUG) log("Strobe STXON - transmit on! at " + cpu.cycles); } @@ -719,6 +725,11 @@ (stateMachine == RadioState.RX_FRAME) || (stateMachine == RadioState.RX_OVERFLOW) || (stateMachine == RadioState.RX_WAIT)) { + + if (sendEvents) { + sendEvent("STXON_CCA", null); + } + if(cca) { status |= STATUS_TX_ACTIVE; setState(RadioState.TX_CALIBRATE); Modified: mspsim/se/sics/mspsim/cli/ProfilerCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2009-01-20 11:37:32 UTC (rev 451) @@ -39,9 +39,13 @@ */ package se.sics.mspsim.cli; +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.EventListener; +import se.sics.mspsim.core.EventSource; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.Profiler; import se.sics.mspsim.util.ComponentRegistry; +import se.sics.mspsim.util.SimpleProfiler; /** * @@ -105,7 +109,57 @@ } }); + + ch.registerCommand("logevents", new BasicAsyncCommand("log events", "") { + Chip chip; + public int executeCommand(CommandContext context) { + chip = cpu.getChip(context.getArgument(0)); + if (chip == null) { + context.err.println("Can not find chip: " + context.getArgument(0)); + } + chip.setEventListener(new EventListener() { + public void event(EventSource source, String event, Object data) { + System.out.println("Event:" + source.getName() + ":" + event); + } + }); + return 0; + } + public void stopCommand(CommandContext context) { + chip.setEventListener(null); + } + }); + ch.registerCommand("tagprof", new BasicCommand("profile between two events", "") { + public int executeCommand(CommandContext context) { + String event1 = context.getArgument(0); + String event2 = context.getArgument(1); + String chip1[] = event1.split("\\."); + String chip2[] = event2.split("\\."); + Chip chipE1 = cpu.getChip(chip1[0]); + if (chipE1 == null) { + context.err.println("Can not find chip: " + chip1[0]); + } + Chip chipE2 = cpu.getChip(chip2[0]); + if (chipE2 == null) { + context.err.println("Can not find chip: " + chip2[0]); + } + Profiler profiler = cpu.getProfiler(); + SimpleProfiler sprof = (SimpleProfiler) profiler; + sprof.addProfileTag(context.getArgument(2), chipE1, chip1[1], + chipE2, chip2[1]); + return 0; + } + }); + + ch.registerCommand("printtags", new BasicCommand("print tags profile", "") { + public int executeCommand(CommandContext context) { + Profiler profiler = cpu.getProfiler(); + SimpleProfiler sprof = (SimpleProfiler) profiler; + sprof.printTagProfile(context.out); + return 0; + } + }); + ch.registerCommand("logcalls", new BasicAsyncCommand("log function calls", "") { @Override Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/core/Chip.java 2009-01-20 11:37:32 UTC (rev 451) @@ -47,9 +47,11 @@ * @author Joakim * */ -public abstract class Chip implements Loggable { +public abstract class Chip implements Loggable, EventSource { private OperatingModeListener[] omListeners; + private EventListener eventListener; + protected boolean sendEvents = false; private String[] modeNames = null; private int mode; private PrintStream log; @@ -83,6 +85,18 @@ modeNames = names; } + + public void setEventListener(EventListener e) { + eventListener = e; + sendEvents = true; + } + + protected void sendEvent(String event, Object data) { + if (eventListener != null) { + eventListener.event(this, event, data); + } + } + public String getModeName(int index) { if (modeNames == null) { return null; Added: mspsim/se/sics/mspsim/core/EventListener.java =================================================================== --- mspsim/se/sics/mspsim/core/EventListener.java (rev 0) +++ mspsim/se/sics/mspsim/core/EventListener.java 2009-01-20 11:37:32 UTC (rev 451) @@ -0,0 +1,5 @@ +package se.sics.mspsim.core; + +public interface EventListener { + public void event(EventSource source, String event, Object data); +} Added: mspsim/se/sics/mspsim/core/EventSource.java =================================================================== --- mspsim/se/sics/mspsim/core/EventSource.java (rev 0) +++ mspsim/se/sics/mspsim/core/EventSource.java 2009-01-20 11:37:32 UTC (rev 451) @@ -0,0 +1,5 @@ +package se.sics.mspsim.core; + +public interface EventSource { + public String getName(); +} Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2009-01-20 11:37:32 UTC (rev 451) @@ -53,11 +53,6 @@ public void reset(int type) { } - - // Should return the cycle it wants the next tick... - public long ioTick(long cycles) { - return cycles + 1000000; - } // write // write a value to the IO unit Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/core/MSP430.java 2009-01-20 11:37:32 UTC (rev 451) @@ -329,6 +329,7 @@ /* When we got the map table we can also profile! */ if (profiler == null) { this.profiler = new SimpleProfiler(); + this.profiler.setCPU(this); } } Modified: mspsim/se/sics/mspsim/core/Multiplier.java =================================================================== --- mspsim/se/sics/mspsim/core/Multiplier.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/core/Multiplier.java 2009-01-20 11:37:32 UTC (rev 451) @@ -80,10 +80,6 @@ this.core = core; } - public boolean needsTick() { - return false; - } - public int read(int address, boolean word, long cycles) { switch (address) { case MPY: Modified: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java 2009-01-13 21:45:18 UTC (rev 450) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2009-01-20 11:37:32 UTC (rev 451) @@ -40,6 +40,9 @@ */ package se.sics.mspsim.util; +import se.sics.mspsim.core.Chip; +import se.sics.mspsim.core.EventListener; +import se.sics.mspsim.core.EventSource; import se.sics.mspsim.core.MSP430Core; import se.sics.mspsim.core.Profiler; import java.io.PrintStream; @@ -48,9 +51,12 @@ import java.util.regex.Pattern; -public class SimpleProfiler implements Profiler { +public class SimpleProfiler implements Profiler, EventListener { private Hashtable<MapEntry,CallEntry> profileData; + private Hashtable<String, TagEntry> tagProfiles; + private Hashtable<String, TagEntry> startTags; + private Hashtable<String, TagEntry> endTags; private CallEntry[] callStack; private int cSP = 0; private MSP430Core cpu; @@ -58,6 +64,9 @@ public SimpleProfiler() { profileData = new Hashtable<MapEntry, CallEntry>(); + tagProfiles = new Hashtable<String, TagEntry>(); + startTags = new Hashtable<String, TagEntry>(); + endTags = new Hashtable<String, TagEntry>(); callStack = new CallEntry[2048]; } @@ -113,7 +122,7 @@ } } } - + public void printProfile(PrintStream out) { printProfile(out, null); } @@ -163,7 +172,7 @@ out.println(" " + callStack[cSP - i - 1].function.getInfo()); } } - + private static class CallEntry implements Comparable<CallEntry> { MapEntry function; long cycles; @@ -177,7 +186,88 @@ } } + private static class TagEntry implements Comparable<TagEntry> { + String tag; + long cycles; + long lastCycles; + int calls; + + public int compareTo(TagEntry o) { + long diff = o.cycles - cycles; + if (diff > 0) return 1; + if (diff < 0) return -1; + return 0; + } + } + + + public void setLogger(PrintStream out) { logger = out; } + + /* + * Tag profiling. + */ + public void measureStart(String tag) { + TagEntry tagEntry = tagProfiles.get(tag); + if (tagEntry == null) { + tagEntry = new TagEntry(); + tagEntry.tag = tag; + tagProfiles.put(tag, tagEntry); + } + /* only the first occurrence of event will set the lastCycles */ + if (tagEntry.lastCycles == 0) { + tagEntry.lastCycles = cpu.cycles; + } + } + + public void measureEnd(String tag) { + TagEntry tagEntry = tagProfiles.get(tag); + if (tagEntry != null) { + if (tagEntry.lastCycles != 0) { + tagEntry.calls++; + tagEntry.cycles += cpu.cycles - tagEntry.lastCycles; + tagEntry.lastCycles = 0; + } + } + } + + public void printTagProfile(PrintStream out) { + TagEntry[] entries = tagProfiles.values().toArray(new TagEntry[tagProfiles.size()]); + Arrays.sort(entries); + for (int i = 0; i < entries.length; i++) { + TagEntry entry = entries[i]; + System.out.println(entry.tag + "\t" + entry.calls + "\t" + entry.cycles); + } + } + + public void addProfileTag(String tag, Chip chip, String start, + Chip chip2, String end) { + System.out.println("Add profile: " + tag + + " start: " + start + " end: " + end); + TagEntry tagEntry = new TagEntry(); + tagEntry.tag = tag; + startTags.put(start, tagEntry); + endTags.put(end, tagEntry); + tagProfiles.put(tag, tagEntry); + chip.setEventListener(this); + chip2.setEventListener(this); + } + + public void event(EventSource source, String event, Object data) { + TagEntry tagEntry = null; + if ((tagEntry = startTags.get(event)) != null) { + /* only the first occurrence of event will set the lastCycles */ + if (tagEntry.lastCycles == 0) { + tagEntry.lastCycles = cpu.cycles; + } + } else if ((tagEntry = endTags.get(event)) != null) { + if (tagEntry.lastCycles != 0) { + tagEntry.calls++; + tagEntry.cycles += cpu.cycles - tagEntry.lastCycles; + tagEntry.lastCycles = 0; + } + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-13 22:49:53
|
Revision: 450 http://mspsim.svn.sourceforge.net/mspsim/?rev=450&view=rev Author: joxe Date: 2009-01-13 21:45:18 +0000 (Tue, 13 Jan 2009) Log Message: ----------- removed debug printout Modified Paths: -------------- mspsim/se/sics/mspsim/core/USART.java mspsim/se/sics/mspsim/util/GDBStubs.java Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2009-01-11 18:34:05 UTC (rev 449) +++ mspsim/se/sics/mspsim/core/USART.java 2009-01-13 21:45:18 UTC (rev 450) @@ -159,7 +159,7 @@ } public void enableChanged(int reg, int bit, boolean enabled) { - System.out.println("enableChanged: " + reg + " bit: " + bit + + if (DEBUG) System.out.println("enableChanged: " + reg + " bit: " + bit + " enabled = " + enabled + " txBit: " + txbit); if (bit == txbit) { txEnabled = enabled; Modified: mspsim/se/sics/mspsim/util/GDBStubs.java =================================================================== --- mspsim/se/sics/mspsim/util/GDBStubs.java 2009-01-11 18:34:05 UTC (rev 449) +++ mspsim/se/sics/mspsim/util/GDBStubs.java 2009-01-13 21:45:18 UTC (rev 450) @@ -83,6 +83,8 @@ System.out.println("GDBStubs: Read " + c + " => " + (char) c); if (c == '#') { readCmd = false; + /* ack the message */ + output.write('+'); handleCmd(cmd, buffer, len); cmd = ""; len = 0; @@ -168,7 +170,6 @@ } public void sendResponse(String resp) throws IOException { - output.write('+'); output.write('$'); int cs = 0; if (resp != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-11 18:34:21
|
Revision: 449 http://mspsim.svn.sourceforge.net/mspsim/?rev=449&view=rev Author: joxe Date: 2009-01-11 18:34:05 +0000 (Sun, 11 Jan 2009) Log Message: ----------- updated changelog Modified Paths: -------------- mspsim/CHANGE_LOG.txt Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2009-01-11 18:24:44 UTC (rev 448) +++ mspsim/CHANGE_LOG.txt 2009-01-11 18:34:05 UTC (rev 449) @@ -1,7 +1,9 @@ 0.96 - added warning on unaligned write/read +- fixed bug in timer system causing severe delays when several CCR/Compare + interrupts was trigger simultaneously +- added profiling of interrupts - 0.95 - initial GDB stubs implementation (only for memory access) - CLI command for setting up gdbstubs server (gdbstubs PORT) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-11 18:24:49
|
Revision: 448 http://mspsim.svn.sourceforge.net/mspsim/?rev=448&view=rev Author: joxe Date: 2009-01-11 18:24:44 +0000 (Sun, 11 Jan 2009) Log Message: ----------- removed debugprintouts Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2009-01-05 16:47:37 UTC (rev 447) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2009-01-11 18:24:44 UTC (rev 448) @@ -603,11 +603,6 @@ // In the main-CPU loop public void handlePendingInterrupts() { // By default no int. left to process... - if (servicedInterrupt == 5 || - servicedInterrupt == 6) { - System.out.println("## Interrupt ended at: " + cycles + - " elapsed: " + (cycles - lastInterruptTime[servicedInterrupt])); - } if (servicedInterrupt > -1) { interruptTime[servicedInterrupt] += cycles - lastInterruptTime[servicedInterrupt]; interruptCount[servicedInterrupt]++; Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2009-01-05 16:47:37 UTC (rev 447) +++ mspsim/se/sics/mspsim/core/Timer.java 2009-01-11 18:24:44 UTC (rev 448) @@ -360,7 +360,7 @@ triggerInterrupts(cycles); } if (lastTIV / 2 < noCompare) { - if (DEBUG || true) { + if (DEBUG) { System.out.println(getName() + " Clearing IFG for CCR" + (lastTIV/2)); } // Clear interrupt flags! @@ -649,7 +649,6 @@ counter = 2 * tccr[0] - counter; } } - // System.out.println("CounterStart: " + counterStart + " C:" + cycles + " bigCounter: " + bigCounter + // " counter" + counter); @@ -688,7 +687,7 @@ // System.out.println("Checking capture register [ioTick]: " + cycles); for (int i = 0, n = noCompare; i < n; i++) { if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) { - if (DEBUG || true) { + if (DEBUG) { System.out.println(getName() + (captureOn[i] ? " CAPTURE: " : " COMPARE: ") + i + " Cycles: " + cycles + " expCap: " + expCaptureTime[i] + @@ -737,7 +736,6 @@ } private void recalculateCompares(long cycles) { - System.out.println("**** RECALCULATE COMPARES !!! ****"); for (int i = 0; i < expCaptureTime.length; i++) { if (expCaptureTime[i] != 0) { int diff = tccr[i] - counter; @@ -746,10 +744,6 @@ diff += 0x10000; } expCaptureTime[i] = cycles + (long) (diff * cyclesMultiplicator); - if (i == 0) { - System.out.println("Updating capture time for CCR0: " + expCaptureTime[0] + - " cyc: " + cycles); - } } } } @@ -804,10 +798,11 @@ System.out.println(getName() +" >>>> Trigger IRQ for CCR0: " + tccr[0] + " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0]); } - if (counter != tccr[0] && trigger) { + if (DEBUG && counter < tccr[0] && trigger) { System.out.print("***** WARNING!!! CTR Err "); System.out.println(getName() +" >>>> Trigger IRQ for CCR0: " + tccr[0] + - " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0]); + " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0] + + " counterPassed: " + counterPassed); } core.flagInterrupt(ccr0Vector, this, trigger); // Trigger this! @@ -842,12 +837,12 @@ " >>>> Triggering IRQ for CCR" + tIndex + " at cycles:" + cycles + " CCR" + tIndex + ": " + tccr[tIndex] + " TAR: " + counter); - if (counter != tccr[tIndex]) { + if (DEBUG && counter < tccr[tIndex]) { System.out.print("***** WARNING!!! CTR Err "); System.out.println(getName() + " >>>> Triggering IRQ for CCR" + tIndex + " at cycles:" + cycles + " CCR" + tIndex + ": " + tccr[tIndex] + " TAR: " + - counter + " expCap: " + expCaptureTime[tIndex]); + counter + " expCap: " + expCaptureTime[tIndex] + " counterPassed: " + counterPassed); } } @@ -916,9 +911,8 @@ core.flagInterrupt(ccr0Vector, this, false); // Remove the flag also... tcctl[0] &= ~CC_IFG; - System.out.println(getName() + " >>>> CCR0 flag set to false"); } - if (MSP430Core.debugInterrupts || true) { + if (MSP430Core.debugInterrupts) { System.out.println(getName() + " >>>> interrupt Serviced " + lastTIV + " at cycles: " + core.cycles + " servicing delay: " + (core.cycles - triggerTime)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-05 16:47:40
|
Revision: 447 http://mspsim.svn.sourceforge.net/mspsim/?rev=447&view=rev Author: joxe Date: 2009-01-05 16:47:37 +0000 (Mon, 05 Jan 2009) Log Message: ----------- added profiling of interrupt vectors + cli command Modified Paths: -------------- mspsim/se/sics/mspsim/cli/ProfilerCommands.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/cli/ProfilerCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2009-01-05 11:30:21 UTC (rev 446) +++ mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2009-01-05 16:47:37 UTC (rev 447) @@ -53,8 +53,6 @@ if (cpu != null) { ch.registerCommand("profile", new BasicCommand("show profile information", "[-clear] [regexp]") { - - @Override public int executeCommand(final CommandContext context) { Profiler profiler = cpu.getProfiler(); if (profiler == null) { @@ -77,11 +75,9 @@ profiler.printProfile(context.out, namematch); return 0; } + }); - }); ch.registerCommand("stacktrace", new BasicCommand("show stack trace", "") { - - @Override public int executeCommand(CommandContext context) { Profiler profiler = cpu.getProfiler(); if (profiler == null) { @@ -94,6 +90,23 @@ }); + ch.registerCommand("irqprofile", new BasicCommand("show interrupt profile", "") { + public int executeCommand(CommandContext context) { + long[] time = cpu.getInterruptTime(); + long[] ctr = cpu.getInterruptCount(); + context.out.println("Interrupt statistics"); + context.out.println("Vector\tAvg\tCount"); + + for (int i = 0; i < ctr.length; i++) { + long avg = ctr[i] != 0 ? (time[i] / ctr[i]) : 0; + context.out.println(i + "\t" + avg + "\t" + ctr[i]); + } + return 0; + } + + }); + + ch.registerCommand("logcalls", new BasicAsyncCommand("log function calls", "") { @Override public int executeCommand(CommandContext context) { Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2009-01-05 11:30:21 UTC (rev 446) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2009-01-05 16:47:37 UTC (rev 447) @@ -119,6 +119,11 @@ private ArrayList<Chip> chips = new ArrayList<Chip>(); private WarningMode warningMode = WarningMode.PRINT; + /* statistics for interrupts */ + private long[] lastInterruptTime = new long[16]; + private long[] interruptTime = new long[16]; + private long[] interruptCount = new long[16]; + public MSP430Core(int type) { // Ignore type for now... setModeNames(MODE_NAMES); @@ -511,10 +516,12 @@ passiveIOUnits[i].reset(RESET_POR); } } - + private void internalReset() { for (int i = 0, n = 16; i < n; i++) { interruptSource[i] = null; + interruptTime[i] = 0; + interruptCount[i] = 0; } servicedInterruptUnit = null; servicedInterrupt = -1; @@ -532,7 +539,15 @@ public void setWarningMode(WarningMode mode) { warningMode = mode; } + + public long[] getInterruptCount() { + return interruptCount; + } + public long[] getInterruptTime() { + return interruptTime; + } + public void reset() { flagInterrupt(15, null, true); } @@ -588,6 +603,16 @@ // In the main-CPU loop public void handlePendingInterrupts() { // By default no int. left to process... + if (servicedInterrupt == 5 || + servicedInterrupt == 6) { + System.out.println("## Interrupt ended at: " + cycles + + " elapsed: " + (cycles - lastInterruptTime[servicedInterrupt])); + } + if (servicedInterrupt > -1) { + interruptTime[servicedInterrupt] += cycles - lastInterruptTime[servicedInterrupt]; + interruptCount[servicedInterrupt]++; + } + reevaluateInterrupts(); servicedInterrupt = -1; @@ -691,6 +716,8 @@ servicedInterrupt = interruptMax; servicedInterruptUnit = interruptSource[servicedInterrupt]; + lastInterruptTime[servicedInterrupt] = cycles; + // Flag off this interrupt - for now - as soon as RETI is // executed things might change! reevaluateInterrupts(); Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2009-01-05 11:30:21 UTC (rev 446) +++ mspsim/se/sics/mspsim/core/Timer.java 2009-01-05 16:47:37 UTC (rev 447) @@ -693,7 +693,8 @@ " Cycles: " + cycles + " expCap: " + expCaptureTime[i] + " => ExpCR: " + Utils.hex16(expCompare[i]) + - " TR: " + counter + " CCR" + i + ": " + tccr[i]); + " TR: " + counter + " CCR" + i + ": " + tccr[i] + " pass: " + + counterPassed); } // Set the interrupt flag... tcctl[i] |= CC_IFG; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-05 12:22:21
|
Revision: 446 http://mspsim.svn.sourceforge.net/mspsim/?rev=446&view=rev Author: joxe Date: 2009-01-05 11:30:21 +0000 (Mon, 05 Jan 2009) Log Message: ----------- possibly fixed Timer bug causing problems when using several CCR regs Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2009-01-04 23:22:49 UTC (rev 445) +++ mspsim/se/sics/mspsim/core/Timer.java 2009-01-05 11:30:21 UTC (rev 446) @@ -213,7 +213,7 @@ private TimeEvent timerTrigger = new TimeEvent(0) { public void execute(long t) { // System.out.println(getName() + " **** executing update timers at " + t + " cycles=" + core.cycles); - updateTimers(t); + updateTimers(core.cycles); } }; @@ -360,13 +360,12 @@ triggerInterrupts(cycles); } if (lastTIV / 2 < noCompare) { - if (DEBUG) { - System.out.println(getName() + " Clearing TIV/Comparex2: " + lastTIV); + if (DEBUG || true) { + System.out.println(getName() + " Clearing IFG for CCR" + (lastTIV/2)); } // Clear interrupt flags! tcctl[lastTIV / 2] &= ~CC_IFG; triggerInterrupts(cycles); - // memory[offset + TCCTL0 + lastTIV] &= ~CC_IFG; } } @@ -689,12 +688,12 @@ // System.out.println("Checking capture register [ioTick]: " + cycles); for (int i = 0, n = noCompare; i < n; i++) { if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) { - if (DEBUG || i < 2) { + if (DEBUG || true) { System.out.println(getName() + (captureOn[i] ? " CAPTURE: " : " COMPARE: ") + i + " Cycles: " + cycles + " expCap: " + expCaptureTime[i] + " => ExpCR: " + Utils.hex16(expCompare[i]) + - " TR: " + Utils.hex16(updateCounter(cycles))); + " TR: " + counter + " CCR" + i + ": " + tccr[i]); } // Set the interrupt flag... tcctl[i] |= CC_IFG; @@ -737,6 +736,7 @@ } private void recalculateCompares(long cycles) { + System.out.println("**** RECALCULATE COMPARES !!! ****"); for (int i = 0; i < expCaptureTime.length; i++) { if (expCaptureTime[i] != 0) { int diff = tccr[i] - counter; @@ -803,7 +803,7 @@ System.out.println(getName() +" >>>> Trigger IRQ for CCR0: " + tccr[0] + " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0]); } - if (counter != tccr[0]) { + if (counter != tccr[0] && trigger) { System.out.print("***** WARNING!!! CTR Err "); System.out.println(getName() +" >>>> Trigger IRQ for CCR0: " + tccr[0] + " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0]); @@ -827,7 +827,8 @@ counter); } tIndex = i; - // TODO: break here if low is higher... + // Lower numbers are higher priority + break; } } } @@ -845,7 +846,7 @@ System.out.println(getName() + " >>>> Triggering IRQ for CCR" + tIndex + " at cycles:" + cycles + " CCR" + tIndex + ": " + tccr[tIndex] + " TAR: " + - counter); + counter + " expCap: " + expCaptureTime[tIndex]); } } @@ -920,6 +921,7 @@ System.out.println(getName() + " >>>> interrupt Serviced " + lastTIV + " at cycles: " + core.cycles + " servicing delay: " + (core.cycles - triggerTime)); } + triggerInterrupts(core.cycles); } public int getModeMax() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-01-04 23:22:53
|
Revision: 445 http://mspsim.svn.sourceforge.net/mspsim/?rev=445&view=rev Author: joxe Date: 2009-01-04 23:22:49 +0000 (Sun, 04 Jan 2009) Log Message: ----------- added debug printout in Timer for debugging Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-12-05 20:59:48 UTC (rev 444) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2009-01-04 23:22:49 UTC (rev 445) @@ -43,7 +43,7 @@ public interface MSP430Constants { - public static final String VERSION = "0.95"; + public static final String VERSION = "0.96"; /* warning mode for CPU errors such as unaligned word access */ public enum WarningMode {SILENT, PRINT, EXCEPTION}; Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2008-12-05 20:59:48 UTC (rev 444) +++ mspsim/se/sics/mspsim/core/Timer.java 2009-01-04 23:22:49 UTC (rev 445) @@ -220,6 +220,8 @@ private int lastTIV; private final int[] srcMap; + + private long triggerTime; /** * Creates a new <code>Timer</code> instance. @@ -488,6 +490,7 @@ case TCCR6: // update of compare register index = (iAddress - TCCR0) / 2; + updateCounter(cycles); if (index == 0) { // Reset the counter to bring it down to a smaller value... // Check if up or updwn and reset if counter too high... @@ -497,7 +500,6 @@ resetCounter(cycles); } tccr[index] = data; - updateCounter(cycles); int diff = data - counter; if (diff < 0) { @@ -511,12 +513,12 @@ Utils.hex16(counter) + " diff: " + Utils.hex16(diff)); } // Use the counterPassed information to compensate the expected capture/compare time!!! - expCaptureTime[index] = cycles + (long)(cyclesMultiplicator * diff) - counterPassed; -// if (counterPassed > 0) { -// System.out.println(getName() + " Comp: " + counterPassed + " cycl: " + cycles + " TR: " + -// counter + " CCR" + index + " = " + data + " diff = " + diff + " cycMul: " + cyclesMultiplicator + " expCyc: " + -// expCaptureTime[index]); -// } + expCaptureTime[index] = cycles + (long)(cyclesMultiplicator * diff + 1) - counterPassed; + if (DEBUG && counterPassed > 0) { + System.out.println(getName() + " Comp: " + counterPassed + " cycl: " + cycles + " TR: " + + counter + " CCR" + index + " = " + data + " diff = " + diff + " cycMul: " + cyclesMultiplicator + " expCyc: " + + expCaptureTime[index]); + } counterPassed = 0; if (DEBUG) { System.out.println(getName() + " Cycles: " + cycles + " expCap[" + index + "]: " + expCaptureTime[index] + " ctr:" + counter + @@ -539,7 +541,7 @@ } void resetCounter(long cycles) { - counterStart = cycles; + counterStart = cycles - counterPassed; // set counterACC to the last returned value (which is the same // as bigCounter except that it is "moduloed" to a smaller value counterAcc = counter; @@ -634,8 +636,6 @@ counterPassed = (int) (divider * (tick - (long) (tick))); long bigCounter = (long) (tick + counterAcc); - //System.out.println("BigStart: " + bigCounterStart + " C:" + cycles + " bigCounter: " + bigCounter); - switch (mode) { case CONTIN: counter = (int) (bigCounter & 0xffff); @@ -651,6 +651,9 @@ } } +// System.out.println("CounterStart: " + counterStart + " C:" + cycles + " bigCounter: " + bigCounter + +// " counter" + counter); + if (DEBUG) { System.out.println(getName() + ": Updating counter cycctr: " + cycctr + " divider: " + divider + " mode:" + mode + " => " + counter); @@ -672,6 +675,8 @@ return; } + updateCounter(cycles); + if (cycles >= nextTimerTrigger) { interruptPending = true; // This should be updated whenever clockspeed changes... @@ -684,7 +689,7 @@ // System.out.println("Checking capture register [ioTick]: " + cycles); for (int i = 0, n = noCompare; i < n; i++) { if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) { - if (DEBUG) { + if (DEBUG || i < 2) { System.out.println(getName() + (captureOn[i] ? " CAPTURE: " : " COMPARE: ") + i + " Cycles: " + cycles + " expCap: " + expCaptureTime[i] + @@ -740,6 +745,10 @@ diff += 0x10000; } expCaptureTime[i] = cycles + (long) (diff * cyclesMultiplicator); + if (i == 0) { + System.out.println("Updating capture time for CCR0: " + expCaptureTime[0] + + " cyc: " + cycles); + } } } } @@ -783,18 +792,28 @@ int tIndex = 0; for (int i = 0, n = noCompare; i < n; i++) { + // check for both IFG and IE boolean newTrigger = (tcctl[i] & CC_TRIGGER_INT) == CC_TRIGGER_INT; trigger = trigger | newTrigger; // This only triggers interrupts - reading TIV clears!??! if (i == 0) { // Execute the interrupt vector... the high-pri one... -// System.out.println(getName() +">>>> Trigger IRQ for CCR0"); + if (DEBUG) { + System.out.println(getName() +" >>>> Trigger IRQ for CCR0: " + tccr[0] + + " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0]); + } + if (counter != tccr[0]) { + System.out.print("***** WARNING!!! CTR Err "); + System.out.println(getName() +" >>>> Trigger IRQ for CCR0: " + tccr[0] + + " TAR: " + counter + " cycles: " + cycles + " expCap: " + expCaptureTime[0]); + } core.flagInterrupt(ccr0Vector, this, trigger); // Trigger this! // This is handled by its own vector!!! if (trigger) { lastTIV = 0; + triggerTime = cycles; return; } } else { @@ -803,8 +822,9 @@ // If so, which TIV would be the correct one? if (newTrigger) { if (DEBUG) { - System.out.println(getName() + " triggering interrupt TIV: " + - (i * 2) + " at cycles:" + cycles); + System.out.println(getName() + " >>>> Triggering IRQ for CCR" + i + + " at cycles:" + cycles + " CCR" + i + ": " + tccr[i] + " TAR: " + + counter); } tIndex = i; // TODO: break here if low is higher... @@ -815,6 +835,18 @@ if (trigger) { // Or if other CCR execute the normal one with correct TAIV lastTIV = memory[tiv] = tIndex * 2; + triggerTime = cycles; + if (DEBUG) System.out.println(getName() + + " >>>> Triggering IRQ for CCR" + tIndex + + " at cycles:" + cycles + " CCR" + tIndex + ": " + tccr[tIndex] + " TAR: " + + counter); + if (counter != tccr[tIndex]) { + System.out.print("***** WARNING!!! CTR Err "); + System.out.println(getName() + + " >>>> Triggering IRQ for CCR" + tIndex + + " at cycles:" + cycles + " CCR" + tIndex + ": " + tccr[tIndex] + " TAR: " + + counter); + } } if (!trigger) { @@ -874,7 +906,7 @@ } - // The interrupt have been serviced... + // The interrupt has been serviced... // Some flags should be cleared (the highest priority flags)? public void interruptServiced(int vector) { if (vector == ccr0Vector) { @@ -882,9 +914,11 @@ core.flagInterrupt(ccr0Vector, this, false); // Remove the flag also... tcctl[0] &= ~CC_IFG; + System.out.println(getName() + " >>>> CCR0 flag set to false"); } - if (MSP430Core.debugInterrupts) { - System.out.println("interrupt Serviced..."); + if (MSP430Core.debugInterrupts || true) { + System.out.println(getName() + " >>>> interrupt Serviced " + lastTIV + + " at cycles: " + core.cycles + " servicing delay: " + (core.cycles - triggerTime)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-12-05 20:59:54
|
Revision: 444 http://mspsim.svn.sourceforge.net/mspsim/?rev=444&view=rev Author: joxe Date: 2008-12-05 20:59:48 +0000 (Fri, 05 Dec 2008) Log Message: ----------- added interrupthandler Added Paths: ----------- mspsim/se/sics/mspsim/core/InterruptHandler.java Added: mspsim/se/sics/mspsim/core/InterruptHandler.java =================================================================== --- mspsim/se/sics/mspsim/core/InterruptHandler.java (rev 0) +++ mspsim/se/sics/mspsim/core/InterruptHandler.java 2008-12-05 20:59:48 UTC (rev 444) @@ -0,0 +1,15 @@ +/** + * + */ +package se.sics.mspsim.core; + +/** + * @author joakim + * + */ +public interface InterruptHandler { + // We should add "Interrupt serviced..." to indicate that its latest + // Interrupt was serviced... + public void interruptServiced(int vector); + public String getName(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-12-05 19:29:39
|
Revision: 443 http://mspsim.svn.sourceforge.net/mspsim/?rev=443&view=rev Author: joxe Date: 2008-12-05 19:29:34 +0000 (Fri, 05 Dec 2008) Log Message: ----------- made USART an SFRModule and added SFRModule handling Modified Paths: -------------- mspsim/se/sics/mspsim/core/IOUnit.java mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/USART.java Added Paths: ----------- mspsim/se/sics/mspsim/core/SFRModule.java Modified: mspsim/se/sics/mspsim/core/IOUnit.java =================================================================== --- mspsim/se/sics/mspsim/core/IOUnit.java 2008-12-04 09:53:20 UTC (rev 442) +++ mspsim/se/sics/mspsim/core/IOUnit.java 2008-12-05 19:29:34 UTC (rev 443) @@ -41,7 +41,7 @@ package se.sics.mspsim.core; -public abstract class IOUnit { +public abstract class IOUnit implements InterruptHandler { int[] memory; int offset; @@ -54,20 +54,6 @@ public void reset(int type) { } - public boolean needsTick() { - return true; - } - - // Default implementation assumes notify write and read on all - // addresses (should be optimized for each unit) - public boolean needsWrite(int address) { - return true; - } - - public boolean needsRead(int address) { - return true; - } - // Should return the cycle it wants the next tick... public long ioTick(long cycles) { return cycles + 1000000; @@ -82,10 +68,6 @@ // read a value from the IO unit public abstract int read(int address, boolean word, long cycles); - // We should add "Interrupt serviced..." to indicate that its latest - // Interrupt was serviced... - public abstract void interruptServiced(int vector); - // Utility function for converting 16 bits data to correct return // value depending on address alignment and word/byte mode public static int return16(int address, int data, boolean word) { Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-12-04 09:53:20 UTC (rev 442) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-12-05 19:29:34 UTC (rev 443) @@ -220,6 +220,7 @@ boolean emuOP = false; if (maxCycles > 0) { + /* max one emulated instruction or maxCycles if in LPM */ while (cycles < maxCycles && !(emuOP = emulateOP(maxCycles))) { } } else { Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-04 09:53:20 UTC (rev 442) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-05 19:29:34 UTC (rev 443) @@ -83,14 +83,14 @@ private SFR sfr; // From the possible interrupt sources - to be able to indicate is serviced. - private IOUnit interruptSource[] = new IOUnit[16]; + private InterruptHandler interruptSource[] = new IOUnit[16]; private int interruptMax = -1; // Op/instruction represents the last executed OP / instruction private int op; public int instruction; int servicedInterrupt = -1; - IOUnit servicedInterruptUnit = null; + InterruptHandler servicedInterruptUnit = null; private boolean interruptsEnabled = false; private boolean cpuOff = false; @@ -539,7 +539,8 @@ // Indicate that we have an interrupt now! // We should only get same IOUnit for same interrupt level - public void flagInterrupt(int interrupt, IOUnit source, boolean triggerIR) { + public void flagInterrupt(int interrupt, InterruptHandler source, + boolean triggerIR) { if (triggerIR) { interruptSource[interrupt] = source; Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2008-12-04 09:53:20 UTC (rev 442) +++ mspsim/se/sics/mspsim/core/SFR.java 2008-12-05 19:29:34 UTC (rev 443) @@ -65,6 +65,9 @@ private int[] memory; private MSP430Core cpu; + private SFRModule[] sfrModule = new SFRModule[16]; + private int[] irqVector = new int[16]; + public SFR(MSP430Core cpu, int[] memory) { super(memory, 0); this.cpu = cpu; @@ -72,12 +75,24 @@ } public void reset(int type) { + ie1 = 0; + ie2 = 0; + ifg1 = 0; + ifg2 = 0; + me1 = 0; + me2 = 0; } - public boolean needsTick() { - return false; + /* reg = 0/1 + * bit = 0-7 (LSB-MSB) + * module = the module that will be "called" + */ + public void registerSFDModule(int reg, int bit, SFRModule module, int irqVec) { + int pos = reg * 8 + bit; + sfrModule[pos] = module; + irqVector[pos] = irqVec; } - + // write // write a value to the IO unit public void write(int address, int value, boolean word, @@ -85,23 +100,16 @@ if (DEBUG ) System.out.println(getName() + " write to: " + address + " = " + value); switch (address) { case IE1: - ie1 = value; - break; case IE2: - ie2 = value; + updateIE(address - IE1, value); break; case IFG1: - ifg1 = value; - break; case IFG2: - ifg2 = value; + updateIFG(address - IFG1, value); break; case ME1: - me1 = value; - break; case ME2: - me2 = value; - break; + updateME(address - ME1, value); default: memory[address] = value; } @@ -129,14 +137,88 @@ } } + private void updateIE(int pos, int value) { + int oldVal = pos == 0 ? ie1 : ie2; + int change = oldVal ^ value; + if (pos == 0) { + ie1 = value; + } else { + ie2 = value; + } + updateIRQ(pos, change); + } + + private void updateIFG(int pos, int value) { + int oldVal = pos == 0 ? ifg1 : ifg2; + int change = oldVal ^ value; + if (pos == 0) { + ifg1 = value; + } else { + ifg2 = value; + } + updateIRQ(pos, change); + } + + private void updateME(int pos, int value) { + int oldVal = pos == 0 ? me1 : me2; + int change = oldVal ^ value; + if (pos == 0) { + me1 = value; + } else { + me2 = value; + } + int reg = pos; + pos = pos * 8; + for (int i = 0; i < 8; i++) { + if ((change & 1) == 1) { + if (sfrModule[pos] != null) { + if (DEBUG) System.out.println("Calling enable changed on module: " + + sfrModule[pos].getName() + " enabled = " + (value & 1) + " bit " + i); + sfrModule[pos].enableChanged(reg, i, (value & 1) > 0); + } + } + change = change >> 1; + value = value >> 1; + pos++; + } + } + + private void updateIRQ(int pos, int change) { + int ifg = pos == 0 ? ifg1 : ifg2; + int ie = pos == 0 ? ie1 : ie2; + pos = pos * 8; + for (int i = 0; i < 8; i++) { + if ((change & 1) == 1) { + if (sfrModule[pos] != null) { + /* interrupt goes directly to the module responsible */ + if (DEBUG) System.out.println("SFR: flagging interrupt: " + + sfrModule[pos].getName() + " " + (ie & ifg & 1)); + cpu.flagInterrupt(irqVector[pos], sfrModule[pos], (ie & ifg & 1) > 0); + } + } + pos++; + change = change >> 1; + ifg = ifg >> 1; + ie = ie >> 1; + } + } + public void setBitIFG(int index, int bits) { - if (index == 0) ifg1 |= bits; - else ifg2 |= bits; + int value = index == 0 ? ifg1 : ifg2; + int after = value | bits; + int change = value ^ after; + if (index == 0) ifg1 = after; + else ifg2 = after; + updateIRQ(index, change); } public void clrBitIFG(int index, int bits) { - if (index == 0) ifg1 &= ~bits; - else ifg2 &= ~bits; + int value = index == 0 ? ifg1 : ifg2; + int after = value & ~bits; + int change = value ^ after; + if (index == 0) ifg1 = after; + else ifg2 = after; + updateIRQ(index, change); } public boolean isIEBitsSet(int index, int flags) { @@ -149,6 +231,7 @@ else return ifg2; } + /* nothing should go here */ public void interruptServiced(int vector) { } Added: mspsim/se/sics/mspsim/core/SFRModule.java =================================================================== --- mspsim/se/sics/mspsim/core/SFRModule.java (rev 0) +++ mspsim/se/sics/mspsim/core/SFRModule.java 2008-12-05 19:29:34 UTC (rev 443) @@ -0,0 +1,11 @@ +package se.sics.mspsim.core; + + +public interface SFRModule extends InterruptHandler { + + public void enableChanged(int reg, int bit, boolean enabled); + +// public void ieChanged(int reg, int bit, boolean enabled); + + /* public void interruptServiced(int reg, int bit); */ +} Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2008-12-04 09:53:20 UTC (rev 442) +++ mspsim/se/sics/mspsim/core/USART.java 2008-12-05 19:29:34 UTC (rev 443) @@ -41,7 +41,7 @@ package se.sics.mspsim.core; -public class USART extends IOUnit { +public class USART extends IOUnit implements SFRModule { public static final boolean DEBUG = false;//true; @@ -68,20 +68,22 @@ private int uartID = 0; - public static final int USART0_RCV_VEC = 9; - public static final int USART0_TRS_VEC = 8; - public static final int USART1_RCV_VEC = 3; - public static final int USART1_TRS_VEC = 2; + public static final int USART0_RX_VEC = 9; + public static final int USART0_TX_VEC = 8; + public static final int USART0_RX_BIT = 6; + public static final int USART0_TX_BIT = 7; + + public static final int USART1_RX_VEC = 3; + public static final int USART1_TX_VEC = 2; + public static final int USART1_RX_BIT = 4; + public static final int USART1_TX_BIT = 5; // Flags. public static final int UTCTL_TXEMPTY = 0x01; + - private USARTListener listener; - private int receiveInterrupt = 0; - private int transmitInterrupt = 0; - private int utxifg; private int urxifg; @@ -101,9 +103,13 @@ private int ubr0; private int ubr1; private int urxbuf; - private int utxbuf; + private int txbit; + private boolean txEnabled = false; + private boolean rxEnabled = false; + private boolean spiMode = false; + private TimeEvent txTrigger = new TimeEvent(0) { public void execute(long t) { // Ready to transmit new byte! @@ -126,17 +132,17 @@ // Initialize - transmit = ok... // and set which interrupts are used if (uartID == 0) { - receiveInterrupt = USART0_RCV_VEC; - transmitInterrupt = USART0_TRS_VEC; + sfr.registerSFDModule(0, USART0_RX_BIT, this, USART0_RX_VEC); + sfr.registerSFDModule(0, USART0_TX_BIT, this, USART0_TX_VEC); utxifg = UTXIFG0; urxifg = URXIFG0; - memory[IFG1] = 0x82; + txbit = USART0_TX_BIT; } else { - receiveInterrupt = USART1_RCV_VEC; - transmitInterrupt = USART1_TRS_VEC; + sfr.registerSFDModule(1, USART1_RX_BIT, this, USART1_RX_VEC); + sfr.registerSFDModule(1, USART1_TX_BIT, this, USART1_TX_VEC); utxifg = UTXIFG1; urxifg = URXIFG1; - memory[IFG1 + 1] = 0x20; + txbit = USART1_TX_BIT; } reset(0); @@ -146,8 +152,21 @@ nextTXReady = cpu.cycles + 1000; nextTXByte = -1; clrBitIFG(utxifg | urxifg); + utctl |= UTCTL_TXEMPTY; cpu.scheduleCycleEvent(txTrigger, nextTXReady); + txEnabled = false; + rxEnabled = false; } + + public void enableChanged(int reg, int bit, boolean enabled) { + System.out.println("enableChanged: " + reg + " bit: " + bit + + " enabled = " + enabled + " txBit: " + txbit); + if (bit == txbit) { + txEnabled = enabled; + } else { + rxEnabled = enabled; + } + } private void setBitIFG(int bits) { sfr.setBitIFG(uartID, bits); @@ -182,6 +201,7 @@ switch (address) { case UCTL: uctl = data; + spiMode = (data & 0x04) > 0; if (DEBUG) System.out.println(getName() + " write to UCTL " + data); break; case UTCTL: @@ -218,22 +238,24 @@ break; case UTXBUF: if (DEBUG) System.out.print(getName() + ": USART_UTXBUF:" + (char) data + " = " + data + "\n"); - - // Interruptflag not set! - clrBitIFG(utxifg); - utctl &= ~UTCTL_TXEMPTY; + if (txEnabled || (spiMode && rxEnabled)) { + // Interruptflag not set! + clrBitIFG(utxifg); + utctl &= ~UTCTL_TXEMPTY; + /* should the interrupt be flagged off here ? - or only the flags */ + if (DEBUG) System.out.println(getName() + " flagging off transmit interrupt"); + // cpu.flagInterrupt(transmitInterrupt, this, false); + + // Schedule on cycles here + // TODO: adding 3 extra cycles here seems to give + // slightly better timing in some test... + nextTXReady = cycles + tickPerByte + 3; + nextTXByte = data; + cpu.scheduleCycleEvent(txTrigger, nextTXReady); + } else { + System.out.println("Ignoring UTXBUF data since TX not active..."); + } utxbuf = data; - /* should the interrupt be flagged off here ? - or only the flags */ - if (DEBUG) System.out.println(getName() + " flagging off transmit interrupt"); - cpu.flagInterrupt(transmitInterrupt, this, false); - - // Schedule on cycles here - // TODO: adding 3 extra cycles here seems to give - // slightly better timing in some test... - nextTXReady = cycles + tickPerByte + 3; - nextTXByte = data; - cpu.scheduleCycleEvent(txTrigger, nextTXReady); - break; } } @@ -319,9 +341,8 @@ nextTXByte = -1; } + utctl |= UTCTL_TXEMPTY; setBitIFG(utxifg); - utctl |= UTCTL_TXEMPTY; - cpu.flagInterrupt(transmitInterrupt, this, isIEBitsSet(utxifg)); if (DEBUG) { if (isIEBitsSet(utxifg)) { @@ -340,6 +361,8 @@ // This needs to be complemented with a method for checking if the USART // is ready for next byte (readyForReceive) that respects the current speed public void byteReceived(int b) { + if (!rxEnabled) return; + if (MSP430Constants.DEBUGGING_LEVEL > 0) { System.out.println(getName() + " byteReceived: " + b); } @@ -350,10 +373,8 @@ // Check if the IE flag is enabled! - same as the IFlag to indicate! if (isIEBitsSet(urxifg)) { if (MSP430Constants.DEBUGGING_LEVEL > 0) { - System.out.println(getName() + " flagging receive interrupt: " + - receiveInterrupt); + System.out.println(getName() + " flagging receive interrupt "); } - cpu.flagInterrupt(receiveInterrupt, this, true); } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-12-04 09:53:26
|
Revision: 442 http://mspsim.svn.sourceforge.net/mspsim/?rev=442&view=rev Author: joxe Date: 2008-12-04 09:53:20 +0000 (Thu, 04 Dec 2008) Log Message: ----------- made autorun to autorun again... Modified Paths: -------------- mspsim/scripts/autorun.sc Modified: mspsim/scripts/autorun.sc =================================================================== --- mspsim/scripts/autorun.sc 2008-12-04 09:52:06 UTC (rev 441) +++ mspsim/scripts/autorun.sc 2008-12-04 09:53:20 UTC (rev 442) @@ -3,4 +3,4 @@ #exec rm log.txt #log CC2420 >log.txt #printcalls >log.txt -#start +start This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-12-04 09:52:26
|
Revision: 441 http://mspsim.svn.sourceforge.net/mspsim/?rev=441&view=rev Author: joxe Date: 2008-12-04 09:52:06 +0000 (Thu, 04 Dec 2008) Log Message: ----------- fixed more config of warning mode in CORE and fixed line command Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/scripts/autorun.sc mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-12-03 15:41:21 UTC (rev 440) +++ mspsim/CHANGE_LOG.txt 2008-12-04 09:52:06 UTC (rev 441) @@ -1,3 +1,7 @@ +0.96 +- added warning on unaligned write/read + + 0.95 - initial GDB stubs implementation (only for memory access) - CLI command for setting up gdbstubs server (gdbstubs PORT) Modified: mspsim/scripts/autorun.sc =================================================================== --- mspsim/scripts/autorun.sc 2008-12-03 15:41:21 UTC (rev 440) +++ mspsim/scripts/autorun.sc 2008-12-04 09:52:06 UTC (rev 441) @@ -3,4 +3,4 @@ #exec rm log.txt #log CC2420 >log.txt #printcalls >log.txt -start +#start Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-12-03 15:41:21 UTC (rev 440) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-12-04 09:52:06 UTC (rev 441) @@ -56,11 +56,14 @@ private long lastCall = 0; private long lastWall = 0; private ComponentRegistry registry; + + private ELF getELF() { + return (ELF) registry.getComponent(ELF.class); + } public void setupCommands(ComponentRegistry registry, CommandHandler ch) { this.registry = registry; final MSP430 cpu = (MSP430) registry.getComponent(MSP430.class); - final ELF elf = (ELF) registry.getComponent(ELF.class); final GenericNode node = (GenericNode) registry.getComponent("node"); if (cpu != null) { ch.registerCommand("break", new BasicAsyncCommand("add a breakpoint to a given address or symbol", @@ -110,7 +113,7 @@ if (mode == 0 || mode == 2) { int pc = cpu.readRegister(0); String adrStr = getSymOrAddr(context, adr); - String pcStr = getSymOrAddrELF(elf, pc); + String pcStr = getSymOrAddrELF(getELF(), pc); String op = "op"; if (type == MEMORY_READ) { op = "Read"; @@ -160,7 +163,7 @@ if (mode == 0) { int pc = cpu.readRegister(0); String adrStr = getRegisterName(register); - String pcStr = getSymOrAddrELF(elf, pc); + String pcStr = getSymOrAddrELF(getELF(), pc); context.out.println("*** Write from " + pcStr + ": " + adrStr + " = " + data); } else { @@ -211,10 +214,10 @@ ch.registerCommand("line", new BasicCommand("print line number of address/symbol", "<addres or symbol>") { public int executeCommand(final CommandContext context) { int adr = context.getArgumentAsAddress(0); - DebugInfo di = elf.getDebugInfo(adr); + DebugInfo di = getELF().getDebugInfo(adr); if (di != null) { di.getLine(); - context.out.println("" + di.getFile() + ": " + di.getLine()); + context.out.println(di); } else { context.err.println("No line number found for: " + context.getArgument(0)); } Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-12-03 15:41:21 UTC (rev 440) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-12-04 09:52:06 UTC (rev 441) @@ -45,8 +45,12 @@ public static final String VERSION = "0.95"; + /* warning mode for CPU errors such as unaligned word access */ + public enum WarningMode {SILENT, PRINT, EXCEPTION}; + public static final int MISALIGNED_READ = 0; public static final int MISALIGNED_WRITE = 1; + public static final int RESET_PUC = 0; public static final int RESET_POR = 1; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 15:41:21 UTC (rev 440) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-04 09:52:06 UTC (rev 441) @@ -117,7 +117,7 @@ private BasicClockModule bcs; private ArrayList<Chip> chips = new ArrayList<Chip>(); - private boolean throwIfWarn; + private WarningMode warningMode = WarningMode.PRINT; public MSP430Core(int type) { // Ignore type for now... @@ -529,8 +529,8 @@ resetIOUnits(); } - public void setThrowIfWarning(boolean t) { - throwIfWarn = t; + public void setWarningMode(WarningMode mode) { + warningMode = mode; } public void reset() { @@ -648,10 +648,10 @@ Utils.hex16(address) + " at $" + Utils.hex16(reg[PC]); break; } - if (throwIfWarn) { + if (warningMode == WarningMode.EXCEPTION) { throw new IllegalStateException(message); } else { - if (DEBUG) { + if (warningMode == WarningMode.PRINT) { System.out.println(message); } } @@ -982,12 +982,12 @@ jump = true; break; default: - System.out.println("Not implemented instruction: " + - Utils.binary16(instruction)); + System.out.println("Not implemented instruction: " + + Utils.binary16(instruction)); } // Perform the Jump if (jump) { - writeRegister(PC, pc + jmpOffset); + writeRegister(PC, pc + jmpOffset); } break; default: @@ -1006,11 +1006,11 @@ // Some CGs should be handled as registry reads only... if ((srcRegister == CG1 && as > AM_INDEX) || srcRegister == CG2) { - src = CREG_VALUES[srcRegister - 2][as]; - if (!word) { - src &= 0xff; - } - cycles += dstRegMode ? 1 : 4; + src = CREG_VALUES[srcRegister - 2][as]; + if (!word) { + src &= 0xff; + } + cycles += dstRegMode ? 1 : 4; } else { switch(as) { // Operand in register! @@ -1059,21 +1059,21 @@ } } } else { - // PC Could have changed above! - pc = readRegister(PC); - if (dstRegister == 2) { - /* absolute mode */ - dstAddress = memory[pc] + (memory[pc + 1] << 8); - } else { - // CG here??? - dstAddress = readRegister(dstRegister) - + memory[pc] + (memory[pc + 1] << 8); - } + // PC Could have changed above! + pc = readRegister(PC); + if (dstRegister == 2) { + /* absolute mode */ + dstAddress = memory[pc] + (memory[pc + 1] << 8); + } else { + // CG here - probably not!??? + dstAddress = readRegister(dstRegister) + + memory[pc] + (memory[pc + 1] << 8); + } - if (op != MOV) - dst = read(dstAddress, word); - pc += 2; - incRegister(PC, 2); + if (op != MOV) + dst = read(dstAddress, word); + pc += 2; + incRegister(PC, 2); } // **** Perform the read... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2008-12-03 15:41:22
|
Revision: 440 http://mspsim.svn.sourceforge.net/mspsim/?rev=440&view=rev Author: fros4943 Date: 2008-12-03 15:41:21 +0000 (Wed, 03 Dec 2008) Log Message: ----------- print bad memory access only in debug mode Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 14:51:24 UTC (rev 439) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 15:41:21 UTC (rev 440) @@ -651,7 +651,9 @@ if (throwIfWarn) { throw new IllegalStateException(message); } else { - System.out.println(message); + if (DEBUG) { + System.out.println(message); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-12-03 14:51:31
|
Revision: 439 http://mspsim.svn.sourceforge.net/mspsim/?rev=439&view=rev Author: joxe Date: 2008-12-03 14:51:24 +0000 (Wed, 03 Dec 2008) Log Message: ----------- added configuration for misalignment warnings Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-12-03 14:17:36 UTC (rev 438) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2008-12-03 14:51:24 UTC (rev 439) @@ -45,6 +45,9 @@ public static final String VERSION = "0.95"; + public static final int MISALIGNED_READ = 0; + public static final int MISALIGNED_WRITE = 1; + public static final int RESET_PUC = 0; public static final int RESET_POR = 1; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 14:17:36 UTC (rev 438) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 14:51:24 UTC (rev 439) @@ -117,6 +117,7 @@ private BasicClockModule bcs; private ArrayList<Chip> chips = new ArrayList<Chip>(); + private boolean throwIfWarn; public MSP430Core(int type) { // Ignore type for now... @@ -528,6 +529,10 @@ resetIOUnits(); } + public void setThrowIfWarning(boolean t) { + throwIfWarn = t; + } + public void reset() { flagInterrupt(15, null, true); } @@ -600,12 +605,7 @@ if (word) { val |= (memory[(address + 1) & 0xffff] << 8); if ((address & 1) != 0) { - if (true) { - throw new IllegalStateException("**** Illegal read - misaligned word from: " + - Utils.hex16(address) + " at $" + Utils.hex16(reg[PC])); - } - System.out.println("**** Illegal read - misaligned word from: " + - Utils.hex16(address) + " at $" + Utils.hex16(reg[PC])); + printWarning(MISALIGNED_READ, address); } } } @@ -614,7 +614,7 @@ } return val; } - + public void write(int dstAddress, int dst, boolean word) { if (breakPoints[dstAddress] != null) { breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE, dstAddress, dst); @@ -630,18 +630,32 @@ if (word) { memory[dstAddress + 1] = (dst >> 8) & 0xff; if ((dstAddress & 1) != 0) { - if (true) { - throw new IllegalStateException("**** Illegal write - misaligned word to: " + - Utils.hex16(dstAddress) + " at $" + Utils.hex16(reg[PC])); - } - System.out.println("**** Illegal write - misaligned word to: " + - Utils.hex16(dstAddress) + " at $" + Utils.hex16(reg[PC])); + printWarning(MISALIGNED_WRITE, dstAddress); } } } } + void printWarning(int type, int address) { + String message = ""; + switch(type) { + case MISALIGNED_READ: + message = "**** Illegal read - misaligned word from: " + + Utils.hex16(address) + " at $" + Utils.hex16(reg[PC]); + break; + case MISALIGNED_WRITE: + message = "**** Illegal write - misaligned word to: " + + Utils.hex16(address) + " at $" + Utils.hex16(reg[PC]); + break; + } + if (throwIfWarn) { + throw new IllegalStateException(message); + } else { + System.out.println(message); + } + } + private int serviceInterrupt(int pc) { int pcBefore = pc; int spBefore = readRegister(SP); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-12-03 14:17:40
|
Revision: 438 http://mspsim.svn.sourceforge.net/mspsim/?rev=438&view=rev Author: joxe Date: 2008-12-03 14:17:36 +0000 (Wed, 03 Dec 2008) Log Message: ----------- throws exception on illegal write/read Modified Paths: -------------- mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-12-03 13:04:33 UTC (rev 437) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-12-03 14:17:36 UTC (rev 438) @@ -208,6 +208,20 @@ } }); + ch.registerCommand("line", new BasicCommand("print line number of address/symbol", "<addres or symbol>") { + public int executeCommand(final CommandContext context) { + int adr = context.getArgumentAsAddress(0); + DebugInfo di = elf.getDebugInfo(adr); + if (di != null) { + di.getLine(); + context.out.println("" + di.getFile() + ": " + di.getLine()); + } else { + context.err.println("No line number found for: " + context.getArgument(0)); + } + return 0; + } + }); + if (node != null) { ch.registerCommand("stop", new BasicCommand("stop the CPU", "") { public int executeCommand(CommandContext context) { Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 13:04:33 UTC (rev 437) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-12-03 14:17:36 UTC (rev 438) @@ -600,8 +600,12 @@ if (word) { val |= (memory[(address + 1) & 0xffff] << 8); if ((address & 1) != 0) { + if (true) { + throw new IllegalStateException("**** Illegal read - misaligned word from: " + + Utils.hex16(address) + " at $" + Utils.hex16(reg[PC])); + } System.out.println("**** Illegal read - misaligned word from: " + - Utils.hex16(address) + " at " + Utils.hex16(reg[PC])); + Utils.hex16(address) + " at $" + Utils.hex16(reg[PC])); } } } @@ -626,8 +630,12 @@ if (word) { memory[dstAddress + 1] = (dst >> 8) & 0xff; if ((dstAddress & 1) != 0) { + if (true) { + throw new IllegalStateException("**** Illegal write - misaligned word to: " + + Utils.hex16(dstAddress) + " at $" + Utils.hex16(reg[PC])); + } System.out.println("**** Illegal write - misaligned word to: " + - Utils.hex16(dstAddress) + " at " + Utils.hex16(reg[PC])); + Utils.hex16(dstAddress) + " at $" + Utils.hex16(reg[PC])); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |