예제 #1
0
int test_synram_rw() {
	int rv = TEST_PASS;
	int i, j;
	int seed = 1234;
	unsigned row = 0;

	for(i=0; i<REPETITIONS; i++) {
		fxv_array_t wdata;
		fxv_array_t rdata;

		for(j=0; j<NUM_BYTES_PER_ARRAY; j++) {
			wdata.bytes[j] = random_lcg(&seed) & 0x3f;
		}

		sync();
		fxv_load_array(1, &wdata);
		syn_store_weights(1, row);
		syn_load_weights(2, row);
		fxv_store_array(&rdata, 2);
		sync();

		for(j=0; j<NUM_WORDS_PER_ARRAY; j++) {
			if( rdata.words[j] != wdata.words[j] ) {
				rv = TEST_FAIL;
				mailbox_write(8*4, (uint8_t*)&rdata, sizeof(rdata));
				mailbox_write(8*4 + sizeof(rdata), (uint8_t*)&wdata, sizeof(wdata));
				return rv;
			}
		}

		row = random_lcg(&seed) % NUM_SYN_LOCATIONS;
	}

	return rv;
}
예제 #2
0
int test_cadc_conversion() {
	int rv = TEST_PASS;
	fxv_array_t converted_causal, converted_acausal;
	fxv_array_t expected;
	int i, j;

	fxv_splatb(0, RST_CAUSAL | RST_ACAUSAL);
	syn_reset(0, 0, COND_ALWAYS);

	for(j=0; j<REPETITIONS; j++) {
		for(i=0; i<NUM_BYTES_PER_ARRAY; ++i)
			expected.bytes[i] = 0x19;

		cadc_load_causal(1, 0);
		cadc_load_acausal_buffered(2, 0);
		fxv_store_array(&converted_causal, 1);
		fxv_store_array(&converted_acausal, 2);
		sync();

		for(i=0; i<NUM_BYTES_PER_ARRAY; ++i) {
			if( (expected.bytes[i] != converted_causal.bytes[i])
					|| (expected.bytes[i] != converted_acausal.bytes[i]) ) {
				rv = TEST_FAIL;
				mailbox_write(8*4, (uint8_t*)&converted_causal, sizeof(converted_causal));
				mailbox_write(8*4 + sizeof(converted_causal), (uint8_t*)&(converted_acausal), sizeof(converted_acausal));
				return rv;
			}
		}
	}

	return rv;
}
예제 #3
0
int test_cadc_test_load() {
	int i, j;
	int rv = TEST_PASS;
	int seed = 1234;
	uint8_t a, c;
	fxv_array_t causal_data;
	fxv_array_t acausal_data;

	for(j=0; j<REPETITIONS; j++) {
		a = random_lcg(&seed);
		c = random_lcg(&seed);

		cadc_test_set(0, c, a);
		cadc_test_load_causal(1, 0);
		cadc_test_load_acausal(2, 0);

		fxv_store_array(&causal_data, 1);
		fxv_store_array(&acausal_data, 2);

		sync();

		for(i=0; i<NUM_BYTES_PER_ARRAY; i++) {
			if( ((uint8_t)(causal_data.bytes[i]) != c) || ((uint8_t)(acausal_data.bytes[i]) != a) ) {
				rv = TEST_FAIL;
				mailbox_write(8*4, (uint8_t*)&causal_data, sizeof(causal_data));
				mailbox_write(8*4 + sizeof(causal_data), (uint8_t*)&c, sizeof(c));
				mailbox_write(8*4 + 2*sizeof(causal_data), (uint8_t*)&acausal_data, sizeof(acausal_data));
				mailbox_write(8*4 + 3*sizeof(causal_data), (uint8_t*)&a, sizeof(a));
				return rv;
			}
		}
	}

	return rv;
}
예제 #4
0
int test_synram_block_rw() {
	static int const block_size = 10;

	int rv = TEST_PASS;
	int i;
	unsigned j;
	int k;
	unsigned loc_start;
	unsigned loc_stop;
	fxv_array_t wdata[block_size];
	int seed = 1234;

	for(i=0; i<REPETITIONS; i++) {
		// generate random data
		for(j=0; j<block_size; ++j)
			for(k=0; k<NUM_BYTES_PER_ARRAY; ++k)
				wdata[j].bytes[k] = 0x3f & random_lcg(&seed);

		loc_start = random_lcg(&seed) % NUM_SYN_LOCATIONS;
		loc_stop = loc_start + 10;
		if( loc_stop >= NUM_SYN_LOCATIONS )
			loc_stop = NUM_SYN_LOCATIONS - 1;

		sync();  // make sure random data is in memory

		// write random data to synapse locations
		for(j=loc_start; j < loc_stop; ++j) {
			fxv_load_array(1, &(wdata[j - loc_start]));
			syn_store_weights(1, j);
		}

		// readback and compare synapse data
		for(j=loc_start; j<loc_stop; ++j) {
			fxv_array_t rdata;

			syn_load_weights(2, j);
			fxv_store_array(&rdata, 2);
			sync();

			for(k=0; k<NUM_WORDS_PER_ARRAY; ++k) {
				if( rdata.words[k] != wdata[j - loc_start].words[k] ) {
					rv = TEST_FAIL;
					mailbox_write(8*4, (uint8_t*)&rdata, sizeof(rdata));
					mailbox_write(8*4 + sizeof(rdata), (uint8_t*)&(wdata[j - loc_start]), sizeof(wdata[j - loc_start]));
					return rv;
				}
			}
		}
	}

	return rv;
}
예제 #5
0
void start() {
	struct {
		int cadc_test_load;
		int synram_rw;
		int synram_block_rw;
		int synram_block_rw_buffered;
		int cadc_conversion;
		int decoder_block_rw;
		int cadc_test_conversion;
	} result;

	/*result.cadc_test_load = TEST_PASS;*/
	/*result.synram_rw = TEST_PASS;*/
	/*result.synram_block_rw = TEST_PASS;*/
	/*result.synram_block_rw_buffered = TEST_PASS;*/
	/*result.cadc_conversion = TEST_PASS;*/
	/*result.decoder_block_rw = TEST_PASS;*/
	/*result.cadc_test_conversion = TEST_PASS;*/

	result.cadc_test_load = test_cadc_test_load();
	result.synram_rw = test_synram_rw();
	result.synram_block_rw = test_synram_block_rw();
	result.synram_block_rw_buffered = test_synram_block_rw_buffered();
	result.cadc_conversion = test_cadc_conversion();
	result.decoder_block_rw = test_decoder_block_rw();
	result.cadc_test_conversion = test_cadc_test_conversion();

	mailbox_write(0, (uint8_t*)&result, sizeof(result));
}
예제 #6
0
/**
 * Set up frame buffer.
 *
 * @param width         Frame buffer width(less than 4096)
 * @param height        Frame buffer height(less than 4096)
 * @param bit_depth     less than 32 bits
 * @return              Pointer to frame buffer info. Return 0 if failed.
 */
FrameBufferInfo *init_framebuffer(int width, int height, int bit_depth) {
  if (width > 4096)
    goto ERROR;
  if (height > 4096)
    goto ERROR;
  if (bit_depth > 32)
    goto ERROR;
  int response;

  FrameBufferInfo *frameBuffer = &frameBufferInfo;
  frameBuffer->p_width = width;
  frameBuffer->p_height = height;
  frameBuffer->v_width = width;
  frameBuffer->v_height = height;
  frameBuffer->gpu_pitch = 0;
  frameBuffer->bit_depth = bit_depth;
  frameBuffer->x = 0;
  frameBuffer->y = 0;
  frameBuffer->gpu_pointer = 0;
  frameBuffer->gpu_size = 0;

  int frameBufferAddr = (int)frameBuffer;
  frameBufferAddr += 0x40000000;
  // Write frame buffer to channel 1
  mailbox_write(frameBufferAddr, 1);
  response = mailbox_read(1);

  if (response != 0)
    return 0;

  return frameBuffer;
ERROR:
  return 0;
}
예제 #7
0
char *framebuffer_init(int x, int y, int depth) {

	struct frame_buffer_info_type fb_info  __attribute__ ((aligned(16)));;

	int result;

	fb_info.phys_x=x;
	fb_info.phys_y=y;
	fb_info.virt_x=x;
	fb_info.virt_y=y;
	fb_info.pitch=0;
	fb_info.depth=depth;
	fb_info.x=0;
	fb_info.y=0;
	fb_info.pointer=0;
	fb_info.size=0;

	if (debug) {
		printk("fb: Writing message @%x to mailbox %x\r\n",
			&fb_info,MAILBOX_BASE);
		printk("fb: asking for ");
		dump_framebuffer_info(&fb_info);
	}

	result=mailbox_write( (unsigned int)(&fb_info)+0x40000000 ,
		MAILBOX_FRAMEBUFFER);

	if (result<0) {
		printk("Mailbox write failed\r\n");
		return NULL;
	}

	result=mailbox_read(MAILBOX_FRAMEBUFFER);

	if (debug) {
		printk("fb: we got ");
		dump_framebuffer_info(&fb_info);
	}

	if (result==-1) {
		printk("Mailbox read failed\r\n");
		return NULL;
	}

	current_fb.pointer=(int)(fb_info.pointer);
	current_fb.phys_x=fb_info.phys_x;
	current_fb.phys_y=fb_info.phys_y;
	current_fb.pitch=fb_info.pitch;
	current_fb.depth=fb_info.depth;

	framebuffer_initialized=1;

	return (char *)(fb_info.pointer);
}
예제 #8
0
void framebuf_init() {
  framebuf_info.width = 1024;
  framebuf_info.height = 768;
  framebuf_info.vwidth = 1024;
  framebuf_info.vheight = 768;
  framebuf_info.pitch = 0;
  framebuf_info.depth = 24;
  framebuf_info.xoffset = 0;
  framebuf_info.yoffset = 0;
  framebuf_info.ptr = 0;
  framebuf_info.size = 0;

  mailbox_write(1, ((uint32)&framebuf_info) + 0x40000000);
  mailbox_read(1);
};
예제 #9
0
void create_framebuffer(unsigned int width, unsigned int height , unsigned int colour_depth){
  if(width > 4096) return;
  if(height > 4096) return;
  if(colour_depth > 32) return;
  framebuffer_info[0] = width;
  framebuffer_info[1] = height;
  framebuffer_info[2] = width;
  framebuffer_info[3] = height;
  framebuffer_info[4] = 0;
  framebuffer_info[5] = colour_depth;
  framebuffer_info[6] = 0;
  framebuffer_info[7] = 0;
  framebuffer_info[8] = 0;
  framebuffer_info[9] = 0;

  mailbox_write((unsigned int)&framebuffer_info,1);

}
예제 #10
0
void* sort8k_entry3( void *data )
{
    sortarg_t * my_arg;
    void *ptr;

    my_arg = (sortarg_t *)data;
    //unsigned int tid = (unsigned int)hthread_self();
    //unsigned int thread_number = ( unsigned int ) data;

    while ( 1 ) {
        // get pointer to next chunk of data
        ptr = (void*)mailbox_read( &my_arg->mb_start );
        // sort it
        bubblesort3( ( unsigned int * ) ptr, N );
        // return
        mailbox_write( &my_arg->mb_done, (void*)23 ); // return any value
    }
    return NULL;
}
int initialize_framebuffer(uint32_t physical_w, uint32_t physical_h, uint32_t virtual_w, uint32_t virtual_h)
{
    print_debug("Initializing framebuffer");

    __screenbuffer->physical_width  = physical_w;
    __screenbuffer->physical_height = physical_h;
    __screenbuffer->virtual_width   = virtual_w;
    __screenbuffer->virtual_height  = virtual_h;
    __screenbuffer->bit_depth       = 32;
    __screenbuffer->gpu_pointer     = 0;


    uint32_t read = 0;
    while (__screenbuffer->gpu_pointer == 0)
    {
        if (mailbox_write(MAILBOX_FRAMEBUFFER, (uint32_t)(__screenbuffer) + 0x40000000) == -1) { return -1; }
        read = mailbox_read(MAILBOX_FRAMEBUFFER);
    }
    return read;
}
예제 #12
0
void fb_init(unsigned width, unsigned height, unsigned depth, unsigned db)
{
  // add code to handle double buffering

  fb.width = width;
  fb.virtual_width = width;
  fb.height = height;
  fb.virtual_height = height;
  fb.depth = depth * 8; // convert number of bytes to number of bits
  fb.x_offset = 0;
  fb.y_offset = 0;

  // set values returned by the GPU to 0; see mailbox manual
  fb.pitch = 0;
  fb.framebuffer = 0;
  fb.size = 0;

  mailbox_write(MAILBOX_FRAMEBUFFER, (unsigned)&fb + GPU_NOCACHE);
  (void) mailbox_read(MAILBOX_FRAMEBUFFER);
}
예제 #13
0
int test_decoder_block_rw() {
	static int const block_size = 10;

	int rv = TEST_PASS;
	int i;
	unsigned j;
	int k;
	unsigned loc_start;
	unsigned loc_stop;
	fxv_array_t wdata[block_size];
	fxv_array_t ddata[block_size];
	int seed = 1234;

	for(i=0; i<REPETITIONS; i++) {
		// generate random data
		for(j=0; j<block_size; ++j)
			for(k=0; k<NUM_BYTES_PER_ARRAY; ++k) {
				wdata[j].bytes[k] = 0x3f & random_lcg(&seed);
				ddata[j].bytes[k] = 0x3f & random_lcg(&seed);
			}

		loc_start = random_lcg(&seed) % NUM_SYN_LOCATIONS;
		loc_stop = loc_start + 10;
		if( loc_stop >= NUM_SYN_LOCATIONS )
			loc_stop = NUM_SYN_LOCATIONS - 1;

		sync();  // make sure random data is in memory

		// write random data to synapse locations
		for(j=loc_start; j < loc_stop; ++j) {
			fxv_load_array(1, &(wdata[j - loc_start]));
			fxv_load_array(2, &(ddata[j - loc_start]));
			syn_store_weights(1, j);
			syn_store_decoders(2, j);
		}

		// readback and compare synapse data
		for(j=loc_start; j<loc_stop; ++j) {
			fxv_array_t rdata_w;
			fxv_array_t rdata_d;

			syn_load_weights(3, j);
			syn_load_decoders(4, j);
			fxv_store_array(&rdata_w, 3);
			fxv_store_array(&rdata_d, 4);
			sync();

			for(k=0; k<NUM_WORDS_PER_ARRAY; ++k) {
				if( rdata_w.words[k] != wdata[j - loc_start].words[k] ) {
					/*rv = TEST_FAIL;*/
					/*mailbox_write(8*4, (uint8_t*)&rdata_w, sizeof(rdata_w));*/
					/*mailbox_write(8*4 + sizeof(rdata_w), (uint8_t*)&(wdata[j - loc_start]), sizeof(wdata[j - loc_start]));*/
					return rv;  //TODO it works if this is commented out. wtf
				}

				if( rdata_d.words[k] != ddata[j - loc_start].words[k] ) {
					rv = TEST_FAIL;
					mailbox_write(8*4, (uint8_t*)&rdata_d, sizeof(rdata_d));
					mailbox_write(8*4 + sizeof(rdata_d), (uint8_t*)&(ddata[j - loc_start]), sizeof(ddata[j - loc_start]));
					return rv;
				}
			}
		}
	}

	return rv;
}