Real Time Embedded Systems (Lab 7 & 8) : COMSATS Institute of Information Technology, Lahore
Real Time Embedded Systems (Lab 7 & 8) : COMSATS Institute of Information Technology, Lahore
EE Department
CIIT, Lahore
EE Department
Implement the SDRAM Chip with the Nios II based embedded system
&
Develop a Micro C/OS-II RTOS application
Objectives:
CIIT, Lahore
EE Department
Introduction
This document explains how the SDRAM chips on Alteras DE2-70 Development and Education
board can be used with a Nios II system implemented by using the Altera Qsys tool and
familiarizes you with the Nios II Software Build Tools (SBT) for Eclipse and the MicroC/OS-II
development flow. The Nios II SBT for Eclipse offers designers a rich development platform for
Nios II applications. The Nios II SBT for Eclipse enables you to integrate the MicroC/OS-II realtime operating system, giving you the ability to build MicroC/OS-II applications for the Nios II
processor quickly. In this lab we implement the built in MicroC/OS-II application on the NIOS II
based embedded system that uses the SDRAM.
CIIT, Lahore
EE Department
Background
The lab 6 explains how the memory in the Cyclone II FPGA chip can be used in the context of a
simple Nios II system. For practical applications it is necessary to have a much larger memory.
The Altera DE2-70 board contains 2 SDRAM chips that can each store 32 Mbytes of data. Each
chip is organized as 4M x 16 bits x 4 banks. The SDRAM chips require careful timing control.
To provide access to the SDRAM chips, the Qsys tool implements an SDRAM Controller circuit.
This circuit generates the signals needed to deal with the SDRAM chips.
Doing this lab, the reader will learn about:
Using the Qsys tool to include an SDRAM interface for a Nios II-based system
Timing issues with respect to the SDRAM on the DE2-70 board
The SDRAM Interface
The two SDRAM chips on the DE2-70 board each have a capacity of 256Mbits (32Mbytes).
Each chip is organized as 4M x 16 bits x 4 banks. The signals needed to communicate with a
chip are shown in Figure 1. All of the signals, except the clock, can be provided by the SDRAM
Controller that can be generated by using the Qsys tool. The clock signal is provided separately.
It has to meet the clock-skew requirements as explained later in the section below. Note that
some signals are active low, which is denoted by the suffix N.
EE Department
CIIT, Lahore
EE Department
Select the Timing tab to get to the window in Figure 4. Configure the SDRAM timing
parameters by setting the refresh command rate to once every 7.8125 microseconds and the delay
after power up to 200 microseconds. Click Finish. Now, in the window of Figure 2, there will be
a sdram module added to the design.
CIIT, Lahore
EE Department
CIIT, Lahore
EE Department
CIIT, Lahore
EE Department
Click Finish to return to the window in Figure 2. Connect the clock and reset output of system
clock clk_0 to the clock and reset inputs of the Clock Signal IP core. All other IP cores
(including the SDRAM) should be adjusted to use the sys_clk output of the Clock Signal core
instead of the system clock. Rename the Clock Signal core to clocks and export the sdram_clk
signal under the name sdram_clk. The final system is shown in Figure 6.
CIIT, Lahore
EE Department
Select the command System > Assign Base Addresses to produce the assignment shown in
Figure 6. To make use of the SDRAM, we need to configure the reset vector and exception
vector of the Nios II processor. Right-click on the cpu and then select Edit to reach the window
in Figure 7. Select sdram to be the memory device for both reset vector and exception vector, as
shown in the figure 7. Click Finish to return to the System Contents tab and regenerate the
system.
CIIT, Lahore
10
EE Department
CIIT, Lahore
11
EE Department
CIIT, Lahore
12
EE Department
CIIT, Lahore
13
EE Department
CIIT, Lahore
14
EE Department
Develop a Micro C/OS-II application Using the Nios II SBT for Eclipse
In this section, you use the Nios II SBT for Eclipse to compile a Hello Micro C/OS-II example
software program to run on the Nios II hardware system configured in the FPGA on your
development board. You create a new software project, build it, and run it on the target
hardware. This section presents the software development flow to demonstrate software running
on the hardware system you created in previous sections.
In this section, you perform the following actions:
Create a new Nios II Micro C/OS-II application and BSP project.
Compile the project.
Run the program on the target hardware.
When the target hardware starts running the program, the Nios II Console view
messages as shown in figure 9.
displays
CIIT, Lahore
15
EE Department
Lab participation
Viva
Total
10
Date
CIIT, Lahore
Obtained Marks
Instructor Signature
16