When creating a DSP design, one of the most important parameters to consider is the spectrum. In Simulink, the spectrum can be easily displayed using a spectrum scope.
Left-click the canvas and type
spectrum
.Connect the spectrum scope at the output of the last filter (the Channel Filter):
Set the Stop Time of the simulation to inf.
Run the simulation. The spectrum scope should display similar to the following:
Now add a block coming from a standard templated C++ kernel which source is in the directory
aiecode_src
. This function will be a frequency shift operation that will be placed after the downsampling chain.Select the block AIE Kernel from the User-defined Functions section of the AI Engine Library and place it in the canvas:
Double-click the block; a GUI will display. Populate it with the following data:
Kernel header file:
aiecode_src/FreqShift.h
Kernel function:
FreqShift
Kernel source file:
aiecode_src/FreqShift.cpp
Click Import. A new GUI displays. FRAME_LENGTH is the template parameter. Its value is
256
because at this stage this is the size of the data frames. The input and output ports have also the same size:256
samples. Click OK.Place this new block between the ‘AIE FIR Channel’ and ‘To Fixed Size’ blocks. Grab the ‘FreqShift’ block from the Reference Chain Simulink design, and place it after the ChannelFilter Simulink block. Your design should now look as follows:
Click Run. The new filter will get compiled and a new spectrum will be displayed:
Switch the Stop Time back to
5000
and verify that the difference is still 0.Developing an AI Engine graph in Model Composer is relatively straightforward. What you have learned here is that you can easily place a spectrum scope within the design at the output of a design, but actually it could be placed anywhere in between two blocks without modifying anything in the kernels and the graph. Furthermore, Simulink has a lot of specific blocksets that can be used to generate test vectors, create a reference model, and compare the signals at any point in the design.
If you want to save some data in a workspace variable for some more complex analysis. This can be done using the Variable Size Signal to Workspace block within the AMD Toolbox –> AI Engine –> Tools blockset:
All the simulations that occur in Simulink are the so-called ‘Emulation-SW’. These types of simulation are bit-exact, but they do not provide any information about timing.