Skip to content

Commit

Permalink
Merge pull request #133 from casper-astro/casper-astro-soak-test
Browse files Browse the repository at this point in the history
Merge of casper-astro-soak-test into master branch after busyweek2020 testing. This should become the new stable commit for tutorial and development work.

Supports:

SNAP (Matlab 2018a, Vivado 2019.1)
SKARAB (Matlab 2018a, Vivado 2019.1)
Red Pitaya (Matlab 2018a, Vivado 2019.1)

ROACH2 -- deprecated. Use v0.9
  • Loading branch information
jkocz committed Oct 19, 2020
2 parents ee6841c + e163a4b commit fe991aa
Show file tree
Hide file tree
Showing 1,812 changed files with 293,597 additions and 2,761,314 deletions.
Binary file modified casper_library/casper_library_correlator.slx
Binary file not shown.
52 changes: 44 additions & 8 deletions casper_library/dec_fir_async_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,44 @@ function dec_fir_async_init(blk)
reuse_block(blk, 'shift2', 'xbsIndex_r4/Shift', ...
'shift_dir', 'Left', 'shift_bits', num2str(lshift), ...
'Position', [200*num_fir_col+500 500 200*num_fir_col+530 515]);
reuse_block(blk, 'convert1', 'xbsIndex_r4/Convert', ...
'Position', [200*num_fir_col+560 300 200*num_fir_col+590 315], ...
'n_bits', num2str(output_width), 'bin_pt', num2str(output_bp), 'arith_type', 'Signed (2''s comp)', ...
'latency', num2str(conv_latency), 'quantization', quantization);
reuse_block(blk, 'convert2', 'xbsIndex_r4/Convert', ...
'Position', [200*num_fir_col+560 500 200*num_fir_col+590 515], ...
'n_bits', num2str(output_width), 'bin_pt', num2str(output_bp), 'arith_type', 'Signed (2''s comp)', ...
'latency', num2str(conv_latency), 'quantization', quantization);


% Original convert. This does not include overlfow detection logic.
%
% reuse_block(blk, 'convert1', 'xbsIndex_r4/Convert', ...
% 'Position', [200*num_fir_col+560 300 200*num_fir_col+590 315], ...
% 'n_bits', num2str(output_width), 'bin_pt', num2str(output_bp), 'arith_type', 'Signed (2''s comp)', ...
% 'latency', num2str(conv_latency), 'quantization', quantization);
% reuse_block(blk, 'convert2', 'xbsIndex_r4/Convert', ...
% 'Position', [200*num_fir_col+560 500 200*num_fir_col+590 515], ...
% 'n_bits', num2str(output_width), 'bin_pt', num2str(output_bp), 'arith_type', 'Signed (2''s comp)', ...
% 'latency', num2str(conv_latency), 'quantization', quantization);

reuse_block(blk, 'convert1', 'casper_library_misc/convert_of', ...
'bit_width_i', num2str(43), ...
'binary_point_i', num2str(34), ...
'bit_width_o', num2str(output_width), ...
'binary_point_o', num2str(output_bp), ...
'quantization', 2, ...
'overflow', 'wrap', ...
'csp_latency', num2str(conv_latency), ...
'Position', [200*num_fir_col+560 300 200*num_fir_col+590 315]);

reuse_block(blk, 'convert2', 'casper_library_misc/convert_of', ...
'bit_width_i', num2str(43), ...
'binary_point_i', num2str(34), ...
'bit_width_o', num2str(output_width), ...
'binary_point_o', num2str(output_bp), ...
'quantization', 2, ...
'overflow', 'wrap', ...
'csp_latency', num2str(conv_latency), ...
'Position', [200*num_fir_col+560 500 200*num_fir_col+590 515]);

reuse_block(blk, 'or_reduce', 'xbsIndex_r4/Logical', ...
'logical_function', 2, ...
'latency', num2str(1), ...
'Position', [200*num_fir_col+620 430 200*num_fir_col+650 490]);


reuse_block(blk, 'ri_to_c', 'casper_library_misc/ri_to_c', ...
'Position', [200*num_fir_col+620 400 200*num_fir_col+650 430]);
Expand All @@ -348,13 +378,19 @@ function dec_fir_async_init(blk)
'Position', [200*num_fir_col+500 250 200*num_fir_col+530 265], 'Port', '1');
reuse_block(blk, 'dout', 'built-in/outport', ...
'Position', [200*num_fir_col+680 400 200*num_fir_col+710 415], 'Port', '2');
reuse_block(blk, 'of_out', 'built-in/outport', ...
'Position', [200*num_fir_col+700 400 200*num_fir_col+710 415], 'Port', '3');

add_line(blk, 'real_sum/2', 'shift1/1');
add_line(blk, 'imag_sum/2', 'shift2/1');
add_line(blk, 'shift1/1', 'convert1/1');
add_line(blk, 'shift2/1', 'convert2/1');
add_line(blk, 'convert1/1', 'ri_to_c/1');
add_line(blk, 'convert1/2', 'or_reduce/1');
add_line(blk, 'convert2/1', 'ri_to_c/2');
add_line(blk, 'convert2/2', 'or_reduce/2');
add_line(blk, 'or_reduce/1', 'of_out/1');

add_line(blk, 'ri_to_c/1', 'dout/1');
%add_line(blk, 'sync_delay/1', 'real_sum/2');
%add_line(blk, 'sync_delay/1', 'imag_sum/2');
Expand Down
32 changes: 30 additions & 2 deletions casper_library/pfb_coeff_gen_calc.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,36 @@
if debug,
coeff_vector = index;
else
windowval = transpose(window(WindowType, alltaps));
total_coeffs = windowval .* sinc(fwidth * ([0:alltaps-1]/(2^PFBSize)-TotalTaps/2));
try
windowval = transpose(window(WindowType, alltaps));
catch err
switch err.identifier
case 'MATLAB:UndefinedFunction'
warning('window function undefined in MATLAB. Attempting to use python variant')
try
windowval = cellfun(@double, cell(py.window.window(WindowType, int32(alltaps))));
catch
error('Python call to window() failed!')
end
otherwise
rethrow(err)
end
end
try
total_coeffs = windowval .* sinc(fwidth * ([0:alltaps-1]/(2^PFBSize)-TotalTaps/2));
catch err
switch err.identifier
case 'MATLAB:UndefinedFunction'
warning('sinc function undefined in MATLAB. Attempting to use python variant')
try
total_coeffs = windowval .* cellfun(@double, cell(py.window.sinc(py.list(fwidth * ([0:alltaps-1]/(2^PFBSize)-TotalTaps/2)))));
catch
error('Python call to sinc() failed!')
end
otherwise
rethrow(err)
end
end
coeff_vector = total_coeffs(index);
end
% end
3 changes: 1 addition & 2 deletions casper_library/pfb_coeff_gen_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ function pfb_coeff_gen_init(blk, varargin)
try
window('hamming',1024);
catch
disp('pfb_coeff_gen_init:Signal Processing Library absent or not working correctly');
error('pfb_coeff_gen_init:Signal Processing Library absent or not working correctly');
warning('pfb_coeff_gen_init:Signal Processing Library absent or not working correctly');
end
%alltaps = TotalTaps*2^PFBSize;
%windowval = transpose(window(WindowType, alltaps));
Expand Down
70 changes: 70 additions & 0 deletions casper_library/python/window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from math import sin, cos, pi

# These window functions duplicated from numpy, because
# importing numpy here breaks MATLAB ?!?

def hanning(M):
if M < 1:
return []
if M == 1:
return [1.0]
nlist = range(0, M)
return [(0.5 - 0.5*cos(2.0*pi*n/(M-1))) for n in nlist]

def blackman(M):
if M < 1:
return []
if M == 1:
return [1.0]
nlist = range(0, M)
return [(0.42 - 0.5*cos(2.0*pi*n/(M-1)) + 0.08*cos(4.0*pi*n/(M-1))) for n in nlist]

def hamming(M):
if M < 1:
return []
if M == 1:
return [1.0]
nlist = range(0, M)
return [(0.54 - 0.46*cos(2.0*pi*n/(M-1))) for n in nlist]

def window(wintype, N):
"""
Try to replicate MATLAB's `window` function.
Inputs:
wintype (string) : window type, eg. "hann", "hamming", etc
N (int) : Number of window points requested
This function will try to call numpy.`wintype`(N) to generate the
desired window.
"""
# Remap names where we know MATLAB and numpy differ
# map is {MATLAB name : numpy name}
remap = {
"hann" : "hanning",
}
wintype = remap.get(wintype, wintype)
try:
winmethod = globals()[wintype]
except KeyError:
raise RuntimeError("Couldn't find window method '%s'" % wintype)
return
#try:
# winmethod = getattr(numpy, wintype)
#except AttributeError:
# print("Couldn't find window method numpy.%s" % wintype)
# return
if callable(winmethod):
return winmethod(N)
else:
raise RuntimeError("Attribute numpy.%s is not callable" % wintype)
return

def sinc(xlist):
if not isinstance(xlist, list):
return sinc([xlist])[0]
rv = []
for x in xlist:
try:
rv += [sin(pi*x) / (pi*x)]
except ZeroDivisionError:
rv += [1.0]
return rv
Binary file added docs/_static/img/AMBA_bus_architectures.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/AXI4-Lite_interface_signals.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/axi4lite_response.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/axi_interconnect.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/example_simulink_design.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/master_slave_interface.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/read_transaction.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/s_axi_wstrb_signals.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/write_transaction.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fe991aa

Please sign in to comment.