OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [tools/] [test.c] - Diff between revs 2 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 6
Line 30... Line 30...
//The program convert will change the first opcode to setting 
//The program convert will change the first opcode to setting 
//the stack pointer.
//the stack pointer.
int main()
int main()
{
{
   int main2();
   int main2();
 
#ifdef MIPS
 
   __asm(".set noreorder");
 
   //The convertion tool will add two opcodes here
 
   __asm("ori $4,$0,0x1");
 
   __asm("mtc0 $4,$12");  //STATUS=1; enable interrupts
 
   __asm(".set reorder");
 
#endif
 
 
   main2();
   main2();
 
 
 
#ifdef MIPS
 
   __asm(".set noreorder");
 
   __asm("nop");
 
 
 
   /*address 0x20 used for storing ISR register values*/
 
   __asm("nop");
 
   __asm("nop");
 
   __asm("nop");
 
   __asm("nop");
 
   __asm("nop");
 
 
 
   /*address 0x30 interrupt service routine*/
 
   __asm("sw $4,0x20($0)");
 
   __asm("sw $5,0x24($0)");
 
 
 
   __asm("ori $5,$0,0xffff");
 
   __asm("ori $4,$0,46");
 
//   __asm("sb $4,0($5)");   /*echo out '.'*/
 
   __asm("nop");
 
 
 
   /*normally clear the interrupt source here*/
 
   /*re-enable interrupts*/
 
   __asm("ori $4,$0,0x1");
 
   __asm("mtc0 $4,$12");   //STATUS=1; enable interrupts
 
   __asm("mfc0 $4, $14");  //C0_EPC=14
 
   __asm("nop");
 
   __asm("lw $5,0x24($0)");
 
   __asm("j $4");
 
   __asm("lw $4,0x20($0)");
 
   __asm(".set reorder");
 
#endif
}
}
 
 
char *strcpy2(char *s, const char *t)
char *strcpy2(char *s, const char *t)
{
{
   char *tmp=s;
   char *tmp=s;
Line 118... Line 158...
   unsigned long m;
   unsigned long m;
   char char_buf[16];
   char char_buf[16];
   short short_buf[16];
   short short_buf[16];
   long long_buf[16];
   long long_buf[16];
 
 
 
#if 1 
   //test shift
   //test shift
   j=0x12345678;
   j=0x12345678;
   for(i=0;i<32;++i) {
   for(i=0;i<32;++i) {
      print_hex(j>>i);
      print_hex(j>>i);
      putchar(' ');
      putchar(' ');
Line 138... Line 179...
      print_hex(j<<i);
      print_hex(j<<i);
      putchar(' ');
      putchar(' ');
   }
   }
   putchar('\n');
   putchar('\n');
   putchar('\n');
   putchar('\n');
 
#endif
 
 
 
#if 1 
   //test multiply and divide
   //test multiply and divide
   j=7;
   j=7;
   for(i=0;i<=10;++i) {
   for(i=0;i<=10;++i) {
      print(j*i,10,0);
      print(j*i,10,0);
      putchar(' ');
      putchar(' ');
Line 170... Line 213...
      print_hex(j%i);
      print_hex(j%i);
      putchar(' ');
      putchar(' ');
   }
   }
   putchar('\n');
   putchar('\n');
   putchar('\n');
   putchar('\n');
 
#endif
 
 
 
#if 1
   //test addition and subtraction
   //test addition and subtraction
   j=0x1234;
   j=0x1234;
   for(i=0;i<10;++i) {
   for(i=0;i<10;++i) {
      print_hex(j+i);
      print_hex(j+i);
      putchar(' ');
      putchar(' ');
Line 184... Line 229...
      print_hex(j-i);
      print_hex(j-i);
      putchar(' ');
      putchar(' ');
   }
   }
   putchar('\n');
   putchar('\n');
   putchar('\n');
   putchar('\n');
 
#endif
 
 
 
#if 1 
   //test bit operations
   //test bit operations
   i=0x1234;
   i=0x1234;
   j=0x4321;
   j=0x4321;
   print_hex(i&j);
   print_hex(i&j);
   putchar(' ');
   putchar(' ');
Line 201... Line 248...
   print_hex(i+0x12);
   print_hex(i+0x12);
   putchar(' ');
   putchar(' ');
   print_hex(i-0x12);
   print_hex(i-0x12);
   putchar('\n');
   putchar('\n');
   putchar('\n');
   putchar('\n');
 
#endif
 
 
 
#if 1 
   //test memory access
   //test memory access
   for(i=0;i<10;++i) {
   for(i=0;i<10;++i) {
      char_buf[i]=i;
      char_buf[i]=i;
      short_buf[i]=i;
      short_buf[i]=i;
      long_buf[i]=i;
      long_buf[i]=i;
Line 220... Line 269...
      j=long_buf[i];
      j=long_buf[i];
      print(j,10,0);
      print(j,10,0);
      putchar('\n');
      putchar('\n');
   }
   }
   putchar('\n');
   putchar('\n');
 
#endif
 
 
   prime();
   prime();
 
 
   putchar('d'); putchar('o'); putchar('n'); putchar('e'); putchar('\n');
   putchar('d'); putchar('o'); putchar('n'); putchar('e'); putchar('\n');
 
 
 
   for(;;) ;
}
}
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.