Signals 
 Home
Matlab Tutorial 
 Links
Discrete  
 Convolution
Continuous  
 Convolution
Cross Correlation
Fourier Transform
Exam 1 Material
Exam 2 Material
Final Exam Material
Fourier Series 
  via FFT
Xtreme DSP
Other Links
Celoxica
Caron Project

Background:

Handel-C is a high level programming language designed to enable compilation of programs directly in to hardware, which is implemented on Field Programmable Gate Array (FPGA). Handel-C is based on the syntax of conventional C (ANSI C), with additional extensions to take advantage of the features of hardware. As Handel-C is high level it is possible to convert a Software Algorithm in to a hardware implementation with the greatest of ease. Handel-C provides an alternative method to hardware design, compared to other methods of hardware design such as Schematic Capture methods and Hardware Definition Languages (HDL). If Hardware Definition Languages are thought of as the Assembly Language equivalent in Hardware Design. Then Handel-C represents the equivalent of a High Level Language in Hardware Design.

To aid the Handel-C programmer it provides macros, similar in concept to the#define directives used by C pre-processors, but which perform more than just textual manipulation of the source. Macros fall into two categories, expressions and procedures.

Macro expressions

Macro expressions themselves are divided into two categories, shared and non-shared expressions. The syntax for both is similar, and is as follows:

macro  expr normal_expr(x) = x + 2;
shared expr shared_expr(x) = x + 3;
int 8 var1, var2;
 
var1 = normal_expr(var2);
var2 = shared_expr(var1);

Either form of macro expression can take any number of parameters. Shared expressions generate hardware only once, the compiler producing the necessary multiplexors for the inputs if there are any, whereas non-shared expressions generate hardware each time they are used, and consequently do not need any multiplexors.

Macro expressions are allowed to be recursive, and complex functions can be built up using select expressions, that direct the compiler to choose one of two expressions, depending on a value that must be a compile time constant. This allows single macro expressions to be used with different width expressions without having to be parametrised on variable width, for example.

It is the responsibility of the programmer to ensure that shared macro expressions with parameters are not used by different sections of code in the same clock cycle. Non-shared expressions, as they generate hardware for each invocation, can be used without restrictions.

 

Macro procedures

Macro procedures are declared and used with the following syntax:

macro proc macro_proc(n) {
    par {
        x = x + n;
        y = y - n;
                                }
}
 
unsigned 8 x, y;
 
void main() {
    macro_proc(6);
}

Hardware is generated for each time the procedure is used. Any number of parameters is allowed, but macro procedures cannot be recursive. However they are allowed to use recursive expressions if required. Macro procedures are a useful device to divide Handel-C code up into sections.

Introduction:

This tutorial is to give you a brief introduction into how Handel-C works through the use of a program called bounce. Bounce is a program that was written in Handel-C to display a square that bounces off the wall of the monitor. There are 3 include files that we will not be concerned with, but I will tell you a little bit about each of them. As with C or C++ you need to include a stdlib.h file and for this program you also need syncgen.h, which is the Sync generator and the dlabunm.h, which is the macro and pin definition file for the digilab board. The file that we will be dealing with is the source file called bounce.c. You will be saving the files into directory. Once you have saved this file you will then be able to make changes to the square size and speed. Your ultimate goal is create a netlist that will be dropped down onto the FPGA and then from there your bouncing square will appear on the monitor.

This is the directory that we were talking about so that the students could destroy the original.

Lab

First step:

On the desktop open the DK1 Design Suite. If you cannot find it on the desktop, then go to "START", select "PROGRAMS", DK1 Design Suite. You should get a blank workspace area that looks like image 1. Go to the "FILE" dropdown menu, select "OPEN WORKSPACE" and select "BOUNCE."

The workspace should open and you should be able to see the bounce.c source file and the header files. Go to the "BUILD" dropdown menu, select "BUILD BOUNCE", at the bottom, there is a window that will open, which will compile & configure bounce.c if changes have been made. At the end it will tell you the errors and warnings if any have occurred.

You have now just created the netlist, which is a gate-level text file representation of a circuit. The netlist suffix is edif (electronic digital interchange format). After you have your .edif file you will create a bit file, which will load the program onto the FPGA.

Second step:

Minimize the DK1 application and open the Xilinx Design Manager, which can either be found on the desktop or in the "PROGRAMS" directory under the "START" menu. Go to the "FILE" dropdown menu, select "NEW PROJECT."

A new window will open and inside the box next to "INPUT DESIGN" click the browse button and search through the files until you end up with the following C:\DK1Work\digilab\bounce\EDIF\bounce.edf. After that is done in the next box next to "WORK DIRECTORY" add your name to the end of the file. Click "OK", twice. 

You have now created a project that will be downloaded onto the FPGA. Click the implement button in the upper left hand corner. This will start the Flow Manager, which is a place and route function for the FPGA. The netlist file is taken and placed onto the FPGA and after a few moments the information is routed together to make the .bit file that will allow you to see your bouncing square on the monitor.

Third step:

On the right hand side there are bunch of buttons. Click on the third one from the bottom, which should say Hardware Debugger. The Debugger program will open and you will see your bounce.bit file. Double click on it, click the "OK" button and watch you code come to life on the monitor.

You can go back into the bounce.c file located in DK1 application and change the border width, speed, and size of your square.

[Signals Home] [Matlab Tutorial Links] [Discrete  Convolution] [Continuous  Convolution] [Cross Correlation] [Fourier Transform] [Exam 1 Material] [Exam 2 Material] [Final Exam Material] [Fourier Series  via FFT] [Xtreme DSP] [Other Links] [Celoxica]