2.0 Code Generation with Ptolemy
In the example of figure 7-(a),
a DSP target system is coded to estimate a power spectrum of a certain signal. At run-time, the estimated spectrum information is transferred to the host computer to be displayed on the screen. Thus, the host computer monitors the DSP system. In the next example in figure 7-(b), a DSP system performs a complicated filtering operation with a signal passed from the host computer, and sends the filtered result back to the host computer. In this case, the DSP hardware serves as a hardware accelerator for number crunching. By the wormhole mechanism in Ptolemy, as demonstrated in the above examples, we are able to make the host computer interact with the DSP system. In Ptolemy, a wormhole is an entity that, from the outside, obeys the semantics of one domain (in this case, it works like an SDF simulation actor), but on the inside, contains actors for another domain entirely.
Data communication between the host computer and the DSP target architecture is achieved in the wormhole boundary. In the SDF domain, data is transferred to the input porthole of the wormhole. The input porthole of a wormhole consists of two parts: one is visible from the outside SDF domain and the other is visible in the inside code-generation domain. The latter part of the porthole is designed in a target-specific manner, so that it sends the incoming data to the target architecture. In the output porthole of the wormhole, the inner part corresponding to the inside code-generation domain receives the data from the DSP hardware, which is transferred to the outer part visible from the outside SDF domain. In summary, for each target architecture, we can optionally design target specific wormholes to communicate data with the Ptolemy simulation environment; all that is needed to create this capability for a new Target is to write a pair of routines for transferring data that use a standard interface.
The interface code is generated by virtual target methods(wormInputCode(), wormOutputCode()), and the actual data transfer is also performed by other target methods (sendWormData(), and receiveWormData()). These methods were described in section 2.5. Unlike the simulation domains, the EventHorizon classes for the CG domain are not involved in the actual data communication, but perform other functions such as input data synchronization. A code-generation wormhole is only fired when all inputs are available from the simulation domain.
An example of a universe that contains a SDF wormhole interfacing to the DSP target is shown in figure 8. The SDF universe is used to here to display the output from a application running on the S-56X. The algorithm running on the DSP card is shown in figure 8. This is a very simple application, where a tone is being generated; the original signal, a upsampled (x 2) version and a downsampled (x 2) version is returned to the parent SDF universe. The code generated for the application shown in figure 8 is listed in section 7.1.
[Next] [Previous] [Up] [Top]