05.07.2013 Views

Script for Laboratory: Designing embedded ASIPs - CES

Script for Laboratory: Designing embedded ASIPs - CES

Script for Laboratory: Designing embedded ASIPs - CES

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.3.2 Debugging with dlxsim<br />

This chapter assumes, that you are not only used to the assembler code and dlxsim, but that<br />

you are also used to the compiler (Chapter 8.3) and inline assembly (Chapter 8.4).<br />

General Points:<br />

• Compare the results from the CoSy compiled version and the gcc-compiled version. For<br />

the gcc compiled version you have to add printf statements <strong>for</strong> all essential variables, like:<br />

#ifndef COSY<br />

printf(“temp1: %i\n”, temp1);<br />

#endif<br />

For the CoSy-compiled version, you have to make the essential variables global, <strong>for</strong> example<br />

moving the variable “temp1” from inside the main method to a global part outside<br />

the main method. All global variables will get an own label in the assembly code with an<br />

underscore be<strong>for</strong>e the name, e.g. the variable “temp1” will get the label “_temp1”. In<br />

dlxsim you can see the value of such global variables with the “get” instruction, e.g. “get<br />

_temp1 i”.<br />

Debugging with dlxsim:<br />

• Sometimes the dlxsim simulation aborts with an error message, e.g. when a load<br />

instruction is trying to access an address that is outside the simulated memory range. In<br />

such cases, you first have to find out, which instruction is causing this crash. With the<br />

instruction “get pc” you can see the address which is currently executed. With the instruction<br />

“get {address} i” you can see which instruction is placed at this address and at which<br />

label this instruction can be found. With the instruction “get {Address}-0x10 20i” you can<br />

see the context of this instruction.<br />

• Getting more debugging in<strong>for</strong>mation from dlxsim is very helpful to understand, what the<br />

assembly code is doing. There<strong>for</strong>e, the dlxsim starting parameters “-da#” and “-dbb#” are<br />

useful. You have to replace the “#” with either a “1” to turn the option on or with a “0” to<br />

turn it off.<br />

• da#: Debug Assembly. This option is turned on by default and it will print status in<strong>for</strong>mation<br />

on the screen <strong>for</strong> every jump/branch/load/store-instruction. You can print<br />

additional status in<strong>for</strong>mation by adding your needed in<strong>for</strong>mation into the sim.c of<br />

dlxsim.<br />

• dbb#: Debug Base Blocks. When you turn on this option then at every start of a baseblock<br />

all changed register values will be printed. A base block is an elementary block<br />

of assembly code that is only executed sequentially. This means, that either all instructions<br />

of a base block are executed (one after the other) or none of them is executed at<br />

all. The borders of a base block (beginning/end) are jumps and labels. The simulation<br />

will create a huge amount of output on the screen if you turn this option on. There<strong>for</strong>e<br />

it is recommended, that you copy the output to a text file <strong>for</strong> easier reading. You can<br />

automatically print everything into a text file if you start dlxsim like:<br />

“../dlxsim -fassembly.dlxsim -dbb1 | tee output.txt”<br />

The “tee” program will copy all output to the screen and to the file.<br />

- 29 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!