-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_of0.m
More file actions
117 lines (101 loc) · 4.42 KB
/
convert_of0.m
File metadata and controls
117 lines (101 loc) · 4.42 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
function convert_of0(bit_width_i, binary_point_i, bit_width_o, binary_point_o, latency, overflow, quantization)
% This is a generated function based on subsystem:
% untitled/convert_of0
% Though there are limitations about the generated script,
% the main purpose of this utility is to make learning
% Sysgen Script easier.
%
% To test it, run the following commands from MATLAB console:
% cfg.source = str2func('convert_of0');
% cfg.toplevel = 'untitled/convert_of0';
% args = {my_bit_width_i, my_binary_point_i, my_bit_width_o, my_binary_point_o, my_latency, my_overflow, my_quantization};
% xBlock(cfg, args);
%
% You can edit convert_of0.m to debug your script.
%
% You can also replace the MaskInitialization code with the
% following commands so the subsystem will be generated
% according to the values of mask parameters.
% cfg.source = str2func('convert_of0');
% cfg.toplevel = gcb;
% args = {bit_width_i, binary_point_i, bit_width_o, binary_point_o, latency, overflow, quantization};
% xBlock(cfg, args);
%
% To configure the xBlock call in debug mode, in which mode,
% autolayout will be performed every time a block is added,
% run the following commands:
% cfg.source = str2func('convert_of0');
% cfg.toplevel = gcb;
% cfg.debug = 1;
% args = {bit_width_i, binary_point_i, bit_width_o, binary_point_o, latency, overflow, quantization};
% xBlock(cfg, args);
%
% To make the xBlock smart so it won't re-generate the
% subsystem if neither the arguments nor the scripts are
% changes, use as the following:
% cfg.source = str2func('convert_of0');
% cfg.toplevel = gcb;
% cfg.depend = {'convert_of0'};
% args = {bit_width_i, binary_point_i, bit_width_o, binary_point_o, latency, overflow, quantization};
% xBlock(cfg, args);
%
% See also xBlock, xInport, xOutport, xSignal, xlsub2script.
%% inports
xlsub2_din = xInport('din');
%% outports
xlsub2_dout = xOutport('dout');
xlsub2_of = xOutport('of');
%% diagram
% block: untitled/convert_of0/all_0s
xlsub2_invert1_out1 = xSignal;
xlsub2_invert2_out1 = xSignal;
xlsub2_all_0s_out1 = xSignal;
xlsub2_all_0s = xBlock(struct('source', 'Logical', 'name', 'all_0s'), ...
struct('logical_function', 'NAND', ...
'latency', latency), ...
{xlsub2_invert1_out1, xlsub2_invert2_out1}, ...
{xlsub2_all_0s_out1});
% block: untitled/convert_of0/all_1s
xlsub2_slice1_out1 = xSignal;
xlsub2_slice2_out1 = xSignal;
xlsub2_all_1s_out1 = xSignal;
xlsub2_all_1s = xBlock(struct('source', 'Logical', 'name', 'all_1s'), ...
struct('logical_function', 'NAND', ...
'latency', latency), ...
{xlsub2_slice1_out1, xlsub2_slice2_out1}, ...
{xlsub2_all_1s_out1});
% block: untitled/convert_of0/and
xlsub2_and = xBlock(struct('source', 'Logical', 'name', 'and'), ...
[], ...
{xlsub2_all_0s_out1, xlsub2_all_1s_out1}, ...
{xlsub2_of});
% block: untitled/convert_of0/convert
xlsub2_convert = xBlock(struct('source', 'Convert', 'name', 'convert'), ...
struct('n_bits', bit_width_o, ...
'bin_pt', binary_point_o, ...
'latency', latency, ...
'pipeline', 'on'), ...
{xlsub2_din}, ...
{xlsub2_dout});
% block: untitled/convert_of0/invert1
xlsub2_invert1 = xBlock(struct('source', 'Inverter', 'name', 'invert1'), ...
[], ...
{xlsub2_slice1_out1}, ...
{xlsub2_invert1_out1});
% block: untitled/convert_of0/invert2
xlsub2_invert2 = xBlock(struct('source', 'Inverter', 'name', 'invert2'), ...
[], ...
{xlsub2_slice2_out1}, ...
{xlsub2_invert2_out1});
% block: untitled/convert_of0/slice1
xlsub2_slice1 = xBlock(struct('source', 'Slice', 'name', 'slice1'), ...
struct('boolean_output', 'on'), ...
{xlsub2_din}, ...
{xlsub2_slice1_out1});
% block: untitled/convert_of0/slice2
xlsub2_slice2 = xBlock(struct('source', 'Slice', 'name', 'slice2'), ...
struct('boolean_output', 'on', ...
'bit1', -1), ...
{xlsub2_din}, ...
{xlsub2_slice2_out1});
end