Embedded Codesign with C and VHDL

WARNING: These pages are under  reconstruction

Quick jumps

simple standalone pwm for the DE0. Open the quartus project and read the .vhd file for documentation.
New ts7300 stuff.
Controlled assessment guidelines and dates.
Assignment Specification 11 - 12 and an example of a succesful completion. (16MB movie file)

Interesting Stuff

A new (almost) completely open source FPGA based board, Linux on the OpenRISC processor here. The European Space Agency are big fans of opencore processors. A comparison of soft-core processors can be found here.


2011 demo's

• Another example of a succesful completion demo'd w/e 25/02/11. (16MB movie file)
• Yet another example of a succesful completion complete with dramatic music

Important stuff

HDL coding guidelines
Code Inspection and more coding standards for hardware & software.
10 hooks to integrate into your hardware, &plus paper on hardware/firmare interface design. You have to register for them though.
Top Ten Usability Mistakes . Also have a browse through the articles on this site
Selecting an embedded OS
RTOS lecture slides
SOPC peripherals programmers guide
DE0 User Manual with pin configuration information

Useful stuff

Official module description.
Papers that you should read.
Keypad info

Interesting stuff

• A couple of useful links if you want to have a go at implementing a vga controller ...
simple pong game with hard coded screen pattern. I have a vhdl version available. It has a good discussion of how vga controllers work.
stand alone vga controller
Webcast from Mentor Graphics on selecting an embedded OS.

***************************************

Introductory lecture slides. The two blank (black) slides are the video clips of succesful coursework. Replacement links...

******************************************

Using the NIOS II IDE video


Is their argument for using a soft-core processor a good one?

******************************************

Setting Up Quartus for the first time

Do this first ......... One time only

Copy this freertos_setup_11.sh script to your home directory; Not the desktop!

Make the setup script executable and then execute it.

You should only need to do this once. However there is a bug in the script so

After running the script enter

   . .bashrc

This will set up your environment, then rerun the freertos_setup_11.sh script again. This time it will unpack the VHDL project archives.

***************************************

Reading List

0: Down and dirty with HW-SW co-design

1: A paper, by Giovanni De Micheli & Rajesh K. Gupta, which gives a useful overview of where hardware/software codesign has evolved from.

2: A discussion on the extent to which software is taking over from hardware. The changing role of software as hardware.

3: Formal Hardware Specification Languages. An overview paper.

4: ESA Discussion Document : 'Using VHDL Cores in System-On-A-Chip Development'.

5: ECCS Software Guidelines in Space Engineering : An overview of the complete guidelines for Management, Engineering and Quality in European Space Engineering. E-40B is worth browsing. It can be found on this page



Code Inspection & Firmware Standards

The following documents and examples should be used as a basis for your own teams standards documents and code review process. The code review/inspection will form part of the assessment for this module.


Up arrowPage Top

TS7300 Information

Data sheet for the new LCD screens

is here. The example code from the TS7300 website is on kenny ...

  /usr/local/ts-7000/samples/lcdmesg.c

A largish user manual for dot matrix character LCD screens full of really useful detail from Optrex Corporation. Check timing details against the data sheet for the specific screen that you are using though. See also this very detailed website.

Bit 7 of the LCD not working? Turn off DMA to enable this bit. Example code to do this is in toggle_dio1.c. the relevent bit is here. Just paste into the initialisation section of your programme.

Schematics, corrected and annotated WARNING: These are large files in order to preserve the detail.( 14Mb - 75 Mb )

Modified OpenCore files for the FPGA

There are two main hardware design files, ts7300_top.v and ts_7300_usercore.vhd. They have both been heavily modified to provide tristate controlled input and output on the 40 pin header. The pins can be set individually for either input or output. Some of the pins have predefined functions which are preserved.

With Hardware Keypad Controller:

This one includes an example of adding your own component into the usercore. Needs a bit of tidying up but synthesises. here. It integrates a keypad scanner. I haven't tested the integrated version but the stand-alone vesion works fine. The clock divider probably needs adjusting to suit the wishbone clock. It also includes potential for an interrupt on receipt of a key press (plus debounce). The interrupt is commented out at present.

NOTE... The registers implemented with this core are different to the standard model refered to below. This is particularly important when using mem-debug with this core. The step by step example for talking to the keypad will not work, neither will the keypad.c example. You must write a C programme to talk to the integrated keypad controller.

Standard Modified TS7300:

Quartus project archive here. Download to a convenient location and use Quartus to unarchive it. Start Quartus and use File -> Open Project, browse to the locatation of the archive file (yellow icon). This will unpack the archive. Select the white icon when you next open the project.

Example software: Copy and unpack C code examples to a suitable place, either on the host or on the target if you are developing and compiling on the target board. It's a .tar.gz file so tar -tzvf ts7300_code.tar.gz will display the contents and directory structure. ( swap the -t for -x to actually extract the contents.). Note that these will have to be cross-compiled for the arm9 and the executables copied across to the board.


cross_compilers: an aside

The example Makefiles expect the environment variable CROSS_COMPILE to be set. If you haven't already got your own local copy of the cross-compiler tools, or your 'build-root' went horribly wrong then you can use the system default.

Either execute the following statements on the command line before compiling, or add them to your .bashrc file. Remember to alter them if cross-compiling for other architectures.

CROSS_COMPILE=/usr/local/gcc-3.3.5-glibc-2.3.2/arm-linux/bin/arm-linux-
export CROSS_COMPILE

5: Add the file toggle_leds.c to the programs directory and edit the Makefile to include it in the build.

6: Open up Quartus and build the opencore project. You may need to add the ts_7300_usercore.vhd file in the project ->add/remove files menu. If all goes well then copy the ts7300_top.rbf file to the ts7300 board.

7: Log in to the target board as root and run load_ts7300 ts7300_top.rbf; this will reconfigure the FPGA with your new image file. Both the red and the green leds on the FPGA side should stay off.

8: Assuming that you have compiled the example programs and the mem_debug utility, then from the programs directory ... First read ( and be confused by ) an overview of the register setup in the FPGA as seen by mem_debug .... now play with the following.




Now you can switch them on and off using mem_debug

Note that mem_debug address offsets are

0x00 vga_reg/vga_read
0x04 vga_enable
0x08 dio2_reg/dio2_read
0x0c dio2_enable
0x10 misc_reg/misc_read
0x14 misc_enable

Using mem_debug:

mem_debug address #pages

address must be hex, we want the memory at 0x72A00000 from the arm's perspective.

pages are 4kbytes, only need one page

Use the following:-


./mem_debug -a 72A00000 1

results in

  ?              Help
  dw addr len    Display len words starting from  addr
  db addr len    Display len bytes starting from addr
  cw addr val    Change word at addr to val
  cb addr val    Change byte at addr to val
  q              Quit

  Notes:
    * addr, len, and val are interpreted as hex values
    * addresses are always byte based
    * addresses are offsets relative to the base address

CMD > 

executing the following

CMD> dw 00 20

should result in something like

72A00000: 00000000 00000000 00000000 00000000 
72A00010: 00000000 00000000 DEADBEEF DEADBEEF 

CMD> cw 14 0c

will enable output for the 2 leds

CMD> cw 10 00

will turn them both on

CMD> cw 10 04

will turn the green one off.

You can connect the keypad, with adapter board, to the vga pins as follows. Identify the flyleads from the adapter board with the help of this image.

identifying flyleads on adaptor

This simple example enables output to all four columns, we'll then write 0b1110 to those four outputs to activate one column. Repeated reads while pushing each row button will give a different value for each row.

./mem_debug -a 72a00000 1
CMD> cw 04 3e0  will enable the required outputs
CMD> cw 00 1c0  writes 1110 to the columns of the keypad

CMD> dw 00 20 no buttons pressed
                 *
72A00000: 00007DDF 000003E0 00000010 0000FDFF 
72A00010: 0000000C 0000000F DEADBEEF DEADBEEF 

CMD> dw 00 20 top row
                 *
72A00000: 00007DDE 000003E0 00000010 0000FDFF 
72A00010: 0000000C 0000000F DEADBEEF DEADBEEF 

CMD> dw 00 20 next row
                 *
72A00000: 00007DDD 000003E0 00000010 0000FDFF 
72A00010: 0000000C 0000000F DEADBEEF DEADBEEF 

CMD> dw 00 20 next row
                 *
72A00000: 00007DDB 000003E0 00000010 0000FDFF 
72A00010: 0000000C 0000000F DEADBEEF DEADBEEF 

CMD> dw 00 20
                 *
72A00000: 00007DD7 000003E0 00000010 0000FDFF 
72A00010: 0000000C 0000000F DEADBEEF DEADBEEF 

A simple example C program to test the keypad here.


Up arrowBack to TS7300 stuff
Up arrowPage Top


Keypad datasheets etc
Scan of the datasheet for the Keypad. PNG format file.
Scan of another datasheet for the Keypad. PNG format file.
Open Cores Keypad Scanner in Verilog
An excellent Keypad Scanner Howto from the winpicprog website.
Useful keypad stuff for the faint-hearted.
keypad vhdl , a cut-down version of the code from the previous link.
Quartus project archive with (untested) pwm. The file my_pwm1.vhd is the toplevel for integrating into the SOPC_Builder.
Lab Worksheets and fixes FAQ

I think I've got a damaged TS7300 board.

• If the board appears to boot & there is activity on the ethernet lights but you have no serial connection then check the following :

How do I stop my command prompt getting so long?

• Currently the default prompt is set to show your entire path. The prompt configuration is in an environment variable $PS1. Typing echo $PS1 at the command prompt to see the current setting. Details of the settings can be found in man bash. A better command prompt to replace that ridiculously long default is one that gives username@machinename:current directory in the title bar of the terminal and a simple bash$ as a prompt. Copy the following into your .bash_profile file, which is a hidden file in your home directory, log out and log back in again to effect the changes. Alternatively just type it on the command line to try it out.


      export PS1="\[\033]0;\u@\h: \W\007\]bash$ "

If you use script to capture command line sequences then this particular prompt will result in garbage in your script file.

It also turns the keyboard beep on unfortunately. To remedy this try one of the following, the first is a 'do once only' will be active from next login


    echo "set bell-style none" > $HOME/.inputrc

    xset -b


Up arrowPage Top
Up arrowBack to FAQs

Up arrowBack to FAQs
Up arrowPage Top



Under reconstruction below this point

Summary instructions for building the nios3.2 cpu on the Apex20ke. ( Text version to be done yet)

Assignment 1 related links:

Jack Ganssle's Firmware standards Manual. You should use this as a basis for your own standards document.

Jack Ganssle's Code Review Guidelines. You will be expected to take part in code review for both VHDL and C as part of this module.



Overview of the EMU robot arm and servos
Emu arm data 1 (.pdf file)
Emu arm data 2 (.pdf)
Emu arm data 3 (.pdf)

srec2flash local copy with default address of 0x100000 and for NIOS v3.2, kindly modified by Dave to fix the borken erase routine. Now erases 16k blocks


altera pwm pre v6.0
Quartus archive file of just the pwm, with simulation file.

Another pwm example here.

Useful Links


Pull your finger out time! How to build a reconfigurable games platform in six hours flat! MissionPossible2006.pdf


Apex 20k Nios development board hardware manual Contains pin mappings between the fpga and the buttons, leds and other peripheral devices.
Nios 3.2 Software Development Manual. A local copy for the cpu & gnutools that we are using.
The Insight debugger homepage. Used as a front end to nios-gdb.
Altera's main Literature Page
Adding components under SOPC for the NIOS I 3.2
Associated design files (zip) for the NIOS I 3.2

Buses

Wishbone Bus Specification
Avalon Bus Specification

Useful Newsgroups

and Mailing lists/sites


Valid HTML 4.01! Viewable With Any Browser