image thumbnail

Sigma Delta Test Bench

by

 

A test bench to simulate and analyse Sigma Delta modulators

DWA_Trial.m
DWA_elem = DWA_elements;


LSB = 2/4;
DAC_low = -1;
step_level = (1+u) % Expected levels are 0,0.5,1,1.5,2 for inputs -1,-0.5,0,0.5,1
number_of_elements = step_level/LSB %Number of elements needed

DWA_elem_shuffle = [0 0 0 0 0];
    
if DWA_index == 1
    DWA_elem
    DWA_elem_shuffle = DWA_elem 
    DWA_index = DWA_index + number_of_elements
elseif DWA_index ==2
    DWA_elem
    DWA_elem_shuffle = [DWA_elem(2) DWA_elem(3) DWA_elem(4) DWA_elem(5) DWA_elem(1)]  
    if number_of_elements >=4
       DWA_index = number_of_elements-3 
    else
        DWA_index = DWA_index+number_of_elements
    end
elseif DWA_index == 3
    DWA_elem
    DWA_elem_shuffle = [DWA_elem(3) DWA_elem(4) DWA_elem(5) DWA_elem(1) DWA_elem(2)] 
    if number_of_elements >=3
       DWA_index = number_of_elements-2 
    else
        DWA_index = DWA_index+number_of_elements
    end 
elseif DWA_index == 4
    DWA_elem
    DWA_elem_shuffle = [DWA_elem(4) DWA_elem(5) DWA_elem(1) DWA_elem(2) DWA_elem(3)]  
    if number_of_elements >=2
       DWA_index = number_of_elements-1 
    else
        DWA_index = DWA_index+number_of_elements
    end
elseif DWA_index == 5
    DWA_elem
    DWA_elem_shuffle = [DWA_elem(5) DWA_elem(1) DWA_elem(2) DWA_elem(3) DWA_elem(4)]
    if number_of_elements >1
       DWA_index = number_of_elements 
    else
        DWA_index = 1
    end   
end


i = 1;

if (u>=1)
    y = (DAC_low+(4*LSB));
elseif (u<1) && (u>=0.5)
    y = DAC_low;
    for i = 1:number_of_elements
        y = y+DWA_elem_shuffle(i);
    end
    %y = (DAC_low+sum(DWA_elem_shuffle(1:number_of_elements)));
elseif (u<0.5) && (u>=0)
    y = DAC_low;
    for i = 1:number_of_elements
        y = y+DWA_elem_shuffle(i);
    end    
    %y = (DAC_low+sum(DWA_elem_shuffle(1:number_of_elements)));
elseif (u<0) && (u>= -0.5)
    y = DAC_low;
    for i = 1:number_of_elements
        y = y+DWA_elem_shuffle(i);
    end     
    %y = (DAC_low+sum(DWA_elem_shuffle(1:number_of_elements)));
elseif (u<-0.5) %&& (u>= -1)
    y = -1;
else
    y = u;

end
y

Contact us