source: ResearchApps/PHY/MIMO_OFDM/fec_decoder_config.m

Last change on this file was 1715, checked in by murphpo, 12 years ago

cleaning up PHY directory; coded PHY is now primary OFDM_MIMO model

File size: 5.3 KB
Line 
1
2function fec_decoder_config(this_block)
3
4  % Revision History:
5  %
6  %   12-Oct-2010  (03:00 hours):
7  %     Original code was machine generated by Xilinx's System Generator after parsing
8  %     E:\My Dropbox\Project\WARP\Sysgen\Rev5\fec_decoder.v
9  %
10  %
11
12  this_block.setTopLevelLanguage('Verilog');
13
14  this_block.setEntityName('fec_decoder');
15
16  % System Generator has to assume that your entity  has a combinational feed through;
17  %   if it  doesn't, then comment out the following line:
18  this_block.tagAsCombinational;
19
20  this_block.addSimulinkInport('nrst');
21  this_block.addSimulinkInport('fec_reg');
22  this_block.addSimulinkInport('start');
23  this_block.addSimulinkInport('vin');
24  this_block.addSimulinkInport('xk_index');
25  this_block.addSimulinkInport('mod_level');
26  this_block.addSimulinkInport('rx_i');
27  this_block.addSimulinkInport('rx_q');
28
29  this_block.addSimulinkOutport('rx_we');
30  this_block.addSimulinkOutport('rx_addr');
31  this_block.addSimulinkOutport('rx_data');
32  this_block.addSimulinkOutport('rx_done');
33  this_block.addSimulinkOutport('rx_we_2');
34  this_block.addSimulinkOutport('rx_addr_2');
35  this_block.addSimulinkOutport('rx_data_2');
36  this_block.addSimulinkOutport('rx_done_2');
37
38  rx_we_port = this_block.port('rx_we');
39  % rx_we_port.setType('UFix_1_0');
40  rx_we_port.setType('UFix_1_0');
41  rx_we_port.useHDLVector(false);
42  rx_addr_port = this_block.port('rx_addr');
43  rx_addr_port.setType('UFix_14_0');
44  rx_data_port = this_block.port('rx_data');
45  rx_data_port.setType('UFix_8_0');
46  rx_done_port = this_block.port('rx_done');
47  % rx_done_port.setType('UFix_1_0');
48  rx_done_port.setType('UFix_1_0');
49  rx_done_port.useHDLVector(false);
50  rx_we_2_port = this_block.port('rx_we_2');
51  % rx_we_2_port.setType('UFix_1_0');
52  rx_we_2_port.setType('Bool');
53  rx_we_2_port.useHDLVector(false);
54  rx_addr_2_port = this_block.port('rx_addr_2');
55  rx_addr_2_port.setType('UFix_14_0');
56  rx_data_2_port = this_block.port('rx_data_2');
57  rx_data_2_port.setType('UFix_8_0');
58  rx_done_2_port = this_block.port('rx_done_2');
59  % rx_done_2_port.setType('UFix_1_0');
60  rx_done_2_port.setType('Bool');
61  rx_done_2_port.useHDLVector(false);
62
63  % -----------------------------
64  if (this_block.inputTypesKnown)
65    % do input type checking, dynamic output type and generic setup in this code block.
66
67    if (this_block.port('nrst').width ~= 1);
68      this_block.setError('Input data type for port "nrst" must have width=1.');
69    end
70
71    this_block.port('nrst').useHDLVector(false);
72
73    if (this_block.port('fec_reg').width ~= 32);
74      this_block.setError('Input data type for port "fec_reg" must have width=32.');
75    end
76
77    if (this_block.port('start').width ~= 1);
78      this_block.setError('Input data type for port "start" must have width=1.');
79    end
80
81    this_block.port('start').useHDLVector(false);
82
83    if (this_block.port('vin').width ~= 1);
84      this_block.setError('Input data type for port "vin" must have width=1.');
85    end
86
87    this_block.port('vin').useHDLVector(false);
88
89    if (this_block.port('xk_index').width ~= 6);
90      this_block.setError('Input data type for port "xk_index" must have width=6.');
91    end
92
93    if (this_block.port('mod_level').width ~= 4);
94      this_block.setError('Input data type for port "mod_level" must have width=4.');
95    end
96
97    if (this_block.port('rx_i').width ~= 16);
98      this_block.setError('Input data type for port "rx_i" must have width=16.');
99    end
100
101    if (this_block.port('rx_q').width ~= 16);
102      this_block.setError('Input data type for port "rx_q" must have width=16.');
103    end
104
105  end  % if(inputTypesKnown)
106  % -----------------------------
107
108  % -----------------------------
109   if (this_block.inputRatesKnown)
110     setup_as_single_rate(this_block,'clk','ce')
111   end  % if(inputRatesKnown)
112  % -----------------------------
113
114    % (!) Set the inout port rate to be the same as the first input
115    %     rate. Change the following code if this is untrue.
116    uniqueInputRates = unique(this_block.getInputRates);
117
118
119  % Add addtional source files as needed.
120  %  |-------------
121  %  | Add files in the order in which they should be compiled.
122  %  | If two files "a.vhd" and "b.vhd" contain the entities
123  %  | entity_a and entity_b, and entity_a contains a
124  %  | component of type entity_b, the correct sequence of
125  %  | addFile() calls would be:
126  %  |    this_block.addFile('b.vhd');
127  %  |    this_block.addFile('a.vhd');
128  %  |-------------
129
130  %    this_block.addFile('');
131  %    this_block.addFile('');
132  this_block.addFile('fec_decoder.v');
133
134return;
135
136
137% ------------------------------------------------------------
138
139function setup_as_single_rate(block,clkname,cename) 
140  inputRates = block.inputRates; 
141  uniqueInputRates = unique(inputRates); 
142  if (length(uniqueInputRates)==1 & uniqueInputRates(1)==Inf) 
143    block.addError('The inputs to this block cannot all be constant.'); 
144    return; 
145  end 
146  if (uniqueInputRates(end) == Inf) 
147     hasConstantInput = true; 
148     uniqueInputRates = uniqueInputRates(1:end-1); 
149  end 
150  if (length(uniqueInputRates) ~= 1) 
151    block.addError('The inputs to this block must run at a single rate.'); 
152    return; 
153  end 
154  theInputRate = uniqueInputRates(1); 
155  for i = 1:block.numSimulinkOutports
156     block.outport(i).setRate(theInputRate); 
157  end 
158  block.addClkCEPair(clkname,cename,theInputRate); 
159  return; 
160
161% ------------------------------------------------------------
162
Note: See TracBrowser for help on using the repository browser.