Professional Documents
Culture Documents
HCMUT
SoC on FPGA
Goal
Introduction
In this laboratory, the goals are to be able to understanding the embedded sstem design flow based on a FPGA. In the laboratory section, a short demonstration will be made at the beginning to instruct how to use the tools with the DE2 board. This final demonstration of this laboratory is to be able to realize a programmable interface for Nios2 system on DE2 board.
Manipulation
The relation between a bus (here the Avalon bus) and a programmable interface connected to this bus. The model of the programmable interface by the processor point of view. This is a register view. What has to be done in the interface when the processor accesses a certain address and how the module reacts. How to translate the characteristic of the interface in VHDL (Verilog). How to implement that (entity/architecture). How to integrate it in the full system. To realize practically the system, we are using the DE2 board.
2.3.1 Simple Nios II Design
In Quartus II: Create a Project and select a FPGA EP2C35F672C6 Open a schematic design file and save it (.bdf file) Create a system NIOSII with SOPC Builder Select the following components from the provided libraries: o NIOS II /s processor, with 4k byte instruction cache o Add on-chip memory SRAM, 32 kbytes with 32 bits width o Add epcs controller o Jtag interface: JTAG UART for debug purpose o Parallel port In 8 bits o Parallel port Out 8 bits o Save o Generate in VHDL (Verilog) o Exit What are the addresses of your different elements ?
2.3.2 Quartus II Design
The SOPC symbol has to be added to the schematic. Add Input and Output pins for Clk, Reset and Input (Switch0) / Output (Switch1) parallel ports. Add pins number by the way of the .cvs file. What pins are you using for your design Clk? Which pins do you connected for parallel ports In/Out? Compile the design and correct the errors. Connect the DE2 board on USB. Download the .sof generated you are programming the hardware FPGA Open again the NIOSII System (doube-click on the symbol)
Create a Working Space in your account, but NOT in the project directly. Create a Hello World project and try it. Select the small version!! Search for IORD() and IOWR() functions on the library generated (search for a io.h file). Search the system.h file and try to find the equivalence with the information provided in SOPC Builder. Modify your program for Reading the Switches and Writing the value to the LedR (as Output) and loop. Try your program and debug It step by step with Eclipse. How do you create the library? How do you compile your project for debugging? How do you specify the memory used for your program? How your program is downloaded on the board?
8 bits width Programmable direction for each individual bit through a Data Direction Register A direct Write/Read access to the Parallel Port Register A Pin Register to read data at the pin level A write access to specify selected bits to be modify as 1, and no change for the other unselected bits. The selected bits are those when a 1 is write at the bit position, the bits with a 0 are not modified. The Parallel Port Register is modified by this access. Same as previous access but for putting a 0. A write with a 1 will modify the port with a 0. The bits with a 0 writing are not changed.
What is the register map for your interface? How many wait states you need for your design on the Avalon bus? Create a new project to realize your programmable interface and simulate the read and write accesses in Quartus using the simulator Tools and the waveform editor.
2.4.2
Nios II Design
On the simple NIOS II design with the following components, add your parallel port design. For this function, you need to create your own library component. On SOPC Builder Create new component and provide the needed information. Generate the IP. Now it can be used as all the others components. Select NIOS II /s processor, with 4k bytes instruction cache Add SRAM 16kbytes with 32 bits width Add epcs controller Jtag interface Your Parallel port 8 bits (ParPort0) Your Parallel port 8 bits (ParPort1) Save Generate in VHDL (Verilog) Exit What are the addresses of your Parallel ports components?
2.4.3 Quartus Design
The SOPC symbol is added to the schematic. Add pins for Clk, Reset and ParPort0 (SW[7..0]) / ParPort1 (LEDR[7..0]) parallel ports Add pins number (search on the web site), they are the same as the previous laboratory. Compile the design and correct the errors. Connect the DE2 board on USB. Download the .sof generated you are programming the hardware FPGA Open again the NIOSII System (double-click on the symbol) Select NIOS IDE you will go to the Eclipse project manager
2.4.4 NIOS IDE
Create a Working Space in your directory, but NOT in the project directly or use a previous one. Program a InitPort() Function to select ParPor0 as input and ParPor1 as Output. Make a simple loop for Reading ParPort0 and copying on the ParPort1. What is in your InitPort() function? How do you make your copy loop? Write a small program on NIOS IDE to implement a led river with your parallel port.
Good luck!