Lab 04 - Microarchitecture - BYU Computer Science Students

advertisement
MSP430 Microarchitecture
Lab 4: MSP430 Microarchitecture

MSP430 Microarchitecture Simulator:




Use the MSP430 Microarchitecture Simulator to create a Finite State Machine that
implements the Texas Instruments MSP430 ISA.
Create states that fetch, decode, evaluate source, evaluate destination, execute,
and store MSP430 instructions and operands.
Execute a program that displays an incrementing counter in the simulator LEDs.
Learning Objectives: After completing the Microarchitecture Lab,
students will be able to:






Implement a MSP430 ISA microarchitecture that executes computer instructions.
Explain how a computer is a Finite State Machine.
List 7 ways operands are accessed by a computer instruction.
Use multiplexors, decoders, drivers, ALUs, and registers to move and store data
within a computer.
Explain the functions of the program counter, stack pointer, and condition code
registers.
Summarize the difference between clock cycles and instruction steps.
BYU CS 224
Lab 4 - Microarchitecture Lab
1
MSP430 Microarchitecture
Microarchitecture Simulator

Simulator buttons:














Run:
Step:
Clock:
Back:
Current State:
Next State:
Reset:
Restart:
Quit:
Load Control:
Save Control:
Load Memory:
Analyze FSM:
Generate continuous clocks
Generate continuous clocks until next Fetch, Clock 1 state.
Generate one clock.
Backup one clock state.
Current instruction execution state.
Next instruction state after a clock.
Reset FSM Control, registers, memory, clocks, and instructions.
Restarts current simulation.
Exit MicroArch Simulator.
Read FSM control from a file.
Save current control to a file.
Loads the currently selected program into memory.
Outputs and analysis of the FSM Control in the Notes window.
Please note: Save learned FSM Control after each instruction in a new file!
BYU CS 224
Lab 4 - Microarchitecture Lab
2
MSP430 Microarchitecture
Lab 4 Machine Code
8000:
8004:
800a:
8010:
;**************************************************************
;
MSP430 Micro-Architecture Simulator Code
;
;
Description: Display an incrementing counter in LEDs.
;**************************************************************
.cdecls C,"msp430.h"
.text
4031 0300
RESET: mov.w
#0x0300,SP
; Init stack pointer
40b2 5a80 0120
mov.w
#WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
d0f2 000f 001E
bis.b
#0x0f,&P4DIR
; Set P1.0-3 output
430e
mov.w
#0,r14
8012:
8016:
8018:
801c:
8020:
4ec2 001D
531e
f03e 000f
401f 0003
120f
loop:
8022:
8026:
8028:
802a:
8391 0000
23fd
41ef
3ff3
wait:
802c: 0002
mov.b
add.w
and.w
mov.w
push
r14,&P4OUT
#1,r14
#0x000f,r14
delay,r15
r15
sub.w
jne
mov.w
jmp
#1,0(sp)
wait
@sp+,r15
loop
delay: .word
.sect
.word
.end
BYU CS 224
; output P1.0-3
; mask counter
; Delay to R15
;
;
;
;
decrement delay count
delay over?
y
repeat
2
".reset"
RESET
Lab 4 - Microarchitecture Lab
; MSP430 RESET Vector
; NMI
3
MSP430 Microarchitecture
MSP430 Microarchitecture Simulator
BYU CS 224
Lab 4 - Microarchitecture Lab
4
MSP430 Microarchitecture
Pass-off

This lab is worth 10 points as follows:
1 point Your micro-architecture simulator executes the first
instruction ("mov.w #0x0600,SP") correctly as outlined in
the tutorial - a 2 word instruction with an immediate mode
source operand and a register mode destination operand.
1 point Your micro-architecture simulator executes the second
instruction ("mov.w #0x5a80,&WDTCTL") correctly - a
three word instruction requiring three memory accesses with
an absolute mode destination operand.
1 point Your micro-architecture simulator executes the third ("bis.b
#0x000f,&P4DIR") and fourth ("mov.w #0,r14")
instructions correctly - the fourth being an emulated
instruction that uses the CG2 Constant Generator for the
source operand and register mode for the destination
operand.
BYU CS 224
Lab 4 - Microarchitecture Lab
5
MSP430 Microarchitecture
Pass-off
1 point Your micro-architecture simulator executes the fifth
instruction ("mov.b r14,&P4OUT") correctly - a two word
instruction writing a register to memory.
1 point Your micro-architecture simulator executes the sixth
instruction ("add.w #1,r14") correctly - another double
operand emulated instruction that uses the Constant
Generator CG2 for the source operand.
1 point Your micro-architecture simulator executes the seventh
("and.w #0x000f,r14") and eighth ("mov.w
Delay,r15") instructions correctly - the latter requiring a
PC-Relative mode for the source operand.
1 point Your micro-architecture simulator executes the ninth
("push.w r15") instruction correctly - a single operand
instruction that requires the EXECUTE phase.
BYU CS 224
Lab 4 - Microarchitecture Lab
6
MSP430 Microarchitecture
Pass-off
1 point Your micro-architecture simulator executes the tenth
("sub.w #1,0x0000(SP)") instruction correctly - an
emulated instruction that uses an indexed register mode for
the destination operand.
1 point Your micro-architecture simulator executes the eleventh
("jne (L1)") instruction correctly - a PC-Relative jump
format that does not require a source nor destination phase.
1 point Finally, your micro-architecture simulator executes the
twelfth ("pop.w r15") and thirteenth ("jmp
(Mainloop)") instructions correctly - the former
instruction's source operand is obtained using the indexed
auto-increment addressing mode "@Rs+".
BYU CS 224
Lab 4 - Microarchitecture Lab
7
MSP430 Microarchitecture
Bonus

In addition to the above points, the following bonus /
deductions apply:
+1 point Passed off with a TA at least one day early. (Note: labs
completed in a previous semester do NOT qualify for the
early pass-off bonus.)
+1 point Your MSP430 micro-architecture implementation is able
to turn on all four LEDs at the same time (170
instructions) in less than 919 clocks.
+2 points Your MSP430 microarchitecture implementation is able
execute the Bonus program and turn on all four LEDs at
the same time (97 instructions) in 544 or less clocks.
-1 point
BYU CS 224
For each school day late. (Timestamps may be used to
verify completion time.)
Lab 4 - Microarchitecture Lab
8
Download