welcome to the HDL coder video series in this video series we will learn a
popular production proven path to take a MATLAB digital signal processing
algorithm through similan fixed point designer and HDL coder to target an FPGA
the first part of the video series we have discussed the strength of MATLAB
and Simulink and provided an overview of the HDL coder self guided tutorial
available on the math works file exchange website in this part of the
video series we will pay attention on implementing the Simulink model for the
pulse detection algorithm and compare it with the golden reference before we
create the Simulink model run the pulse detector reference algorithm this will
initialize all the parameters in the MATLAB workspace which we will pull into
the Similan model during the build to stream the data in the Similan model we
will use the signal from workspace block which will stream the receive signal one
sample at a time the sample data is passed to the discrete fi our filter
block with its coefficients referencing the core filter variable enable logging
of specific signals during the build stages of the Similan model we will
utilize the log signals to verify the output of the Similan model with the
golden reference algorithm to implement the hardware friendly peak detector use
the raw sum of the square of the real and complex magnitudes since using
complex operations such as square root will end up being resource expensive to
evaluate the magnitude square the signal is split into its real and imaginary
components with the following blocks
enable the signal dimensions and port data to visualize the data changes in
Simulink to detect the peak the tab delay block buffers the magnitude
squared signal into 11 samples to create the sliding window
to implement the above peak detection we will copy the hardware friendly
algorithm in the Simulink model using the MATLAB function block
copy and paste the algorithm in the MATLAB function block we will modify the
algorithm to work with the buffered sample data and define the window land
variable as a parameter this method enables to detect the pulse immediately
as this processes the data sample that follows the pulse as they arrive in
addition this technique avoid storing the entire data sample in a fixed Ram
the parameter argument in the MATLAB function block take the value from the
MATLAB model workspace clear the tunable option window Len must be a constant
expression for cogeneration purpose the middle sample in the stored 11 samples
is compared to the other 10 to see if it's the largest of the Levin and if so
if it is larger than the threshold we specify the threshold is the key for
identifying the peak versus all the local ones as we slide the window
you
the output of the peak detection implementation signals mid sample and
detected our inputs to a unit delay enable block which will hold the peak
value for display when the detected signal is true to visualize the outcome
connect a display block using the test bench script pulse detector v1 we will
run the output comparison of the MATLAB golden reference and the Similan
hardware implementation model the comparison proved that the Similan
streaming model matches with the MATLAB reference and the error is just a
floating-point precision error in the second part of this video series on the
HDL coder we have implemented the hardware implementation in Simulink and
compared it against the MATLAB golden reference we have also demonstrated the
seamless interaction between MATLAB and Simulink environments during the
Simulink model built in the next video we will prepare the Simulink model for
HDL code generation