How to use buffering for port output

  • version

    1.0.1

  • scope

    Example.

    This code is provided as example code for a user to base their code on.

  • description

    How to use buffering for port output

  • boards

    Unless otherwise specified, this example runs on the SliceKIT Core Board, but can easily be run on any XMOS device by using a different XN file.

The XMOS architecture provides buffers that can improve the performance of programs that perform I/O on clocked ports. A buffer can hold data output by the processor until the next falling edge of the port’s clock, allowing the processor to execute other instructions during this time.

The declaration

out buffered port:32 out_port = XS1_PORT_1A;

declares a buffered output port named out_port, which refers to the 1-bit port identifier XS1_PORT_1A. Note that the size of the port FIFO is specified as part of the buffered port declaration using the colon. Output to the port is performed as normal.

out_port <: counter;

The port buffers the data so that the processor can continue executing subsequent instructions. On each falling edge of the clock, the port takes the next bit of data from its buffer and drives it on its pins.