This example shows how to create a custom step response-based CTLE block in Simulink® to model wired communication links of your own specifications. The custom CTLE block exhibits equivalent behavior as the default pole/zero based CTLE block from the SerDes Toolbox™. This example also illustrates:
how to use the MATLAB function blocks to model custom algorithms in Simulink,
how to include large data files into your model,
how to create custom Initialization Subsystem algorithms to perform Init (impulse based) optimization before the Simulink simulation starts, and
how to validate the model using the Simulation Data Inspector.
The first time you call the step response-based CTLE, it loads a data table in the memory. The data table contains a reference step response for each filter configuration. The CTLE resamples or interpolates the step response to the simulation time step, differentiates the step to obtain the impulse response, and then convolves this with the input waveform. It is easier to resample step response than impulse response due to the difficulty of properly capturing the peak of an impulse response.
Typically, the data table with the reference step responses is obtained from circuit simulations. But for this example, extract the step response from the default CTLE from the SerDes Toolbox to characterize its behavior. It is important to ensure that the time step of the characterization data is fine enough so that all relevant step response behavior is captured. Use 32 samples per symbol, which results in a time step size of 3.125 ps and is more than sufficient for this CTLE.
Create a CTLE object with the default peaking characteristics.
SymbolTime = 100e-12; SamplesPerSymbol = 32; dt = SymbolTime/SamplesPerSymbol; CTLE1 = serdes.CTLE(... 'SymbolTime',SymbolTime,... %Duration of a single symbol 'SampleInterval',dt,... %time step size 'DCGain',0:-1:-8,... %DC Gain 'PeakingGain',0:8,... %Peaking Gain 'PeakingFrequency',5e9,... %Peaking Frequency 'Mode',1); %Mode is fixed
For each configuration of the CTLE, stimulate the CTLE with an ideal step response excitation to extract the reference CTLE step responses and observe the output waveforms.
stimulus = ones(25*SamplesPerSymbol,1); stimulus(1:SamplesPerSymbol) = 0; numberOfConfig = CTLE1.ConfigCount; stepResponse = zeros(length(stimulus),numberOfConfig); for ii = 1:numberOfConfig CTLE1.ConfigSelect = ii-1; release(CTLE1); stepResponse(:,ii) = CTLE1(stimulus); end t1 = dt*(0:size(stepResponse,1)-1); figure, plot(t1,stepResponse) xlabel('time [s]'),ylabel('[V]') title('CTLE Step responses') legend(cellstr(num2str((0:(numberOfConfig-1))'))) grid on
Finally save the matrix of step responses, 'stepResponse', and the sample interval, 'dt', to a .mat file. Observe that each column of the matrix represents a different CTLE configuration. This example uses the filename 'myCTLEdata.mat' for the data. If you change the file name, then you also need to manually update the file references in the stepCTLE.m function and the Simulink Initialize Subsystem references.
If you already have your own CTLE behavior recorded from circuit simulations, you can put the data into the same file format as below, with the fields 'stepResponse' and 'dt' equivalently set. If your own CTLE is characterized by impulse responses, you can use the function impulse2step to first convert them to step responses.
Create the reference data file.
Use the SerDes Designer App to create a receiver model with a Pass Through and a CTLE block. This setup allows for a straightforward validation process to show that the step response based CTLE has the same behavior as the pole/zero based CTLE.
Open the SerDes Designer app.
Add a Passthrough block and rename it to 'StepCTLE'
Add a CTLE block.
Select the Channel block to open its Block Parameters dialog box. Include crosstalk by selecting Enable Crosstalk parameter. Having crosstalk enabled ensures that the impulse response matrix input to Init will have multiple columns during testing and so any custom Init code will need to correctly process multi-dimensional arrays. Ensuring proper behavior here will avoid later issues when the model is exported to IBIS-AMI.
Export the SerDes system to Simulink.
Modify the Simulink model to include the MATLAB function block and parameters to control the custom CTLE block. Open the Block Parameters dialog box for the Configuration block, then click on the Open SerDes IBIS-AMI Manager button and select the AMI-Rx tab. Under the Model_Specific parameter, select StepCTLE and click the Add Parameter… button. In the newly opened window, set Parameter name to Mode, Usage to In, Type to Integer, Format to List, List values to [2 0 1], and List_Tip values to ["adapt" "off" "fixed"].
Select StepCTLE under the Model_Specific parameter again and click the Add Parameter… button. In the newly opened window, set Parameter name to ConfigSelect, Usage to InOut, Type to Integer, Format to List, and List values to [0 1 2 3 4 5 6 7 8].
With the inclusion of the above parameters, the Simulink model view shows the StepCTLE subsystem in the StepCTLE window.
Add a MATLAB Function block to the StepCTLE subsystem and open it.
Copy the contents of the file stepCTLE.m in the MATLAB Function block.
From the MATLAB toolstrip, click the Edit Data button in the Editor tab to open the Ports and Data Manager dialog box. Select the SampleInterval parameter. In the General tab, change Scope from Input to Parameter and click the Apply button.
The stepCTLE function has two primary behaviors:
It loads the step response data, resamples it according to the simulation sample interval, and differentiates the step response to obtain the impulse response.
It filters (or convolves) the incoming waveform with the impulse response.
The first primary behavior is essential so that the stepCTLE has consistent behavior over changes in the simulation time step size.
Observe that this function utilizes persistent variables. Persistent variables have permanent storage in MATLAB similar to global variables. But unlike global variables, persistent variables are known only to the function that declares them. In a Simulink model, each MATLAB function block contains its own copy of persistent data. If a MATLAB function that contains a persistent variable is called from two different blocks, the model has two persistent variables. Also, each run of the simulation creates a new copy of the persistent data.
Observe the use of the coder.load function instead of the 'load' function to access the data in the .mat file. When this code is compiled, the data in the .mat file will be hard coded into the executable and is an excellent way of including large data files into the model.
From Simulink, connect the parameter blocks to the MATLAB function block. Delete the ConfigSelect write block as it will not be used. Also delete the Pass Through System object block.
Add a display block from the Simulink Library Browser to observe the adapted value of ConfigSelect parameter. To observe the adapted ConfigSelect parameter of the SerDes Toolbox CTLE, also add a display block under the CTLE mask. You can then verify that both blocks adapt to the same configuration select.
The SerDes Simulink model can perform Init (impulse-based) analysis before the zero simulation time with the Initialize Subsystem block. Open the Init block in the Rx subsystem. Click the Refresh Init button and then the Show Init button to bring up the MATLAB Editor. Disregard any warning messages about refresh Init skipping the MATLAB Function block.
Cut and paste the contents of CustomUserCodeForInit.m in the custom user code area of the Init function.
Observe that like in the stepCTLE function, this code loads the step response data file, then resamples it and converts to impulse responses. This code additionally performs optimization to select which of the many CTLE configurations 'best' equalizes the signal using the SNR metric as the goodness criteria. Once the ConfigSelect has been determined, the CTLE response is applied to the primary impulse and crosstalk impulse responses.
An alternative to using MATLAB function blocks is to use System Objects. System objects do not require the use of persistent variables (which are not currently allowed in the Initialize Subsystem block) and allow for better code sharing between the Simulink model version of a block and the Initialize subsystem version of the block like many of the System objects in the SerDes Toolbox.
To validate that the step response based CTLE is equivalent to the default CTLE from the SerDes Toolbox, log the output waveform and perform two simulations:
Enable the step based CTLE and disable the pole/zero based CTLE
Disable the step based CTLE and enable the pole/zero based CTLE
The top level output waveform of the model is already logged (as shown by the broadcast or wifi symbol) for use by the post-simulation analysis results.
Open the SerDes IBIS-AMI Manager dialog box from Configuration block. Set the Mode of the pole/zero based CTLE's to off. Set the Mode of the step based CTLE to adapt and run the simulation.
Then set the Mode of the pole/zero based CTLE's to adapt. Set the Mode of the step based CTLE to off and rerun the simulation
From the Simulink toolstrip, click the Data Inspector button from the Simulation tab. Change the line color of the most recent simulation results and zoom in on the first few symbols of the simulation. Observe how the only difference between the waveforms is a one symbol delay thus validating the accuracy of the step response based CTLE. The one symbol-time delay is due to the step response characterization data and while this can be removed, it doesn't make a large impact on SerDes simulations or analysis.