Contains functions for handling re-entrant tasks and functions. More...
#include "defines.h"
Go to the source code of this file.
Functions | |
reentrant * | reentrant_create (func_unit *funit) |
Allocates and initializes the reentrant structure for the given functional unit. | |
void | reentrant_dealloc (reentrant *ren, func_unit *funit, expression *expr) |
Deallocates all memory associated with the given reentrant structure. |
Contains functions for handling re-entrant tasks and functions.
Allocates and initializes the reentrant structure for the given functional unit.
Allocates and initializes the reentrant structure for the given functional unit, compressing and packing the bits into the given data structure.
funit | Pointer to functional unit to create a new reentrant structure for |
References reentrant_s::data, reentrant_s::data_size, malloc_safe, PROFILE, PROFILE_END, reentrant_count_afu_bits(), and reentrant_store_data_bits().
Referenced by expression_op_func__passign().
00366 { PROFILE(REENTRANT_CREATE); 00367 00368 reentrant* ren = NULL; /* Pointer to newly created reentrant structure */ 00369 int data_size; /* Number of uint8s needed to store the given functional unit */ 00370 unsigned int bits = 0; /* Number of bits needed to store signal values */ 00371 int i; /* Loop iterator */ 00372 00373 /* Get size needed to store data */ 00374 bits = reentrant_count_afu_bits( funit ); 00375 00376 /* Calculate data size */ 00377 data_size = ((bits & 0x7) == 0) ? (bits >> 3) : ((bits >> 3) + 1); 00378 00379 /* If there is data to store, allocate the needed memory and populate it */ 00380 if( data_size > 0 ) { 00381 00382 /* Allocate the structure */ 00383 ren = (reentrant*)malloc_safe( sizeof( reentrant ) ); 00384 00385 /* Set the data size */ 00386 ren->data_size = data_size; 00387 00388 /* Allocate and initialize memory for data */ 00389 ren->data = (uint8*)malloc_safe( sizeof( uint8 ) * ren->data_size ); 00390 for( i=0; i<data_size; i++ ) { 00391 ren->data[i] = 0; 00392 } 00393 00394 /* Walk through the signal list in the reentrant functional unit, compressing and saving vector values */ 00395 reentrant_store_data_bits( funit, ren, 0 ); 00396 00397 } 00398 00399 PROFILE_END; 00400 00401 return( ren ); 00402 00403 }
void reentrant_dealloc | ( | reentrant * | ren, | |
func_unit * | funit, | |||
expression * | expr | |||
) |
Deallocates all memory associated with the given reentrant structure.
Pops data back into the given functional unit and deallocates all memory associated with the given reentrant structure.
ren | Pointer to the reentrant structure to deallocate from memory | |
funit | Pointer to functional unit associated with this reentrant structure | |
expr | Pointer of expression to exclude from updating (optional) |
References reentrant_s::data, reentrant_s::data_size, free_safe, PROFILE, PROFILE_END, and reentrant_restore_data_bits().
Referenced by expression_op_func__func_call(), and sim_thread().
00413 { PROFILE(REENTRANT_DEALLOC); 00414 00415 if( ren != NULL ) { 00416 00417 /* If we have data being stored, pop it */ 00418 if( ren->data_size > 0 ) { 00419 00420 /* Walk through each bit in the compressed data array and assign it back to its signal */ 00421 reentrant_restore_data_bits( funit, ren, 0, expr ); 00422 00423 /* Deallocate the data uint8 array */ 00424 free_safe( ren->data, (sizeof( uint8 ) * ren->data_size) ); 00425 00426 } 00427 00428 /* Deallocate memory allocated for this reentrant structure */ 00429 free_safe( ren, sizeof( reentrant ) ); 00430 00431 } 00432 00433 PROFILE_END; 00434 00435 }