- At the command prompt, type
open Lab1_4_2.slx
to open the design shown in the following figure.
- In the MATLAB Command Window
enter:
MyCoeffs = xlfda_numerator('FDATool')
- Double-click the instance Gateway In2 to confirm the data is being sampled as 16-bit fixed-point value.
- Click Cancel to exit the Properties Editor.
- Click the Run simulation button to simulate the design and
confirm instance Spectrum Analyzer SysGen Fixed shows the filtered output.
As you will see if you examine the output of instance FIR-Fixed-Point (shown in the previous figure) System Generator has automatically propagated the input data type through the filter and determined the output must be 43-bit (with 28 binary bits) to maintain the resolution of the signal.
This is based on the bit-growth through the filter and the fact that the filter coefficients (constants in instance FIR-Fixed-Point) are 16-bit.
- In the MATLAB Command
Window, enter
sum(abs(MyCoeffs))
to determine the absolute maximum gain using the current coefficients.
Taking into account the positive and negative values of the coefficients the maximum gain possible is 1.2070 and the output signal should only ever be slightly smaller in magnitude than the input signal, which is a 16-bit signal. There is no need to have 15 bits (43-28) of data above the binary point.
You will now use the Reinterpret and Convert blocks to manipulate the fixed-point data to be no greater than the width required for an accurate result and produce the most hardware efficient design.
- Right-click with the mouse anywhere in the canvas and select Xilinx BlockAdd.
- In the Add Block entry box, type
Reinterpret
. - Double-click the Reinterpret component to add it to the design.
- Repeat the previous three steps for these components:
- Convert
- Scope
- In the design, select the Gateway
Out2 instance.
- Right-click and use Copy and Paste to create a new instance of the Gateway Out block.
- Paste twice again to create two more instances of the Gateway Out (for a total of three new instances).
- Double-click the Scope
component.
- In the Scope properties dialog box, select .
- Select
and confirm that the Number of input ports is 3. - Click OK to close the Configuration Properties dialog box.
- Select to close the Scope properties dialog box.
- Connect the blocks as shown in the next figure.
- Rename the signal names into the scope as shown in the following
figure: Convert, Reinterpret and Growth.
To rename a signal, click the existing name label and edit the text, or if there is no text double-click the wire and type the name.
- Click the Run simulation button to simulate the design.
- Double-click the Scope
to examine the signals.Tip: You might need to zoom in and adjust the scale in to view the signals in detail.
The Reinterpret and Convert blocks have not been configured at this point and so all three signals are identical.
The Xilinx Reinterpret block forces its output to a new type without any regard for retaining the numerical value represented by the input. The block allows for unsigned data to be reinterpreted as signed data, or, conversely, for signed data to be reinterpreted as unsigned. It also allows for the reinterpretation of the data's scaling, through the repositioning of the binary point within the data.
In this exercise you will scale the data by a factor of 2 to model the presence of additional design processing which might occur in a larger system. The Reinterpret block can also be used to scale down.
- Double-click the Reinterpret block to open the Properties Editor.
- Select Force Binary Point.
- Enter the value
27
in the input field Output Binary Point and click OK.The Xilinx Convert block converts each input sample to a number of a desired arithmetic type. For example, a number can be converted to a signed (two's complement) or unsigned value. It also allows the signal quantization to be truncated or rounded and the signal overflow to be wrapped, saturated, or to be flagged as an error.
In this exercise, you will use the Convert block to reduce the size of the 43-bit word back to a 16-bit value. In this exercise the Reinterpret block has been used to model a more complex design and scaled the data by a factor of 2. You must therefore ensure the output has enough bits above the binary point to represent this increase.
- Double-click the Convert block to open the Properties Editor.
- In the Fixed-Point Precision section, enter
13
for the Binary Point and click OK. - Save the design.
- Click the Run simulation button to simulate the design.
- Double-click the Scope
to examine the signals.Tip: You might need to zoom in and adjust the scale in to view the signals in detail.
In the following figure you can see the output from the filter (Growth) has values between plus and minus 1. The output from the Reinterpret block moves the data values to between plus and minus 2.
In this detailed view of the waveform, the final output (Convert) shows no difference in fidelity, when compared to the reinterpret results, but uses only 16 bits.
The final step is to synthesize this design into hardware.
- Double-click the System Generator token to open the Properties Editor.
- On the Compilation tab, ensure the Compilation target is IP catalog.
- On the Clocking tab, under Perform analysis select Post Synthesis and from Analyzer type menu select Resource. This option gives the resource utilization details after completion.
- Click Generate to compile
the design into a hardware description. After completion, it generates the
resource utilization in Resource Analyzer window as shown in the following
figure.
- Click OK to dismiss the Compilation status dialog box.
- Click OK to dismiss the
System Generator token.
Notice, as compared to the results in Step 1 (Figure 37: Lab1_1 Resource Analyzer Results) these results show approximately
- 45% more Flip-Flops
- 20% more LUTs
- 30% more DSP48s
However, this design contains both the original floating-point filter and the new fixed-point version: the fixed-point version therefore uses approximately 75-50% fewer resources with the acceptable signal fidelity and design performance.
- Exit the Vivado Design Suite.
- Exit the Lab1_4_2.slx worksheet.
In this part you will re-implement the design from Part 1: Designing with Floating-Point
Data Types using fixed-point data types, and compare this new design with the original
design. This exercise will demonstrate the advantages and disadvantages of using
fixed-point types and how System Generator allows you to easily
compare the designs, allowing you to make trade-offs between accuracy and resources
within the Simulink environment before committing to an FPGA
implementation.