ECE 3610 Laboratory 1 Introduction to ARM Assembly Language Programming

$30.00

Download Details:

  • Name: lab01-ujkcwj.zip
  • Type: zip
  • Size: 5.71 KB

Description

Rate this product

This laboratory is an introduction to the operation and basic programming of the ARM Cortex A9 processor. For this
laboratory we will be using the Intel DE10-Standard development board. Te FPGA on the board includes two ARM
processors, in addition to the reprogrammable logic circuitry which you used in the prerequisite course ECE 2220.
IMPORTANT: Te circuitry on the development board is sensitive to electrostatic discharge. Before handling
components, ensure that you ground yourself in order to discharge any static electricity that may be present on your
person. Grounding straps may be provided at your workstations for this purpose. Also, try to handle the board without
making contact with pins and connectors.
NOTE: Before leaving the laboratory room, you need to demonstrate a working system to the teaching assistant.
Procedure
Te ARM processor may be programmed in a high-level language (i.e. C, C++, Python, etc.), which is what is typically
done when developing sofware for most computer systems. However, when working with system sofware at that level,
much of the detail of what the processor is doing is not directly observable. While this separation can be considered an
advantage of a high-level language, it is our objective in this course for you to understand the details of what the CPU is
doing when it’s running programs and executing instructions. Terefore, we want to be able to monitor the CPU as it
processes instructions and observe the low-level changes that happen along the way. In order to achieve that, we will be
working with programs written in assembly language.
Te programming tool we will be using is specifcally intended for use with Intel/Altera FPGA development boards and is
similar to the programming environment shown in the course textbook. Te tool is called the Intel FPGA Monitor Program
and can be found in Windows Start menu under the Intel FPGA UP 18.0 folder, or through a shortcut icon on the desktop.

Connect the power supply to your DE10-Standard FPGA board, then connect a USB cable from your PC to the USB port
just above the power connector. Power-on the board and launch the Intel FPGA Monitor Program. Once the programming
tool loads, you will see the following application window.
Te window is divided into separate sections (panes). Te main section, titled Disassembly shows the version of the
program code that is loaded into the processor. When executing the program in single-step mode (discussed later), this
pane will highlight the current instruction and allow you to set breakpoints. Te Registers pane shows the contents of the
16 internal registers within the processor. Te Info & Errors pane provides messages associated with the assembly and
downloading of the machine code to the processor.
Te frst step in preparing to compile and execute a program is to create a new project to contain the project fles. From
the File menu select the New Project… menu item. Tis will open the New Project Wizard.

USB from PC
Power supply
ECE 3610 Microprocessing Systems Laboratory 1
Te frst page of the wizard is shown in the fgure to
the right. Use the Browse… button to select a Project
Directory that will hold your project fles. Note that the
fle path to this directory, and the directory name itself
can not have spaces or the project will not compile
properly later. Te Project Name feld can be anything
you like, but once again, it may not have spaces in the
name. Te Project Name does not need to be the same
as the Project Directory, although in this example they
happen to be the same. Te last selection for this
window is the Architecture of the processor for which
the program is being assembled. For our purposes,
this should always be set to ARM Cortex-A9.
Click Next> to advance to the next page of the wizard.
Tis page of the wizard is used to select the target
system on which the programs will be run. From the
pop-up menu, choose DE10-Standard Computer.
Doing so will auto-complete the remainder of the
page.
Click Next>.

Te next page of the wizard concerns the type of
programs the project will be working with. In our
case, we will be writing assembly code, so the
Program Type should be set to Assembly Program.
Tis page also allows us to include code from several
example programs. To do this, select the checkbox to
Include a sample program with this project. We will
start with a very simple example, appropriately titled
Simple Program.
One these options have been chosen, click Next>.
Te page which follows allows you to add your own
source fles to the project. At this point we have no
fles to include beyond those already provided by the
example program, so click Next> to continue.
Te next step is to select parameters for the processor
in the FPGA. For the Host Connection, select DE-SoC,
if it is not already selected. If the Host Connection
list is blank, then verify that your FPGA board is
powered on and plugged into the PC. Ten click the
Refresh button to update the USB device list.
Te FPGA contains two processors, which are able to
run independent programs. For our purposes, we will
only be using one of these. From the Processor list,
select the ARM_A9_HPS_arm_a9_0.
Te Terminal device can be lef at its default value of
Semihosting.
Once again, click Next> to continue.

Te fnal page of the wizard allows for selection of
memory settings. For the programs in this laboratory,
the default Basic setting is what will be used.
At this point, clicking Save will create the project fles
in the project directory.
Te ARM processor is one component within the FPGA chip. Te processor is directly connected to some of the physical
pins on the chip and through those pins to some of the devices on the development board. However, in order to connect
the processor to other devices on the board, it is necessary to provide logical circuitry for the FPGA to make those
connections. Fortunately, the project wizard has already included the design fles needed to accomplish this, so there is no
need to prepare one ourselves, in this case.
Afer saving the project confguration in the New Project Wizard (above), you will be offered the option of downloading
the needed logic to the FPGA. Clicking Yes with bring you back to the original application window. In the Info & Errors
pane you will see the FPGA design fle being compiled by Quartus and then downloaded to the board.
If you receive a warning from Windows Defender attempting to block the Java component of the tool from performing
the download, simply choose Cancel to dismiss those warnings. Afer doing so, or any other time where the power to the
board has been interrupted and therefore the FPGA confguration has been lost, simply choose the Download System…
item from the Actions menu.

Assembling and Executing a Program
Te entire process up to this point has prepared the development board and the sofware tool in preparation for the
sofware. Now we are able to actually assemble the sample program and load it into the memory on the DE10 board so
that the ARM processor can run it.
Below the Edit menu is the Compile button. Clicking that button will compile the assembly language program. To the right
of the Compile button is the Load button. Clicking that button will copy the machine code into the main memory on the
FPGA board ready for the ARM processor to execute it.
Once the load is complete, the additional program execution controls will become available below the Help menu and the
Disassembly window will show the program, with the frst instruction highlighted.
Te program instructions shown in red are the instructions as they were written by the programmer. Te instructions in
green are the actual instructions that result from the assembly (compilation) of the programmer’s assembly code. Some
modifcations to the programmer’s code are made by the assembler in order to get the intended result while adjusting for
some limitations of the instructions themselves.
Now that a program is actually loaded into the processor, the Registers pane shows the current contents of the processor’s
registers. Te ARM processor has 16 registers in total. Registers r0 through r12 are general purpose and can be used by
the programmer to hold any 32-bit value as needed. Te remaining three registers have specialized functions, so they are
not shown as r13, r14, r15, but rather are given the special labels sp, lr, and pc. Te last entry in the list is the cpsr,
which in the ARM architecture is known as the Current Processor Status Register. It stores the condition code bits
(N, Z, C, V) as the most signifcant 4 bits of the 32-bit word.

To execute the program, click on the green Play button (just below and slightly to the right of the Help menu). Tis will
run the program, but will not actively update the view in the monitor window. To stop the execution, click the Pause
button (to the right of the Play button). Alternatively, you can step through the program, one instruction at a time, by
using the Step button (located right below the Help menu). When doing so, the highlighted instruction in the Disassembly
pane tracks where the program is, while the Registers window updates (in red type) the registers which were just modifed
by the last instruction.
Step through the sample program, while changing the switch settings on the DE10 board and observe the changes which
occur to the registers as this is done. Notice that the CPSR does not change, since none of the program instructions
indicate that an update should be performed.
Modifying the Program
Te Intel FPGA Monitor Program does not allow you to directly edit the assembly code. Tat must be done in another text
editor, such as NotePad++. Te assembly code source fle for the example above can be found in the fle
simple_program.s within your project directory.
For convenience in performing the program modifcations below, a copy of Table 3.1 from the textbook is reproduced
here for your reference. It is a short list of some basic assembly language instructions.
1. For the frst program modifcation, instead of simply reading the switch value and storing it directly to the LEDs,
modify the code so that it now reads the switch value, multiplies that value by 16, and stores that result to the LEDs.
Assemble the modifed code and download it to the DE10. Run the program and describe how the LEDs now change
in response to the switches.

2. Te second modifcation is intended for you to explore the behaviour of the status bits stored in the CPSR. Instead of
simply reading the switch value and storing it directly to the LEDs, modify the code to read the switch value, subtract
8 from the value, and store that result to the LEDs. Use the version of the subtraction operation that updates the
CPSR. Assemble the modifed code and download it to the DE10. Both run and single-step through the program to
see how it operates. Pay particular attention to the value of the status bits (most signifcant bits) in the CPSR.
3. For the next modifcation we wish to explore the use of a branch (BEQ) statement. Change the code so that the value
of the switches is read, and if the lowest-order switch is 0, then light the lowest 2 LEDs, while if it is 1, then light the
top two LEDs. (Te values of the other switches need not be considered.)
4. Finally, make your own modifcation of the original code (or further modify any of the above three changes in your
own way). Describe what the modifed code is intended to do, and verify its operation by running the code on the
DE10.