Skip to content
This repository
tree: ac6f5451b4
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 59 lines (46 sloc) 2.224 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
function adc_overflow_detector_init(cur_block_name, varargin)

defaults = {};
if same_state(cur_block_name, 'defaults', defaults, varargin{:}), return, end

check_mask_type(cur_block_name, 'of_detect_bus');
munge_block(cur_block_name, varargin{:});

nStreams = get_var('nStreams', 'defaults', defaults, varargin{:});
bit_width = get_var('bit_width', 'defaults', defaults, varargin{:});
delete_lines(cur_block_name);

if mod(nStreams,2) ~= 0
    errordlg('Must have an even number of polyphase samples');
end

num_ddr_streams = nStreams/2;
adder_inputs = [];
for k=1:num_ddr_streams,
    adder_inputs = [adder_inputs, '+'];
end
set_param([cur_block_name, '/Add'], 'Inputs', adder_inputs);
for k=0:num_ddr_streams-1,
    of_pos = [105, 25+85*k, 145, 80+85*k];
    in0_pos = [45, 33+85*k, 75, 47+85*k];
    in1_pos = [45, 58+85*k, 75, 72+85*k];
    
    reuse_block(cur_block_name, ['of', num2str(k)], 'xps_library/ADCs/of1', ...
        'Position', of_pos);
    reuse_block(cur_block_name, ['s', num2str(k)], 'built-in/Inport', ...
        'Position', in0_pos, 'Port', num2str(k+1));
    reuse_block(cur_block_name, ['s', num2str(k+num_ddr_streams)], 'built-in/Inport', ...
        'Position', in1_pos, 'Port', num2str(k+num_ddr_streams+1));
    add_line(cur_block_name, ['s', num2str(k), '/1'], ['of', num2str(k), '/1']);
    add_line(cur_block_name, ['s', num2str(k+num_ddr_streams), '/1'], ['of', num2str(k), '/2']);
    
    % Set the bus bit position
    
    % Connect to the adder block
    add_line(cur_block_name, ['of', num2str(k), '/1'], ['Add/', num2str(k+1)]);
    
% reuse_block(cur_block_name, ['sample', num2str(k-1), '_ds'], 'dspsigops/Downsample', ...
% 'N', num2str(nStreams), ...
% 'phase', num2str(mod(ds_phase,nStreams)), ...
% 'Position', downsample_pos);
% add_line(cur_block_name, 'adc_bias/1', ['sample', num2str(k-1), '_ds/1']);
% ds_phase = ds_phase + 1;
%
% reuse_block(cur_block_name, ['s', num2str(k-1)], 'built-in/Outport', ...
% 'Position', output_pos);
% add_line(cur_block_name, ['sample', num2str(k-1), '_ds/1'], ['s', num2str(k-1),'/1']);
end

add_line(cur_block_name, 'Add/1', 'overflow/1');

clean_blocks(cur_block_name);
   
end
Something went wrong with that request. Please try again.