Ejemplo n.º 1
0
void
PrintLine(int A, int B, int Q, int R)
{
    PrintBits(A);
    PrintBits(B);
    PrintBits(Q);
    PrintBits(R);
    printf("\n");
}
Ejemplo n.º 2
0
int main(void)
	{
	static struct {int a[8], b[8], sum ; } testcase[] =
		{
		{{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,1},0},
		{{1,1,1,1,1,1,1,1},{1,0,0,0,0,0,0,0},0},
		{{1,0,1,0,1,0,1,0},{1,0,1,0,1,0,1,0},-86},
		{{1,1,0,1,0,0,0,0},{0,1,1,0,1,1,1,1},1},
		{{1,0,1,0,1,0,1,0},{0,1,0,1,0,1,0,1},-1}
		} ;
	int k ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		for (k = 0; k < ENTRIES(testcase); k++)
			{
			int *a = testcase[k].a ;
			int *b = testcase[k].b ;
			int sum[8] ;
			uint32_t before, after, cycles ;

			printf(" Test Case %d: ", k+1) ;
			PrintBits(a) ;
			printf("+") ;
			PrintBits(b) ;
			printf("\n") ;

			printf("   Correct Sum: ") ;
			PrintByte(testcase[k].sum) ;
			printf("\n") ;

            before = GetClockCycleCount() ;
			AddBinary(a, b, sum) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("      Your Sum: ") ;
			if (PrintBits(sum) != (uint8_t) testcase[k].sum) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;
			printf("  Clock Cycles: %lu\n", cycles) ;

			printf("\n") ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
	}
Ejemplo n.º 3
0
void testRang1()
{
	cout<<"testRang1:"<<endl;

	bitset<8> sbits;
	Bitset<32> bits(0xA1F01001);
	PrintBits(bits);
	bits.Rang(24, 8, sbits);
	PrintBits(sbits);
	sbits = bits.Rang(0,8, sbits); 
	PrintBits(sbits);
	
}
Ejemplo n.º 4
0
void testRang2()
{
	cout<<"testRang2:"<<endl;

	Bitset<32> bits(0);
	bitset<8> sbits0(0x01);
	bits.Rang(0, sbits0);
	PrintBits(bits);
	bitset<8> sbits1(0x10);
	bits.Rang(8, sbits1);
	PrintBits(bits);
	bitset<8> sbits2(0xf0);
	bits.Rang(16, sbits2);
	PrintBits(bits);
	bitset<8> sbits3(0xa1);
	bits.Rang(24, sbits3);
	PrintBits(bits);
	
}
Ejemplo n.º 5
0
int main(void)
	{
	static struct {int a[8], b[8], sum ; } testcase[] =
		{
		{{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,1},0},
		{{1,1,1,1,1,1,1,1},{1,0,0,0,0,0,0,0},0},
		{{1,0,1,0,1,0,1,0},{1,0,1,0,1,0,1,0},-86},
		{{1,1,0,1,0,0,0,0},{0,1,1,0,1,1,1,1},1},
		{{1,0,1,0,1,0,1,0},{0,1,0,1,0,1,0,1},-1}
		} ;
	int k ;


		for (k = 0; k < ENTRIES(testcase); k++)
			{
			int *a = testcase[k].a ;
			int *b = testcase[k].b ;
			int sum[8] ;
			uint32_t before, after, cycles ;

			printf(" Test Case %d: \n", k+1) ;
			PrintBits(a) ;
			printf("\n") ;
			PrintBits(b) ;
			printf("\n") ;

			printf("   Correct Sum: \n") ;
			PrintByte(testcase[k].sum);
			printf("\n") ;

			AddBinary(a, b, sum) ;

			printf("      Your Sum: \n") ;
			PrintBits(sum);
			printf("\n") ;

			printf("\n") ;

			}

		printf("Press button to start over.\n") ;
		}