9.5. Software Stream Macro Interfaces
Once an algorithm has been implemented in hardware and optimized (see Chapter 10), it may be capable of sustaining extremely fast data rates, possibly consuming and processing data every one or two clock cycles. Consequently, the software portion that supplies the data to the hardware should be able to output data as efficiently as practical in order to take advantage of the hardware implementation.
One way to reduce overhead in a software application is to reduce the use of function calls, which are inherently inefficient due to their need for stack-related overhead.
The standard method provided for opening, reading, writing, and closing streams is represented by the co_stream_open, co_stream_read, co_stream_write and co_stream_close functions. These functions may be used in hardware or software processes to set up and manage the communication of data across stream interfaces. These stream interfaces are subsequently implemented as buffered channels (FIFOs) on the hardware side of the interface and as low-level (memory-mapped) bus interfaces on the software side.
The overhead of making a simple procedure call to the Impulse C stream functions can require many cycles, potentially resulting in poor performance to the point of negating any potential benefits of hardware acceleration. The macro versions of these stream read and write functions therefore eliminate this function call overhead by using inline assembly instructions for a more efficient implementation.
For hardware processes you should always use the standard Impulse functions and observe the stream guidelines described in Chapter 4. For software processes, however, you may increase the performance of your stream I/O by replacing the co_stream_open, co_stream_read, co_stream_write, and co_stream_close function calls (which are procedural interfaces) with more direct calls that are provided in the form of the following Impulse C macros:
In general, you should defer the use of these macros until late in the development process in order to preserve hardware/software compatibility for your Impulse C processes. It is not possible or desirable to use these macros for hardware processes.