Assignment 1 with Solutions - Microprocessor System Design | ECE 3534, Assignments of Microprocessors

Answers to project1 Material Type: Assignment; Professor: Thweatt; Class: Microprocessor System Design; Subject: Electrical & Computer Engineer; University: Virginia Polytechnic Institute And State University; Term: Fall 2007;

Typology: Assignments

Pre 2010

Uploaded on 11/08/2008

danfrantzen
danfrantzen 🇺🇸

1 document

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 3534 – Microprocessor System Design Fall 2007 (rev. 8/29)
Laboratory Assignment 1: Introduction to the Spartan3E and MicroBlaze
THIS ASSIGNMENT IS TO BE DONE INDIVIDUALLY
Solutions
Instructor (circle): Abbott Athanas Thweatt
Honor pledge: I have neither given nor received unauthorized assistance on this assignment.
[Digitally] Signed: ________________________________________________________________
pf3
pf4
pf5
pf8

Partial preview of the text

Download Assignment 1 with Solutions - Microprocessor System Design | ECE 3534 and more Assignments Microprocessors in PDF only on Docsity!

ECE 3534 – Microprocessor System Design Fall 2007 (rev. 8/29)

Laboratory Assignment 1: Introduction to the Spartan3E and MicroBlaze

THIS ASSIGNMENT IS TO BE DONE INDIVIDUALLY

Solutions

Instructor (circle): Abbott Athanas Thweatt

Honor pledge : I have neither given nor received unauthorized assistance on this assignment.

[Digitally] Signed: ________________________________________________________________

Introduction

This lab will help you become familiar with the Digilent Spartan3E board configured with a MicroBlaze processor, and with the software tools that are needed to interface with it. Completion of this lab assignment should take about four hours. Please read over the entire handout before starting.

A formal, written laboratory report is not required for this assignment. Instead, write your answers directly (and neatly) on a printout of this assignment. You should turn in a single, completed printout to your instructor, in class, on the due date.

Equipment Needed

Most of these items are described at your Blackboard site, or at the CEL web site, www.ece.vt.edu/cel:

  • Spartan3E board configured with the latest processor configuration file
  • WinXP laptop with a USB connector
  • All software installed from the class DVD
  • Baseline processor configuration file (posted on Blackboard). This file will create a C:\fall07- directory, which contains all of the necessary baseline files for creating applications.

References

Refer to the sources listed below as needed:

  • Spartan3E Starter Kit Users Guide
  • MicroBlaze Reference Guide
  • Embedded System Tools Reference Manual

All of these documents are available on your Blackboard site.

Protecting your Equipment

Electrostatic discharge can destroy the Spartan3E board. Always discharge yourself by touching the board’s ground connection, next to the power jack, before touching components on the board, changing jumpers, connecting communications cables, or wiring components on the breadboards. Always transport your board when it is inside of the provided anti-static bubble-wrap pouch.

Among other things, this lab will help you test your Spartan3E board for correct operation. Although each unit was tested before it was shipped, a very small number of hardware failures have been observed. If at any time during the semester you think that your kit has a hardware failure, you should first try the tests described here again before concluding that your board is broken. (In the past, the vast majority of “hardware failures” have turned out to be wiring or programming errors.) If these tests fail, then you should try the self-test station in the CEL. To learn about the test procedure, see the instructions posted at www.ece.vt.edu/cel/help/hardware-support.html.

Notes:

  • Keep the directory names in your path reasonably small. There should be no spaces in the directory path (as in C:\Documents and Settings\administrator).
  • When using Notepad/Textpad, save the file by typing "blinky.s". If not, an automatic .txt extension may be added to the file.
  1. Open a EDK Shell: Start-> Xilinx Platform Studio -> Accessories -> Launch EDK Shell
  2. Change directory to where you saved the file:

cd c:/fall07-1/Applications

  1. Assemble the program:

mb-as -als=blinky.lst -o blinky.o blinky.s

  1. You should have gotten one error message during assembly. Edit the file, blinky.lst and search for the string "Error". Write down the complete error message:

**** Error:Invalid register number at ',r0,0'

The above instruction attempts to write its result to general-purpose register r63. How many general-purpose registers are there in the MicroBlaze? 32

  1. Edit the blinky.s file and change the reference from r63 to r6. Save the file and reassemble it. You should not encounter any errors.
  2. Referring to the LST file, what hex address does the instruction, xori r27,r7,-1 (identified with the comment "MARKER A") map to? 0x00c

What is the machine code value for the instruction,

xori r27,r7,-1 0xAB67FFFF hex

If register r7 contained the value 0x1234 prior to the execution of this instruction, what would

be the contents of r27 be after the instruction executed? 0xFFFFEDCB

  1. Link the file to create an ELF executable file:

mb-ld -o blinky.elf blinky.o -Ttext 0

This command will create the executable file, blinky.elf. ELF is a type of executable file, and is also an acronym.

Use Google or other online resources to determine what ELF stands for:

Executable and Linking (or Linkable) Format

  1. The "text" portion of an ELF file is the portion that contains the executable instructions. Issue the command,

mb-size blinky.elf

How big, in bytes, is the text portion of the blinky.elf program?

216 bytes (base 10).

Executing Blinky. To proceed from here, you must connect your board to your laptop using the supplied USB cable, plug-in and connect the power cable to your board, and turn on the sliding ON switch in the upper left corner of the board. Make sure that the slide switches on the lower right-hand side of the board are slid to the down (off) position (slid towards the bottom of the board).

  1. Open a EDK Shell: Start-> Xilinx Platform Studio -> Accessories -> Launch EDK Shell
  2. Change directory to your baseline directory. You must be in this directory to proceed:

cd c:/fall07-

  1. Start the Xilinx Microprocessor Debugger:

xmd

This will produce lots of text, ending with something similar to:

JTAG MDM Connected to MicroBlaze 1 Connected to "mb" target. id = 0 Starting GDB server for "mb" target (id = 0_ at TCP port no 1234 XMD% INFO: MDT - XMP File already loaded XMD%

If you do not see this, you could have a connectivity problem between your laptop USB and the board.

  1. Load your program. At the XMD% prompt, enter:

dow Applications/blinky.elf

  1. Remove the breakpoint by entering the XMD command: bpr 0x94. You may need to use another address other than 0x94.
  2. Run the program by issuing the XMD command run. The XMD prompt should change to RUNNING>
  3. Using the program source, and observing the behavior of the LEDs, determine the function of each of the four slide switches:

SWITCH FUNCTION

SW0 RESETS COUNT TO ZERO

SW1 COUNT UP OR DOWN

SW2 PAUSE

SW3 SPEED: FAST OR SLOW

  1. Stop execution by entering the XMD command, stop.
  2. Edit your blinky.s source file and comment out the lines that have the comment "MARKER C" on it. Assemble, link and download the new executable. How does this affect the behavior of the program:

The program counts faster, because 4 “no-op” instructions have been removed from a delay loop.

This step will be used in validation.

  1. Discover other neat XMD commands. At the XMD prompt, type help.

MicroBlaze Assembly Language

When you first look at the instruction list in Chapter 4 of the MicroBlaze Processor Reference Guide, you may be puzzled by the lack of specific instructions for common operations such as clearing, complementing, incrementing, decrementing and copying register values. Older architectures such as the 68HC11 and PIC processors have these instructions. Provide a single MicroBlaze instruction equivalent to each of the following operations:

clear r5: add r5,r0,r0 (several possibililties)

complement r10: xori r10,r10,-1 (several possibilities)

increment r3: addi r3, r3, 1 (a few other possibilities)

decrement r4: addi r4, r4, -1 (a few other possibilities)

copy r7 to r8: add r8, r7, r0 (a few other possibilities)

There is a Type A and a Type B version of most instructions. When performing integer arithmetic, describe the circumstances in which you would use each of these instruction types: (2 points)

Type B instructions are essential when using immediate constants.

Type A instructions are essential when operating on three registers at the same time.

In the context of the MicroBlaze architecture, what is sign extension and why is it necessary for Type B instructions? (2 points)

When a 16-bit immediate value is given, it must typically be converted to a 32-bit value for compatibility with values stored in general-purpose registers. “Sign extension” replicates the MSB of the 16-bit immediate data to the full 32 bits, thereby preserving both the magnitude and the sign of the original value.

What is the difference between a MicroBlaze machine instruction and an assembler directive? Give an example of each. (3 points)

A machine instruction is a 32-bit word that can be executed by the MicroBlaze. A machine- language instruction is typically generated by the assembler from a single assembly-language instruction. Example: addi r3,r5, 1

Assembler directives are instructions for the assembler, not for the MicroBlaze. These directives control the behavior of the assembly process, and help make the code easier to read by humans. Here are some examples:

.equ MY_CONSTANT, 60 .org 0x

Validation

A correct validation is worth 12 points. The maximum possible score for this assignment is 50 points.