User manual
DSM tutorials
Now define a Handel-C interface to attach this pin to a Handel-C variable. Use the Handel-C bus_out
interface as the pin is an output from the device driver. Define a variable to serve as the expression
output on the interface:
static unsigned 1 LedValue = 0;
interface bus_out () Led0 (unsigned 1 data = LedValue) with {data = LedPin};
Note that making the
LedValue variable static prevents it from being visible outside the file it is
defined in.
Implement a macro procedure to set a value on the LED:
macro proc SetLED (Value)
{
LedValue = Value;
}
The device interface in this case is sufficient to use as the API since there are no command sequences
or timing constraints required by the device.
RAM device driver
This PSL tutorial example demonstrates how to implement a device driver for asynchronous static RAM.
The timing information for this example is taken from the data sheet for Cypress Static RAM part number
CY7C1049B-25. You can obtain the data sheet from
http://www.cypress.com. A similar RAM
device is used on some versions of the Celoxica RC1000 board.
Handel-C offers special support for RAM devices that allows an external RAM to be accessed in a
Handel-C program using C array syntax. The Handel-C language semantics state that assignments
take one clock cycle. Reads and writes using the built in array syntax must therefore complete within a
single Handel-C clock cycle. This is fine when the speed of the RAM is comparable with or faster than
the clock speed of your design. However, if the RAM is slower than your design you may prefer to use
multi-cycle procedures instead. This allows you to control how many clock cycles a read or write takes
and therefore your device driver can be more flexible with regard to the system clock frequency. This
example shows two RAM driver implementations. The first uses the Handel-C built in RAM support, and
the second uses macro procedures.
The RAM device driver API requires two functions, read and write. Here are the prototypes:
/* Read a datum from RAM at specified Address into (*DataPtr)
* Parameters: Address : input of type (unsigned 16)
* DataPtr : input of type (unsigned 8)*
*/
macro proc RAMRead (Address, DataPtr);
/* Write a datum from Data into RAM at specified Address
* Parameters: Address : input of type (unsigned 16)
* Data : input of type (unsigned 8)
*/
macro proc RAMWrite (Address, Data);
This device has the following connections:
• 8 bit bi-directional data bus
• 16 bit input address bus
• active low chip select pin
• active low write enable pin
• active low output enable pin
www.celoxica.com
Page 32