This example shows how to customize a flash ADC by adding the metastability probability as an impairment and how to measure the said impairment. This is to validate our impairment implementation. The example also shows the effect of metastability on the dynamic performance (AC analysis) of the flash ADC. When the digital output from a comparator is ambiguous (neither '1' nor '0') , the output is defined as metastable. The ambiguous output is expressed as NaN. This example model uses a MATLAB function block to add the metastability impairment to a flash ADC architecture. Another subsystem reports the metastability probability on the fly.

Extract the inner structure of the flash ADC to add customized impairment. Add a flash ADC block from the Mixed Signal Blockset™ library to a Simulink® canvas. Look under the mask to find the flat structure of the ADC. Copy paste the complete structure to another new blank canvas.

For this example, we delete the 'Clock Generator' block as it is not used to provide the start conversion clock. An external stimuli block is used for that purpose. Barring the clock generator block, flash ADC consists of 2 major components:

Flash ADC comparators: The flash ADC uses 2^NBits comparators in parallel. The block itself is based on MATLAB code. Before simulation starts, they calculate the individual reference voltages and store them in a vector. On every specified edge, the input is compared to the references using MATLAB's ability to compare vectors. This generates thermometer code in much the same way the real flash ADC does, without the lag from (NBits) individual comparator blocks in the model. Various parameters of its mask will be configured as follows

Number of bits: 10 (we will be creating the example for a 10-bit ADC)

Input range: [-1 1] (the default setting)

INL vector: 0 (we want to disable this impairment to see the real effect of metastability)

Fault Aware Ones Counter: This block is an impairment and the other major half of the flash ADC architecture rolled into one. Real ADCs handle conversion from thermometer to binary through logic circuits. This block just takes the sum-of-elements of the vector. It then applies that sum to a lookup table to simulate missing codes, otherwise known as bubbles. The various parameters for this block are like flash ADC comparator block mentioned above. The only additional parameter is the missing codes which is entered as an empty vector.

What we see from the image below is a top view of the flash ADC block on the left side and its inner structure pasted on the top right side. Bottom right is the structure with only the important components required for this example.

To add metastability impairment we place a MATLAB function block soon after the flash ADC comparators as shown in the figure below. This block sets thermometer code signals to NaN with a probability specified in its mask using a uniform random number generator. It resets them on the next relevant edge. MATLAB code behind the impairment block is as follows:

% function y = metastability(u, Probability) % mult = ones(size(u)); % mult(rand(size(u)) < Probability(1)) = NaN; % metastability = NaN % y = u .* mult; % end

As you can observe from the image above the mask of the impairment block requires one parameter i.e. metastability probability that user wants to implement in the flash ADC block.

The idea behind measuring metastability impairment is very simplistic. We count the number of NaNs encountered and divide that by the number of total comparator outputs generated during the complete simulation. A simple Simulink implementation of metastability probability measurement is shown below.

The Inports are: * ADC output: This port takes in the output digital code generated by the flash ADC. * Ready signal: This port takes in the ready signal signifying the rate at which the digital conversion is taking place. at each rising edge of the Ready signal digital code gets generated.

Below is the model combining the customized flash ADC with its output connected to the metastability probability measurement system. In the model we have a 10-bit flash ADC with metastability probability of 1e-6 added. the stimuli block generates an analog signal of 100Hz and a start conversion clock with a frequency of 100MHz (this will be ADC's rate of operation). We have a dashboard scope which provides the behavior of the probability number over time. There is a display block also to provide the current probability being measured by the subsystem. One needs to run the simulation for a longer period to see the probability number getting settled to the desired value (1e-6 in this case)

```
NBits=10;
model1='flashAdc_metastability.slx';
open_system(model1);
sim(model1);
```

Here we observe the effect of metastability on the dynamic performance of ADCs. The model shows two setup of flash ADC systems: One with metastability and the other without it. We have a post processing block that takes in the impaired digital output and converts the NaNs to a 0. This is because the digital output with NaNs can't be recognized by a spectrum analyzer as valid signal for spectral analysis. We also hookup ADC AC measurement block to observe various performance metrics like SNR, ENOB, noise floor etc. The simulation results show the AC analysis brings significant drop in performance for ADC with metastability as shown by the lower ENOB and higher noise floor.

```
model2='flashAdc_metastability_Effect.slx';
open_system(model2);
sim(model2);
```