Custom Data Types
The ability to define custom data types makes it easy to adapt SystemC to any type of application. In the example discussed previously, the data that needs to be passed between modules consists of three large arrays. The following code implements this data:
struct rgb_plane {
int red_plane\[4096][4096];
int green_plane\[4096][4096];
int blue_plane\[4096][4096];
int width;
int height;
};
struct rgb_ptr_pkt {
rgb_plane *rgb_plane_ptr;
rgb_ptr_pkt& operator = ( const rgb_ptr_pkt& rhs) {
rgb_plane_ptr = rhs.rgb_plane_ptr;
return * this;
}
inline bool operator
rgb_plane_ptr);
}
};
inline
ostream&
operator const rgb_ptr_pkt& a )
{
os
return os;
}
void
sc_trace( sc_trace_file* tf, const rgb_ptr_pkt& a, const sc_string& name );
void sc_trace( sc_trace_file* tf, const rgb_ptr_pkt& a,
const sc_string& name )
{
sc_trace( tf, a.rgb_plane_ptr, name);
}
Four operations must be defined for each custom data type. The SystemC simulator uses these to perform the data movement between the modules. However, another one defined in the source project defines a type that contains the three planes and avoids the use of a pointer. This data type should be used if hardware synthesis is desired.
Visualizing Data
For complex algorithms, or those dealing with a variety of data streams of differing complexity, the challenge occasionally involves visualizing the data to see the accuracy of computation. That is especially true for 2D and 3D applications. SystemC also offers the ability to log signals into VCD (Value Change Dump) or WIF (Waveform Intermediate Format) files, creating an efficient way to view all signals of interest in parallel over short or long time intervals. Freeware VCD viewers exist to view these types of files. Most of the EDA tools can also read such files. These tools tend to offer more sophisticated ways of viewing signals.
The sample program introduces a novel concept of using small visualization pipelets embedded in each module. It uses the VTK to implement these pipelets. They’re run every time the module is run. The pipelet is initialized when the module is initialized and before it enters the main loop. It’s possible to customize the pipelet based on the nature of the data being operated on in that module. The visualization pipelet in the filter module depicts the data at three different points during the transformations.
Figure 5 shows the same pipelet being used to render the RGB planes in a window. The interactor controls the mouse interaction. The image in the window can be rotated, zoomed, and moved around for better viewing. VTK provides a rich set of tools to make the rendered visualization more insightful. The “VTK User’s Guide” in combination with many examples that can be found on the Web provide a more rounded understanding of VTK’s inherent strengths.
Managing Complexity
SystemC helps technical managers by enforcing an interface-driven style that’s also hierarchical in nature. After identifying the modules and defining the interfaces, they can be distributed over multiple resources and managed. Furthermore, they can be unit-tested with test benches. If the module is sufficiently complex, it can be divided further. SystemC-based development handles the boundaries of hardware and software in a seamless manner. The same code can be implemented in either domain, or any shade or combination of the two.
For algorithm developers and system architects, SystemC offers a consistent vernacular from the paper concept to implementation on any platform. This ability to provide a consistent interface is another way of managing the development of complex systems. Most current tools and languages are either too high-level to be efficient in translating to the implementation platform, or these languages are too low a level for algorithm developers or system architects.
The example visualization support shown here is especially effective in applications dealing with 2D and 3D data. Developers in genomic signal processing and biotechnology can also exploit these modeling techniques, because they need to model the behavior of complex organisms over time.
A number of good books written about SystemC help ease the learning curve. SystemC: From Ground Up, by David C. Black and Jack Donovan, provides detailed insights into using SystemC for implementing complex hardware/software systems. Both SystemC and VTK described in this article are complex software packages, and both of them have C++ as their building foundation. They’re both powerful in the capabilities they deliver, but when combined they provide a much-needed tool for current product and technology development. And like most good things in life, they cost nothing.
Additional Resources:
Download source code of a simple pipeline project from www.softserv-intl.com/complexity.zip
www.sy stemc.org/
http://public.kitware.c om/VTK/
|