How to use buffering for port input

  • 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 input

  • 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 sampled by a port until the processor is ready to input it.

The declaration

in buffered port:32 in_port = XS1_PORT_1A;

declares a buffered input port named in_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 port declaration using the colon. Input from the port is performed as normal.

in_port :> data;

At most one value is sampled by the port and inserted to the FIFO per period of its clock. If the FIFO is full, the oldest value is dropped to make room for the most recently sampled value.