OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-cbasic.c] - Diff between revs 425 and 475

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

Rev 425 Rev 475
Line 1... Line 1...
/* Test basic c functionality.  */
/* Test basic c functionality, and BSS section clearing.  */
#include "cpu-utils.h"
#include "cpu-utils.h"
#include "lib-utils.h"
#include "lib-utils.h"
 
 
signed long test_cond(int i)
signed long test_cond(int i)
{
{
Line 155... Line 155...
  report(i);
  report(i);
 
 
  return i;
  return i;
}
}
 
 
 
 
 
/* Test of BSS section being cleared at initialisation. */
 
/* BSS testing requires correct linker symbols in script*/
 
 
 
static char testchar = 0;
 
static short testshort = 0;
 
static int testint = 0;
 
static long long int testlonglong = 0;
 
 
 
#define BSS_BEGINNING _bss_start
 
#define BSS_END _bss_end
 
 
 
/* Variables that will be determined by linker script */
 
extern unsigned int BSS_BEGINNING;
 
extern unsigned int BSS_END;
 
 
 
void
 
test_bss(void)
 
{
 
  unsigned long * bss_start_pointer;
 
  unsigned long * bss_end_pointer;
 
 
 
  char * test_char_ptr;
 
  short * test_short_ptr;
 
  int * test_int_ptr;
 
  long long int * test_long_ptr;
 
 
 
  bss_start_pointer = (unsigned long*) &BSS_BEGINNING;
 
  bss_end_pointer = (unsigned long*) &BSS_END;
 
 
 
  report ((unsigned long) bss_start_pointer);
 
  report ((unsigned long) bss_end_pointer);
 
 
 
  test_char_ptr = (char*) &testchar;
 
  test_short_ptr = (short*) &testshort;
 
  test_int_ptr = (int*) &testint;
 
  test_long_ptr = (long long int*) &testlonglong;
 
 
 
  report ((unsigned long) test_char_ptr);
 
  report ((unsigned long)testchar & 0xff);
 
  if (testchar & 0xff)
 
    exit(1);
 
 
 
  report ((unsigned long) test_short_ptr);
 
  report ((unsigned long) testshort & 0xffff);
 
  if (testshort & 0xffff)
 
    exit(2);
 
 
 
  report ((unsigned long) test_int_ptr);
 
  report ((unsigned long) testint);
 
  if (testint)
 
    exit(3);
 
 
 
  report ((unsigned long) test_long_ptr);
 
  report ((unsigned long) testlonglong & 0xffffffff);
 
  report ((unsigned long) (testlonglong >> 32) & 0xffffffff);
 
  if (testlonglong & 0xffffffff)
 
    exit(4);
 
  if ((testlonglong >> 32) & 0xffffffff)
 
    exit(5);
 
 
 
  /* This should be junk (maybe Xs in RTL sim) */
 
  int uninited_int;
 
  report ((unsigned long) &uninited_int);
 
  report ((unsigned long) uninited_int);
 
 
 
  return;
 
}
 
 
int main()
int main()
{
{
        signed long result1 = 0;
        signed long result1 = 0;
        signed long result2 = 0;
        signed long result2 = 0;
        signed long result3 = 0;
        signed long result3 = 0;
 
        unsigned long final_result;
 
 
 
        test_bss();
 
 
        result1 = test_cond(1);
        result1 = test_cond(1);
        result2 = test_cond(-1);
        result2 = test_cond(-1);
        result3 -= result1 + result2;
        result3 -= result1 + result2;
        report(result2);
        report(result2);
Line 191... Line 263...
        result1 = test_array(1);
        result1 = test_array(1);
        result2 = test_array(-1);
        result2 = test_array(-1);
        result3 -= result1 + result2;
        result3 -= result1 + result2;
        report(result2);
        report(result2);
 
 
        // gives us 8000000d (goooood)
        // Check final result
        report(result3+0x3474E142);
        final_result = (unsigned long)result3;
        if (result3+0x3474E142 == 0x8000000d)
 
          exit(0);
        // Should give us 0x8000000d (Gooooood)
 
        final_result += 0x3474E142;
 
 
 
        report(final_result);
 
 
 
        if (final_result == 0x8000000d)
 
          return 0;
        else
        else
          exit(1);
          return 1;
}
}
 
 
 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.