##// END OF EJS Templates
sync
paul -
r182:4c7c1d90c7d1 VHDL_0_1_28
parent child
Show More
@@ -1,2 +1,2
1 a0aa2c6f13574ae69c8645af2a2afa5d448e6c76 LFR_basic-parameters
2 a8668a35669295aaba22432d247158626f00a52a header/lfr_common_headers
1 0f2eb26d750be2b6d8a3f5dee479b4575d3b93be LFR_basic-parameters
2 95a8d83f1d0c59f28a679e66e23464f21c12dd8a header/lfr_common_headers
@@ -34,7 +34,8 void increment_seq_counter(unsigned shor
34 34 void getTime( unsigned char *time);
35 35 unsigned long long int getTimeAsUnsignedLongLongInt( );
36 36 void send_dumb_hk( void );
37 void get_v_e1_e2_f3(unsigned char *spacecraft_potential);
37 void get_v_e1_e2_f3( unsigned char *spacecraft_potential );
38 void get_temperatures( unsigned char *temperatures );
38 39 void get_cpu_load( unsigned char *resource_statistics );
39 40
40 41 extern int sched_yield( void );
@@ -45,6 +45,9 typedef struct {
45 45 volatile int coarse_time_load;
46 46 volatile int coarse_time;
47 47 volatile int fine_time;
48 volatile int temp_scm;
49 volatile int temp_pcb;
50 volatile int temp_fpga;
48 51 } time_management_regs_t;
49 52
50 53 // PDB >= 0.1.28
@@ -142,6 +142,10 static inline void SM_average(float *ave
142 142 static inline void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM,
143 143 ring_node *ring_node_tab[],
144 144 unsigned int nbAverageNORM, unsigned int nbAverageSBM );
145
146 void ASM_patch( float *inputASM, float *outputASM );
147 void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent );
148
145 149 static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized,
146 150 float divider );
147 151 static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat,
@@ -391,7 +391,7 int create_all_tasks( void ) // create a
391 391 {
392 392 status = rtems_task_create(
393 393 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
394 RTEMS_DEFAULT_MODES,
394 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
395 395 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
396 396 );
397 397 }
@@ -407,7 +407,7 int create_all_tasks( void ) // create a
407 407 {
408 408 status = rtems_task_create(
409 409 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
410 RTEMS_DEFAULT_MODES,
410 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
411 411 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
412 412 );
413 413 }
@@ -423,7 +423,7 int create_all_tasks( void ) // create a
423 423 {
424 424 status = rtems_task_create(
425 425 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
426 RTEMS_DEFAULT_MODES,
426 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
427 427 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
428 428 );
429 429 }
@@ -226,6 +226,7 rtems_task hous_task(rtems_task_argument
226 226 spacewire_update_statistics();
227 227
228 228 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
229 get_temperatures( housekeeping_packet.hk_lfr_temp_scm);
229 230 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
230 231
231 232 // SEND PACKET
@@ -459,6 +460,24 void get_v_e1_e2_f3( unsigned char *spac
459 460 spacecraft_potential[5] = e2_ptr[3];
460 461 }
461 462
463 void get_temperatures( unsigned char *temperatures )
464 {
465 unsigned char* temp_scm_ptr;
466 unsigned char* temp_pcb_ptr;
467 unsigned char* temp_fpga_ptr;
468
469 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
470 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
471 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
472
473 temperatures[0] = temp_scm_ptr[2];
474 temperatures[1] = temp_scm_ptr[3];
475 temperatures[2] = temp_pcb_ptr[2];
476 temperatures[3] = temp_pcb_ptr[3];
477 temperatures[4] = temp_fpga_ptr[2];
478 temperatures[5] = temp_fpga_ptr[3];
479 }
480
462 481 void get_cpu_load( unsigned char *resource_statistics )
463 482 {
464 483 unsigned char cpu_load;
@@ -20,7 +20,10 ring_node_asm asm_ring_burst_sbm_f0 [ NB
20 20 ring_node ring_to_send_asm_f0 [ NB_RING_NODES_ASM_F0 ];
21 21 int buffer_asm_f0 [ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ];
22 22
23 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
23 float asm_f0_patched_norm [ TOTAL_SIZE_SM ];
24 float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ];
25 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
26
24 27 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
25 28 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
26 29 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
@@ -259,6 +262,9 rtems_task prc0_task( rtems_task_argumen
259 262
260 263 incomingMsg = (asm_msg*) incomingData;
261 264
265 ASM_patch( incomingMsg->norm->matrix, asm_f0_patched_norm );
266 ASM_patch( incomingMsg->burst_sbm->matrix, asm_f0_patched_burst_sbm );
267
262 268 //****************
263 269 //****************
264 270 // BURST SBM1 SBM2
@@ -268,12 +274,12 rtems_task prc0_task( rtems_task_argumen
268 274 {
269 275 sid = getSID( incomingMsg->event );
270 276 // 1) compress the matrix for Basic Parameters calculation
271 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbm->matrix, compressed_sm_sbm_f0,
277 ASM_compress_reorganize_and_divide( asm_f0_patched_burst_sbm, compressed_sm_sbm_f0,
272 278 nb_sm_before_f0.burst_sbm_bp1,
273 279 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
274 280 ASM_F0_INDICE_START);
275 281 // 2) compute the BP1 set
276 BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
282 // BP1_set( compressed_sm_sbm_f0, k_coeff_intercalib_f0_sbm, NB_BINS_COMPRESSED_SM_SBM_F0, packet_sbm_bp1.data );
277 283 // 3) send the BP1 set
278 284 set_time( packet_sbm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeSBM );
279 285 set_time( packet_sbm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeSBM );
@@ -302,12 +308,12 rtems_task prc0_task( rtems_task_argumen
302 308 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
303 309 {
304 310 // 1) compress the matrix for Basic Parameters calculation
305 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f0,
311 ASM_compress_reorganize_and_divide( asm_f0_patched_norm, compressed_sm_norm_f0,
306 312 nb_sm_before_f0.norm_bp1,
307 313 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
308 314 ASM_F0_INDICE_START );
309 315 // 2) compute the BP1 set
310 BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
316 // BP1_set( compressed_sm_norm_f0, k_coeff_intercalib_f0_norm, NB_BINS_COMPRESSED_SM_F0, packet_norm_bp1.data );
311 317 // 3) send the BP1 set
312 318 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
313 319 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
@@ -330,7 +336,7 rtems_task prc0_task( rtems_task_argumen
330 336 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
331 337 {
332 338 // 1) reorganize the ASM and divide
333 ASM_reorganize_and_divide( incomingMsg->norm->matrix,
339 ASM_reorganize_and_divide( asm_f0_patched_norm,
334 340 asm_f0_reorganized,
335 341 nb_sm_before_f0.norm_bp1 );
336 342 // 2) convert the float array in a char array
@@ -22,7 +22,7 ring_node ring_to_send_asm_f1 [ NB
22 22 int buffer_asm_f1 [ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ];
23 23
24 24 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
25 char asm_f1_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
25 char asm_f1_char [ TOTAL_SIZE_SM * 2 ];
26 26 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
27 27 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
28 28
@@ -302,7 +302,7 rtems_task prc1_task( rtems_task_argumen
302 302 NB_BINS_COMPRESSED_SM_F1, NB_BINS_TO_AVERAGE_ASM_F1,
303 303 ASM_F1_INDICE_START );
304 304 // 2) compute the BP1 set
305 BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
305 // BP1_set( compressed_sm_norm_f1, k_coeff_intercalib_f1_norm, NB_BINS_COMPRESSED_SM_F1, packet_norm_bp1.data );
306 306 // 3) send the BP1 set
307 307 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
308 308 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
@@ -184,7 +184,7 rtems_task prc2_task( rtems_task_argumen
184 184
185 185 while(1){
186 186 status = rtems_message_queue_receive( queue_id_q_p2, incomingData, &size, //************************************
187 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
187 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF2
188 188
189 189 incomingMsg = (asm_msg*) incomingData;
190 190
@@ -195,32 +195,34 rtems_task prc2_task( rtems_task_argumen
195 195 // NORM
196 196 //*****
197 197 //*****
198 // 1) compress the matrix for Basic Parameters calculation
199 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
200 nb_sm_before_f2.norm_bp1,
201 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
202 ASM_F2_INDICE_START );
203 // BP1_F2
198 204 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F2)
199 205 {
200 // 1) compress the matrix for Basic Parameters calculation
201 ASM_compress_reorganize_and_divide( incomingMsg->norm->matrix, compressed_sm_norm_f2,
202 nb_sm_before_f2.norm_bp1,
203 NB_BINS_COMPRESSED_SM_F2, NB_BINS_TO_AVERAGE_ASM_F2,
204 ASM_F2_INDICE_START );
205 // 2) compute the BP1 set
206 BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data );
207 // 3) send the BP1 set
206 // 1) compute the BP1 set
207 // BP1_set( compressed_sm_norm_f2, k_coeff_intercalib_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp1.data );
208 // 2) send the BP1 set
208 209 set_time( packet_norm_bp1.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
209 210 set_time( packet_norm_bp1.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
210 211 BP_send( (char *) &packet_norm_bp1, queue_id_send,
211 212 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F2 + PACKET_LENGTH_DELTA,
212 213 SID_NORM_BP1_F2 );
213 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
214 {
215 // 1) compute the BP2 set using the same ASM as the one used for BP1
216 BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data );
217 // 2) send the BP2 set
218 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
219 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
220 BP_send( (char *) &packet_norm_bp2, queue_id_send,
221 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
222 SID_NORM_BP2_F2 );
223 }
214 }
215 // BP2_F2
216 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F2)
217 {
218 // 1) compute the BP2 set
219 BP2_set( compressed_sm_norm_f2, NB_BINS_COMPRESSED_SM_F2, packet_norm_bp2.data );
220 // 2) send the BP2 set
221 set_time( packet_norm_bp2.time, (unsigned char *) &incomingMsg->coarseTimeNORM );
222 set_time( packet_norm_bp2.acquisitionTime, (unsigned char *) &incomingMsg->coarseTimeNORM );
223 BP_send( (char *) &packet_norm_bp2, queue_id_send,
224 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F2 + PACKET_LENGTH_DELTA,
225 SID_NORM_BP2_F2 );
224 226 }
225 227
226 228 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F2)
@@ -53,13 +53,13 ring_node * getRingNodeForAveraging( uns
53 53 //***********************************************************
54 54 // Interrupt Service Routine for spectral matrices processing
55 55
56 void spectral_matrices_isr_f0( void )
56 void spectral_matrices_isr_f0( unsigned char statusReg )
57 57 {
58 58 unsigned char status;
59 59 rtems_status_code status_code;
60 60 ring_node *full_ring_node;
61 61
62 status = spectral_matrix_regs->status & 0x03; // [0011] get the status_ready_matrix_f0_x bits
62 status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits
63 63
64 64 switch(status)
65 65 {
@@ -111,13 +111,13 void spectral_matrices_isr_f0( void )
111 111 }
112 112 }
113 113
114 void spectral_matrices_isr_f1( void )
114 void spectral_matrices_isr_f1( unsigned char statusReg )
115 115 {
116 116 rtems_status_code status_code;
117 117 unsigned char status;
118 118 ring_node *full_ring_node;
119 119
120 status = (spectral_matrix_regs->status & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
120 status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits
121 121
122 122 switch(status)
123 123 {
@@ -169,12 +169,12 void spectral_matrices_isr_f1( void )
169 169 }
170 170 }
171 171
172 void spectral_matrices_isr_f2( void )
172 void spectral_matrices_isr_f2( unsigned char statusReg )
173 173 {
174 174 unsigned char status;
175 175 rtems_status_code status_code;
176 176
177 status = (spectral_matrix_regs->status & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
177 status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits
178 178
179 179 switch(status)
180 180 {
@@ -212,11 +212,11 void spectral_matrices_isr_f2( void )
212 212 }
213 213 }
214 214
215 void spectral_matrix_isr_error_handler( void )
215 void spectral_matrix_isr_error_handler( unsigned char statusReg )
216 216 {
217 217 rtems_status_code status_code;
218 218
219 if (spectral_matrix_regs->status & 0x7c0) // [0111 1100 0000]
219 if (statusReg & 0x7c0) // [0111 1100 0000]
220 220 {
221 221 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
222 222 }
@@ -232,13 +232,17 rtems_isr spectral_matrices_isr( rtems_v
232 232 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
233 233 // 7 6 5 4 3 2 1 0
234 234
235 spectral_matrices_isr_f0();
235 unsigned char statusReg;
236 236
237 spectral_matrices_isr_f1();
237 statusReg = spectral_matrix_regs->status;
238
239 spectral_matrices_isr_f0( statusReg );
238 240
239 spectral_matrices_isr_f2();
241 spectral_matrices_isr_f1( statusReg );
240 242
241 spectral_matrix_isr_error_handler();
243 spectral_matrices_isr_f2( statusReg );
244
245 spectral_matrix_isr_error_handler( statusReg );
242 246 }
243 247
244 248 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
@@ -536,3 +540,47 unsigned char getSID( rtems_event_set ev
536 540 return sid;
537 541 }
538 542
543 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
544 {
545 unsigned int i;
546 float re;
547 float im;
548
549 for (i=0; i<NB_BINS_PER_SM; i++){
550 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
551 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
552 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
553 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
554 }
555 }
556
557 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
558 {
559 unsigned int i;
560 float re;
561
562 for (i=0; i<NB_BINS_PER_SM; i++){
563 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
564 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
565 }
566 }
567
568 void ASM_patch( float *inputASM, float *outputASM )
569 {
570 extractReImVectors( inputASM, outputASM, 1); // b1b2
571 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
572 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
573 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
574 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
575 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
576 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
577 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
578 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
579 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
580
581 copyReVectors(inputASM, outputASM, 0 ); // b1b1
582 copyReVectors(inputASM, outputASM, 9 ); // b2b2
583 copyReVectors(inputASM, outputASM, 16); // b3b3
584 copyReVectors(inputASM, outputASM, 21); // e1e1
585 copyReVectors(inputASM, outputASM, 24); // e2e2
586 }
@@ -63,3 +63,32 void ASM_compress_reorganize_and_divide(
63 63 }
64 64 }
65 65 }
66
67 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
68 {
69 unsigned int i;
70 float re;
71 float im;
72
73 for (i=0; i<NB_BINS_PER_SM; i++){
74 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
75 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
76 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
77 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
78 }
79
80 }
81
82 void ASM_patch( float *inputASM, float *outputASM )
83 {
84 extractReImVectors( inputASM, outputASM, 1); // b1b2
85 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
86 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
87 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
88 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
89 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
90 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
91 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
92 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
93 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
94 }
@@ -12,6 +12,7 int main(void)
12 12
13 13 float input_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
14 14 float output_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
15 float patched_ASM [ NB_VALUES_PER_SM * NB_BINS_PER_SM ];
15 16 float output_ASM_compressed [ NB_VALUES_PER_SM * NB_BINS_COMPRESSED_SM_F0 ];
16 17
17 18 //*******
@@ -28,6 +29,8 int main(void)
28 29 }
29 30 }
30 31
32 ASM_patch( input_ASM, patched_ASM );
33
31 34 ASM_reorganize_and_divide( input_ASM, output_ASM,
32 35 1 ); // divider
33 36
@@ -59,6 +62,8 int main(void)
59 62 NB_BINS_TO_AVERAGE_ASM_F0,
60 63 ASM_F0_INDICE_START);
61 64
65 ASM_patch( input_ASM, patched_ASM );
66
62 67 return 0;
63 68 }
64 69
General Comments 0
You need to be logged in to leave comments. Login now