@@ -1,338 +1,332 | |||||
1 | #ifndef FSW_PROCESSING_H_INCLUDED |
|
1 | #ifndef FSW_PROCESSING_H_INCLUDED | |
2 | #define FSW_PROCESSING_H_INCLUDED |
|
2 | #define FSW_PROCESSING_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <grspw.h> |
|
5 | #include <grspw.h> | |
6 | #include <math.h> |
|
6 | #include <math.h> | |
7 | #include <stdlib.h> // abs() is in the stdlib |
|
7 | #include <stdlib.h> // abs() is in the stdlib | |
8 | #include <stdio.h> |
|
8 | #include <stdio.h> | |
9 | #include <math.h> |
|
9 | #include <math.h> | |
10 | #include <grlib_regs.h> |
|
10 | #include <grlib_regs.h> | |
11 |
|
11 | |||
12 | #include "fsw_params.h" |
|
12 | #include "fsw_params.h" | |
13 |
|
13 | |||
14 | typedef struct ring_node_asm |
|
14 | typedef struct ring_node_asm | |
15 | { |
|
15 | { | |
16 | struct ring_node_asm *next; |
|
16 | struct ring_node_asm *next; | |
17 | float matrix[ TOTAL_SIZE_SM ]; |
|
17 | float matrix[ TOTAL_SIZE_SM ]; | |
18 | unsigned int status; |
|
18 | unsigned int status; | |
19 | } ring_node_asm; |
|
19 | } ring_node_asm; | |
20 |
|
20 | |||
21 | typedef struct |
|
21 | typedef struct | |
22 | { |
|
22 | { | |
23 | unsigned char targetLogicalAddress; |
|
23 | unsigned char targetLogicalAddress; | |
24 | unsigned char protocolIdentifier; |
|
24 | unsigned char protocolIdentifier; | |
25 | unsigned char reserved; |
|
25 | unsigned char reserved; | |
26 | unsigned char userApplication; |
|
26 | unsigned char userApplication; | |
27 | unsigned char packetID[2]; |
|
27 | unsigned char packetID[2]; | |
28 | unsigned char packetSequenceControl[2]; |
|
28 | unsigned char packetSequenceControl[2]; | |
29 | unsigned char packetLength[2]; |
|
29 | unsigned char packetLength[2]; | |
30 | // DATA FIELD HEADER |
|
30 | // DATA FIELD HEADER | |
31 | unsigned char spare1_pusVersion_spare2; |
|
31 | unsigned char spare1_pusVersion_spare2; | |
32 | unsigned char serviceType; |
|
32 | unsigned char serviceType; | |
33 | unsigned char serviceSubType; |
|
33 | unsigned char serviceSubType; | |
34 | unsigned char destinationID; |
|
34 | unsigned char destinationID; | |
35 | unsigned char time[6]; |
|
35 | unsigned char time[6]; | |
36 | // AUXILIARY HEADER |
|
36 | // AUXILIARY HEADER | |
37 | unsigned char sid; |
|
37 | unsigned char sid; | |
38 | unsigned char pa_bia_status_info; |
|
38 | unsigned char pa_bia_status_info; | |
39 | unsigned char sy_lfr_common_parameters_spare; |
|
39 | unsigned char sy_lfr_common_parameters_spare; | |
40 | unsigned char sy_lfr_common_parameters; |
|
40 | unsigned char sy_lfr_common_parameters; | |
41 | unsigned char acquisitionTime[6]; |
|
41 | unsigned char acquisitionTime[6]; | |
42 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
42 | unsigned char pa_lfr_bp_blk_nr[2]; | |
43 | // SOURCE DATA |
|
43 | // SOURCE DATA | |
44 | unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
44 | unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] | |
45 | } bp_packet; |
|
45 | } bp_packet; | |
46 |
|
46 | |||
47 | typedef struct |
|
47 | typedef struct | |
48 | { |
|
48 | { | |
49 | unsigned char targetLogicalAddress; |
|
49 | unsigned char targetLogicalAddress; | |
50 | unsigned char protocolIdentifier; |
|
50 | unsigned char protocolIdentifier; | |
51 | unsigned char reserved; |
|
51 | unsigned char reserved; | |
52 | unsigned char userApplication; |
|
52 | unsigned char userApplication; | |
53 | unsigned char packetID[2]; |
|
53 | unsigned char packetID[2]; | |
54 | unsigned char packetSequenceControl[2]; |
|
54 | unsigned char packetSequenceControl[2]; | |
55 | unsigned char packetLength[2]; |
|
55 | unsigned char packetLength[2]; | |
56 | // DATA FIELD HEADER |
|
56 | // DATA FIELD HEADER | |
57 | unsigned char spare1_pusVersion_spare2; |
|
57 | unsigned char spare1_pusVersion_spare2; | |
58 | unsigned char serviceType; |
|
58 | unsigned char serviceType; | |
59 | unsigned char serviceSubType; |
|
59 | unsigned char serviceSubType; | |
60 | unsigned char destinationID; |
|
60 | unsigned char destinationID; | |
61 | unsigned char time[6]; |
|
61 | unsigned char time[6]; | |
62 | // AUXILIARY HEADER |
|
62 | // AUXILIARY HEADER | |
63 | unsigned char sid; |
|
63 | unsigned char sid; | |
64 | unsigned char pa_bia_status_info; |
|
64 | unsigned char pa_bia_status_info; | |
65 | unsigned char sy_lfr_common_parameters_spare; |
|
65 | unsigned char sy_lfr_common_parameters_spare; | |
66 | unsigned char sy_lfr_common_parameters; |
|
66 | unsigned char sy_lfr_common_parameters; | |
67 | unsigned char acquisitionTime[6]; |
|
67 | unsigned char acquisitionTime[6]; | |
68 | unsigned char source_data_spare; |
|
68 | unsigned char source_data_spare; | |
69 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
69 | unsigned char pa_lfr_bp_blk_nr[2]; | |
70 | // SOURCE DATA |
|
70 | // SOURCE DATA | |
71 | unsigned char data[ 143 ]; // 13 bins * 11 Bytes |
|
71 | unsigned char data[ 143 ]; // 13 bins * 11 Bytes | |
72 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
72 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 | |
73 |
|
73 | |||
74 | typedef struct asm_msg |
|
74 | typedef struct asm_msg | |
75 | { |
|
75 | { | |
76 | ring_node_asm *norm; |
|
76 | ring_node_asm *norm; | |
77 | ring_node_asm *burst_sbm; |
|
77 | ring_node_asm *burst_sbm; | |
78 | rtems_event_set event; |
|
78 | rtems_event_set event; | |
79 | unsigned int coarseTimeNORM; |
|
79 | unsigned int coarseTimeNORM; | |
80 | unsigned int fineTimeNORM; |
|
80 | unsigned int fineTimeNORM; | |
81 | unsigned int coarseTimeSBM; |
|
81 | unsigned int coarseTimeSBM; | |
82 | unsigned int fineTimeSBM; |
|
82 | unsigned int fineTimeSBM; | |
83 | } asm_msg; |
|
83 | } asm_msg; | |
84 |
|
84 | |||
85 | extern unsigned char thisIsAnASMRestart; |
|
85 | extern unsigned char thisIsAnASMRestart; | |
86 |
|
86 | |||
87 | extern volatile int sm_f0[ ]; |
|
87 | extern volatile int sm_f0[ ]; | |
88 | extern volatile int sm_f1[ ]; |
|
88 | extern volatile int sm_f1[ ]; | |
89 | extern volatile int sm_f2[ ]; |
|
89 | extern volatile int sm_f2[ ]; | |
90 |
|
90 | |||
91 | // parameters |
|
91 | // parameters | |
92 | extern struct param_local_str param_local; |
|
92 | extern struct param_local_str param_local; | |
93 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
93 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
94 | extern unsigned char rw_fbins_mask_f0[16]; |
|
|||
95 | extern unsigned char rw_fbins_mask_f1[16]; |
|
|||
96 | extern unsigned char rw_fbins_mask_f2[16]; |
|
|||
97 | extern unsigned char merged_fbins_mask_f0[16]; |
|
|||
98 | extern unsigned char merged_fbins_mask_f1[16]; |
|
|||
99 | extern unsigned char merged_fbins_mask_f2[16]; |
|
|||
100 |
|
94 | |||
101 | // registers |
|
95 | // registers | |
102 | extern time_management_regs_t *time_management_regs; |
|
96 | extern time_management_regs_t *time_management_regs; | |
103 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; |
|
97 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; | |
104 |
|
98 | |||
105 | extern rtems_name misc_name[5]; |
|
99 | extern rtems_name misc_name[5]; | |
106 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
100 | extern rtems_id Task_id[20]; /* array of task ids */ | |
107 |
|
101 | |||
108 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); |
|
102 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); | |
109 | // ISR |
|
103 | // ISR | |
110 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
104 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); | |
111 |
|
105 | |||
112 | //****************** |
|
106 | //****************** | |
113 | // Spectral Matrices |
|
107 | // Spectral Matrices | |
114 | void reset_nb_sm( void ); |
|
108 | void reset_nb_sm( void ); | |
115 | // SM |
|
109 | // SM | |
116 | void SM_init_rings( void ); |
|
110 | void SM_init_rings( void ); | |
117 | void SM_reset_current_ring_nodes( void ); |
|
111 | void SM_reset_current_ring_nodes( void ); | |
118 | // ASM |
|
112 | // ASM | |
119 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); |
|
113 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); | |
120 |
|
114 | |||
121 | //***************** |
|
115 | //***************** | |
122 | // Basic Parameters |
|
116 | // Basic Parameters | |
123 |
|
117 | |||
124 | void BP_reset_current_ring_nodes( void ); |
|
118 | void BP_reset_current_ring_nodes( void ); | |
125 | void BP_init_header(bp_packet *packet, |
|
119 | void BP_init_header(bp_packet *packet, | |
126 | unsigned int apid, unsigned char sid, |
|
120 | unsigned int apid, unsigned char sid, | |
127 | unsigned int packetLength , unsigned char blkNr); |
|
121 | unsigned int packetLength , unsigned char blkNr); | |
128 | void BP_init_header_with_spare(bp_packet_with_spare *packet, |
|
122 | void BP_init_header_with_spare(bp_packet_with_spare *packet, | |
129 | unsigned int apid, unsigned char sid, |
|
123 | unsigned int apid, unsigned char sid, | |
130 | unsigned int packetLength, unsigned char blkNr ); |
|
124 | unsigned int packetLength, unsigned char blkNr ); | |
131 | void BP_send( char *data, |
|
125 | void BP_send( char *data, | |
132 | rtems_id queue_id, |
|
126 | rtems_id queue_id, | |
133 | unsigned int nbBytesToSend , unsigned int sid ); |
|
127 | unsigned int nbBytesToSend , unsigned int sid ); | |
134 | void BP_send_s1_s2(char *data, |
|
128 | void BP_send_s1_s2(char *data, | |
135 | rtems_id queue_id, |
|
129 | rtems_id queue_id, | |
136 | unsigned int nbBytesToSend, unsigned int sid ); |
|
130 | unsigned int nbBytesToSend, unsigned int sid ); | |
137 |
|
131 | |||
138 | //****************** |
|
132 | //****************** | |
139 | // general functions |
|
133 | // general functions | |
140 | void reset_sm_status( void ); |
|
134 | void reset_sm_status( void ); | |
141 | void reset_spectral_matrix_regs( void ); |
|
135 | void reset_spectral_matrix_regs( void ); | |
142 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
136 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); | |
143 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); |
|
137 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); | |
144 | unsigned char getSID( rtems_event_set event ); |
|
138 | unsigned char getSID( rtems_event_set event ); | |
145 |
|
139 | |||
146 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
140 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); | |
147 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
141 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); | |
148 |
|
142 | |||
149 | //*************************************** |
|
143 | //*************************************** | |
150 | // DEFINITIONS OF STATIC INLINE FUNCTIONS |
|
144 | // DEFINITIONS OF STATIC INLINE FUNCTIONS | |
151 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
145 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
152 | ring_node *ring_node_tab[], |
|
146 | ring_node *ring_node_tab[], | |
153 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
147 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
154 | asm_msg *msgForMATR ); |
|
148 | asm_msg *msgForMATR ); | |
155 |
|
149 | |||
156 | static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
150 | static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
157 | ring_node *ring_node_tab[], |
|
151 | ring_node *ring_node_tab[], | |
158 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
152 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
159 | asm_msg *msgForMATR ); |
|
153 | asm_msg *msgForMATR ); | |
160 |
|
154 | |||
161 | void ASM_patch( float *inputASM, float *outputASM ); |
|
155 | void ASM_patch( float *inputASM, float *outputASM ); | |
162 |
|
156 | |||
163 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); |
|
157 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); | |
164 |
|
158 | |||
165 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
159 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, | |
166 | float divider ); |
|
160 | float divider ); | |
167 |
|
161 | |||
168 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
162 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, | |
169 | float divider, |
|
163 | float divider, | |
170 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
164 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); | |
171 |
|
165 | |||
172 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
166 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); | |
173 |
|
167 | |||
174 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
168 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
175 | ring_node *ring_node_tab[], |
|
169 | ring_node *ring_node_tab[], | |
176 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
170 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
177 | asm_msg *msgForMATR ) |
|
171 | asm_msg *msgForMATR ) | |
178 | { |
|
172 | { | |
179 | float sum; |
|
173 | float sum; | |
180 | unsigned int i; |
|
174 | unsigned int i; | |
181 |
|
175 | |||
182 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
176 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
183 | { |
|
177 | { | |
184 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] |
|
178 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] | |
185 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] |
|
179 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] | |
186 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] |
|
180 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] | |
187 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] |
|
181 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] | |
188 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] |
|
182 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] | |
189 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] |
|
183 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] | |
190 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] |
|
184 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] | |
191 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; |
|
185 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; | |
192 |
|
186 | |||
193 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
187 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) | |
194 | { |
|
188 | { | |
195 | averaged_spec_mat_NORM[ i ] = sum; |
|
189 | averaged_spec_mat_NORM[ i ] = sum; | |
196 | averaged_spec_mat_SBM[ i ] = sum; |
|
190 | averaged_spec_mat_SBM[ i ] = sum; | |
197 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
191 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
198 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
192 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
199 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
193 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
200 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
194 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
201 | } |
|
195 | } | |
202 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
196 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) | |
203 | { |
|
197 | { | |
204 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
198 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); | |
205 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
199 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); | |
206 | } |
|
200 | } | |
207 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
201 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) | |
208 | { |
|
202 | { | |
209 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
203 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); | |
210 | averaged_spec_mat_SBM[ i ] = sum; |
|
204 | averaged_spec_mat_SBM[ i ] = sum; | |
211 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
205 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
212 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
206 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
213 | } |
|
207 | } | |
214 | else |
|
208 | else | |
215 | { |
|
209 | { | |
216 | averaged_spec_mat_NORM[ i ] = sum; |
|
210 | averaged_spec_mat_NORM[ i ] = sum; | |
217 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
211 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); | |
218 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
212 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
219 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
213 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
220 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) |
|
214 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) | |
221 | } |
|
215 | } | |
222 | } |
|
216 | } | |
223 | } |
|
217 | } | |
224 |
|
218 | |||
225 | void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
219 | void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
226 | ring_node *ring_node_tab[], |
|
220 | ring_node *ring_node_tab[], | |
227 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
221 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
228 | asm_msg *msgForMATR ) |
|
222 | asm_msg *msgForMATR ) | |
229 | { |
|
223 | { | |
230 | float sum; |
|
224 | float sum; | |
231 | unsigned int i; |
|
225 | unsigned int i; | |
232 |
|
226 | |||
233 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
227 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
234 | { |
|
228 | { | |
235 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]; |
|
229 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]; | |
236 | averaged_spec_mat_NORM[ i ] = sum; |
|
230 | averaged_spec_mat_NORM[ i ] = sum; | |
237 | averaged_spec_mat_SBM[ i ] = sum; |
|
231 | averaged_spec_mat_SBM[ i ] = sum; | |
238 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
232 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
239 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
233 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
240 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
234 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
241 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
235 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
242 | } |
|
236 | } | |
243 | } |
|
237 | } | |
244 |
|
238 | |||
245 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
239 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) | |
246 | { |
|
240 | { | |
247 | int frequencyBin; |
|
241 | int frequencyBin; | |
248 | int asmComponent; |
|
242 | int asmComponent; | |
249 | unsigned int offsetASM; |
|
243 | unsigned int offsetASM; | |
250 | unsigned int offsetASMReorganized; |
|
244 | unsigned int offsetASMReorganized; | |
251 |
|
245 | |||
252 | // BUILD DATA |
|
246 | // BUILD DATA | |
253 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
247 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
254 | { |
|
248 | { | |
255 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
249 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) | |
256 | { |
|
250 | { | |
257 | offsetASMReorganized = |
|
251 | offsetASMReorganized = | |
258 | frequencyBin * NB_VALUES_PER_SM |
|
252 | frequencyBin * NB_VALUES_PER_SM | |
259 | + asmComponent; |
|
253 | + asmComponent; | |
260 | offsetASM = |
|
254 | offsetASM = | |
261 | asmComponent * NB_BINS_PER_SM |
|
255 | asmComponent * NB_BINS_PER_SM | |
262 | + frequencyBin; |
|
256 | + frequencyBin; | |
263 | averaged_spec_mat_reorganized[offsetASMReorganized ] = |
|
257 | averaged_spec_mat_reorganized[offsetASMReorganized ] = | |
264 | averaged_spec_mat[ offsetASM ] / divider; |
|
258 | averaged_spec_mat[ offsetASM ] / divider; | |
265 | } |
|
259 | } | |
266 | } |
|
260 | } | |
267 | } |
|
261 | } | |
268 |
|
262 | |||
269 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
263 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
270 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
264 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) | |
271 | { |
|
265 | { | |
272 | int frequencyBin; |
|
266 | int frequencyBin; | |
273 | int asmComponent; |
|
267 | int asmComponent; | |
274 | int offsetASM; |
|
268 | int offsetASM; | |
275 | int offsetCompressed; |
|
269 | int offsetCompressed; | |
276 | int k; |
|
270 | int k; | |
277 |
|
271 | |||
278 | // BUILD DATA |
|
272 | // BUILD DATA | |
279 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
273 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
280 | { |
|
274 | { | |
281 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
275 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
282 | { |
|
276 | { | |
283 | offsetCompressed = // NO TIME OFFSET |
|
277 | offsetCompressed = // NO TIME OFFSET | |
284 | frequencyBin * NB_VALUES_PER_SM |
|
278 | frequencyBin * NB_VALUES_PER_SM | |
285 | + asmComponent; |
|
279 | + asmComponent; | |
286 | offsetASM = // NO TIME OFFSET |
|
280 | offsetASM = // NO TIME OFFSET | |
287 | asmComponent * NB_BINS_PER_SM |
|
281 | asmComponent * NB_BINS_PER_SM | |
288 | + ASMIndexStart |
|
282 | + ASMIndexStart | |
289 | + frequencyBin * nbBinsToAverage; |
|
283 | + frequencyBin * nbBinsToAverage; | |
290 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
284 | compressed_spec_mat[ offsetCompressed ] = 0; | |
291 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
285 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
292 | { |
|
286 | { | |
293 | compressed_spec_mat[offsetCompressed ] = |
|
287 | compressed_spec_mat[offsetCompressed ] = | |
294 | ( compressed_spec_mat[ offsetCompressed ] |
|
288 | ( compressed_spec_mat[ offsetCompressed ] | |
295 | + averaged_spec_mat[ offsetASM + k ] ); |
|
289 | + averaged_spec_mat[ offsetASM + k ] ); | |
296 | } |
|
290 | } | |
297 | compressed_spec_mat[ offsetCompressed ] = |
|
291 | compressed_spec_mat[ offsetCompressed ] = | |
298 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
292 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
299 | } |
|
293 | } | |
300 | } |
|
294 | } | |
301 | } |
|
295 | } | |
302 |
|
296 | |||
303 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
297 | void ASM_convert( volatile float *input_matrix, char *output_matrix) | |
304 | { |
|
298 | { | |
305 | unsigned int frequencyBin; |
|
299 | unsigned int frequencyBin; | |
306 | unsigned int asmComponent; |
|
300 | unsigned int asmComponent; | |
307 | char * pt_char_input; |
|
301 | char * pt_char_input; | |
308 | char * pt_char_output; |
|
302 | char * pt_char_output; | |
309 | unsigned int offsetInput; |
|
303 | unsigned int offsetInput; | |
310 | unsigned int offsetOutput; |
|
304 | unsigned int offsetOutput; | |
311 |
|
305 | |||
312 | pt_char_input = (char*) &input_matrix; |
|
306 | pt_char_input = (char*) &input_matrix; | |
313 | pt_char_output = (char*) &output_matrix; |
|
307 | pt_char_output = (char*) &output_matrix; | |
314 |
|
308 | |||
315 | // convert all other data |
|
309 | // convert all other data | |
316 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
310 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) | |
317 | { |
|
311 | { | |
318 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
312 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) | |
319 | { |
|
313 | { | |
320 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; |
|
314 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; | |
321 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; |
|
315 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; | |
322 | pt_char_input = (char*) &input_matrix [ offsetInput ]; |
|
316 | pt_char_input = (char*) &input_matrix [ offsetInput ]; | |
323 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; |
|
317 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; | |
324 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
318 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float | |
325 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
319 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float | |
326 | } |
|
320 | } | |
327 | } |
|
321 | } | |
328 | } |
|
322 | } | |
329 |
|
323 | |||
330 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, |
|
324 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, | |
331 | float divider, |
|
325 | float divider, | |
332 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); |
|
326 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); | |
333 |
|
327 | |||
334 | int getFBinMask(int k, unsigned char channel); |
|
328 | int getFBinMask(int k, unsigned char channel); | |
335 |
|
329 | |||
336 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); |
|
330 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); | |
337 |
|
331 | |||
338 | #endif // FSW_PROCESSING_H_INCLUDED |
|
332 | #endif // FSW_PROCESSING_H_INCLUDED |
General Comments 0
You need to be logged in to leave comments.
Login now