Main Content

Optimize DDR5 Write Transfer Using Digital Twin

This example shows how to optimize the on-die terminations (ODT), controller Tx FFE equalization settings, and SDRAM Rx DFE equalization settings for a DDR5 write transfer.

A digital twin is a software that emulates a hardware system. You can use it to evaluate the hardware before building, to optimize the performance of the hardware, and to develop hardware training techniques.

Setup Project

Extract the example project OptimizeDigitalTwin.zip attached with this example.

unzip OptimizeDigitalTwin.zip

Open the interface interface1 of the example project using the Parallel Link Designer app.

optimize_digital_twin.png

The example project has a single sheet sheet1 that has a generic DDR5 controller DQ and two generic DDR5 SDRAMs.The SDRAM IBIS file specifies 9 different DQ impedance settings. The controller Tx has 4 FFE taps. The settings of taps of -1, 1, and 2 determine the value of tap 0. The Rx has 4 DFE taps.

The variables that are not searched are set to only one value. Since the project mimics hardware settings, the corners (etch, process, interconnect variables) are set to have one value. The adaptation mode of AMI equalization parameters is set to fixed.

The permutation solution space defines the search space for the ODT, FFE, and DFE settings.

The project contains one transfer in a schematic sheet. To use a statistical engine to perform simulation analysis, STAT Mode is selected in each schematic sheet. This example searches the permutation solution space of a signal integrity project using genetic algorithm. Then, it switches to Case Mode to reduce the number of simulations needed to run. This switch between permutation mode and case mode is automatically done by the genetic search algorithm used in this example. For more information about STAT mode, case mode, and permutation mode, see STAT Mode and Solution Space.

Note: In this example, the solution space has already been populated for you and switched back to Case Mode to reduce the number of simulations. If you are creating a project of your own, start the solution space in permutation mode to allow all possible values of parameters.

solution_space_permutation_mode.png

To reduce simulation time, the example does not perform waveform and timing analysis. If you have license to Parallel Computing Toolbox™, it is highly recommended that you turn on parallel processing to reduce the simulation time.

Close the app before you run the genetic search algorithm.

Genetic Search Algorithm

A genetic search algorithm (OptimSI.p) is used to find the settings that maximize the Tmid statistical eye height. The genetic algorithm requires two inputs from the command prompt:

  • a population size that defines how many cases you want to evaluate in each generation,

  • and the maximum number of generations you want to keep optimizing if the results does not converge.

The first call to the genetic algorithm creates a population size of cases randomly chosen from the Permutation Mode solution space. At the end of the first call, the script loads up the sheet in the Case Mode solution space.

After the first generation is simulated, the solution space of the first generation and the metric Stat Tmid Eye Height for all the cases are fed back to the genetic algorithm to generate the population of the next generation. This next generation contains the best members of previous generation, members by recombining the best members with each other, and members by mutating the best members. This process is repeated until either the search algorithm decides the results have converged, the metric has changed by less than .1 mV, or the number of generations reaches a maximum number of generations limit. The interface is left with the best case in two identical cases in the Case Mode.

The Stat Tmid Eye Height is the height of the target BER contour at the time center of the 1e-3 BER contour. The target BER contour is set to 1e-3 in the Simulation Options parameter. The 1e-3 BER contour is used because typical firmware training hardware look for errors while sweeping the DQ/DQS skew and Vref. The firmware runs each setting for ~1000 UI, thus the 1e-3 contour. As the training converges, the hardware can run for longer times to get better data.

Best Case Simulation

Set the maximum number of generation (maxGenerations) to 2 and the population size (populationSize) to 10. The script creates the first generation of population, simulate, and generate metrics for all cases. It then uses these metrics to generate new cases until the metric stops improving or it hits the limit of maximum number of generations.

SIP=exampleScriptTraining('OptimizeDigitalTwin', 'sheet', 'sheet1', 'populationSize', 10, 'maxGenerations', 2, 'graphics', true);

In the first generation, the script generates 10 simulation scenarios that reaches a maximum Stat Tmid Eye Height of 95 mV.

gen_1.png

In the second generation, the script keeps the best 3 scenarios and regenerates 7 scenarios and reruns the simulation. In this case, the maximum Stat Tmid Eye Height is 103 mV.

gen_2.png

Since the example limits the maximum number of generations to 2, the optimization stops here. The script reruns the best case scenario of the second generation two more times for further exploration.

Click the Autoload Results button. The results contain two cases as was run before. Both the cases are identical and contain the best case scenario for this example.

Compare Genetic Algorithm with Existing Algorithm

To see how close the genetic algorithm came to an existing algorithm in the Rx AMI model that optimizes the Rx DFE, modify the case 2 SDRAM1:DFEandCDR.Mode to adapt.

solutions_space.png

Rerun the simulations. Since the population size and maximum number of generations used in the example is low, case 2 returns a higher value of Stat Tmid Eye Height, closer to 200 mV.

best_eye_height.png

The statistical eye diagram when the DFE is set to adapt Mode is shown:

adapt_result.png

The statistical eye diagram when the DFE is set to fixed Mode that shows only the effect of the genetic algorithm is shown:

gen_result.png

Close the app.

To see the true capabilities of the genetic search algorithm, rerun the simulations with a population size of 100 and maximum number of generations 12.

SIP=exampleScriptTraining('OptimizeDigitalTwin', 'sheet', 'sheet1', 'populationSize', 100, 'maxGenerations', 12, 'graphics', false);

The search converges at the seventh generation with a maximum Stat Tmid Eye Height of 231 mV.

gen_7.png

Open the project in the Parallel Link Designer app. Change the case 2 SDRAM1:DFEandCDR.Mode to adapt. If you compare the results with DFE Mode set to fixed with the DFE Mode set to adapt, you can see that even with DFE Mode set to fixed, genetic search algorithm provides a slightly better result.

high_population.png

Without this scripting capability, the app requires to simulate a huge permutation solution space to optimize the Tx FFE taps or the Rx ODT settings. There are 618,647,323,959 possible combinations of the 3 FFE tap, 4 DFE tap and 2 ODT variables. Genetic algorithm only needs to simulate ~1000 cases.

Optimize Channel

You can create a sheet with interconnect from your DDR5 channel, your Controller IBIS file, and your SDRAM IBIS file. Select one transfer and set the FFE and DFE tap values to define your search space by setting each of the taps to the values you choose. To populate the variables that have a list of possible values, right click on the variable and select the Set All Values option. Manually populate variables that have a range of float values. Edit the transfer nets to enable sweeping the models in the model selector. Include the models that you want searched for the Controller and all the SDRAMs. Do not include SDRAM models that are drivers and Controller models that are receivers.

There are three helper functions attached with this script to help you run the optimization process. To point to the project and the sheet you created, run this command:

exampleScriptTraining('<your project>','sheet', '<your sheet>', 'populationSize', 10, 'maxGenerations', 2, 'graphics', true) 

Note: If you encounter the error No cases have ~0 metric, rerun the simulation with a larger value for maximum number of generations.

Additional Uses

You can replace the genetic search method with the methods that have been implemented in your controller firmware written in “C”. To do so, modify the exampleScriptTraining script to point to your search algorithm instead of the optimSi.p algorithm used in this example. You can also codegen the attached GeneticSearch algorithm to generates “C” code, then use this “C” code in your firmware.