Beispiel #1
0
// test
int main(){
	int i;
	write(-1000);
	errorCount = 0;
	write(paraTest(10));
	eight_queen(0);
	write(gCount);
	structTest();
	breakContinueTest();
	for(i = 0; i < 25; ++i){
		write(callTest(i));
	}
	for(i = 0; i < 25; ++i){
		write(feb2(i));
	}
	logicArithmaticTest();
	arrayTest();
	scopeVariableTest();
	arithmaticTest();
	loopTest();
	relopTest();
	dfs(0,0);
	write(errorCount);
	write(-2000);
	return 0;
}
Beispiel #2
0
Datei: test.c Projekt: 8l/beri
int main(void)
{
	int i;
	int j;
	int data;
	int data2=0;
	char in = 0;
	i = 0x0000000004000500;
	int numBad = 1;
	int count;
	long long cpi;
	volatile void *wptr;
	short leds = 0;
	char capInit = 0;

	//mv1kC1(0x9800000040000000, 0x9800000000001000);
	
	//setInterrupts();
	//__writeStringLoopback("Stack TLB entry setup.\n");
	__writeString("Hello World! Have a BERI nice day!\n");
	//debugTlb();
	//cp0Regs();
	
//	causeTrap();
//	__writeString("Came back from trap and still alive :)\n");

//	sysCtrlTest();
//	data = rdtscl(5);

	//int coreid = getCoreID();
/*
	if (coreid == 0)
	{	
		delay();
		coreCount++;
	}
	else
	{
		coreCount++;
	}
*/

	while(in != 'Q') 
	{
		if (in != '\n') {
			//if (coreid == 0)
			{
			globalReset = 0;
			coreFlag = 0;
			__writeString("\n Number of Cores in Use : ");
			__writeHex(coreCount);

			__writeString("\n Menu:\n");
			__writeString("   \"F\" for floating point co-processor test.\n");
			__writeString("   \"L\" for load-linked and store-conditional test.\n");
			__writeString("   \"A\" for arithmetic test result.\n");
			__writeString("   \"B\" array bounds checking benchmark.\n");
			__writeString("   \"D\" for multiply and divide test.\n");
			__writeString("   \"C\" for Count register test.\n");
			__writeString("   \"M\" for eternal memory test.\n");
			//__writeString("   \"N\" for networking test.\n");
			__writeString("   \"V\" for framebuffer test.\n");
			__writeString("   \"K\" for Capability initialization.\n");
			__writeString("   \"l\" to invert LEDs.\n");
			__writeString("   \"T\" for touchscreen test.\n");
			__writeString("   \"q\" for quicksort boundschecking test.\n");
			__writeString("   \"d\" for domain crossing benchmark.\n");
			__writeString("   \"G\" for compositor test.\n");
			__writeString("   \"Q\" to quit.\n");
			}
		}

		in = __readUARTChar();
		__writeUARTChar(in);
		__writeString("\n");
		//__writeHex(in);
		//__writeString("\n");
	
		if (in == 'F') {
			__writeString("Floating Point co-processor test\n");
			CoProFPTest();
		}
		
		if (in == 'L') {
			__writeString("Load-linked and store-conditional test:\n");
			data = 13;
			data = ll(&data);
			data = sc(&data, 14);
			//__writeHex(data);
			__writeString(" < load-linked and store-conditional result (0)\n");
			data = testNset(&data, 14);
			//__writeHex(data);
			__writeString(" < test and set result (1)\n");
		}
		
		if (in == 'A') {
			__writeString("Arithmetic test:\n");
			data = 0;
			data = arithmaticTest();
			__writeHex(data);
			__writeString(" < arithmetic test result (0)\n");
		}
		
		if (in == 'T') {
			int * tX= (int *)0x9000000005000000;
			int * tY= (int *)0x9000000005000004;
			int * tDown= (int *)0x9000000005000008;
			__writeString("X:");
			data = *tX;
			__writeHex(data);
			
			__writeString("   Y:");
			data = *tY;
			__writeHex(data);
			
			__writeString("   Down:");
			data = *tDown;
			__writeHex(data);
			
			__writeString("\n");
		}
	
		if (in == 'G') {
			__writeString("Compositor test:\n");
		}
		
		if (in == 'D') {
			numBad = 1;
			__writeString("Multiply and divide test.\n");
			for (i = -10; i < 10; i++) {
				data = numBad * i;
				__writeHex(numBad);
				__writeString(" * ");
				__writeHex(i);
				__writeString(" = ");
				__writeHex(data);
				__writeString("\n");
				if (i!=0) data2 = data / i;
				__writeHex(data);
				__writeString(" / ");
				__writeHex(i);
				__writeString(" = ");
				__writeHex(data2);
				__writeString("\n");
				__writeString("\n");
				if (data == 0) data = 1;
				numBad = data;
			}
		}
		
		if (in == 'M') {
			__writeString("Memory test:\n");
			i = 0;
			while(1) 	{
				count = getCount();
        //__writeString("count:");
				//__writeHex(count);
        //__writeString("\n");
				int idx = 0;
				for (j=0; j<0x4000; j++) {
					idx = i+j;
					((volatile int *)DRAM_BASE)[idx] = DRAM_BASE + (idx<<2);
				}
				for (j=0; j<0x4000; j++) {
					idx = i+j;
					data = ((volatile int *)DRAM_BASE)[idx];
					if (data != (int)(DRAM_BASE + (idx<<2))) {
						//__writeHex((int)(DRAM_BASE + (idx<<2))); 
						//__writeString(" = ");
						//__writeHex(data);
						//__writeString("?\n");
						numBad++;
					}
				}
				cpi = getCount() - count;
        //__writeString("newCount - count:");
				//__writeHex(cpi);
				//__writeString("\n");
        
				__writeHex((int)(DRAM_BASE + (idx<<2))); 
				__writeString(" = ");
				__writeHex(data);
				__writeString("?\n");
				if (numBad == 0) {
					__writeString("All good! \n");
				} else {
					__writeHex(numBad);
					__writeString(" were bad :(\n");
					numBad = 0;
				}
				cpi = (cpi*1000);
        
        //__writeString("diff*1000:");
				//__writeHex(cpi);
       //__writeString("\n");
       
        // 8 instructions in the first loop, 12 in the second.
				cpi = cpi/((8+12)*0x4000);
        
				__writeString("CPI of ");
				__writeDigit(cpi);
				__writeString("\n");
				
				i+=0x4000;
				if (i > 0x07000000) i = 0;
			}
		}
		if (in == 'C') {
			__writeString("Count Register Test:\n");
			for(i=0;i<10;i++) 	{
				data = ((volatile int *)MIPS_PHYS_TO_UNCACHED(CHERI_COUNT))[0];
				__writeHex(data);
				__writeString(", ");
			}
			__writeString("\n");
		}
		
		if (in == 'K') {
			if (capInit==0) {
				FBIncBase(0x9000000004000000);
				long length = FBGetLeng();
				length = length - 800*600*2;
				FBDecLeng(length);
				capInit = 1;
			}
			
			__writeString("C4.base=    ");__writeHex(FBGetBase());__writeString("\n");
			__writeString("C4.length=  ");__writeHex(FBGetLeng());__writeString("\n");
			CapRegDump();

		}
		if (in == 'V') {
			int color = 0x8888;
			int x = 50;
			int y = 50;
			int length = 75;
			int height = 50;
			long frameBuff = 0x9000000004000000;

			
			for (x=200; x<500; x+=100) {
				for (y=300; y<500; y+=75) {
					draw3DRect(color, x, y, length, height);
				}
			}
			
			
			for (i=0; i<(800*600/4); i++) {
				FBSDR(0x0C63F80007E0001F,i<<3);
			}
			
			int offset = y*800 + x;
			int addOff;
			int totOff;
			for (i=0; i<(800*600); i++) {
				((volatile short*)frameBuff)[i] = i;
			}
			for (i=0; i<height; i++) {
				for (j=0; j<length; j++) {
					addOff = (800*i) + j;
					totOff = (offset+addOff);
					((volatile short*)frameBuff)[totOff] = color;
				}
			}
		}
		if (in == 'l') {
			leds = ~leds;
			IO_WR(CHERI_LEDS,leds);
		}
		
		if (in == 'N') {
			wptr = (void *)CHERI_NET_RX;
			i = *(volatile int *)wptr;
			__writeString("After accessing CHERI_NET_RX, read:\n");
			__writeDigit(i);

			i = 0xabcd;
			wptr = (void *)CHERI_NET_TX;
			__writeString("Before writing 123 to CHERI_NET_TX\n");
			*((volatile int *)CHERI_NET_TX) = i;
			__writeString("After writing 123 to CHERI_NET_TX\n");
		}
		
		if (in == 'B') {
		  arrayBench();
		}
		if (in == 'q') {
		  doQuicksort();
		}
		if (in == 'd') {
			armArray();
		}
// ADDED >>
                if (in == 'X') {
			int A[SORT_SIZE];

			writeString("Branch Exercise:\n");
			fillArray(A, SORT_SIZE/2, 1000);
			bubbleSort(A, SORT_SIZE/2);
			writeString("Finished Bubble Sort!\n");
			for (i = 0; i<SORT_SIZE/2; i+= SORT_SIZE/2/32) {
				writeHex(i);
				writeString(" = ");
				writeHex(A[i]);
				writeString("\n");
			}
			fillArray(A, SORT_SIZE, 1234);
			quickSort(A, 0, SORT_SIZE);
			writeString("Finished Quick Sort!\n");
			for (i = 0; i<SORT_SIZE; i+= SORT_SIZE/32) {
				writeHex(i);
				writeString(" = ");
				writeHex(A[i]);
				writeString("\n");
			}
			writeString("Searching for each element...\n");
			for (j = 0; j<4; j++) {
				for (i = 0; i<SORT_SIZE; i++) {
					binarySearch(A, A[i], 0, SORT_SIZE);
				}
			}
			writeString("Searching Done.\n");
			writeString("Starting Modular Eponentiation\n");
			for (i = 0; i<SORT_SIZE/4; i++) {
				writeHex(modExp(i,0xAAAAAAAAAAAAAAAA));
				writeString("\n");
			}
                }
// ADDED <<
		//debugRegs();
	}

	return 0;
}