macsim/src/noc/pbuffer.c
// enqueue a flit in the buffer
enqueue a flit in the buffer
enqueue a flit in the buffer
bool msgenque(p_buffer_t *buffer, flit_container_t *flit){
	if(buffer->slots==0){
		return false;
	}
	p_buffer_entry_t *entry = malloc(sizeof(p_buffer_entry_t));		
	if(entry == NULL){
		fatal("Malloc failed to allocate memory");
	}
	entry->flit = flit;
	entry->next = NULL;
	if(buffer->tail == NULL){				
		buffer->head = entry;
		buffer->tail = entry;
	} else{
		buffer->tail->next = entry;
		buffer->tail = entry;
	}
	buffer->slots = buffer->slots - 1; 	
	return true;
}
bool msgenque ( p_buffer_t * buffer , flit_container_t * flit ) { if ( buffer -> slots == 0 ) { return false ; } p_buffer_entry_t * entry = malloc ( sizeof ( p_buffer_entry_t ) ) ; if ( entry == NULL ) { fatal ( " " ) ; } entry -> flit = flit ; entry -> next = NULL ; if ( buffer -> tail == NULL ) { buffer -> head = entry ; buffer -> tail = entry ; } else { buffer -> tail -> next = entry ; buffer -> tail = entry ; } buffer -> slots = buffer -> slots - 1 ; return true ; }
enqueue a flit in the buffer
enqueue a flit in the buffer
//new entry // init entry //if the buffer is empty, set new head //decrement available slots