USING EASYHDL TO SPECIFY DIGITAL SIGNALS

Declaring the Output(s)

The output pin(s) for a digital scriptable generator should be declared as PIN variables. For example:

PIN Q        // Single bit output

PIN D[0..7] // 8 bit data bus

The lower and upper bounds of an array must both lie in the range 0 to 255, so a single declaration can describe a bus of up to 256 bits.

A local generator script contains an implicit declaration of PIN OUT.

Prefixing the name with an exclamation mark declares the pin as inverted, so that the state the script assigns is applied to the net the other way up:

PIN !NRESET // Inverted output

Where the generator has a name that is not a valid EasyHDL variable name you can use an ALIAS command. Everything up to a comma or the end of the line is taken as the existing name, so a name containing spaces needs no quoting:

ALIAS OUT=Test Signal

PIN OUT

Program Flow

When an EasyHDL script is used to specify digital signals, the entire script is executed from the top and executes until one of the following conditions is met:

  • An END statement is executed.
  • The last statement in the script is executed.
  • A SLEEP or WAIT command causes suspension of the script.

Once an END statement or the end of the script has been reached, it will not be re-invoked until a CALLBACK or TIMER event is scheduled. These commands will cause the script to be resumed (if suspended) or else re-executed from the top with a corresponding event id. Note that there is only ever one thread of execution; if an event occurs whilst the script is suspended or sleeping then execution always resumes at the following statement.

Typically, a digital generator script will consist of output assignments interspersed with SLEEP or WAIT statements so as to create the desired timing. For example, the following code will 'bit bang' a serial data stream from a variable at 9600 baud.

// Bit Bang a single character

// 1 Start bit, 1 Stop bit and no

// parity are assumed.

INT d, j

TIME BITTIME=104u

// Start bit

OUT = 0

SLEEP FOR BITTIME

// Data bits

FOR j=0 TO 7

OUT = d & (1 << j)

SLEEP FOR BITTIME

NEXT j

// Stop bit

OUT = 1

SLEEP FOR BITTIME

Specifying Output Transitions

You can specify the output of a digital generator in several ways:

  • As an instantaneous value (transition with zero delay)
    OUT=dout
  • As a future value
    OUT=vout AT time

Multiple future assignments may be scheduled at once. For example, a single pulse could be described with

OUT=1 AT time

OUT=0 AT time+width

  • As a timed transition.

    OUT=dout AFTER delay
    OUT=dout AFTER tdlh,tdhl

In the case of a timed transition with two parameters, tdlh is used when the output is rising (low to high transition) and tdhl is used when it is falling (high to low transition).

See Also:

BOOL and PIN Types

Assigning To Variables

The SLEEP Command

The WAIT Command

The ALIAS Command