-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbit_reverse_draw_v2.m
More file actions
executable file
·66 lines (50 loc) · 2.18 KB
/
Copy pathbit_reverse_draw_v2.m
File metadata and controls
executable file
·66 lines (50 loc) · 2.18 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
59
60
61
62
63
64
65
66
% Monroe_Library: mask script
% Author: Ryan Monroe
% Copyright 2007, 2005, by the California Institute of Technology.
% ALL RIGHTS RESERVED. United States Government Sponsorship
% acknowledged. Any commercial use must be negotiated with the Office
% of Technology Transfer at the California Institute of Technology.
% This software may be subject to U.S. export control laws. By
% accepting this software, the user agrees to comply with all
% applicable U.S. export laws and regulations. User has the
% responsibility to obtain export licenses, or other export authority
% as may be required before exporting such information to foreign
% countries or providing access to foreign persons.
function bit_reverse_draw_v2(nBits, radix4)
%bit reverser
% xBlock;
% nBits=6;
% radix4=true;
% pathToBlock = 'path:bit_reverse';
% if (exist('calledFromInit') == 0) % then we are calling this from another xBlock drawer, and the variables were passed by struct. This allows us to use the xBlocks caching feature.
% %it is necessary because xBlocks dosen't like you calling functions
% %with arguments while drawing another xBlocks object. The workaround
% %is to put all your arguments in a global variable and just set them
% %immeadiately before calling the argument. By making this check, we
% %pull the variables directly from the argument list, if we are calling
% %this via an init command (thus fufilling the caching prerequsites),
% %and from a struct if calling from within an xBlocks function (thus
% %fufilling the function call requirements)
% nBits=drawing_parameters.nBits;
% end
iIn = xInport('in');
oOut = xOutport('out');
for(i= 1:nBits)
sSlices{i} = xSignal;
blockName = strcat('slice', num2str(nBits-i+1));
sSlices{i} = xSliceBool(iIn,'upper', -1*(i-1), blockName);
end
if(~exist('radix4','var') || ~radix4)
sSlicesReo=sSlices(end:-1:1);
else
if(~isInt(nBits/2))
error('nBits must be even for radix4');
end
inds=1:nBits;
inds_rs=reshape(inds,2,nBits/2).';
inds_bitrev=inds_rs(end:-1:1,:).';
inds_fin = inds_bitrev(:);
sSlicesReo=sSlices(inds_fin);
end
sOut = xConcat(sSlicesReo, 'concat');
oOut.bind(sOut);