mirror of https://github.com/contiki-ng/mspsim
added some configuration support for MSP430 core
git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@784 23d1a52b-0c3c-0410-b72d-8f29ab48fe35
This commit is contained in:
parent
2ea5f90c8f
commit
7c58b8e3ce
6
Makefile
6
Makefile
|
|
@ -60,9 +60,11 @@ JAVAARGS=-classpath "${CLASSPATH}"
|
|||
ifndef FIRMWAREFILE
|
||||
ESBFIRMWARE = firmware/esb/sensor-demo.firmware
|
||||
SKYFIRMWARE = firmware/sky/blink.firmware
|
||||
Z1FIRMWARE = firmware/z1/blink.firmware
|
||||
else
|
||||
ESBFIRMWARE = ${FIRMWAREFILE}
|
||||
SKYFIRMWARE = ${FIRMWAREFILE}
|
||||
Z1FIRMWARE = ${FIRMWAREFILE}
|
||||
endif
|
||||
|
||||
CPUTEST := tests/cputest.firmware
|
||||
|
|
@ -71,7 +73,7 @@ TIMERTEST := tests/timertest.firmware
|
|||
SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc}
|
||||
BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware ${SCRIPTS}
|
||||
|
||||
PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli debug platform ${addprefix platform/,esb sky jcreate sentillausb} plugin profiler net ui util extutil/highlight extutil/jfreechart}
|
||||
PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli debug platform ${addprefix platform/,esb sky jcreate sentillausb, z1} plugin profiler net ui util extutil/highlight extutil/jfreechart}
|
||||
|
||||
SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))}
|
||||
|
||||
|
|
@ -116,6 +118,8 @@ runskyprof: compile
|
|||
|
||||
runtelos: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(ARGS) $(SKYFIRMWARE) $(MAPFILE)
|
||||
runz1: compile
|
||||
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(ARGS) $(Z1FIRMWARE) $(MAPFILE)
|
||||
|
||||
|
||||
test: cputest
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ service controlgui start
|
|||
service nodegui start
|
||||
#service stackchart start
|
||||
#rflistener output CC2420 >> rfdata.txt
|
||||
start
|
||||
stop
|
||||
#start
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2011, 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.
|
||||
*
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Joakim Eriksson
|
||||
*/
|
||||
|
||||
package se.sics.mspsim.config;
|
||||
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.Timer;
|
||||
|
||||
public class MSP430f1611Config extends MSP430Config {
|
||||
|
||||
|
||||
public MSP430f1611Config() {
|
||||
maxInterruptVector = 15;
|
||||
|
||||
/* configuration for the timers */
|
||||
TimerConfig timerA = new TimerConfig(6, 5, 3, 0x160, Timer.TIMER_Ax149, "TimerA");
|
||||
TimerConfig timerB = new TimerConfig(13, 12, 7, 0x180, Timer.TIMER_Bx149, "TimerB");
|
||||
timerConfig = new TimerConfig[] {timerA, timerB};
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Copyright (c) 2011, 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.
|
||||
*
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Joakim Eriksson
|
||||
*/
|
||||
|
||||
package se.sics.mspsim.config;
|
||||
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.Timer;
|
||||
|
||||
public class MSP430f2617Config extends MSP430Config {
|
||||
|
||||
|
||||
public MSP430f2617Config() {
|
||||
/* 32 vectors for the MSP430X series */
|
||||
maxInterruptVector = 31;
|
||||
MSP430XArch = true;
|
||||
|
||||
/* configuration for the timers */
|
||||
TimerConfig timerA = new TimerConfig(25, 24, 3, 0x160, Timer.TIMER_Ax149, "TimerA");
|
||||
TimerConfig timerB = new TimerConfig(29, 28, 7, 0x180, Timer.TIMER_Bx149, "TimerB");
|
||||
timerConfig = new TimerConfig[] {timerA, timerB};
|
||||
}
|
||||
}
|
||||
|
|
@ -77,8 +77,8 @@ public class MSP430 extends MSP430Core {
|
|||
* Creates a new <code>MSP430</code> instance.
|
||||
*
|
||||
*/
|
||||
public MSP430(int type, ComponentRegistry registry) {
|
||||
super(type, registry);
|
||||
public MSP430(int type, ComponentRegistry registry, MSP430Config config) {
|
||||
super(type, registry, config);
|
||||
disAsm = new DisAsm();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,25 @@ public interface MSP430Constants {
|
|||
public static final int XOR = 0xe;
|
||||
public static final int AND = 0xf;
|
||||
|
||||
|
||||
// MSP430X instructions
|
||||
public static final int MOVA_IND0 = 0x0000;
|
||||
public static final int MOVA_IND1 = 0x0010;
|
||||
public static final int MOVA_ABS2REG = 0x0020;
|
||||
public static final int MOVA_INDX2REG = 0x0030;
|
||||
public static final int MOVA_REG2ABS = 0x0060;
|
||||
public static final int MOVA_REG2INDX = 0x0070;
|
||||
public static final int MOVA_IMM2REG = 0x0080;
|
||||
public static final int CMPA_IMM = 0x0090;
|
||||
public static final int ADDA_IMM = 0x00a0;
|
||||
public static final int SUBA_IMM = 0x00b0;
|
||||
public static final int MOVA_REG = 0x00c0;
|
||||
public static final int CMPA_REG = 0x00d0;
|
||||
public static final int ADDA_REG = 0x00e0;
|
||||
public static final int SUBA_REG = 0x00f0;
|
||||
|
||||
|
||||
|
||||
public static final String[] TWO_OPS = {
|
||||
"-","-","-","-","MOV", "ADD", "ADDC", "SUBC", "SUB",
|
||||
"CMP", "DADD", "BIT", "BIC", "BIS", "XOR", "AND"
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
public static final int RETURN = 0x4130;
|
||||
|
||||
public static final boolean DEBUG = false;
|
||||
public static final boolean debugInterrupts = false;
|
||||
public static final boolean debugInterrupts = true;//false;
|
||||
|
||||
public static final boolean EXCEPTION_ON_BAD_OPERATION = true;
|
||||
|
||||
|
|
@ -82,6 +82,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
public long cycles = 0;
|
||||
public long cpuCycles = 0;
|
||||
MapTable map;
|
||||
public MSP430Config config;
|
||||
|
||||
// Most HW needs only notify write and clocking, others need also read...
|
||||
// For notify write...
|
||||
|
|
@ -93,9 +94,11 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
private SFR sfr;
|
||||
private Watchdog watchdog;
|
||||
|
||||
// From the possible interrupt sources - to be able to indicate is serviced.
|
||||
private InterruptHandler interruptSource[] = new InterruptHandler[16];
|
||||
|
||||
// From the possible interrupt sources - to be able to indicate is serviced.
|
||||
// NOTE: 64 since more modern MSP430's have more than 16 vectors (5xxx has 64).
|
||||
private InterruptHandler interruptSource[] = new InterruptHandler[64];
|
||||
private final int MAX_INTERRUPT;
|
||||
|
||||
protected int interruptMax = -1;
|
||||
// Op/instruction represents the last executed OP / instruction
|
||||
private int op;
|
||||
|
|
@ -136,10 +139,11 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
|
||||
boolean isFlashBusy;
|
||||
|
||||
public MSP430Core(int type, ComponentRegistry registry) {
|
||||
public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) {
|
||||
super("MSP430", "MSP430 Core", null);
|
||||
MAX_INTERRUPT = config.maxInterruptVector;
|
||||
this.registry = registry;
|
||||
|
||||
this.config = config;
|
||||
// The CPU need to register itself as chip
|
||||
addChip(this);
|
||||
|
||||
|
|
@ -150,15 +154,16 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
// Maybe for debugging purposes...
|
||||
ioUnits = new IOUnit[PORTS + 9];
|
||||
|
||||
Timer ta = new Timer(this, "A", Timer.TIMER_Ax149, memory, 0x160);
|
||||
Timer tb = new Timer(this, "B", Timer.TIMER_Bx149, memory, 0x180);
|
||||
// first step towards making core configurable
|
||||
Timer ta = new Timer(this, memory, config.timerConfig[0]);
|
||||
Timer tb = new Timer(this, memory, config.timerConfig[1]);
|
||||
for (int i = 0, n = 0x20; i < n; i++) {
|
||||
memOut[0x160 + i] = ta;
|
||||
memOut[0x180 + i] = tb;
|
||||
memIn[0x160 + i] = ta;
|
||||
memIn[0x180 + i] = tb;
|
||||
memOut[config.timerConfig[0].offset + i] = ta;
|
||||
memIn[config.timerConfig[0].offset + i] = ta;
|
||||
memOut[config.timerConfig[1].offset + i] = tb;
|
||||
memIn[config.timerConfig[1].offset + i] = tb;
|
||||
}
|
||||
|
||||
|
||||
/* TODO: this range is only valid for the F1611 series (Sky, etc) */
|
||||
flash = new Flash(this, memory,
|
||||
new FlashRange(0x4000, 0x10000, 512, 64),
|
||||
|
|
@ -238,7 +243,6 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
// Usarts
|
||||
ioUnits[passIO++] = usart0;
|
||||
ioUnits[passIO++] = usart1;
|
||||
|
||||
|
||||
// Add the timers
|
||||
ioUnits[passIO++] = ta;
|
||||
|
|
@ -653,7 +657,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
}
|
||||
|
||||
public void reset() {
|
||||
flagInterrupt(15, null, true);
|
||||
flagInterrupt(MAX_INTERRUPT, null, true);
|
||||
}
|
||||
|
||||
// Indicate that we have an interrupt now!
|
||||
|
|
@ -665,16 +669,16 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
|
||||
if (debugInterrupts) {
|
||||
if (source != null) {
|
||||
System.out.println("### Interrupt flagged ON by " + source.getName() + " prio: " + interrupt);
|
||||
System.out.println("### Interrupt " + interrupt + " flagged ON by " + source.getName() + " prio: " + interrupt);
|
||||
} else {
|
||||
System.out.println("### Interrupt flagged ON by <null>");
|
||||
System.out.println("### Interrupt " + interrupt + " flagged ON by <null>");
|
||||
}
|
||||
}
|
||||
|
||||
// MAX priority is executed first - update max if this is higher!
|
||||
if (interrupt > interruptMax) {
|
||||
interruptMax = interrupt;
|
||||
if (interruptMax == 15) {
|
||||
if (interruptMax == MAX_INTERRUPT) {
|
||||
// This can not be masked at all!
|
||||
interruptsEnabled = true;
|
||||
}
|
||||
|
|
@ -825,7 +829,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
|
||||
// Only store stuff on irq except reset... - not sure if this is correct...
|
||||
// TODO: Check what to do if reset is called!
|
||||
if (interruptMax < 15) {
|
||||
if (interruptMax < MAX_INTERRUPT) {
|
||||
// Push PC and SR to stack
|
||||
// store on stack - always move 2 steps (W) even if B.
|
||||
writeRegister(SP, sp = spBefore - 2);
|
||||
|
|
@ -838,7 +842,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
writeRegister(SR, 0); // sr & ~CPUOFF & ~SCG1 & ~OSCOFF);
|
||||
|
||||
// Jump to the address specified in the interrupt vector
|
||||
writeRegister(PC, pc = read(0xffe0 + interruptMax * 2, true));
|
||||
writeRegister(PC, pc = read(0xfffe - (MAX_INTERRUPT - interruptMax) * 2, true));
|
||||
|
||||
servicedInterrupt = interruptMax;
|
||||
servicedInterruptUnit = interruptSource[servicedInterrupt];
|
||||
|
|
@ -847,9 +851,9 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
// executed things might change!
|
||||
reevaluateInterrupts();
|
||||
|
||||
if (servicedInterrupt == 15) {
|
||||
// System.out.println("**** Servicing RESET! => " + Utils.hex16(pc));
|
||||
internalReset();
|
||||
if (servicedInterrupt == MAX_INTERRUPT) {
|
||||
if (debugInterrupts) System.out.println("**** Servicing RESET! => " + Utils.hex16(pc));
|
||||
internalReset();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -860,7 +864,8 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
System.out.println("### Executing interrupt: " +
|
||||
servicedInterrupt + " at "
|
||||
+ pcBefore + " to " + pc +
|
||||
" SP before: " + spBefore);
|
||||
" SP before: " + spBefore +
|
||||
" Vector: " + Utils.hex16(0xfffe - (MAX_INTERRUPT - servicedInterrupt) * 2));
|
||||
}
|
||||
|
||||
// And call the serviced routine (which can cause another interrupt)
|
||||
|
|
@ -952,6 +957,29 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
writeRegister(PC, pc);
|
||||
|
||||
switch (op) {
|
||||
case 0:
|
||||
// MSP430X - additional instructions
|
||||
op = instruction & 0xf0f0;
|
||||
System.out.println("Executing MSP430X instruction op:" + Utils.hex16(op) +
|
||||
" ins:" + Utils.hex16(instruction) + " PC = " + Utils.hex16(pc - 2));
|
||||
int src = 0;
|
||||
/* data is either bit 19-16 or src register */
|
||||
int srcData = (instruction & 0x0f00) >> 8;
|
||||
int dstData = (instruction & 0x000f);
|
||||
switch(op) {
|
||||
// 20 bit register write
|
||||
case MOVA_IMM2REG:
|
||||
src = read(pc, true);
|
||||
writeRegister(PC, pc += 2);
|
||||
dst = src + (srcData << 16);
|
||||
System.out.println("*** Writing $" + Utils.hex16(dst) + " to reg: " + dstData);
|
||||
writeRegister(dstData, dst);
|
||||
break;
|
||||
default:
|
||||
System.out.println("MSP430X instructions not yet supported...");
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
// -------------------------------------------------------------------
|
||||
// Single operand instructions
|
||||
|
|
@ -1197,7 +1225,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
dstRegMode = ((instruction >> 7) & 1) == 0;
|
||||
dstAddress = -1;
|
||||
int srcAddress = -1;
|
||||
int src = 0;
|
||||
src = 0;
|
||||
|
||||
// Some CGs should be handled as registry reads only...
|
||||
if ((srcRegister == CG1 && as > AM_INDEX) || srcRegister == CG2) {
|
||||
|
|
@ -1415,7 +1443,7 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
writeRegister(SR, sr);
|
||||
break;
|
||||
default:
|
||||
System.out.println("DoubleOperand not implemented: " + op + " at " + pc);
|
||||
System.out.println("DoubleOperand not implemented: op = " + op + " at " + pc);
|
||||
if (EXCEPTION_ON_BAD_OPERATION) {
|
||||
EmulationException ex = new EmulationException("Bad operation: " + op + " at " + pc);
|
||||
ex.initCause(new Throwable("" + pc));
|
||||
|
|
@ -1479,4 +1507,13 @@ public class MSP430Core extends Chip implements MSP430Constants {
|
|||
public int getConfiguration(int parameter) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String info() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
buf.append("Vector: at $" + Utils.hex16(0xfffe - i * 2) + " -> $" +
|
||||
Utils.hex16(read(0xfffe - i * 2, true)) + "\n");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,13 +76,13 @@ public class Timer extends IOUnit {
|
|||
public static final int TBIV = 0x011e;
|
||||
public static final int TAIV = 0x012e;
|
||||
|
||||
public static final int TACCR0_VECTOR = 6;
|
||||
// Other is on 5
|
||||
public static final int TACCR1_VECTOR = 5;
|
||||
|
||||
public static final int TBCCR0_VECTOR = 13;
|
||||
// Other is on 12
|
||||
public static final int TBCCR1_VECTOR = 12;
|
||||
// public static final int TACCR0_VECTOR = 6;
|
||||
// // Other is on 5
|
||||
// public static final int TACCR1_VECTOR = 5;
|
||||
//
|
||||
// public static final int TBCCR0_VECTOR = 13;
|
||||
// // Other is on 12
|
||||
// public static final int TBCCR1_VECTOR = 12;
|
||||
|
||||
public static final int TCTL = 0;
|
||||
public static final int TCCTL0 = 2;
|
||||
|
|
@ -409,9 +409,9 @@ public class Timer extends IOUnit {
|
|||
*
|
||||
*/
|
||||
|
||||
public Timer(MSP430Core core, String type, int[] srcMap, int[] memory, int offset) {
|
||||
super("Timer" + type, "Timer " + type, memory, offset);
|
||||
this.srcMap = srcMap;
|
||||
public Timer(MSP430Core core, int[] memory, MSP430Config.TimerConfig config) {
|
||||
super(config.name, config.name, memory, config.offset);
|
||||
this.srcMap = config.srcMap;
|
||||
this.core = core;
|
||||
noCompare = (srcMap.length / 4) - 1;
|
||||
if (DEBUG) {
|
||||
|
|
@ -420,18 +420,17 @@ public class Timer extends IOUnit {
|
|||
if (srcMap == TIMER_Ax149) {
|
||||
tiv = TAIV;
|
||||
timerOverflow = 0x0a;
|
||||
ccr0Vector = TACCR0_VECTOR;
|
||||
ccr1Vector = TACCR1_VECTOR;
|
||||
} else {
|
||||
tiv = TBIV;
|
||||
timerOverflow = 0x0e;
|
||||
ccr0Vector = TBCCR0_VECTOR;
|
||||
ccr1Vector = TBCCR1_VECTOR;
|
||||
}
|
||||
counterTrigger.name += ' ' + type;
|
||||
ccr0Vector = config.ccr0Vector;
|
||||
ccr1Vector = config.ccrXVector;
|
||||
|
||||
counterTrigger.name += ' ' + config.name;
|
||||
|
||||
for (int i = 0; i < noCompare; i++) {
|
||||
ccr[i] = new CCR(0, "CCR" + i + " " + type, i == 0 ? ccr0Vector : ccr1Vector, i);
|
||||
ccr[i] = new CCR(0, "CCR" + i + " " + config.name, i == 0 ? ccr0Vector : ccr1Vector, i);
|
||||
}
|
||||
|
||||
reset(0);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import se.sics.mspsim.core.Chip;
|
|||
import se.sics.mspsim.core.EmulationException;
|
||||
import se.sics.mspsim.core.EmulationLogger;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.MSP430Constants;
|
||||
import se.sics.mspsim.extutil.highlight.HighlightSourceViewer;
|
||||
import se.sics.mspsim.ui.ControlUI;
|
||||
|
|
@ -84,8 +85,8 @@ public abstract class GenericNode extends Chip implements Runnable {
|
|||
protected OperatingModeStatistics stats;
|
||||
|
||||
|
||||
public GenericNode(String id) {
|
||||
super(id, new MSP430(0, new ComponentRegistry()));
|
||||
public GenericNode(String id, MSP430Config config) {
|
||||
super(id, new MSP430(0, new ComponentRegistry(), config));
|
||||
this.cpu = (MSP430)super.cpu;
|
||||
this.registry = cpu.getRegistry();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import se.sics.mspsim.chip.TR1001;
|
|||
import se.sics.mspsim.core.IOPort;
|
||||
import se.sics.mspsim.core.IOUnit;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.PortListener;
|
||||
import se.sics.mspsim.core.USART;
|
||||
import se.sics.mspsim.extutil.jfreechart.DataChart;
|
||||
|
|
@ -90,7 +91,8 @@ public class ESBNode extends GenericNode implements PortListener {
|
|||
*
|
||||
*/
|
||||
public ESBNode() {
|
||||
super("ESB");
|
||||
/* this should be a config for the MSP430f149 */
|
||||
super("ESB", new MSP430Config());
|
||||
}
|
||||
|
||||
public Leds getLeds() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import se.sics.mspsim.chip.PacketListener;
|
|||
import se.sics.mspsim.core.IOPort;
|
||||
import se.sics.mspsim.core.IOUnit;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
import se.sics.mspsim.core.PortListener;
|
||||
import se.sics.mspsim.core.USART;
|
||||
import se.sics.mspsim.core.USARTListener;
|
||||
|
|
@ -47,7 +48,8 @@ public abstract class CC2420Node extends GenericNode implements PortListener, US
|
|||
protected String flashFile;
|
||||
|
||||
public CC2420Node(String id) {
|
||||
super(id);
|
||||
/* this should be a config for the MSP430x1611 */
|
||||
super(id, new MSP430Config());
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package se.sics.mspsim.platform.z1;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import se.sics.mspsim.config.MSP430f2617Config;
|
||||
import se.sics.mspsim.core.IOPort;
|
||||
import se.sics.mspsim.core.IOUnit;
|
||||
import se.sics.mspsim.core.PortListener;
|
||||
import se.sics.mspsim.platform.GenericNode;
|
||||
import se.sics.mspsim.platform.esb.ESBNode;
|
||||
import se.sics.mspsim.util.ArgumentManager;
|
||||
|
||||
public class Z1Node extends GenericNode implements PortListener {
|
||||
|
||||
IOPort port1;
|
||||
|
||||
public Z1Node() {
|
||||
super("Z1", new MSP430f2617Config());
|
||||
}
|
||||
|
||||
public void portWrite(IOPort source, int data) {
|
||||
System.out.println("Write to port: " + source + " => " + data);
|
||||
}
|
||||
|
||||
private void setupNodePorts() {
|
||||
IOUnit unit = cpu.getIOUnit("P1");
|
||||
if (unit instanceof IOPort) {
|
||||
port1 = (IOPort) unit;
|
||||
port1.setPortListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setupNode() {
|
||||
setupNodePorts();
|
||||
}
|
||||
|
||||
public int getModeMax() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
Z1Node node = new Z1Node();
|
||||
ArgumentManager config = new ArgumentManager();
|
||||
config.handleArguments(args);
|
||||
node.setupArgs(config);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@
|
|||
package se.sics.mspsim.util;
|
||||
import java.io.*;
|
||||
import se.sics.mspsim.core.MSP430;
|
||||
import se.sics.mspsim.core.MSP430Config;
|
||||
|
||||
public class IHexReader {
|
||||
|
||||
|
|
@ -138,7 +139,7 @@ public class IHexReader {
|
|||
// System.out.println("T ^ T => " + (true ^ true) +
|
||||
// " T ^ F => " + (false ^ true));
|
||||
|
||||
MSP430 cpu = new MSP430(0, new ComponentRegistry());
|
||||
MSP430 cpu = new MSP430(0, new ComponentRegistry(), new MSP430Config());
|
||||
int[] memory = cpu.getMemory();
|
||||
reader.readFile(memory, args[0]);
|
||||
cpu.reset();
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ public class SimpleProfiler implements Profiler, EventListener {
|
|||
private CallListener[] callListeners;
|
||||
|
||||
/* statistics for interrupts */
|
||||
private long[] lastInterruptTime = new long[16];
|
||||
private long[] interruptTime = new long[16];
|
||||
private long[] interruptCount = new long[16];
|
||||
private long[] lastInterruptTime = new long[64];
|
||||
private long[] interruptTime = new long[64];
|
||||
private long[] interruptCount = new long[64];
|
||||
private int servicedInterrupt;
|
||||
private int interruptLevel;
|
||||
private int interruptFrom;
|
||||
|
|
@ -310,7 +310,7 @@ public class SimpleProfiler implements Profiler, EventListener {
|
|||
}
|
||||
out.println("********** Profile IRQ **************************");
|
||||
out.println("Vector Average Calls Tot.Cycles");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int i = 0; i < cpu.config.maxInterruptVector + 1; i++) {
|
||||
out.print((i < 10 ? "0" : "") + i + " ");
|
||||
out.printf("%4d ",(interruptCount[i] > 0 ? (interruptTime[i] / interruptCount[i]):0));
|
||||
out.printf("%8d %8d",interruptCount[i],interruptTime[i]);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class Test implements USARTListener {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MSP430 cpu = new MSP430(0, new ComponentRegistry());
|
||||
MSP430 cpu = new MSP430(0, new ComponentRegistry(), new MSP430Config());
|
||||
int index = 0;
|
||||
if (args[index].startsWith("-")) {
|
||||
// Flag
|
||||
|
|
|
|||
Loading…
Reference in New Issue