Esempio n. 1
0
//
// This is the Consumer process that reads ciphertext from 
// the hardware process to display.
//
void Consumer(co_stream AESoutputStream)
{
	co_uint8 streamValue;
	
	co_stream_open(AESoutputStream, O_RDONLY, INT_TYPE(STREAMWIDTH));
	printf("Consumer reading data.\n");
	while ( co_stream_read(AESoutputStream, &streamValue, sizeof(co_int8)) == co_err_none ) {
		printf("  -> 0x%x\n", streamValue);
	}
	co_stream_close(AESoutputStream);
}
Esempio n. 2
0
void function_eight(co_stream s_in1, co_stream s_in2, co_stream s_out) {
    co_int32 i, a, b, c, n1, n2;
    co_stream_open(s_in1, 0, co_type_create(co_int_sort, 32));
    co_stream_open(s_in2, 0, co_type_create(co_int_sort, 32));
    co_stream_open(s_out, 1, co_type_create(co_int_sort, 32));
    co_stream_read(s_in1, &n1, sizeof(co_int32));
    co_stream_read(s_in2, &n2, sizeof(co_int32));
    a = 0;
    b = 1;
    for (i = 1; i <= n1; i++) {
        c = a + b;
        a = b;
        b = c;
    }
    b = ((b + n2) < 0 ? -(b + n2) : (b + n2)) % n1;
    co_stream_write(s_out, &b, sizeof(co_int32));
    co_stream_close(s_out);
    co_stream_close(s_in1);
    co_stream_close(s_in2);
}
Esempio n. 3
0
void Consumer(co_stream input_stream)
{
	char c;

	co_stream_open(input_stream, O_RDONLY, CHAR_TYPE);
	xil_printf("consumer, 123\n");

	while ( co_stream_read(input_stream, &c, sizeof(char)) == co_err_none ) {
		xil_printf("Consumer read %c from stream: input_stream\n", c);
	}
	co_stream_close(input_stream);
}
Esempio n. 4
0
void my_main_function(co_stream s_in, co_stream s_out) {
    int i;
    int hi = 10000000;
    int32 err;
    co_stream_open(s_in, 0, co_type_create(co_int_sort, 32));
    co_stream_open(s_out, 1, co_type_create(co_int_sort, 32));
    co_stream_write(s_out, &(hi), sizeof (hi));
    (err = (co_stream_read(s_in, &(hi), sizeof (hi)) != co_err_none));
    printf("Rez = %d\n", hi);
    printf("SERIALSTOP");
    co_stream_close(s_in);
    co_stream_close(s_out);
}
Esempio n. 5
0
void consumer_func(co_stream input_stream) {
	
//  char *p = "1CL55u078r08bt0ccq1b7j094m24co6d8k161l622p26ef3edg1bee248i33aa028c01ab000000000";

  char *p = "1CL55u069l198o6b5t527k4d8j074r091m742p4e4c0d1g215a00000000000000000000000000000";
  
  char c; int valid = 1;  int count = 0;

  co_stream_open(input_stream, O_RDONLY, CHAR_TYPE);
  
  co_stream_read(input_stream, &c, sizeof(char));
  printf("%c", c); ++p;
  
  co_stream_read(input_stream, &c, sizeof(char));
  printf("%c", c); ++p;
  
  co_stream_read(input_stream, &c, sizeof(char));
  printf("%c", c); ++p;
  
  printf("\n");
  
  while (co_stream_read(input_stream, &c, sizeof(char)) == co_err_none ) {
  	
    printf("%c", c);   	

	++count;	
	if(c != *(p++)) valid = 0;
	
	if(count == 4) { printf("\n"); count = 0; }
	
	if((*p) == 0) {
		printf("\nDone ");
		if(valid == 1) printf("PASS");
		else printf("FAIL");
		exit(0);
	}	
  }
  co_stream_close(input_stream);
}
Esempio n. 6
0
void stub_function_two(co_stream s_in, co_stream s_out)
{
    co_int32 n;
    
	co_stream_open(s_in, O_RDONLY, INT_TYPE(32));
	co_stream_open(s_out, O_WRONLY, INT_TYPE(32));
    
   	co_stream_read(s_in, &n, sizeof(co_int32));
   	
	co_stream_write(s_out, &n, sizeof(co_int32));

	co_stream_close(s_out);
	co_stream_close(s_in);
}
Esempio n. 7
0
void my_function(co_stream s_in, co_stream s_out) {
    co_int32 i, a, b, c, n;
    co_stream_open(s_in, 0, co_type_create(co_int_sort, 32));
    co_stream_open(s_out, 1, co_type_create(co_int_sort, 32));
    co_stream_read(s_in, &n, sizeof(co_int32));
    a = 0;
    b = 1;
    for (i = 1; i <= n; i++) {
        c = a + b;
        a = b;
        b = c;
    }
    co_stream_write(s_out, &b, sizeof(co_int32));
    co_stream_close(s_out);
    co_stream_close(s_in);
}
Esempio n. 8
0
void my_function(co_stream s_in, co_stream s_out)
{
    co_int32 i, a, b, c, n;
    
    co_stream_open(s_in, O_RDONLY, INT_TYPE(32));
    co_stream_open(s_out, O_WRONLY, INT_TYPE(32));

   	co_stream_read(s_in, &n, sizeof(co_int32));

	a = 0;
	b = 1;
	
	for (i = 1; i<= n; i++)
	{
		c = a + b;
		a = b;
		b = c;
	}

	co_stream_write(s_out, &b, sizeof(co_int32));

	co_stream_close(s_out);
	co_stream_close(s_in);
}
Esempio n. 9
0
//
// This is the hardware process.
// 
void Sorter(co_stream input, co_stream output)
{
	co_int32 nSample = 0;
	co_int32 samples[STREAMDEPTH];
	co_int32 index;
	co_int32 innerIndex;
	co_uint32 NUM_LOOPS = 10000;
	co_int32 counter = 0;

	// Zero out the sample buffer
	for (index = 0; index < STREAMDEPTH; index++)
	{
		samples[index] = 0;
	}
	
	do // Hardware processes run forever
	{	
		// Read values from the stream and store them in a buffer
		index = 0;
		co_stream_open(input, O_RDONLY, INT_TYPE(STREAMWIDTH));
		{
			while (co_stream_read(input, &nSample, sizeof(co_int32)) == co_err_none)
			{
				samples[index++] = nSample;
			}
		}
		co_stream_close(input);
	
		// Sort the data using the bubblesort algorithm
		for (counter = 0; counter < NUM_LOOPS; counter++)
		{
			for (index = 0; index < STREAMDEPTH; index++)
			{
				for (innerIndex = 0; innerIndex < STREAMDEPTH - 1; innerIndex++)
				{
					if (counter % 2 == 0)
					{
						if (samples[innerIndex] > samples[innerIndex + 1])
						{
							nSample = samples[innerIndex + 1];
							samples[innerIndex + 1] = samples[innerIndex];
							samples[innerIndex] = nSample;
						}
					}
					else
					{
						if (samples[innerIndex] < samples[innerIndex + 1])
						{
							nSample = samples[innerIndex + 1];
							samples[innerIndex + 1] = samples[innerIndex];
							samples[innerIndex] = nSample;
						}
					}
				}
			}
		}

		// Write out the sorted values
		co_stream_open(output, O_WRONLY, INT_TYPE(STREAMWIDTH));
		for (index = 0; index < STREAMDEPTH; index++)
		{
			co_stream_write(output, &samples[index], sizeof(co_int32));
		}
		co_stream_close(output);
	} 
	while(1);
}