c_src/read_source/core1/Overlays/stream.cc
// creates a stream with a buffer in OCM
creates a stream with a buffer in OCM
creates a stream with a buffer in OCM
pr_flow::stream::stream( pr_flow::stream_id_t stream_id, pr_flow::direction_t direction, width_t words, pr_flow::axi_port_t port, pr_flow::memory_t mem  )
{
	uint32_t offset = 0;
	this->bsp_table = NULL;
	this->head = 0;
	this->tail = 0;
	this->port = port;
	this->buff_size = MASK;
	this->direction = direction;
	this->bytes_written = 0;
	this->bytes_read = 0;
	this->bsp_id = 0;
	this->stream_id = stream_id;
	this->words = words;
		this->memory = mem;
		if(mem == OCM)
		{
			this->buff = (volatile wide_t*)get_ocm_memory(stream_id,direction);
			Xil_SetTlbAttributes((UINTPTR)this->buff, NORM_NONCACHE);
		}
		else if( mem == RR_CACHE )
		{
			this->buff = (volatile wide_t*)get_global_memory(stream_id,direction);
			Xil_SetTlbAttributes((UINTPTR)this->buff, 0x605);
			dmb();
		}
		else if(mem == CACHE || mem == DDR )
		{
			this->buff = (volatile wide_t*)malloc(sizeof(wide_t)*RAW_BUFFER_SIZE);
			assert(this->buff != NULL);
			if( mem == CACHE ){
				Xil_SetTlbAttributes((UINTPTR)this->buff, 0x605);
				dmb();
			}
			if( mem == DDR ){
				Xil_SetTlbAttributes((UINTPTR)this->buff, NORM_NONCACHE);
				dmb();
			}
		}
		offset = *((uint32_t*)(&this->buff));
		memset((void*)this->buff, 0, RAW_BUFFER_SIZE*sizeof(wide_t));
		dmb();
	if( direction != SW_SHARED )
	{
		 get space for our config
		this->axi_config = (bsp_template_t*)malloc( sizeof(bsp_template_t) );
		assert(this->axi_config != NULL);
		 get our function pointers
		this->bsp_table = get_jump_table(pr_flow::test_t::CIRCULAR_BUFF_MANY_128,this->direction);
		int rval = initialize_ip(offset,words);
		assert( rval == XST_SUCCESS );
	}
	else if( direction == SW_SHARED )
	{
		 no interaction with the hardware so our config is null
		this->axi_config = NULL;
	}
	else
	{
		 invalid arg crash the program
		assert(0);
	}
}
pr_flow :: stream :: stream ( pr_flow :: stream_id_t stream_id , pr_flow :: direction_t direction , width_t words , pr_flow :: axi_port_t port , pr_flow :: memory_t mem ) { uint32_t offset = 0 ; this -> bsp_table = NULL ; this -> head = 0 ; this -> tail = 0 ; this -> port = port ; this -> buff_size = MASK ; this -> direction = direction ; this -> bytes_written = 0 ; this -> bytes_read = 0 ; this -> bsp_id = 0 ; this -> stream_id = stream_id ; this -> words = words ; this -> memory = mem ; if ( mem == OCM ) { this -> buff = ( volatile wide_t * ) get_ocm_memory ( stream_id , direction ) ; Xil_SetTlbAttributes ( ( UINTPTR ) this -> buff , NORM_NONCACHE ) ; } else if ( mem == RR_CACHE ) { this -> buff = ( volatile wide_t * ) get_global_memory ( stream_id , direction ) ; Xil_SetTlbAttributes ( ( UINTPTR ) this -> buff , 0x605 ) ; dmb ( ) ; } else if ( mem == CACHE || mem == DDR ) { this -> buff = ( volatile wide_t * ) malloc ( sizeof ( wide_t ) * RAW_BUFFER_SIZE ) ; assert ( this -> buff != NULL ) ; if ( mem == CACHE ) { Xil_SetTlbAttributes ( ( UINTPTR ) this -> buff , 0x605 ) ; dmb ( ) ; } if ( mem == DDR ) { Xil_SetTlbAttributes ( ( UINTPTR ) this -> buff , NORM_NONCACHE ) ; dmb ( ) ; } } offset = * ( ( uint32_t * ) ( & this -> buff ) ) ; memset ( ( void * ) this -> buff , 0 , RAW_BUFFER_SIZE * sizeof ( wide_t ) ) ; dmb ( ) ; if ( direction != SW_SHARED ) { this -> axi_config = ( bsp_template_t * ) malloc ( sizeof ( bsp_template_t ) ) ; assert ( this -> axi_config != NULL ) ; this -> bsp_table = get_jump_table ( pr_flow :: test_t :: CIRCULAR_BUFF_MANY_128 , this -> direction ) ; int rval = initialize_ip ( offset , words ) ; assert ( rval == XST_SUCCESS ) ; } else if ( direction == SW_SHARED ) { this -> axi_config = NULL ; } else { assert ( 0 ) ; } }
creates a stream with a buffer in OCM
creates a stream with a buffer in OCM
// set the unique characteristics of the stream // // // get space for our config // get our function pointers // no interaction with the hardware so our config is null // invalid arg crash the program