Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Export from Signal Tap Quartus prime in Matlab

Status
Not open for further replies.

jayeffe

Junior Member level 2
Junior Member level 2
Joined
Jan 22, 2022
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
124
hi everyone I have to modify this example file which must show me the data of the signal tap.
I need to view the FFT of the ADC_DA_F and DAC_DA_F Signal

i have to do the same thing for other similar signals, eg ADC_DB, DAC_DB

the example file that is generated by the signal tap has the shape I entered.
I am not an expert in matlab and the example file only works with two signals from the demonstration.

Code:
function [A2D, D2A]= nstp_plot(stp_txt_file_name)

%A2D_SignalName = 'HSTCD_AD_DA';
A2D_SignalName = 'ADC_DB';
A2D_Index = 0;
D2A_SignalName = 'DAC_DB';
D2A_Index = 0;

A2D='';
D2A='';
close all;


if ~isempty(dir(stp_txt_file_name))
    startdata=0;
    first_data=0;
    fid = fopen(stp_txt_file_name);
    if fid ~= -1    % file open is OK.
%----- get signal index---------------------------------
        key_hit = 0;
        while(key_hit == 0)
            tline = fgetl(fid); % get one line string
            disp(tline); % for debug
            if (strcmp(strtok(tline), 'Key'))
                fprintf ('hit\n');  % for debug
                key_hit = 1;
                ken_fine_end = 0;
                tline = fgetl(fid);     % read space line
                while (ken_fine_end == 0)
                    tline = fgetl(fid);
                    ken_fine_end = isempty(tline);  % if space line, setup find to end
                    [key_Index,      tline]  = strtok(tline);
                    [key_Equ,        tline]  = strtok(tline);
                    [key_signalName, tline]  = strtok(tline);
                    fprintf ('\"%s\"  \"%s\"  \"%s\" \n',key_Index,key_Equ,key_signalName);  % for debug
                    if (strcmp(key_signalName,A2D_SignalName))
                        A2D_Index = sscanf(key_Index,'%d') + 2; % add 2 to correct sample number and array index.
                        fprintf ('A2D Hit, Index = %d\n',A2D_Index);  % for debug
                    else
                        if (strcmp(key_signalName,D2A_SignalName))
                        D2A_Index = sscanf(key_Index,'%d') + 2; % add 2 to correct sample number and array index.
                            fprintf ('D2A Hit, Index = %d\n',D2A_Index);  % for debug
                        end;
                    end;
                end;
            end;
        end;

        while (feof(fid)<1)
            tline = fgetl(fid);
            if (strcmp(tline, 'sample'))
                startdata=1;
            end;
            if (startdata==1) && (length(tline)>10)
                a = sscanf(tline,'%d');
%                if (length(a) > max(A2D_Index,D2A_Index))
                    if (first_data == 0)
                        A2D = a(A2D_Index);
                        D2A = a(D2A_Index);
                    else
                        A2D = [A2D a(A2D_Index)];
                        D2A = [D2A a(D2A_Index)];
                    end;
%                end;
                first_data = first_data + 1;
            end;
        end;
        fclose(fid);
    end;
else
    disp(['  unable to locate : ' stp_txt_file_name]);
end;


if length(A2D)>2^11-1
    if (strcmp(A2D_SignalName,'HSTCD_AD_DA'))
        STII_FFTPLOT(A2D-2048*4,'ADA Development Kit - Normalized spectral plot of the 14 bit output bus of ADC_A (J1)');
    elseif (strcmp(A2D_SignalName,'ADC_DB'))
        STII_FFTPLOT(A2D-2048*4,'ADA Development Kit - Normalized spectral plot of the 14 bit output bus of ADC_B (J2)');
    end;
end


if length(D2A)>2^11-1
    STII_FFTPLOT(D2A-2048*4,'ADA Development Kit - Normalized spectral plot of 14 bits of input data of DAC_B (J4)');
end


% ===================================================================
% function STII_FFTPLOT(data,ttitle)
% input data    data    : input data sequence
%               ttitle    : plot title string
function STII_FFTPLOT(data,ttitle)
fs = 1e5;
color ='r';
N=(2^11);

data = data(1:N);
snc=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Kaiser window values

FILE:

Signal Legend:

Key Signal Name

0 = ADC_DA_F
1 = DAC_DA
2 = DAC_DB
3 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|dataa[0..13]
4 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|datab[0..13]

Data Table:

Signals-> 0 1 2 3 4

sample

-16 11904 1910 1910 947 4096
-15 6594 5043 5043 293 8191
-14 12901 8484 8484 10 4096
-13 7384 4106 4106 128 1
-12 12908 129 129 634 4096
-11 10919 4730 4730 1479 8191

write your code inside this tags
 
Last edited by a moderator:

hi everyone I have to modify this example file which must show me the data of the signal tap.
I need to view the FFT of the ADC_DA_F and DAC_DA_F Signal

i have to do the same thing for other similar signals, eg ADC_DB, DAC_DB

the example file that is generated by the signal tap has the shape I entered.
I am not an expert in matlab and the example file only works with two signals from the demonstration.

Code:
function [A2D, D2A]= nstp_plot(stp_txt_file_name)

%A2D_SignalName = 'HSTCD_AD_DA';
A2D_SignalName = 'ADC_DB';
A2D_Index = 0;
D2A_SignalName = 'DAC_DB';
D2A_Index = 0;

A2D='';
D2A='';
close all;


if ~isempty(dir(stp_txt_file_name))
    startdata=0;
    first_data=0;
    fid = fopen(stp_txt_file_name);
    if fid ~= -1    % file open is OK.
%----- get signal index---------------------------------
        key_hit = 0;
        while(key_hit == 0)
            tline = fgetl(fid); % get one line string
            disp(tline); % for debug
            if (strcmp(strtok(tline), 'Key'))
                fprintf ('hit\n');  % for debug
                key_hit = 1;
                ken_fine_end = 0;
                tline = fgetl(fid);     % read space line
                while (ken_fine_end == 0)
                    tline = fgetl(fid);
                    ken_fine_end = isempty(tline);  % if space line, setup find to end
                    [key_Index,      tline]  = strtok(tline);
                    [key_Equ,        tline]  = strtok(tline);
                    [key_signalName, tline]  = strtok(tline);
                    fprintf ('\"%s\"  \"%s\"  \"%s\" \n',key_Index,key_Equ,key_signalName);  % for debug
                    if (strcmp(key_signalName,A2D_SignalName))
                        A2D_Index = sscanf(key_Index,'%d') + 2; % add 2 to correct sample number and array index.
                        fprintf ('A2D Hit, Index = %d\n',A2D_Index);  % for debug
                    else
                        if (strcmp(key_signalName,D2A_SignalName))
                        D2A_Index = sscanf(key_Index,'%d') + 2; % add 2 to correct sample number and array index.
                            fprintf ('D2A Hit, Index = %d\n',D2A_Index);  % for debug
                        end;
                    end;
                end;
            end;
        end;

        while (feof(fid)<1)
            tline = fgetl(fid);
            if (strcmp(tline, 'sample'))
                startdata=1;
            end;
            if (startdata==1) && (length(tline)>10)
                a = sscanf(tline,'%d');
%                if (length(a) > max(A2D_Index,D2A_Index))
                    if (first_data == 0)
                        A2D = a(A2D_Index);
                        D2A = a(D2A_Index);
                    else
                        A2D = [A2D a(A2D_Index)];
                        D2A = [D2A a(D2A_Index)];
                    end;
%                end;
                first_data = first_data + 1;
            end;
        end;
        fclose(fid);
    end;
else
    disp(['  unable to locate : ' stp_txt_file_name]);
end;


if length(A2D)>2^11-1
    if (strcmp(A2D_SignalName,'HSTCD_AD_DA'))
        STII_FFTPLOT(A2D-2048*4,'ADA Development Kit - Normalized spectral plot of the 14 bit output bus of ADC_A (J1)');
    elseif (strcmp(A2D_SignalName,'ADC_DB'))
        STII_FFTPLOT(A2D-2048*4,'ADA Development Kit - Normalized spectral plot of the 14 bit output bus of ADC_B (J2)');
    end;
end


if length(D2A)>2^11-1
    STII_FFTPLOT(D2A-2048*4,'ADA Development Kit - Normalized spectral plot of 14 bits of input data of DAC_B (J4)');
end


% ===================================================================
% function STII_FFTPLOT(data,ttitle)
% input data    data    : input data sequence
%               ttitle    : plot title string
function STII_FFTPLOT(data,ttitle)
fs = 1e5;
color ='r';
N=(2^11);

data = data(1:N);
snc=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Kaiser window values

FILE:

Signal Legend:

Key Signal Name

0 = ADC_DA_F
1 = DAC_DA
2 = DAC_DB
3 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|dataa[0..13]
4 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|datab[0..13]

Data Table:

Signals-> 0 1 2 3 4

sample

-16 11904 1910 1910 947 4096
-15 6594 5043 5043 293 8191
-14 12901 8484 8484 10 4096
-13 7384 4106 4106 128 1
-12 12908 129 129 634 4096
-11 10919 4730 4730 1479 8191

write your code inside this tags
The way I read data from signaltap into matlab is few clicks:
1) set all signals to signed or unsigned as applicable (not hex, not binary)
2) right click on signaltap and choose signaltap list file.
3) you will get text file. delete header and keep only matrix of values making note of signal names per column
4) load that matrix into matlab workspace: load <mymatrix.txt>
5) select any column from matrix e.g data1 = mymatrix( : , 2); i.e. all data in column 2 (normally colum1 is sample index).
Finally process data1 as required e.g. y = fft(data1);
 

I had already found this thing.
I wanted to know if I can modify this code somehow to get the FFTs of the signals that interest me. What should I remove from this listing.
The code below comes from a siglnal tap.
 

I had already found this thing.
I wanted to know if I can modify this code somehow to get the FFTs of the signals that interest me. What should I remove from this listing.
The code below comes from a siglnal tap.
I see.
You got 6 columns, The first is sample index (minus means before trigger).
the columns 2 to 6 are your signals as named in your list:
0 = ADC_DA_F This column 2 (matlab starts from1)
1 = DAC_DA This column 3
2 = DAC_DB ...etc
3 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|dataa[0..13]
4 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|datab[0..13]

to read column 2 in matlab as example:
x = data( : ,2);

to do fft: y = fft( x ,N) where N is your chosen resolution
 

I Try this:
obviously fft () doesn't work. need something else
Code:
M = dlmread('stp1_auto_signaltap_0.txt', ' ',16, 6)

ADC_DA = M(:,1);

DAC_DA = M(:,2);

DAC_DB = M(:,3);

DATA_A = M(:,4);

DATA_B = M(:,5);
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top