
4–6
Chapter 4: Using MegaCore Functions
MegaCore Function Design Example
Adding Stimulus and Scope Blocks
To create a sample design to test the low-pass filter by feeding the filter two sine
waves ( Figure 4–4 on page 4–8 ), follow these steps:
1. Add two Sine Wave blocks (from the Simulink Sources library).
1
DSP Builder automatically gives the second block a unique name.
2. Use the Block Parameters dialog box to set the parameters for the Sine Wave block
( Table 4–1 ).
Table 4–1. Parameters for the Sine Wave Blocks
Value
Parameter
Sine Wave
Sine Wave1
Sine type
Time
Amplitude
Bias
Samples per period
Number of offset examples
Sample time
Interpret vector parameters as 1-D
Sample based
Use simulation time
64
0
200
0
1
On
Sample based
Use simulation time
64
0
7
0
1
On
3. Repeat Step 2 for the Sine Wave1 block.
4. Connect the outputs from the Sine Wave and Sine Wave1 blocks to an Add block
(from the Simulink Math Operations library).
5. Add an Input block (from the IO & Bus library in the Altera DSP Builder
Blockset ) and connect it between the Add block and the ast_sink_data pin on the
my_fir_compiler block.
6. Use the Block Parameters dialog box to set the parameters ( Table 4–2 ).
Table 4–2. Parameters for the Input Block
Parameter
Bus Type
[number of bits].[]
Specify Clock
Value
Signed Integer
8
Off
7. Add a Constant block (from the IO & Bus library) and connect this block to both
the ast_sink_valid and ast_source_ready pins on the my_fir_compiler block.
8. Add another Constant block (from the IO & Bus library) and connect this block to
the ast_sink_error pin on the my_fir_compiler block.
DSP Builder Handbook
Volume 2: DSP Builder Standard Blockset
November 2013 Altera Corporation