-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_delay_en_init_xblock.m
More file actions
156 lines (134 loc) · 7.47 KB
/
sync_delay_en_init_xblock.m
File metadata and controls
156 lines (134 loc) · 7.47 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Center for Astronomy Signal Processing and Electronics Research %
% http://casper.berkeley.edu %
% Copyright (C) 2011 Suraj Gowda Hong Chen %
% %
% This program is free software; you can redistribute it and/or modify %
% it under the terms of the GNU General Public License as published by %
% the Free Software Foundation; either version 2 of the License, or %
% (at your option) any later version. %
% %
% This program is distributed in the hope that it will be useful, %
% but WITHOUT ANY WARRANTY; without even the implied warranty of %
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %
% GNU General Public License for more details. %
% %
% You should have received a copy of the GNU General Public License along %
% with this program; if not, write to the Free Software Foundation, Inc., %
% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sync_delay_en_init_xblock(DelayLen)
% Mask Initialization code
BitWidth = max(2, ceil(log2(DelayLen+1)));
UseCounter = 1;
if DelayLen == 0,
UseCounter = 0;
end
%% inports
xlsub2_In = xInport('In');
xlsub2_en = xInport('en');
%% outports
xlsub2_Out = xOutport('Out');
%% diagram
% block: delay_7/sync_delay_en/Constant
xlsub2_Constant_out1 = xSignal;
xlsub2_Constant = xBlock(struct('source', 'Constant', 'name', 'Constant'), ...
struct('arith_type', 'Unsigned', ...
'n_bits', BitWidth, ...
'bin_pt', 0, ...
'explicit_period', 'on'), ...
{}, ...
{xlsub2_Constant_out1});
% block: delay_7/sync_delay_en/Constant1
xlsub2_Constant1_out1 = xSignal;
xlsub2_Constant1 = xBlock(struct('source', 'Constant', 'name', 'Constant1'), ...
struct('arith_type', 'Unsigned', ...
'const', 0, ...
'n_bits', BitWidth, ...
'bin_pt', 0, ...
'explicit_period', 'on'), ...
{}, ...
{xlsub2_Constant1_out1});
% block: delay_7/sync_delay_en/Constant2
xlsub2_Constant2_out1 = xSignal;
xlsub2_Constant2 = xBlock(struct('source', 'Constant', 'name', 'Constant2'), ...
struct('arith_type', 'Unsigned', ...
'const', DelayLen, ...
'n_bits', BitWidth, ...
'bin_pt', 0, ...
'explicit_period', 'on'), ...
{}, ...
{xlsub2_Constant2_out1});
% block: delay_7/sync_delay_en/Constant3
xlsub2_Constant3_out1 = xSignal;
xlsub2_Constant3 = xBlock(struct('source', 'Constant', 'name', 'Constant3'), ...
struct('arith_type', 'Unsigned', ...
'const', UseCounter, ...
'n_bits', 1, ...
'bin_pt', 0, ...
'explicit_period', 'on'), ...
{}, ...
{xlsub2_Constant3_out1});
% block: delay_7/sync_delay_en/Counter
xlsub2_Logical1_out1 = xSignal;
xlsub2_Counter_out1 = xSignal;
xlsub2_Counter = xBlock(struct('source', 'Counter', 'name', 'Counter'), ...
struct('operation', 'Down', ...
'n_bits', BitWidth, ...
'load_pin', 'on', ...
'en', 'on', ...
'use_rpm', 'on'), ...
{xlsub2_In, xlsub2_Constant2_out1, xlsub2_Logical1_out1}, ...
{xlsub2_Counter_out1});
% block: delay_7/sync_delay_en/Logical
xlsub2_Relational1_out1 = xSignal;
xlsub2_Logical_out1 = xSignal;
xlsub2_Logical = xBlock(struct('source', 'Logical', 'name', 'Logical'), ...
struct('logical_function', 'OR', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_In, xlsub2_Relational1_out1}, ...
{xlsub2_Logical_out1});
% block: delay_7/sync_delay_en/Logical1
xlsub2_Logical1 = xBlock(struct('source', 'Logical', 'name', 'Logical1'), ...
struct('n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_Logical_out1, xlsub2_en}, ...
{xlsub2_Logical1_out1});
% block: delay_7/sync_delay_en/Mux
xlsub2_Relational_out1 = xSignal;
xlsub2_Mux = xBlock(struct('source', 'Mux', 'name', 'Mux'), ...
struct('arith_type', 'Signed (2''s comp)', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_Constant3_out1, xlsub2_In, xlsub2_Relational_out1}, ...
{xlsub2_Out});
% block: delay_7/sync_delay_en/Relational
xlsub2_Relational = xBlock(struct('source', 'Relational', 'name', 'Relational'), ...
struct('latency', 0), ...
{xlsub2_Constant_out1, xlsub2_Counter_out1}, ...
{xlsub2_Relational_out1});
% block: delay_7/sync_delay_en/Relational1
xlsub2_Relational1 = xBlock(struct('source', 'Relational', 'name', 'Relational1'), ...
struct('mode', 'a!=b', ...
'latency', 0), ...
{xlsub2_Counter_out1, xlsub2_Constant1_out1}, ...
{xlsub2_Relational1_out1});
% block: delay_7/sync_delay_en/warn period Logical0
xlsub2_warn_period_Logical0 = xBlock(struct('source', 'xbsReplacements_r4/Warning', 'name', 'warn period Logical0'), ...
struct('period', 1), ...
{}, ...
{});
% block: delay_7/sync_delay_en/warn period Logical10
xlsub2_warn_period_Logical10 = xBlock(struct('source', 'xbsReplacements_r4/Warning', 'name', 'warn period Logical10'), ...
struct('period', 1), ...
{}, ...
{});
% block: delay_7/sync_delay_en/warn period Relational10
xlsub2_warn_period_Relational10 = xBlock(struct('source', 'xbsReplacements_r4/Warning', 'name', 'warn period Relational10'), ...
struct('period', 1), ...
{}, ...
{});
end