Beispiel #1
0
int main(void)
  {
  short i, j, aux1; // pixel index
  while(1) // repeat forever:
  {
    for(j = 0; j < 128; j++){
      microblaze_bread_datafsl(hist, cameraout_slot_id); // read histogram gray level value
      aux1 = hist >> 3; // using auxiliary variable because I don't know if the compiler
                // optimizes the processing in for(i = 0; i < (hist >> 3); i++);
      for(i = 0; i < aux1 ; i++){
        imageout[i][j] = 255;
      }
    }

    //Invert output so that the histogram does not display upside down
    for(i = 63; i >= 0; i--){
      for(j = 0; j < 128; j++){
        microblaze_bwrite_datafsl(imageout[i][j],camerain_slot_id);// write a pixel to the VGA output
        imageout[i][j] = 0;
      }
    }

  }
  return 0;
}
int main()
{
    init_platform();

    printf("status => ");
    printf("done: %u  ",XEncrypt_IsDone());
    printf("idle: %u\n",XEncrypt_IsIdle());

    int i,j;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            microblaze_bwrite_datafsl(PlainText[i][j], 0) ;
            microblaze_bwrite_datafsl(Key[i][j], 1) ;
        }
    }

    printf("wrote data\n");

    unsigned CipherText[4][4];
    XEncrypt_Start();

    unsigned val;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            microblaze_bread_datafsl(val, 2) ;
            CipherText[i][j] = val;
        }
    }

    printf("status => ");
    printf("done: %u  ",XEncrypt_IsDone());
    printf("idle: %u\n",XEncrypt_IsIdle());

    //check
    int errors = 0;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            if(CipherText[i][j] != GoldenCipherText[i][j]) {
                printf("Error! Calculated key does NOT match golden key at index: [%d][%d] !!!\n",i,j);
                errors++;
            }
        }
    }

    printf("-- CipherText Check Completed - Found %d errors.\n",errors);

    print("Hello World\n\r");

    cleanup_platform();

    return 0;
}
Beispiel #3
0
int main(void)
{
	unsigned int OutData = 0x01;	// will contain the value presented in the leds
	XGpio GpioDrv;	// this is the driver for our GPIO
	int DelayCtl;	// delay control variable
	short i,j,k,l;	// pixel index
	short max,min;
	XGpio_Initialize(&GpioDrv, MY_GPIO_ID);	// Initialize the GPIO driver
	XGpio_SetDataDirection(&GpioDrv, LED_CHANNEL, 0x0);	// Set the direction for all signals to be outputs
	while (1)	// repeat forever:
	{
		if (OutData & 0x80) OutData = 0x01;
		else OutData <<= 1;		// shift the current on-led to the left
		XGpio_DiscreteWrite(&GpioDrv, LED_CHANNEL, OutData); 		// write to the correct channel of the GPIO
		for(DelayCtl = 0; DelayCtl < LED_DELAY; DelayCtl++);		// apply the delay before next update

		for(i = 0; i < num_lin; i++) for(j=0; j<num_col;j++) microblaze_bread_datafsl(image[i][j], cameraout_slot_id);		// read a full frame from the camera
		
		min = SHRT_MAX;
		max = SHRT_MIN;
		
		for(i=0;i < num_lin; i++){
			for(j=0; j<num_col;j++){
				derivative[i][j] = 0;
				for(k=0;k<2;k++){
					for(l=0;l<2;l++){
						if(i+k<num_lin && j+l<num_col) derivative[i][j] += image[i+k][j+l] * Kernel[k][l] + image[i+1+k][j+1+l] * Kernel[1-k][1-l];
					}
				}
				if(derivative[i][j] < min) min = derivative[i][j];
				if(derivative[i][j] > max) max = derivative[i][j];
			}
		}
		
		for(i=0;i < num_lin; i++){
			for(j=0; j<num_col;j++){
				derivative[i][j] -= min;
				derivative[i][j] = derivative[i][j] * 256 / (max-min);
			}
		}

		for(i = 0; i < num_lin; i++) for(j=0; j<num_col;j++) microblaze_bwrite_datafsl(derivative[i][j],camerain_slot_id);		// write a full frame to the VGA output
	}
	return 0;	// end application
}
Beispiel #4
0
int main (void){
	unsigned int OutData = 0x01; // will contain the value presented in the leds
	XGpio GpioDrv; // this is the driver for our GPIO
	int DelayCtl; // delay control variable
	int i,j; // pixel index
	int pos,max;

	XGpio_Initialize(&GpioDrv, MY_GPIO_ID); // Initialize the GPIO driver
	XGpio_SetDataDirection(&GpioDrv, LED_CHANNEL, 0x0); // Set the direction for all signals to be outputs

	while(1)// repeat forever:
	{
		if(OutData & 0x80) OutData = 0x01;
		else OutData <<= 1; // shift the current on-led to the left

		XGpio_DiscreteWrite(&GpioDrv, LED_CHANNEL, OutData); // write to the correct channel of the GPIO

		for(DelayCtl = 0; DelayCtl < LED_DELAY; DelayCtl++); // apply the delay before next update

		for(i = 0; i < N; i++) {
				d[i] = 0;
				microblaze_bread_datafsl(image[i], cameraout_slot_id);
		}

        max=0;
		for(i = 0; i < 128; i++) {
			for(j = 0; j < 64; j++) {
                pos = i +(j*128);

				d[pos] = 6*image[pos];

				// Canto Superior Esquerdo
				if(i!=0 || j!=0)
					d[pos] += -(image[pos-128-1] );

				// Canto Inferior Direito
				if(i!=128 || j!=64)
					d[pos] += -(image[pos+128+1] );

				//Linha de Cima
				if(j!=0)
					d[pos] += -(image[pos-128] );

				//Linha de Baixo
				if(j!=64)
					d[pos] += -(image[pos+128] );

				//Coluna Esquerda
				if(i!=0)
					d[pos] += -(image[pos-1] );

				//Coluna Direita
				if(i!=128)
					d[pos] += -(image[pos+1] );

				if ( d[pos] > max )
					max = d[pos] ;
				else if ( -d[pos] > max )
					max = -d[pos] ;
			}
		}


		//Normalização
        for (i = 0; i < N; i++) {
            image[i]= 128 + d[i]*127/max;
        }

		for(i = 0; i < 128; i++) image[i] = 0;
		for(i = 0; i < 128; i++) image[i+63*128] = 0;
		for(j = 0; j < 64; j++) image[j*128] = 0;
		for(j = 0; j < 64; j++) image[127+j*128] = 0;

		for(i = 0; i < N; i++) microblaze_bwrite_datafsl(image[i],camerain_slot_id);// write a full frame to the VGA output
	}

	return 0;// end application
}