You are on page 1of 14

EDK Tutorial 4

Simulating with BFM and Modelsim SE

-Introduction

Modelsim SE is a standard for simulating large scale projects. The ability to simulate the
entire EDK system is a major benefit for debugging components of the project as well as
the entire system.
The software provided by UNM is for academic use only. It is not intended for
commercial work and should not be used for such.

Figure 1. Entire list of tutorials

-Objective

The objective is to use ModelsimSE to simulate a simple EDK project.

-Process

Open project
ModelsimSE.ini file modification
Update environment variables
Clean simulation files
Generate simulation files

-Implementation

1
Figure 2. Modifying Hello World C code

Open the previously created project from Tutorial 1. Modify the hello world file as
shown above. This will print a single “U” to the UART. The significance of this is that
the character “U” is 55 in hex. This will allow visualization of a nice waveform.

Figure 3. Change UART

2
Change the rate of the UART. This will allow the simulation not to have to run as long.

Figure 4. Generate test bench

Generate the test bench template for simulation.

Figure 5. Simulate with SE

3
Use the Modelsim SE simulator that has been loaded.

Figure 6. HDLs Supported

Select appropriate HDLs to support or just leave as default.

Figure 7. Library Locations

Point to the correct library locations.


4
Figure 8. Library Locations

Point to the correct library locations.

Figure 9. Recompile

Compile all libraries.

5
Figure 10. Clean Simulation

Clean all older simulation files.

Figure 11. Generate Simulation Files

Regenerate the Simulation HDL files for running the new simulation.

6
Figure 12. Launch Simulator

Launch the Modelsim Simulator.

Figure 13. Compile the designs

Compile the design and simulation files into Modelsim.

7
Figure 14. Load the design

Load the design into the Simulator.

Figure 15. Set up waveform window

Set up the waveform window. When this is done, the various signals associated with the
project should be visiable.

8
Figure 16. Run Simulation

Run the simulation. For this tutorial, 2ms was chosen as it was a sufficient amount of
time to obtain output data from the UART. This is a user choice.

Figure 17. Undock waveform window

By undocking the waveform window, it is easier to visualize all the signals.

9
Figure 18. Waveforms

There are many signals that are displayed in the simulation. The user should spend time
going through some of them to include the general purpose registers.

Figure 19. “U” on Transmit

By expanding the UART transmit it is possible to see the 01010101 that represents the
“U” coming out of the UART.

10
Figure 20. Launch EDK Shell

Another useful tool is the capability to visualize the Assembly code. To do this it will be
necessary to disassemble the .elf file. Launch the EDK Shell.

Figure 21. Transit to .elf file

Travel into your project director and go to the executable.elf file.

Figure 22. Disassembly of .elf file

11
Disassemble the .elf file into a text tile. In this tutorial, the dump.dis file name was
chosen.

Figure 23. Open .dis file

Using WordPad, open the .dis file.

Figure 24. Dump file

If the user searches for the “U” then they will see the applicable assembly code.

12
Attachment 1

This is an excerpt from a Xilinx Application Note for modifying the modelsim.ini file

MTI ModelSim SE and ModelSim PE (5.7 or later) - Windows 2000/XP


Simulator Setup
NOTE: When using ModelSim PE (5.7 or later), the SWIFT interface must be enabled.
Please contact the vendor to enable this option.

Although ModelSim SE and ModelSim PE (5.7 or later) support the SWIFT Interface,
you must make certain modifications to the default ModelSim setup to enable this
feature.
You must make the following changes to the "modelsim.ini" file located in the
"%MODEL_TECH%" directory:

1. After the lines:


; Simulator resolution
; Set to fs, ps, ns, us, ms, or sec with optional prefix of 1, 10, or 100.

edit the statement that follows, from "Resolution = ns" to "Resolution = ps."

2. After the lines:


; Specify whether paths in simulator commands should be described
; in VHDL or Verilog format. For VHDL, PathSeparator = /
; for Verilog, PathSeparator = .

comment the following statement by adding a semicolon (;) at the beginning of the line:
PathSeparator = /

3. After the line:


; List of dynamically loaded objects for Verilog PLI applications

add the following statement:


Veriuser=$MODEL_TECH/libswiftpli.dll

4. After the line:


; Logic Modeling's SmartModel SWIFT software (Windows NT)

add the following statements:


libsm = $MODEL_TECH/libsm.dll
libswift=$LMC_HOME/lib/pcnt.lib/libswift.dll

NOTE: It is important that you change the order in which the commands appear in the
"modelsim.ini" file. The simulation might not work if you do not follow the order
recommended above.

13
Attachment 2
Compiling the Modelsim Libraries and
______________________________________________

I would first install the BFM package then compile libraries.

To compile libraries it should look like the following setup which I think is default. If it
isn’t the default, then it is a good idea to place the compiled libraries into a common
location such as “sim.”

Then you would use the same C:\simlib\EDK9.2_mti_se_nt path for the EDK_Lib.

Then make sure the smartmodel paths are setup correctly for the environmental variables
and the modelsim.ini. Which the installed path for the Smartmodels is at
C:\simlib\EDK9.2_mti_se_nt\smartmodel\nt\installed_nt.

Smartmodels are used for the PPC405 model.


The ISE_Lib is used for base components like FIFOs etc.
The EDK_Lib is used for the cores inside EDK.
You need to add the correct environmental variables like:

LMC_HOME C:\simlib\EDK9.2_mti_se_nt\smartmodel\nt\installed_nt
Add to the PATH %LMC_HOME%\bin;%LMC_HOME%\lib\pcnt.lib;

14

You might also like