Wentworth Institute of Technology

Department of Electrical Engineering and Technology

Elec 667 Advanced Programmable Logic

Lab 2 Eclipse Software Build Tool

 

In the last lab we built a Nios II processor, successfully generated, and compile the device.  In this lab we write a C program using Eclipse to run on the processor.  If you have not done so previously you will need to download the Nios II Embedded Design Suite from Altera.  Our system includes two pin outs: reset_n to Vcc and Clk_0 to PIN_N2, the global clock for the Cyclone II.  For this first design, we won’t need to declare the I/O pins as we are going with the simplest of designs to learn the process.

Figure 1 Successfully compiled design with 4 inputs and 8 outputs.

Instructions:

1.       Begin by opening the SOPC for the Nios II processor.  Go to the second page and click upon the button:  .  This opens the Eclipse Workspace tool.

2.        Quartus and the SOPC Builder can remain open while you work with Eclipse.   Notice that the Workspace is in the C: drive and no spaces are allowed in the directory path.  The workspace should be in the same folder that contains the Quartus Project. 

Figure 2 Workspace Launcher

3.       Click okay when you have a folder set up on your hard drive.  The last project you worked on will open unless this is your first project. 

 

4.       From the main screen, click on File>New>Nios II Application and BSP from Template.  BSP stands for Board Service Package. 

Figure 3 Starting a new project.

5.       The next screen is probably the most important.

Figure 4 Setting the parameters for the design

6.       Change the Project Template to Hello World Small. Notice: NO spaces in Project name.

7.       At the top of the form, the Target Hardware information is contained in the SOPC information file.  This is important because the file tells Eclipse where and what I/O are used in the processor and what the system ID is.  This file has the extension *.sopcinfo and is in the folder you created the Quartus project in.  Click on the browse button  and add that file to this form.

8.       Name the project to illuminate the functionality for this project.  If you put a space in the name a message appears across the top of the form:.  Notice that the default location of the project is the same as the Quartus II project.

9.       Click on finish will cause the software build tools to begin to write files seen in the console window at the bottom.  Over 300 files are created and can be seen by clicking on any of the expand buttons.  A window similar to the following screen appears with the project (expanded) showing in the navigation window.

Figure 5 Opening screen of the Nios II Software Build Tools (SBT) for the Eclipse IDE.

10.   The main window is the file viewer, below it is the Terminal window with multiple Tabs one which makes this a Console window for I/O (stdin, stdout).  On the right is an Outline View of the project that is partially hidden by a Welcome window that contains tutorials for this IDE.

11.   The first folder shown in the navigation window on the left is the Nios II Application project.  The second folder is the Board Support Package (BSP) project.  When these folders are expanded you can see the various files and folders created. 

Figure 6 Close up of the folders expanded one level.

12.   We are now going to look at the properties of the BSP.  Highlight the BSP>>right click>>select Properties.  

Figure 7 Instruction 12 illustrated.

13.   The following window will open if you highlight Nios II BSP Properties in the navigation tree. 

Figure 8 Close up view of the changes we made in the BSP property window.

14.   In the lower right-hand side of this window is a button… .  I’d like you to click on to open yet another window, the BSP Editor window. 

Figure 9 BSP Editing window.

15.   Across the top are some tabs, click on the Linker Script tab to get the next window.

Figure 10 Memory location is confirmed.

16.   Verify that the onchip_memory is the default location and the right size.  If we had multiple memory devices to choose from this is the location where we can set what goes to which memory devise.  Since we made changes, we need to generate new files by clicking on  in the lower right corner.  After this finishes, we’re going to back out of here.  Close the BSP editor window then press OK to close the BSP project properties window.

17.   Let’s look at the C program.  Click on the Hello_World.c file under the application folder.

Figure 11 Checking the C program.

18.   If you don’t have the workspace matched up with the Quartus folder where the project resides Eclipse won’t write the C program in the Project Explorer application folder from the Template.   

19.   In the comments section there is mention that the software requires a STDOUT device in the system hardware.  Since we haven’t connected any I/O we can discover how the output gets to the screen by opening up the system.h file. 

 

Figure 12 Our STDOUT device is the JTAG connections.

20.   At this point we are going to compile the project.  Highlight the application folder, right-click and select Build Project.

Figure 13 Building the project.

21.   After the build has finished, you are ready for the final step provide you have downloaded the processor to the DE2 board all ready.  The programming screen back in Quartus II software should be closed to make sure the USB connection is available. 

Figure 14 This was a successful build.

22.   The final step is to Run the program on Nios II hardware.  Make sure your USB cable is connected correctly.  Select the project application, then click on Run As>> Nios II Hardware.

Figure 15 Downloading the application to the DE2 board.

23.   If the Run Configuration window comes up verifying there are no errors with the build and verifies the target then press the RUN button.  The computer talks to the DE2 Board when the two blue LEDs (POWER and GOOD) are joined momentarily by the blue LOAD LED.  

24.   The results come up in the Nios II Console window:

Figure 16 Output successfully achieved.

25.   Back in the Console window we see what the machine was reporting:

Figure 17 Starting address shown.

26.   As a modest demonstrate of your C programming abilities, change the screen printout to include your name. 

Figure 18 Modified screen output.

Lab Report

27.   Since you have now become acquainted with the design process, write up a summary sheet of the steps you take to get a working project.  Write up all the errors you encountered and how you cleared them.  Remember to capture screen shots for your lab report especially the project outcome which reveal some text in the Console window.