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...> - 2007-12-06 11:48:01
|
Revision: 36 http://mspsim.svn.sourceforge.net/mspsim/?rev=36&view=rev Author: joxe Date: 2007-12-06 03:47:45 -0800 (Thu, 06 Dec 2007) Log Message: ----------- added some support for debug info - stabs - in ELF files Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/ELFSection.java Added Paths: ----------- mspsim/se/sics/mspsim/util/DebugInfo.java mspsim/se/sics/mspsim/util/ELFDebug.java Added: mspsim/se/sics/mspsim/util/DebugInfo.java =================================================================== --- mspsim/se/sics/mspsim/util/DebugInfo.java (rev 0) +++ mspsim/se/sics/mspsim/util/DebugInfo.java 2007-12-06 11:47:45 UTC (rev 36) @@ -0,0 +1,75 @@ +/** + * 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: ELF.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * ELF + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; +import se.sics.mspsim.core.*; + +public class DebugInfo { + + private String file; + private String path; + private int lineNo; + private String function; + + public DebugInfo(int line, String path, String file, String fun) { + this.lineNo = line; + this.file = file; + this.path = path; + this.function = fun; + } + + public String getFile() { + return file; + } + + public String getPath() { + return path; + } + + public String getFunction() { + return function; + } + + public int getLine() { + return lineNo; + } + +} // DebugInfo Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2007-12-01 12:06:29 UTC (rev 35) +++ mspsim/se/sics/mspsim/util/ELF.java 2007-12-06 11:47:45 UTC (rev 36) @@ -77,7 +77,11 @@ ELFSection strTable; ELFSection symTable; + ELFSection dbgStab; + ELFSection dbgStabStr; + ELFDebug debug; + public ELF(byte[] data) { elfData = data; pos = 0; @@ -215,6 +219,17 @@ strTable = sections[i]; } } + + /* Find sections */ + for (int i = 0, n = shnum; i < n; i++) { + if (".stabstr".equals(sections[i].getSectionName())) { + dbgStabStr = sections[i]; + } + if (".stab".equals(sections[i].getSectionName())) { + dbgStab = sections[i]; + } + } + } private void readPrograms() { @@ -232,6 +247,9 @@ readHeader(); readPrograms(); readSections(); + if (dbgStab != null) { + debug = new ELFDebug(this, dbgStab, dbgStabStr); + } } public void loadPrograms(int[] memory) { @@ -256,6 +274,10 @@ } } + public DebugInfo getDebugInfo(int adr) { + return debug.getDebugInfo(adr); + } + public MapTable getMap() { MapTable map = new MapTable(); @@ -315,22 +337,30 @@ public static void main(String[] args) throws Exception { ELF elf = readELF(args[0]); - for (int i = 0, n = elf.shnum; i < n; i++) { - System.out.println("-- Section header " + i + " --\n" + elf.sections[i]); - if (".stab".equals(elf.sections[i].getSectionName()) || - ".stabstr".equals(elf.sections[i].getSectionName())) { - int adr = elf.sections[i].offset; - System.out.println(" == Section data =="); - for (int j = 0, m = 2000; j < m; j++) { - System.out.print((char) elf.elfData[adr++]); - if (i % 20 == 19) System.out.println(""); + if (args.length < 2) { + for (int i = 0, n = elf.shnum; i < n; i++) { + System.out.println("-- Section header " + i + " --\n" + elf.sections[i]); + if (".stab".equals(elf.sections[i].getSectionName()) || + ".stabstr".equals(elf.sections[i].getSectionName())) { + int adr = elf.sections[i].offset; + System.out.println(" == Section data =="); + for (int j = 0, m = 2000; j < m; j++) { + System.out.print((char) elf.elfData[adr++]); + if (i % 20 == 19) System.out.println(""); + } } + System.out.println(""); } - System.out.println(""); } - elf.getMap(); - + if (args.length > 1) { + DebugInfo dbg = elf.getDebugInfo(Integer.parseInt(args[1])); + if (dbg != null) { + System.out.println("File: " + dbg.getFile()); + System.out.println("Function: " + dbg.getFunction()); + System.out.println("LineNo: " + dbg.getLine()); + } + } } Added: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java (rev 0) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2007-12-06 11:47:45 UTC (rev 36) @@ -0,0 +1,166 @@ +/** + * 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: ELF.java,v 1.3 2007/10/21 21:17:34 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * ELF + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 21:17:34 $ + * $Revision: 1.3 $ + */ + +package se.sics.mspsim.util; +import se.sics.mspsim.core.*; + +public class ELFDebug { + + private Stab[] stabs; + + public static final int N_FUN = 0x24; + public static final int N_SLINE = 0x44; + public static final int N_SO = 0x64; // filename and path + + public static final boolean DEBUG = false; + + ELFSection dbgStab; + ELFSection dbgStabStr; + + public ELFDebug(ELF elf, ELFSection stab, ELFSection stabstr) { + dbgStab = stab; + dbgStabStr = stabstr; + + int len = dbgStab.size; + int count = len / dbgStab.entSize; + int addr = dbgStab.offset; + + if (DEBUG) System.out.println("Number of stabs:" + count); + stabs = new Stab[count]; + for (int i = 0, n = count; i < n; i++) { + elf.pos = addr; + int nI = elf.readElf32(); + String stabData = elf.dbgStabStr.getName(nI); + int type = elf.readElf8(); + int other = elf.readElf8(); + int desc = elf.readElf16(); + int value = elf.readElf32(); + stabs[i] = new Stab(stabData, type, other, desc, value); + + if (DEBUG) { + System.out.println("Stab: " + Utils.hex8(type) + + " " + stabData + " o:" + other + + " d:" + desc + " v:" + value); + } + addr += dbgStab.entSize; + } + } + + /* Just pick up file + some other things */ + public DebugInfo getDebugInfo(int address) { + String currentPath = null; + String currentFile = null; + String currentFunction = null; + int lastAddress = 0; + int currentLine = 0; + int currentLineAdr = 0; + for (int i = 0, n = stabs.length; i < n; i++) { + Stab stab = stabs[i]; + switch(stab.type) { + case N_SO: + if (stab.value < address) { + if (stab.data != null && stab.data.endsWith("/")) { + currentPath = stab.data; + lastAddress = stab.value; + currentFunction = null; + } else { + currentFile = stab.data; + lastAddress = stab.value; + currentFunction = null; + } + } else { + /* requires sorted order of all file entries in stab section */ + System.out.println("FILE: Already passed address..." + + currentPath + " " + + currentFile + " " + currentFunction); + return null; + } + break; + case N_SLINE: + if (currentPath != null) { /* only files with path... */ + if (currentLineAdr < address) { + currentLine = stab.desc; + currentLineAdr = lastAddress + stab.value; + if (currentLineAdr >= address) { + // Finished!!! + if (DEBUG) { + System.out.println("File: " + currentPath + " " + currentFile); + System.out.println("Function: " + currentFunction); + System.out.println("Line No: " + currentLine); + } + return new DebugInfo(currentLine, currentPath, currentFile, + currentFunction); + } + } + } + break; + case N_FUN: + if (stab.value < address) { + currentFunction = stab.data; + lastAddress = stab.value; + } else { + System.out.println("FUN: Already passed address..."); + return null; + } + break; + } + } + return null; + } + + private class Stab { + + String data; + int type; + int other; + int desc; + int value; + + Stab(String data, int type, int other, int desc, int value) { + this.data = data; + this.type = type; + this.other = other; + this.desc = desc; + this.value = value; + } + } + +} // ELFDebug Modified: mspsim/se/sics/mspsim/util/ELFSection.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFSection.java 2007-12-01 12:06:29 UTC (rev 35) +++ mspsim/se/sics/mspsim/util/ELFSection.java 2007-12-06 11:47:45 UTC (rev 36) @@ -46,15 +46,15 @@ public static final int TYPE_NULL = 0; public static final int TYPE_PROGBITS = 1; public static final int TYPE_SYMTAB = 2; - public static final int TYPE_STRTAB =3; - public static final int TYPE_RELA = 4; - public static final int TYPE_HASH = 5; + public static final int TYPE_STRTAB = 3; + public static final int TYPE_RELA = 4; + public static final int TYPE_HASH = 5; public static final int TYPE_DYNAMIC = 6; - public static final int TYPE_NOTE = 7; - public static final int TYPE_NOBITS = 8; - public static final int TYPE_REL = 9; - public static final int TYPE_SHLIB = 10; - public static final int TYPE_DYNSYM = 11; + public static final int TYPE_NOTE = 7; + public static final int TYPE_NOBITS = 8; + public static final int TYPE_REL = 9; + public static final int TYPE_SHLIB = 10; + public static final int TYPE_DYNSYM = 11; public static final int SYMBIND_LOCAL = 0; public static final int SYMBIND_GLOBAL = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-01 12:06:32
|
Revision: 35 http://mspsim.svn.sourceforge.net/mspsim/?rev=35&view=rev Author: joxe Date: 2007-12-01 04:06:29 -0800 (Sat, 01 Dec 2007) Log Message: ----------- refactored profiling to separate class Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/util/ControlUI.java mspsim/se/sics/mspsim/util/Test.java Added Paths: ----------- mspsim/se/sics/mspsim/core/Profiler.java mspsim/se/sics/mspsim/util/SimpleProfiler.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-12-01 00:04:48 UTC (rev 34) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-12-01 12:06:29 UTC (rev 35) @@ -40,11 +40,8 @@ */ package se.sics.mspsim.core; -import java.util.Arrays; -import java.util.Hashtable; +import se.sics.mspsim.util.*; -import se.sics.mspsim.util.Utils; - public class MSP430 extends MSP430Core { public static final int RETURN = 0x4130; @@ -61,14 +58,12 @@ private long nextSleep = 0; private long nextOut = 0; - private long instCtr = 0; + private double lastCPUPercent = 0d; + private long instCtr = 0; private DisAsm disAsm; - private MapTable map; - private Hashtable<String,CallEntry> profileData; - private CallEntry[] callStack; - private int cSP = 0; + private Profiler profiler; /** * Creates a new <code>MSP430</code> instance. @@ -79,6 +74,10 @@ disAsm = new DisAsm(); } + public double getCPUPercent() { + return lastCPUPercent; + } + public DisAsm getDisAsm() { return disAsm; } @@ -108,7 +107,7 @@ if (cycles > nextOut && !debug) { printCPUSpeed(reg[PC]); - nextOut = cycles + 10000007; + nextOut = cycles + 20000007; } if (emulateOP()) { @@ -118,15 +117,16 @@ execCounter[reg[PC]]++; } - if (map != null) { + if (profiler != null) { if ((instruction & 0xff80) == CALL) { /* The profiling should only be made on actual cpuCycles */ - profileCall(map.getFunction(reg[PC]), cpuCycles); - // System.out.println("Call," + map.getFunction(reg[PC]) + "," + - // cycles); + String function = map.getFunction(reg[PC]); + if (function == null) { + function = "fkn at $" + Utils.hex16(reg[PC]); + } + profiler.profileCall(function, cpuCycles); } else if (instruction == RETURN) { - profileReturn(cpuCycles); - //System.out.println("Return," + cycles); + profiler.profileReturn(cpuCycles); } } } @@ -146,81 +146,6 @@ } } - private void profileCall(String function, long cycles) { -// System.out.println("Call at: " + Utils.hex16(reg[PC])); - if (callStack[cSP] == null) { - callStack[cSP] = new CallEntry(); - } - if (function == null) { - function = "fkn at $" + Utils.hex16(reg[PC]); - } - callStack[cSP].function = function; - callStack[cSP].calls = 0; - callStack[cSP++].cycles = cycles; - } - - private void profileReturn(long cycles) { - String fkn = callStack[--cSP].function; -// System.out.println("Profiler: return / call stack: " + cSP + ", " + fkn); - - long elapsed = cycles - callStack[cSP].cycles; - if (callStack[cSP].calls >= 0) { - CallEntry ce = profileData.get(fkn); - if (ce == null) { - profileData.put(fkn, ce = new CallEntry()); - ce.function = fkn; - } - ce.cycles += elapsed; - ce.calls++; - } - } - - public void clearProfile() { - if (profileData != null) { - CallEntry[] entries = - profileData.values().toArray(new CallEntry[0]); - for (int i = 0, n = entries.length; i < n; i++) { - entries[i].cycles = 0; - entries[i].calls = 0; - } - for (int i = 0, n = callStack.length; i < n; i++) { - CallEntry e = callStack[i]; - if (e != null) { - e.calls = -1; - } - } - } - } - - public void printProfile() { - CallEntry[] entries = - profileData.values().toArray(new CallEntry[0]); - Arrays.sort(entries); - for (int i = 0, n = entries.length; i < n; i++) { - int c = entries[i].calls; - if (c > 0) { - String cyclesS = "" + entries[i].cycles; - String callS = "" + c; - String avgS = "" + (c > 0 ? (entries[i].cycles / c) : 0); - System.out.print(entries[i].function); - printSpace(56 - entries[i].function.length() - avgS.length()); - System.out.print(avgS); - System.out.print(' '); - printSpace(8 - callS.length()); - System.out.print(callS); - System.out.print(' '); - printSpace(10 - cyclesS.length()); - System.out.println(cyclesS); - } - } - } - - private void printSpace(int len) { - for (int i = 0; i < len; i++) { - System.out.print(' '); - } - } - public long step() { if (running) { throw new IllegalStateException("step not possible when CPU is running"); @@ -285,6 +210,7 @@ + 1000 * (cpud / td ) + " cyc/s " + (10000 * cpud / cd)/100.0 + "%"); } + lastCPUPercent = (10000 * cpud / cd)/100.0; time = System.currentTimeMillis(); lastCycles = cycles; lastCpuCycles = cpuCycles; @@ -299,27 +225,15 @@ debug = db; } - public void setMap(MapTable map) { - if (profileData == null) { - profileData = new Hashtable<String,CallEntry>(); - callStack = new CallEntry[2048]; - } - this.map = map; + public Profiler getProfiler() { + return profiler; } - private static class CallEntry implements Comparable { - String function; - long cycles; - int calls; - - public int compareTo(Object o) { - if (o instanceof CallEntry) { - long diff = ((CallEntry)o).cycles - cycles; - if (diff > 0) return 1; - if (diff < 0) return -1; - } - return 0; + public void setMap(MapTable map) { + this.map = map; + /* When we got the map table we can also profile! */ + if (profiler == null) { + this.profiler = new SimpleProfiler(); } } - } Added: mspsim/se/sics/mspsim/core/Profiler.java =================================================================== --- mspsim/se/sics/mspsim/core/Profiler.java (rev 0) +++ mspsim/se/sics/mspsim/core/Profiler.java 2007-12-01 12:06:29 UTC (rev 35) @@ -0,0 +1,57 @@ +/** + * 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: MSP430.java,v 1.4 2007/10/21 22:02:22 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * MSP430 + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 22:02:22 $ + * $Revision: 1.4 $ + */ + +package se.sics.mspsim.core; +import java.util.Arrays; +import java.util.Hashtable; + +import se.sics.mspsim.util.Utils; + +public interface Profiler { + + public void profileCall(String function, long cycles); + public void profileReturn(long cycles); + + public void clearProfile(); + + public void printProfile(); + +} Modified: mspsim/se/sics/mspsim/util/ControlUI.java =================================================================== --- mspsim/se/sics/mspsim/util/ControlUI.java 2007-12-01 00:04:48 UTC (rev 34) +++ mspsim/se/sics/mspsim/util/ControlUI.java 2007-12-01 12:06:29 UTC (rev 35) @@ -57,6 +57,8 @@ public class ControlUI extends JPanel implements ActionListener { + private static final String TITLE = "MSPSim monitor"; + private JFrame window; private MSP430 cpu; private DebugUI dui; @@ -76,7 +78,7 @@ WindowUtils.addSaveOnShutdown("StackUI", stackWindow); stackWindow.setVisible(true); - window = new JFrame("MSPSim monitor"); + window = new JFrame(TITLE); // window.setSize(320,240); window.setLayout(new BorderLayout()); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -121,8 +123,13 @@ return jb; } + private void updateCPUPercent() { + window.setTitle(TITLE + " CPU On: " + cpu.getCPUPercent() + "%"); + } + public void actionPerformed(ActionEvent ae) { String cmd = ae.getActionCommand(); + updateCPUPercent(); if ("Debug On".equals(cmd)) { cpu.setDebug(true); ((JButton) ae.getSource()).setText("Debug Off"); @@ -145,9 +152,13 @@ stepAction.setEnabled(true); } else if ("Profile Dump".equals(cmd)) { - cpu.printProfile(); - // } else if ("Single Step".equals(cmd)) { -// cpu.step(); + if (cpu.getProfiler() != null) { + cpu.getProfiler().printProfile(); + } else { + System.out.println("*** No profiler available"); + } + // } else if ("Single Step".equals(cmd)) { + // cpu.step(); // dui.repaint(); } dui.updateRegs(); Added: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java (rev 0) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2007-12-01 12:06:29 UTC (rev 35) @@ -0,0 +1,150 @@ +/** + * 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: MSP430.java,v 1.4 2007/10/21 22:02:22 nfi Exp $ + * + * ----------------------------------------------------------------- + * + * MSP430 + * + * Author : Joakim Eriksson + * Created : Sun Oct 21 22:00:00 2007 + * Updated : $Date: 2007/10/21 22:02:22 $ + * $Revision: 1.4 $ + */ + +package se.sics.mspsim.util; +import se.sics.mspsim.core.Profiler; +import java.util.Arrays; +import java.util.Hashtable; + + +public class SimpleProfiler implements Profiler { + + private Hashtable<String,CallEntry> profileData; + private CallEntry[] callStack; + private int cSP = 0; + + public SimpleProfiler() { + profileData = new Hashtable<String,CallEntry>(); + callStack = new CallEntry[2048]; + } + + public void profileCall(String function, long cycles) { +// System.out.println("Call at: " + Utils.hex16(reg[PC])); + if (callStack[cSP] == null) { + callStack[cSP] = new CallEntry(); + } + callStack[cSP].function = function; + callStack[cSP].calls = 0; + callStack[cSP++].cycles = cycles; + } + + public void profileReturn(long cycles) { + String fkn = callStack[--cSP].function; +// System.out.println("Profiler: return / call stack: " + cSP + ", " + fkn); + + long elapsed = cycles - callStack[cSP].cycles; + if (callStack[cSP].calls >= 0) { + CallEntry ce = profileData.get(fkn); + if (ce == null) { + profileData.put(fkn, ce = new CallEntry()); + ce.function = fkn; + } + ce.cycles += elapsed; + ce.calls++; + } + } + + public void clearProfile() { + if (profileData != null) { + CallEntry[] entries = + profileData.values().toArray(new CallEntry[0]); + for (int i = 0, n = entries.length; i < n; i++) { + entries[i].cycles = 0; + entries[i].calls = 0; + } + for (int i = 0, n = callStack.length; i < n; i++) { + CallEntry e = callStack[i]; + if (e != null) { + e.calls = -1; + } + } + } + } + + public void printProfile() { + CallEntry[] entries = + profileData.values().toArray(new CallEntry[0]); + Arrays.sort(entries); + + System.out.println("************************* Profile Data **************************************"); + System.out.println("Function Average Calls Tot.Cycles"); + + + for (int i = 0, n = entries.length; i < n; i++) { + int c = entries[i].calls; + if (c > 0) { + String cyclesS = "" + entries[i].cycles; + String callS = "" + c; + String avgS = "" + (c > 0 ? (entries[i].cycles / c) : 0); + System.out.print(entries[i].function); + printSpace(56 - entries[i].function.length() - avgS.length()); + System.out.print(avgS); + System.out.print(' '); + printSpace(8 - callS.length()); + System.out.print(callS); + System.out.print(' '); + printSpace(10 - cyclesS.length()); + System.out.println(cyclesS); + } + } + } + + private void printSpace(int len) { + for (int i = 0; i < len; i++) { + System.out.print(' '); + } + } + + private static class CallEntry implements Comparable { + String function; + long cycles; + int calls; + + public int compareTo(Object o) { + if (o instanceof CallEntry) { + long diff = ((CallEntry)o).cycles - cycles; + if (diff > 0) return 1; + if (diff < 0) return -1; + } + return 0; + } + } +} Modified: mspsim/se/sics/mspsim/util/Test.java =================================================================== --- mspsim/se/sics/mspsim/util/Test.java 2007-12-01 00:04:48 UTC (rev 34) +++ mspsim/se/sics/mspsim/util/Test.java 2007-12-01 12:06:29 UTC (rev 35) @@ -73,9 +73,9 @@ } else if (line.startsWith("DEBUG")) { cpu.setDebug(true); } else if (line.startsWith("PROFILE")) { - cpu.printProfile(); + cpu.getProfiler().printProfile(); } else if (line.startsWith("CLEARPROFILE")) { - cpu.clearProfile(); + cpu.getProfiler().clearProfile(); } } else { lineBuffer.append((char) data); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-12-01 00:05:00
|
Revision: 34 http://mspsim.svn.sourceforge.net/mspsim/?rev=34&view=rev Author: joxe Date: 2007-11-30 16:04:48 -0800 (Fri, 30 Nov 2007) Log Message: ----------- some minor fixes Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/util/StackUI.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-11-30 23:09:51 UTC (rev 33) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-12-01 00:04:48 UTC (rev 34) @@ -56,7 +56,10 @@ // Debug time - measure cycles private long lastCycles = 0; + private long lastCpuCycles = 0; private long time; + private long nextSleep = 0; + private long nextOut = 0; private long instCtr = 0; @@ -103,11 +106,13 @@ } } + if (cycles > nextOut && !debug) { + printCPUSpeed(reg[PC]); + nextOut = cycles + 10000007; + } + if (emulateOP()) { instCtr++; - if ((instCtr % 1000007) == 0 && !debug) { - printCPUSpeed(reg[PC]); - } if (execCounter != null) { execCounter[reg[PC]]++; @@ -126,6 +131,15 @@ } } + /* Just a test to see if it gets down to a reasonable speed */ + if (cycles > nextSleep) { + try { + Thread.sleep(10); + } catch (Exception e) { + } + nextSleep = cycles + 50000; + } + // if ((instruction & 0xff80) == CALL) { // System.out.println("Call to PC = " + reg[PC]); // } @@ -260,14 +274,20 @@ private void printCPUSpeed(int pc) { int td = (int)(System.currentTimeMillis() - time); int cd = (int) (cycles - lastCycles); + int cpud = (int) (cpuCycles - lastCpuCycles); + if (td == 0 || cd == 0) return; + if (DEBUGGING_LEVEL > 0) { - System.out.println("Time elapsed: " + td - + " cycDiff: " + cd - + " => " + 1000 * (cd / td ) + " cycles / s"); + System.out.println("Elapsed: " + td + + " cycDiff: " + cd + " => " + 1000 * (cd / td ) + + " cyc/s cpuDiff:" + cpud + " => " + + 1000 * (cpud / td ) + " cyc/s " + + (10000 * cpud / cd)/100.0 + "%"); } time = System.currentTimeMillis(); lastCycles = cycles; + lastCpuCycles = cpuCycles; disAsm.disassemble(pc, memory, reg); } Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2007-11-30 23:09:51 UTC (rev 33) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2007-12-01 00:04:48 UTC (rev 34) @@ -136,5 +136,5 @@ public static final int CLKCAPTURE_BOTH = 3; - public static final int DEBUGGING_LEVEL = 0; + public static final int DEBUGGING_LEVEL = 1; } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2007-11-30 23:09:51 UTC (rev 33) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2007-12-01 00:04:48 UTC (rev 34) @@ -337,7 +337,7 @@ servicedInterruptUnit = null; servicedInterrupt = -1; interruptMax = -1; - cpuOff = false; + writeRegister(SR, 0); } // Indicate that we have an interrupt now! Modified: mspsim/se/sics/mspsim/util/StackUI.java =================================================================== --- mspsim/se/sics/mspsim/util/StackUI.java 2007-11-30 23:09:51 UTC (rev 33) +++ mspsim/se/sics/mspsim/util/StackUI.java 2007-12-01 00:04:48 UTC (rev 34) @@ -49,7 +49,7 @@ public class StackUI extends JPanel implements CPUMonitor { - private static final int STACK_FRAME = 2048; + private static final int STACK_FRAME = 1024; private int updateCyclePeriod = 2500; private MSP430 cpu; @@ -106,8 +106,8 @@ if (this.maxData[pos] < size) { this.maxData[pos] = size; } - if (cpu.cycles - lastCycles > updateCyclePeriod) { - lastCycles = cpu.cycles; + if (cpu.cpuCycles - lastCycles > updateCyclePeriod) { + lastCycles = cpu.cpuCycles; //System.out.println("STACK UPDATE: " + type + "," + adr + "," + data); pos = (pos + 1) % this.minData.length; this.minData[pos] = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-11-30 23:10:04
|
Revision: 33 http://mspsim.svn.sourceforge.net/mspsim/?rev=33&view=rev Author: joxe Date: 2007-11-30 15:09:51 -0800 (Fri, 30 Nov 2007) Log Message: ----------- implemented intitial support for LPM - CPUOFF mode Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Constants.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-11-26 15:25:22 UTC (rev 32) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-11-30 23:09:51 UTC (rev 33) @@ -103,31 +103,32 @@ } } - instCtr++; - if ((instCtr % 10000007) == 0 && !debug) { - printCPUSpeed(reg[PC]); - } + if (emulateOP()) { + instCtr++; + if ((instCtr % 1000007) == 0 && !debug) { + printCPUSpeed(reg[PC]); + } - if (execCounter != null) { - execCounter[reg[PC]]++; + if (execCounter != null) { + execCounter[reg[PC]]++; + } + + if (map != null) { + if ((instruction & 0xff80) == CALL) { + /* The profiling should only be made on actual cpuCycles */ + profileCall(map.getFunction(reg[PC]), cpuCycles); + // System.out.println("Call," + map.getFunction(reg[PC]) + "," + + // cycles); + } else if (instruction == RETURN) { + profileReturn(cpuCycles); + //System.out.println("Return," + cycles); + } + } } - emulateOP(); - // if ((instruction & 0xff80) == CALL) { // System.out.println("Call to PC = " + reg[PC]); // } - - if (map != null) { - if ((instruction & 0xff80) == CALL) { - profileCall(map.getFunction(reg[PC]), cycles); - // System.out.println("Call," + map.getFunction(reg[PC]) + "," + - // cycles); - } else if (instruction == RETURN) { - profileReturn(cycles); - //System.out.println("Return," + cycles); - } - } } } Modified: mspsim/se/sics/mspsim/core/MSP430Constants.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Constants.java 2007-11-26 15:25:22 UTC (rev 32) +++ mspsim/se/sics/mspsim/core/MSP430Constants.java 2007-11-30 23:09:51 UTC (rev 33) @@ -108,6 +108,12 @@ public static final int OVERFLOW = 1 << OVERFLOW_B; public static final int GIE = 1 << GIE_B; + /* For the LPM management */ + public static final int CPUOFF = 0x0010; + public static final int OSCOFF = 0x0020; + public static final int SCG0 = 0x0040; + public static final int SCG1 = 0x0080; + // #define C 0x0001 // #define Z 0x0002 // #define N 0x0004 Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2007-11-26 15:25:22 UTC (rev 32) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2007-11-30 23:09:51 UTC (rev 33) @@ -69,6 +69,7 @@ public int memory[] = new int[MAX_MEM]; public long cycles = 0; + public long cpuCycles = 0; // Most HW needs only notify write and clocking, others need also read... // For notify write... @@ -96,6 +97,7 @@ IOUnit servicedInterruptUnit = null; boolean interruptsEnabled = false; + boolean cpuOff = false; // Not private since they are needed (for fast access...) int dcoFrq = 2500000; @@ -239,7 +241,12 @@ } reg[r] = value; if (r == SR) { + boolean oldCpuOff = cpuOff; interruptsEnabled = ((value & GIE) == GIE); + cpuOff = ((value & CPUOFF) == CPUOFF); + if (cpuOff != oldCpuOff) { +// System.out.println("LPM CPUOff: " + cpuOff + " cycles: " + cycles); + } } } @@ -330,6 +337,7 @@ servicedInterruptUnit = null; servicedInterrupt = -1; interruptMax = -1; + cpuOff = false; } // Indicate that we have an interrupt now! @@ -403,6 +411,8 @@ } nextIOTickCycles = smallestCyc; nextIOTickIndex = index; +// System.out.println("Smallest IO cycles: " + smallestCyc + " => " + +// ioUnits[index].getName()); } // Read method that handles read from IO units! @@ -456,6 +466,8 @@ memory[0xffe0 + interruptMax * 2] + (memory[0xffe0 + interruptMax * 2 + 1] << 8)); + writeRegister(SR, sr & ~CPUOFF & ~SCG1 & ~OSCOFF); + servicedInterrupt = interruptMax; servicedInterruptUnit = interruptSource[servicedInterrupt]; // Flag off this interrupt - for now - as soon as RETI is @@ -474,23 +486,40 @@ return pc; } - public void emulateOP() { + /* returns true if any instruction was emulated - false if CpuOff */ + public boolean emulateOP() { int pc = readRegister(PC); + long startCycles = cycles; // ------------------------------------------------------------------- + // I/O processing + // ------------------------------------------------------------------- + if (cycles >= nextIOTickCycles) { + handleIO(); + } + + + // ------------------------------------------------------------------- // Interrupt processing [after the last instruction was executed] // ------------------------------------------------------------------- if (interruptsEnabled && servicedInterrupt == -1 && interruptMax >= 0) { pc = serviceInterrupt(pc); } + /* Did not execute any instructions */ + if (cpuOff) { +// System.out.println("Jumping: " + (nextIOTickCycles - cycles)); + cycles = nextIOTickCycles; + return false; + } + // This is quite costly... should probably be made more // efficiently (maybe in CORE where PC is read anyway?) if (breakPoints[pc] != null) { if (breakpointActive) { breakPoints[pc].cpuAction(CPUMonitor.BREAK, pc, 0); breakpointActive = false; - return; + return false; } else { // Execute this instruction - this is second call... breakpointActive = true; @@ -513,13 +542,6 @@ boolean write = false; boolean updateStatus = true; - // ------------------------------------------------------------------- - // I/O processing - // ------------------------------------------------------------------- - if (cycles > nextIOTickCycles) { - handleIO(); - } - // When is PC increased probably immediately (e.g. here)? pc += 2; writeRegister(PC, pc); @@ -939,6 +961,8 @@ ((dst & 0x80) > 0 ? NEGATIVE : 0)); writeRegister(SR, sr); } + + cpuCycles += cycles - startCycles; + return true; } - } Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2007-11-26 15:25:22 UTC (rev 32) +++ mspsim/se/sics/mspsim/core/USART.java 2007-11-30 23:09:51 UTC (rev 33) @@ -127,27 +127,18 @@ } private void setBitIFG(int bits) { -// if (uartID == 0) memory[IFG1] |= bits; -// else memory[IFG1 + 1] |= bits; sfr.setBitIFG(uartID, bits); } private void clrBitIFG(int bits) { -// if (uartID == 0) memory[IFG1] &= ~bits; -// else memory[IFG1 + 1] &= ~bits; sfr.clrBitIFG(uartID, bits); } private int getIFG() { -// if (uartID == 0) return memory[IFG1]; -// return memory[IFG1 + 1]; return sfr.getIFG(uartID); } private boolean isIEBitsSet(int bits) { -// if (uartID == 0) return (memory[IE1] & bits) == bits; -// // Check this!!! -// return (memory[IE1 + 1] & bits) == bits; return sfr.isIEBitsSet(uartID, bits); } @@ -307,11 +298,11 @@ // Indicate interrupt also! setBitIFG(urxifg); - // Check if the IE flags are enabled! - same as the IFlag to indicate! + // 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); + receiveInterrupt); } cpu.flagInterrupt(receiveInterrupt, this, true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-11-26 15:25:37
|
Revision: 32 http://mspsim.svn.sourceforge.net/mspsim/?rev=32&view=rev Author: joxe Date: 2007-11-26 07:25:22 -0800 (Mon, 26 Nov 2007) Log Message: ----------- added license text Modified Paths: -------------- mspsim/Makefile Added Paths: ----------- mspsim/license.txt Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-11-26 10:24:34 UTC (rev 31) +++ mspsim/Makefile 2007-11-26 15:25:22 UTC (rev 32) @@ -62,7 +62,7 @@ CPUTEST := tests/cputest.firmware -BINARY := README.txt images/*.jpg firmware/*/*.firmware +BINARY := README.txt license.txt images/*.jpg firmware/*/*.firmware PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util chip} Added: mspsim/license.txt =================================================================== --- mspsim/license.txt (rev 0) +++ mspsim/license.txt 2007-11-26 15:25:22 UTC (rev 32) @@ -0,0 +1,25 @@ +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 was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-11-26 10:24:53
|
Revision: 31 http://mspsim.svn.sourceforge.net/mspsim/?rev=31&view=rev Author: nifi Date: 2007-11-26 02:24:34 -0800 (Mon, 26 Nov 2007) Log Message: ----------- added archive generation for source release Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-11-26 09:34:12 UTC (rev 30) +++ mspsim/Makefile 2007-11-26 10:24:34 UTC (rev 31) @@ -62,6 +62,8 @@ CPUTEST := tests/cputest.firmware +BINARY := README.txt images/*.jpg firmware/*/*.firmware + PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util chip} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} @@ -74,19 +76,18 @@ # MAKE ############################################################### -.PHONY: compile $(CPUTEST) +.PHONY: all compile jar help run runesb runsky test cputest $(CPUTEST) mtest +all: compile + compile: $(OBJECTS) -all: compile - jar: compile $(JAR) cf $(JARFILE) ${addsuffix /*.class,$(PACKAGES)} images/*.jpg help: - @echo "Usage: make [all,compile,clean]" + @echo "Usage: make [all,compile,clean,run,runsky,runesb]" -.PHONY: run run: compile java se.sics.mspsim.util.IHexReader $(FIRMWAREFILE) $(MAPFILE) @@ -96,7 +97,6 @@ runsky: compile java se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPFILE) -.PHONY: cputest test test: cputest cputest: $(CPUTEST) @@ -105,13 +105,20 @@ $(CPUTEST): (cd tests && $(MAKE)) -.PHONY: mtest mtest: compile $(CPUTEST) @-$(RM) mini-test_cpu.txt java se.sics.util.Test -debug $(CPUTEST) >mini-test_cpu.txt ############################################################### +# ARCHIVE GENERATION +############################################################### + +source: + zip -9 mspsim-source-`date '+%F'`.zip Makefile $(BINARY) *.java $(addsuffix /*.java,$(PACKAGES)) tests/Makefile tests/*.c tests/*.h + + +############################################################### # CLASS COMPILATION ############################################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-11-26 09:34:15
|
Revision: 30 http://mspsim.svn.sourceforge.net/mspsim/?rev=30&view=rev Author: joxe Date: 2007-11-26 01:34:12 -0800 (Mon, 26 Nov 2007) Log Message: ----------- Modified Paths: -------------- mspsim/README.txt Modified: mspsim/README.txt =================================================================== --- mspsim/README.txt 2007-11-26 09:18:29 UTC (rev 29) +++ mspsim/README.txt 2007-11-26 09:34:12 UTC (rev 30) @@ -8,7 +8,7 @@ * System requirements You need a recent Java to run MSPSim. Java SE 1.5 or newer is -recommended. The current version of MSPSim also requires Make for +recommended. The current version of MSPSim also requires make for compiling. * Building MSPSim @@ -41,10 +41,9 @@ - Easy to add external components that emulates external HW - Supports monitoring of registers, adding breakpoints, etc. - Built-in profiling of executed code -- Emulates external HW such as sensors and TR1001 and CC2420 radio - chips. +- Emulates some external hardware such as TR1001 and CC2420. -* What is emulated MSP430 +* What is emulated of the MSP430 - CPU (instruction level simulation) - Timer A/B subsystem - USARTs This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-11-26 09:18:41
|
Revision: 29 http://mspsim.svn.sourceforge.net/mspsim/?rev=29&view=rev Author: joxe Date: 2007-11-26 01:18:29 -0800 (Mon, 26 Nov 2007) Log Message: ----------- added simple readme Added Paths: ----------- mspsim/README.txt Added: mspsim/README.txt =================================================================== --- mspsim/README.txt (rev 0) +++ mspsim/README.txt 2007-11-26 09:18:29 UTC (rev 29) @@ -0,0 +1,59 @@ +* MSPSim version 0.8 + +MSPSim is a Java-based instruction level emulator of the MSP430 series +microprocessor and emulation of some sensor networking +platforms. Supports loading of IHEX and ELF firmware files, and has +some tools for monitoring stack, setting breakpoints, and profiling. + +* System requirements + +You need a recent Java to run MSPSim. Java SE 1.5 or newer is +recommended. The current version of MSPSim also requires Make for +compiling. + +* Building MSPSim + +You will build MSPSim by typing + +>make + +* Running examples + +Run the default example on the ESB node emulator by typing: + +>make runesb + +(here you can pass the PIR with the mouse and click on the + user button to get reaction from the example application). + + +Run the default example on the Sky node emulator by typing: + +>make runsky + +(this is a leds-blinker only and does not react to any mouse + movements or button clicks). + + +* Main Features +- Instruction level emulation of MSP430 microprocessor +- Supports loading of ELF and IHEX files +- Easy to add external components that emulates external HW +- Supports monitoring of registers, adding breakpoints, etc. +- Built-in profiling of executed code +- Emulates external HW such as sensors and TR1001 and CC2420 radio + chips. + +* What is emulated MSP430 +- CPU (instruction level simulation) +- Timer A/B subsystem +- USARTs +- Digital I/O +- Multiplication unit + +* Limitations of the emulation (some of them) on version 0.8 +- currently the emulator runs as if it can use all memory as RAM + (e.g. flash writes, etc not supported) +- no DMA implementation +- no ADs implemented (fully) +- timer system not 100% emulated This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-11-19 23:40:39
|
Revision: 28 http://mspsim.svn.sourceforge.net/mspsim/?rev=28&view=rev Author: nifi Date: 2007-11-19 15:40:37 -0800 (Mon, 19 Nov 2007) Log Message: ----------- added support for button sensor and reset button on the Sky platform Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyGui.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2007-11-19 15:51:50 UTC (rev 27) +++ mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2007-11-19 23:40:37 UTC (rev 28) @@ -45,8 +45,8 @@ import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; @@ -55,8 +55,7 @@ import se.sics.mspsim.util.SerialMon; import se.sics.mspsim.util.WindowUtils; -public class SkyGui extends JComponent implements KeyListener, - MouseMotionListener { +public class SkyGui extends JComponent implements KeyListener { public static final int GREEN_Y = 40; public static final int BLUE_Y = 46; @@ -100,8 +99,42 @@ window.setVisible(true); window.addKeyListener(this); - window.addMouseMotionListener(this); + MouseAdapter mouseHandler = new MouseAdapter() { + + private boolean buttonDown = false; + private boolean resetDown = false; + + // For the button sensor and reset button on the Sky nodes. + public void mousePressed(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + if (x > 126 && x < 138) { + if (y > 65 && y < 76) { + SkyGui.this.node.setButton(buttonDown = true); + } else if (y > 95 && y < 107) { + resetDown = true; + } + } + } + + public void mouseReleased(MouseEvent e) { + if (buttonDown) { + SkyGui.this.node.setButton(buttonDown = false); + + } else if (resetDown) { + int x = e.getX(); + int y = e.getY(); + resetDown = false; + if (x > 126 && x < 138 && y > 95 && y < 107) { + SkyGui.this.node.getCPU().reset(); + } + } + } + }; +// window.addMouseMotionListener(mouseHandler); + window.addMouseListener(mouseHandler); + // Add some windows for listening to serial output MSP430 cpu = node.getCPU(); IOUnit usart = cpu.getIOUnit("USART 1"); @@ -111,17 +144,7 @@ } } - public void mouseMoved(MouseEvent e) { - // System.out.println("Mouse moved: " + e.getX() + "," + e.getY()); - int x = e.getX(); - int y = e.getY(); - } - - public void mouseDragged(MouseEvent e) { - } - - - public void paintComponent(Graphics g) { + protected void paintComponent(Graphics g) { Color old = g.getColor(); int w = getWidth(), h = getHeight(); int iw = skyImage.getIconWidth(), ih = skyImage.getIconHeight(); Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-11-19 15:51:50 UTC (rev 27) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-11-19 23:40:37 UTC (rev 28) @@ -53,6 +53,9 @@ public static final boolean DEBUG = false; + // Port 2. + public static final int BUTTON_PIN = 7; + public static final int CC2420_CHIP_SELECT = 0x04; /* P1.0 - Input: FIFOP from CC2420 */ /* P1.3 - Input: FIFO from CC2420 */ @@ -96,6 +99,11 @@ port1 = (IOPort) unit; } + unit = cpu.getIOUnit("Port 2"); + if (unit instanceof IOPort) { + port2 = (IOPort) unit; + } + IOUnit usart0 = cpu.getIOUnit("USART 0"); if (usart0 instanceof USART) { radio = new CC2420(); @@ -112,6 +120,10 @@ } } + public void setButton(boolean hi) { + port2.setPinState(BUTTON_PIN, hi ? IOPort.PIN_HI : IOPort.PIN_LOW); + } + public boolean getDebug() { return cpu.getDebug(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-11-19 15:51:53
|
Revision: 27 http://mspsim.svn.sourceforge.net/mspsim/?rev=27&view=rev Author: nifi Date: 2007-11-19 07:51:50 -0800 (Mon, 19 Nov 2007) Log Message: ----------- blink with nullmac instead of xmac to avoid lots of radio activity Modified Paths: -------------- mspsim/firmware/sky/blink.firmware Modified: mspsim/firmware/sky/blink.firmware =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-11-19 10:45:35
|
Revision: 26 http://mspsim.svn.sourceforge.net/mspsim/?rev=26&view=rev Author: joxe Date: 2007-11-19 02:45:34 -0800 (Mon, 19 Nov 2007) Log Message: ----------- minor leds fix Modified Paths: -------------- mspsim/se/sics/mspsim/platform/sky/SkyGui.java Modified: mspsim/se/sics/mspsim/platform/sky/SkyGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2007-11-19 10:29:23 UTC (rev 25) +++ mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2007-11-19 10:45:34 UTC (rev 26) @@ -58,16 +58,16 @@ public class SkyGui extends JComponent implements KeyListener, MouseMotionListener { - public static final int GREEN_Y = 39; - public static final int BLUE_Y = 47; + public static final int GREEN_Y = 40; + public static final int BLUE_Y = 46; public static final int RED_Y = 34; public static final int LED_X = 10; - public static final Color BLUE_TRANS = new Color(0x40,0x40,0xff,0xa0); + public static final Color BLUE_TRANS = new Color(0x80,0x80,0xff,0xa0); public static final Color GREEN_TRANS = new Color(0x40, 0xf0, 0x40, 0xa0); public static final Color RED_TRANS = new Color(0xf0, 0x40, 0x40, 0xa0); - public static final Color BLUE_C = new Color(0xff8080ff); + public static final Color BLUE_C = new Color(0xffa0a0ff); public static final Color GREEN_C = new Color(0xff60ff60); public static final Color RED_C = new Color(0xffff8000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-11-19 10:29:38
|
Revision: 25 http://mspsim.svn.sourceforge.net/mspsim/?rev=25&view=rev Author: joxe Date: 2007-11-19 02:29:23 -0800 (Mon, 19 Nov 2007) Log Message: ----------- added very simple sky firmware Modified Paths: -------------- mspsim/Makefile mspsim/se/sics/mspsim/platform/sky/SkyGui.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Added Paths: ----------- mspsim/firmware/sky/ mspsim/firmware/sky/blink.firmware Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-11-05 09:35:29 UTC (rev 24) +++ mspsim/Makefile 2007-11-19 10:29:23 UTC (rev 25) @@ -54,7 +54,7 @@ ifndef FIRMWAREFILE ESBFIRMWARE = firmware/esb/sensor-demo.firmware -SKYFIRMWARE = firmware/sky/sensor-demo.firmware +SKYFIRMWARE = firmware/sky/blink.firmware else ESBFIRMWARE = $FIRMWAREFILE SKYFIRMWARE = $FIRMWAREFILE Added: mspsim/firmware/sky/blink.firmware =================================================================== (Binary files differ) Property changes on: mspsim/firmware/sky/blink.firmware ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: mspsim/se/sics/mspsim/platform/sky/SkyGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2007-11-05 09:35:29 UTC (rev 24) +++ mspsim/se/sics/mspsim/platform/sky/SkyGui.java 2007-11-19 10:29:23 UTC (rev 25) @@ -58,15 +58,18 @@ public class SkyGui extends JComponent implements KeyListener, MouseMotionListener { - public static final int GREEN_Y = 34; + public static final int GREEN_Y = 39; public static final int BLUE_Y = 47; + public static final int RED_Y = 34; public static final int LED_X = 10; public static final Color BLUE_TRANS = new Color(0x40,0x40,0xff,0xa0); public static final Color GREEN_TRANS = new Color(0x40, 0xf0, 0x40, 0xa0); + public static final Color RED_TRANS = new Color(0xf0, 0x40, 0x40, 0xa0); public static final Color BLUE_C = new Color(0xff8080ff); public static final Color GREEN_C = new Color(0xff60ff60); + public static final Color RED_C = new Color(0xffff8000); private SerialMon serial; private SerialMon radio; @@ -133,6 +136,12 @@ } // Display all active leds + if (node.redLed) { + g.setColor(RED_TRANS); + g.fillOval(LED_X - 2, RED_Y - 1, 9, 5); + g.setColor(RED_C); + g.fillOval(LED_X, RED_Y, 4, 3); + } if (node.greenLed) { g.setColor(GREEN_TRANS); g.fillOval(LED_X - 2, GREEN_Y - 1, 9, 5); Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-11-05 09:35:29 UTC (rev 24) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2007-11-19 10:29:23 UTC (rev 25) @@ -65,13 +65,16 @@ private IOPort port1; private IOPort port2; private IOPort port4; + private IOPort port5; private CC2420 radio; private ExtFlash flash; - public static final int BLUE_LED = 0x01; - public static final int GREEN_LED = 0x02; + public static final int BLUE_LED = 0x40; + public static final int GREEN_LED = 0x20; + public static final int RED_LED = 0x10; + public boolean redLed; public boolean blueLed; public boolean greenLed; @@ -82,11 +85,10 @@ */ public SkyNode(MSP430 cpu) { this.cpu = cpu; - IOUnit unit = cpu.getIOUnit("Port 2"); + IOUnit unit = cpu.getIOUnit("Port 5"); if (unit instanceof IOPort) { - port2 = (IOPort) unit; - System.out.println("Found port 2!!!"); - port2.setPortListener(this); + port5 = (IOPort) unit; + port5.setPortListener(this); } unit = cpu.getIOUnit("Port 1"); @@ -124,7 +126,8 @@ public void portWrite(IOPort source, int data) { - if (source == port2) { + if (source == port5) { + redLed = (data & RED_LED) == 0; blueLed = (data & BLUE_LED) == 0; greenLed = (data & GREEN_LED) == 0; if (gui != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-11-05 10:06:00
|
Revision: 24 http://mspsim.svn.sourceforge.net/mspsim/?rev=24&view=rev Author: nifi Date: 2007-11-05 01:35:29 -0800 (Mon, 05 Nov 2007) Log Message: ----------- changed to not count active calls after clear profile + only show functions called at least once in printProfile Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-11-01 15:45:43 UTC (rev 23) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-11-05 09:35:29 UTC (rev 24) @@ -140,6 +140,7 @@ function = "fkn at $" + Utils.hex16(reg[PC]); } callStack[cSP].function = function; + callStack[cSP].calls = 0; callStack[cSP++].cycles = cycles; } @@ -148,21 +149,31 @@ // System.out.println("Profiler: return / call stack: " + cSP + ", " + fkn); long elapsed = cycles - callStack[cSP].cycles; - CallEntry ce = profileData.get(fkn); - if (ce == null) { - profileData.put(fkn, ce = new CallEntry()); - ce.function = fkn; + if (callStack[cSP].calls >= 0) { + CallEntry ce = profileData.get(fkn); + if (ce == null) { + profileData.put(fkn, ce = new CallEntry()); + ce.function = fkn; + } + ce.cycles += elapsed; + ce.calls++; } - ce.cycles += elapsed; - ce.calls++; } public void clearProfile() { - CallEntry[] entries = - profileData.values().toArray(new CallEntry[0]); - for (int i = 0, n = entries.length; i < n; i++) { - entries[i].cycles = 0; - entries[i].calls = 0; + if (profileData != null) { + CallEntry[] entries = + profileData.values().toArray(new CallEntry[0]); + for (int i = 0, n = entries.length; i < n; i++) { + entries[i].cycles = 0; + entries[i].calls = 0; + } + for (int i = 0, n = callStack.length; i < n; i++) { + CallEntry e = callStack[i]; + if (e != null) { + e.calls = -1; + } + } } } @@ -171,19 +182,21 @@ profileData.values().toArray(new CallEntry[0]); Arrays.sort(entries); for (int i = 0, n = entries.length; i < n; i++) { - String cyclesS = "" + entries[i].cycles; int c = entries[i].calls; - String callS = "" + c; - String avgS = "" + (c > 0 ? (entries[i].cycles / c) : 0); - System.out.print(entries[i].function); - printSpace(56 - entries[i].function.length() - avgS.length()); - System.out.print(avgS); - System.out.print(' '); - printSpace(8 - callS.length()); - System.out.print(callS); - System.out.print(' '); - printSpace(10 - cyclesS.length()); - System.out.println(cyclesS); + if (c > 0) { + String cyclesS = "" + entries[i].cycles; + String callS = "" + c; + String avgS = "" + (c > 0 ? (entries[i].cycles / c) : 0); + System.out.print(entries[i].function); + printSpace(56 - entries[i].function.length() - avgS.length()); + System.out.print(avgS); + System.out.print(' '); + printSpace(8 - callS.length()); + System.out.print(callS); + System.out.print(' '); + printSpace(10 - cyclesS.length()); + System.out.println(cyclesS); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2007-11-01 15:45:57
|
Revision: 23 http://mspsim.svn.sourceforge.net/mspsim/?rev=23&view=rev Author: fros4943 Date: 2007-11-01 08:45:43 -0700 (Thu, 01 Nov 2007) Log Message: ----------- added chip + fixed inner classes in jar rule Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-11-01 10:41:24 UTC (rev 22) +++ mspsim/Makefile 2007-11-01 15:45:43 UTC (rev 23) @@ -62,7 +62,7 @@ CPUTEST := tests/cputest.firmware -PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util} +PACKAGES := ${addprefix se/sics/mspsim/,core platform/esb platform/sky util chip} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} @@ -81,7 +81,7 @@ all: compile jar: compile - $(JAR) cf $(JARFILE) $(OBJECTS) images/*.jpg + $(JAR) cf $(JARFILE) ${addsuffix /*.class,$(PACKAGES)} images/*.jpg help: @echo "Usage: make [all,compile,clean]" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2007-11-01 10:41:37
|
Revision: 22 http://mspsim.svn.sourceforge.net/mspsim/?rev=22&view=rev Author: fros4943 Date: 2007-11-01 03:41:24 -0700 (Thu, 01 Nov 2007) Log Message: ----------- jar support in Makefile Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-10-30 10:47:10 UTC (rev 21) +++ mspsim/Makefile 2007-11-01 10:41:24 UTC (rev 22) @@ -68,6 +68,7 @@ OBJECTS := $(SOURCES:.java=.class) +JARFILE := mspsim.jar ############################################################### # MAKE @@ -79,6 +80,9 @@ all: compile +jar: compile + $(JAR) cf $(JARFILE) $(OBJECTS) images/*.jpg + help: @echo "Usage: make [all,compile,clean]" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-10-30 10:47:27
|
Revision: 21 http://mspsim.svn.sourceforge.net/mspsim/?rev=21&view=rev Author: nifi Date: 2007-10-30 03:47:10 -0700 (Tue, 30 Oct 2007) Log Message: ----------- shorter function names Modified Paths: -------------- mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2007-10-30 10:43:28 UTC (rev 20) +++ mspsim/se/sics/mspsim/util/ELF.java 2007-10-30 10:47:10 UTC (rev 21) @@ -287,7 +287,7 @@ if (sAddr > 0 && sAddr < 0x10000) { String symbolName = sn; if (bind == ELFSection.SYMBIND_LOCAL) { - symbolName += " (local in " + currentFile + ")"; + symbolName += " (" + currentFile + ')'; } map.setFunctionName(sAddr, symbolName); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-10-30 10:43:34
|
Revision: 20 http://mspsim.svn.sourceforge.net/mspsim/?rev=20&view=rev Author: nifi Date: 2007-10-30 03:43:28 -0700 (Tue, 30 Oct 2007) Log Message: ----------- added call count and average cycles per call to profile data Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-10-30 10:02:38 UTC (rev 19) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-10-30 10:43:28 UTC (rev 20) @@ -152,10 +152,9 @@ if (ce == null) { profileData.put(fkn, ce = new CallEntry()); ce.function = fkn; - ce.cycles = elapsed; - } else { - ce.cycles += elapsed; } + ce.cycles += elapsed; + ce.calls++; } public void clearProfile() { @@ -163,6 +162,7 @@ profileData.values().toArray(new CallEntry[0]); for (int i = 0, n = entries.length; i < n; i++) { entries[i].cycles = 0; + entries[i].calls = 0; } } @@ -171,15 +171,25 @@ profileData.values().toArray(new CallEntry[0]); Arrays.sort(entries); for (int i = 0, n = entries.length; i < n; i++) { - printFkn(entries[i].function); - System.out.println(" " + entries[i].cycles); + String cyclesS = "" + entries[i].cycles; + int c = entries[i].calls; + String callS = "" + c; + String avgS = "" + (c > 0 ? (entries[i].cycles / c) : 0); + System.out.print(entries[i].function); + printSpace(56 - entries[i].function.length() - avgS.length()); + System.out.print(avgS); + System.out.print(' '); + printSpace(8 - callS.length()); + System.out.print(callS); + System.out.print(' '); + printSpace(10 - cyclesS.length()); + System.out.println(cyclesS); } } - public void printFkn(String f) { - System.out.print(f); - for (int len = f.length(); len < 40; len++) { - System.out.print(" "); + private void printSpace(int len) { + for (int i = 0; i < len; i++) { + System.out.print(' '); } } @@ -266,6 +276,7 @@ private static class CallEntry implements Comparable { String function; long cycles; + int calls; public int compareTo(Object o) { if (o instanceof CallEntry) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-10-30 10:02:47
|
Revision: 19 http://mspsim.svn.sourceforge.net/mspsim/?rev=19&view=rev Author: nifi Date: 2007-10-30 03:02:38 -0700 (Tue, 30 Oct 2007) Log Message: ----------- added CLEARPROFILE command for test Modified Paths: -------------- mspsim/se/sics/mspsim/util/Test.java Modified: mspsim/se/sics/mspsim/util/Test.java =================================================================== --- mspsim/se/sics/mspsim/util/Test.java 2007-10-30 10:01:27 UTC (rev 18) +++ mspsim/se/sics/mspsim/util/Test.java 2007-10-30 10:02:38 UTC (rev 19) @@ -39,17 +39,18 @@ * $Revision: 1.2 $ */ package se.sics.mspsim.util; -import se.sics.mspsim.core.*; import java.io.IOException; +import se.sics.mspsim.core.*; + /** * Test - tests a firmware file and exits when reporting "FAIL:" first * on a line... */ public class Test implements USARTListener { - String line = ""; - MSP430 cpu; + private StringBuilder lineBuffer = new StringBuilder(); + private MSP430 cpu; public Test(MSP430 cpu) { this.cpu = cpu; @@ -61,6 +62,8 @@ public void dataReceived(USART source, int data) { if (data == '\n') { + String line = lineBuffer.toString(); + lineBuffer.setLength(0); System.out.println("#|" + line); if (line.startsWith("FAIL:")) { System.exit(0); @@ -71,10 +74,11 @@ cpu.setDebug(true); } else if (line.startsWith("PROFILE")) { cpu.printProfile(); + } else if (line.startsWith("CLEARPROFILE")) { + cpu.clearProfile(); } - line = ""; } else { - line += (char) data; + lineBuffer.append((char) data); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-10-30 10:01:31
|
Revision: 18 http://mspsim.svn.sourceforge.net/mspsim/?rev=18&view=rev Author: nifi Date: 2007-10-30 03:01:27 -0700 (Tue, 30 Oct 2007) Log Message: ----------- added clearProfile for clearing profile data Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-10-29 18:19:04 UTC (rev 17) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-10-30 10:01:27 UTC (rev 18) @@ -158,6 +158,14 @@ } } + public void clearProfile() { + CallEntry[] entries = + profileData.values().toArray(new CallEntry[0]); + for (int i = 0, n = entries.length; i < n; i++) { + entries[i].cycles = 0; + } + } + public void printProfile() { CallEntry[] entries = profileData.values().toArray(new CallEntry[0]); @@ -170,12 +178,7 @@ public void printFkn(String f) { System.out.print(f); - int len = f.length(); - if (len < 40) - len = 40 - len; - else - len = 0; - for (int i = 0, n = len; i < n; i++) { + for (int len = f.length(); len < 40; len++) { System.out.print(" "); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-10-29 19:03:08
|
Revision: 17 http://mspsim.svn.sourceforge.net/mspsim/?rev=17&view=rev Author: joxe Date: 2007-10-29 11:19:04 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added possibility to profile from unit test framework Modified Paths: -------------- mspsim/se/sics/mspsim/util/Test.java mspsim/tests/cputest.c Modified: mspsim/se/sics/mspsim/util/Test.java =================================================================== --- mspsim/se/sics/mspsim/util/Test.java 2007-10-26 13:26:33 UTC (rev 16) +++ mspsim/se/sics/mspsim/util/Test.java 2007-10-29 18:19:04 UTC (rev 17) @@ -69,6 +69,8 @@ System.exit(0); } else if (line.startsWith("DEBUG")) { cpu.setDebug(true); + } else if (line.startsWith("PROFILE")) { + cpu.printProfile(); } line = ""; } else { Modified: mspsim/tests/cputest.c =================================================================== --- mspsim/tests/cputest.c 2007-10-26 13:26:33 UTC (rev 16) +++ mspsim/tests/cputest.c 2007-10-29 18:19:04 UTC (rev 17) @@ -256,7 +256,7 @@ testBitFields(); testFunctions(); testModulo(); - + /* printf("PROFILE\n"); */ printf("EXIT\n"); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-10-26 13:26:36
|
Revision: 16 http://mspsim.svn.sourceforge.net/mspsim/?rev=16&view=rev Author: nifi Date: 2007-10-26 06:26:33 -0700 (Fri, 26 Oct 2007) Log Message: ----------- added reset button Modified Paths: -------------- mspsim/se/sics/mspsim/platform/esb/ESBGui.java Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2007-10-26 13:25:48 UTC (rev 15) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2007-10-26 13:26:33 UTC (rev 16) @@ -82,6 +82,7 @@ private JFrame window; private ESBNode node; private boolean buttonDown = false; + private boolean resetDown = false; public ESBGui(ESBNode node) { this.node = node; @@ -105,8 +106,8 @@ window.setVisible(true); window.addKeyListener(this); - window.addMouseMotionListener(this); - window.addMouseListener(this); + addMouseMotionListener(this); + addMouseListener(this); // Add some windows for listening to serial output MSP430 cpu = node.getCPU(); @@ -130,8 +131,8 @@ // System.out.println("Mouse moved: " + e.getX() + "," + e.getY()); int x = e.getX(); int y = e.getY(); - node.setPIR(x > 5 && x < 80 && y > 50 && y < 130); - node.setVIB(x > 60 && x < 100 && y > 180 && y < 200); + node.setPIR(x > 18 && x < 80 && y > 35 && y < 100); + node.setVIB(x > 62 && x < 95 && y > 160 && y < 178); } public void mouseDragged(MouseEvent e) {} @@ -143,13 +144,30 @@ public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); - if (x > 0 && x < 24 && y > 180 && y < 200) { - node.setButton(buttonDown = true); + if (y > 152 && y < 168) { + if (x > 0 && x < 19) { + node.setButton(buttonDown = true); + } else { + int w = esbImage.getIconWidth(); + if (x > w - 20 && x < w) { + resetDown = true; + } + } } } public void mouseReleased(MouseEvent e) { if (buttonDown) { node.setButton(buttonDown = false); + } else if (resetDown) { + int x = e.getX(); + int y = e.getY(); + if (y > 152 && y < 168) { + int w = esbImage.getIconWidth(); + if (x > w - 20 && x < w) { + node.getCPU().reset(); + } + } + resetDown = false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2007-10-26 13:26:01
|
Revision: 15 http://mspsim.svn.sourceforge.net/mspsim/?rev=15&view=rev Author: nifi Date: 2007-10-26 06:25:48 -0700 (Fri, 26 Oct 2007) Log Message: ----------- use FIRMWAREFILE if specified Modified Paths: -------------- mspsim/Makefile Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-10-26 13:11:08 UTC (rev 14) +++ mspsim/Makefile 2007-10-26 13:25:48 UTC (rev 15) @@ -52,9 +52,13 @@ # SERVER OBJECTS ############################################################### -FIRMWAREFILE = blinker2.ihex +ifndef FIRMWAREFILE ESBFIRMWARE = firmware/esb/sensor-demo.firmware SKYFIRMWARE = firmware/sky/sensor-demo.firmware +else +ESBFIRMWARE = $FIRMWAREFILE +SKYFIRMWARE = $FIRMWAREFILE +endif CPUTEST := tests/cputest.firmware @@ -115,12 +119,8 @@ # CLEAN (untrusted, use with great care!!!) ############################################################### -.PHONY: clean claen clena +.PHONY: clean -claen: clean - -clena: clean - clean: ifdef WINDIR -$(RM) *.class ${addsuffix /*.class,$(PACKAGES)} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-10-26 13:11:22
|
Revision: 14 http://mspsim.svn.sourceforge.net/mspsim/?rev=14&view=rev Author: joxe Date: 2007-10-26 06:11:08 -0700 (Fri, 26 Oct 2007) Log Message: ----------- clear interrupt related info during reset Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2007-10-26 13:02:55 UTC (rev 13) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2007-10-26 13:11:08 UTC (rev 14) @@ -324,6 +324,12 @@ public void reset() { resetIOUnits(); reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); + for (int i = 0, n = 16; i < n; i++) { + interruptSource[i] = null; + } + servicedInterruptUnit = null; + servicedInterrupt = -1; + interruptMax = -1; } // Indicate that we have an interrupt now! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-10-26 13:03:05
|
Revision: 13 http://mspsim.svn.sourceforge.net/mspsim/?rev=13&view=rev Author: joxe Date: 2007-10-26 06:02:55 -0700 (Fri, 26 Oct 2007) Log Message: ----------- fixed reset to call reset on all IOUnits Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2007-10-26 12:43:41 UTC (rev 12) +++ mspsim/se/sics/mspsim/core/MSP430.java 2007-10-26 13:02:55 UTC (rev 13) @@ -213,10 +213,6 @@ running = false; } - public void reset() { - reg[PC] = memory[0xfffe] + (memory[0xffff] << 8); - } - public int getExecCount(int address) { if (execCounter != null) { return execCounter[address]; Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2007-10-26 12:43:41 UTC (rev 12) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2007-10-26 13:02:55 UTC (rev 13) @@ -312,6 +312,20 @@ } } + private void resetIOUnits() { + for (int i = 0, n = lastIOUnitPos; i < n; i++) { + ioUnits[i].reset(); + } + for (int i = 0, n = passiveIOUnits.length; i < n; i++) { + passiveIOUnits[i].reset(); + } + } + + public void reset() { + resetIOUnits(); + reg[PC] = memory[0xfffe] + (memory[0xffff] << 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) { @@ -920,4 +934,5 @@ writeRegister(SR, sr); } } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-10-26 12:43:52
|
Revision: 12 http://mspsim.svn.sourceforge.net/mspsim/?rev=12&view=rev Author: joxe Date: 2007-10-26 05:43:41 -0700 (Fri, 26 Oct 2007) Log Message: ----------- added firmware for esb demo Modified Paths: -------------- mspsim/Makefile mspsim/se/sics/mspsim/core/IOPort.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java Added Paths: ----------- mspsim/firmware/esb/ mspsim/firmware/esb/sensor-demo.firmware Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2007-10-25 12:23:33 UTC (rev 11) +++ mspsim/Makefile 2007-10-26 12:43:41 UTC (rev 12) @@ -53,6 +53,8 @@ ############################################################### FIRMWAREFILE = blinker2.ihex +ESBFIRMWARE = firmware/esb/sensor-demo.firmware +SKYFIRMWARE = firmware/sky/sensor-demo.firmware CPUTEST := tests/cputest.firmware @@ -81,10 +83,10 @@ java se.sics.mspsim.util.IHexReader $(FIRMWAREFILE) $(MAPFILE) runesb: compile - java se.sics.mspsim.platform.esb.ESBNode $(FIRMWAREFILE) $(MAPFILE) + java se.sics.mspsim.platform.esb.ESBNode $(ESBFIRMWARE) $(MAPFILE) runsky: compile - java se.sics.mspsim.platform.sky.SkyNode $(FIRMWAREFILE) $(MAPFILE) + java se.sics.mspsim.platform.sky.SkyNode $(SKYFIRMWARE) $(MAPFILE) .PHONY: cputest test test: cputest Added: mspsim/firmware/esb/sensor-demo.firmware =================================================================== (Binary files differ) Property changes on: mspsim/firmware/esb/sensor-demo.firmware ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Modified: mspsim/se/sics/mspsim/core/IOPort.java =================================================================== --- mspsim/se/sics/mspsim/core/IOPort.java 2007-10-25 12:23:33 UTC (rev 11) +++ mspsim/se/sics/mspsim/core/IOPort.java 2007-10-26 12:43:41 UTC (rev 12) @@ -136,7 +136,9 @@ // case IFG: if (interrupt > 0) { // IFG - writing a zero => clear the flag! - System.out.println(getName() + " Clearing IFlag: " + data); + if (DEBUG) { + System.out.println(getName() + " Clearing IFlag: " + data); + } interruptFlag &= data; memory[offset + IFG] = interruptFlag; cpu.flagInterrupt(interrupt, this, interruptFlag > 0); @@ -169,14 +171,19 @@ // LO/HI transition if (state == PIN_HI) { interruptFlag |= bit; - System.out.println(getName() + " Flagging interrupt (HI): " + bit); + if (DEBUG) { + System.out.println(getName() + + " Flagging interrupt (HI): " + bit); + } } } else { // HI/LO transition if (state == PIN_LOW) { interruptFlag |= bit; - System.out.println(getName() + " Flagging interrupt (LOW): " + - bit); + if (DEBUG) { + System.out.println(getName() + + " Flagging interrupt (LOW): " + bit); + } } } } Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2007-10-25 12:23:33 UTC (rev 11) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2007-10-26 12:43:41 UTC (rev 12) @@ -47,6 +47,7 @@ import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; +import java.awt.event.MouseListener; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; @@ -57,7 +58,8 @@ import se.sics.mspsim.util.WindowUtils; public class ESBGui extends JComponent implements KeyListener, - MouseMotionListener { + MouseMotionListener, + MouseListener { public static final int GREEN_X = 3; public static final int YELLOW_X = 10; @@ -79,6 +81,7 @@ private ImageIcon esbImage; private JFrame window; private ESBNode node; + private boolean buttonDown = false; public ESBGui(ESBNode node) { this.node = node; @@ -103,6 +106,7 @@ window.addKeyListener(this); window.addMouseMotionListener(this); + window.addMouseListener(this); // Add some windows for listening to serial output MSP430 cpu = node.getCPU(); @@ -130,10 +134,27 @@ node.setVIB(x > 60 && x < 100 && y > 180 && y < 200); } - public void mouseDragged(MouseEvent e) { + public void mouseDragged(MouseEvent e) {} + public void mouseClicked(MouseEvent e) {} + public void mouseEntered(MouseEvent e) {} + public void mouseExited(MouseEvent e) {} + + // For the button sensor on the ESB nodes. + public void mousePressed(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + if (x > 0 && x < 24 && y > 180 && y < 200) { + node.setButton(buttonDown = true); + } } + public void mouseReleased(MouseEvent e) { + if (buttonDown) { + node.setButton(buttonDown = false); + } + } + public void paintComponent(Graphics g) { Color old = g.getColor(); int w = getWidth(), h = getHeight(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |