-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbl_buffer_init_xblock.m
More file actions
144 lines (124 loc) · 6.58 KB
/
dbl_buffer_init_xblock.m
File metadata and controls
144 lines (124 loc) · 6.58 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Center for Astronomy Signal Processing and Electronics Research %
% http://casper.berkeley.edu %
% Copyright (C) 2011 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 dbl_buffer_init_xblock(depth, latency)
%% inports
xlsub2_rw_mode = xInport('rw_mode');
xlsub2_wr_addr = xInport('wr_addr');
xlsub2_rd_addr = xInport('rd_addr');
xlsub2_din1 = xInport('din1');
xlsub2_we = xInport('we');
%% outports
xlsub2_dout = xOutport('dout');
%% diagram
% block: reorder_xblock_models/dbl_buffer/Constant
xlsub2_Constant_out1 = xSignal;
xlsub2_Constant = xBlock(struct('source', 'Constant', 'name', 'Constant'), ...
struct('arith_type', 'Boolean', ...
'const', 0, ...
'n_bits', 1, ...
'bin_pt', 0, ...
'explicit_period', 'on'), ...
{}, ...
{xlsub2_Constant_out1});
% block: reorder_xblock_models/dbl_buffer/Mux
xlsub2_Mux_out1 = xSignal;
xlsub2_Mux = xBlock(struct('source', 'Mux', 'name', 'Mux'), ...
struct('latency', 1, ...
'arith_type', 'Signed (2''s comp)', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_rw_mode, xlsub2_wr_addr, xlsub2_rd_addr}, ...
{xlsub2_Mux_out1});
% block: reorder_xblock_models/dbl_buffer/Mux2
xlsub2_Mux2_out1 = xSignal;
xlsub2_Mux2 = xBlock(struct('source', 'Mux', 'name', 'Mux2'), ...
struct('latency', 1, ...
'arith_type', 'Signed (2''s comp)', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_rw_mode, xlsub2_we, xlsub2_Constant_out1}, ...
{xlsub2_Mux2_out1});
% block: reorder_xblock_models/dbl_buffer/Mux3
xlsub2_Mux3_out1 = xSignal;
xlsub2_Mux3 = xBlock(struct('source', 'Mux', 'name', 'Mux3'), ...
struct('latency', 1, ...
'arith_type', 'Signed (2''s comp)', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_rw_mode, xlsub2_rd_addr, xlsub2_wr_addr}, ...
{xlsub2_Mux3_out1});
% block: reorder_xblock_models/dbl_buffer/Mux5
xlsub2_Mux5_out1 = xSignal;
xlsub2_Mux5 = xBlock(struct('source', 'Mux', 'name', 'Mux5'), ...
struct('latency', 1, ...
'arith_type', 'Signed (2''s comp)', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_rw_mode, xlsub2_Constant_out1, xlsub2_we}, ...
{xlsub2_Mux5_out1});
% block: reorder_xblock_models/dbl_buffer/Mux6
xlsub2_delay_out1 = xSignal;
xlsub2_bram1_out1 = xSignal;
xlsub2_bram0_out1 = xSignal;
xlsub2_Mux6 = xBlock(struct('source', 'Mux', 'name', 'Mux6'), ...
struct('latency', 1, ...
'arith_type', 'Signed (2''s comp)', ...
'n_bits', 8, ...
'bin_pt', 2), ...
{xlsub2_delay_out1, xlsub2_bram1_out1, xlsub2_bram0_out1}, ...
{xlsub2_dout});
% block: reorder_xblock_models/dbl_buffer/bram0
xlsub2_delay1_out1 = xSignal;
xlsub2_bram0 = xBlock(struct('source', 'Single Port RAM', 'name', 'bram0'), ...
struct('depth', depth, ...
'initVector', 0, ...
'write_mode', 'Read Before Write', ...
'latency', latency, ...
'use_rpm', 'off'), ...
{xlsub2_Mux_out1, xlsub2_delay1_out1, xlsub2_Mux2_out1}, ...
{xlsub2_bram0_out1});
% block: reorder_xblock_models/dbl_buffer/bram1
xlsub2_delay2_out1 = xSignal;
xlsub2_bram1 = xBlock(struct('source', 'Single Port RAM', 'name', 'bram1'), ...
struct('depth', depth, ...
'initVector', 0, ...
'write_mode', 'Read Before Write', ...
'latency', latency, ...
'use_rpm', 'off'), ...
{xlsub2_Mux3_out1, xlsub2_delay2_out1, xlsub2_Mux5_out1}, ...
{xlsub2_bram1_out1});
% block: reorder_xblock_models/dbl_buffer/delay
xlsub2_delay = xBlock(struct('source', 'Delay', 'name', 'delay'), ...
struct('latency', latency + 1), ...
{xlsub2_rw_mode}, ...
{xlsub2_delay_out1});
% block: reorder_xblock_models/dbl_buffer/delay1
xlsub2_delay1 = xBlock(struct('source', 'Delay', 'name', 'delay1'), ...
[], ...
{xlsub2_din1}, ...
{xlsub2_delay1_out1});
% block: reorder_xblock_models/dbl_buffer/delay2
xlsub2_delay2 = xBlock(struct('source', 'Delay', 'name', 'delay2'), ...
[], ...
{xlsub2_din1}, ...
{xlsub2_delay2_out1});
end