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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [sim/] [testsuite/] [common/] [alu-tst.c] - Diff between revs 157 and 223

Only display areas with differences | Details | Blame | View Log

Rev 157 Rev 223
#define WITH_TARGET_WORD_MSB 0
#define WITH_TARGET_WORD_MSB 0
#define WITH_TARGET_WORD_BITSIZE 64
#define WITH_TARGET_WORD_BITSIZE 64
#define WITH_HOST_WORD_BITSIZE (sizeof (int) * 8)
#define WITH_HOST_WORD_BITSIZE (sizeof (int) * 8)
#define WITH_TARGET_BYTE_ORDER BIG_ENDIAN /* does not matter */
#define WITH_TARGET_BYTE_ORDER BIG_ENDIAN /* does not matter */
 
 
#define ASSERT(EXPRESSION) \
#define ASSERT(EXPRESSION) \
{ \
{ \
  if (!(EXPRESSION)) { \
  if (!(EXPRESSION)) { \
    fprintf (stderr, "%s:%d: assertion failed - %s\n", \
    fprintf (stderr, "%s:%d: assertion failed - %s\n", \
             __FILE__, __LINE__, #EXPRESSION); \
             __FILE__, __LINE__, #EXPRESSION); \
    abort (); \
    abort (); \
  } \
  } \
}
}
 
 
#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE)
#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE)
 
 
#include <string.h>
#include <string.h>
 
 
#include "sim-basics.h"
#include "sim-basics.h"
 
 
#include "sim-alu.h"
#include "sim-alu.h"
 
 
#include <stdio.h>
#include <stdio.h>
 
 
typedef struct {
typedef struct {
  char *op;
  char *op;
  unsigned64 arg;
  unsigned64 arg;
} alu_op;
} alu_op;
 
 
typedef struct {
typedef struct {
  unsigned64 begin;
  unsigned64 begin;
  alu_op ops[4];
  alu_op ops[4];
  unsigned64 result;
  unsigned64 result;
  int carry_borrow;
  int carry_borrow;
  int overflow;
  int overflow;
} alu_test;
} alu_test;
 
 
#define MAX_INT8 UNSIGNED64 (127)
#define MAX_INT8 UNSIGNED64 (127)
#define MIN_INT8 UNSIGNED64 (128)
#define MIN_INT8 UNSIGNED64 (128)
 
 
#define MAX_INT16 UNSIGNED64 (32767)
#define MAX_INT16 UNSIGNED64 (32767)
#define MIN_INT16 UNSIGNED64 (32768)
#define MIN_INT16 UNSIGNED64 (32768)
 
 
#define MAX_INT32 UNSIGNED64 (0x7fffffff)
#define MAX_INT32 UNSIGNED64 (0x7fffffff)
#define MIN_INT32 UNSIGNED64 (0x80000000)
#define MIN_INT32 UNSIGNED64 (0x80000000)
 
 
#define MAX_INT64 UNSIGNED64 (0x7fffffffffffffff)
#define MAX_INT64 UNSIGNED64 (0x7fffffffffffffff)
#define MIN_INT64 UNSIGNED64 (0x8000000000000000)
#define MIN_INT64 UNSIGNED64 (0x8000000000000000)
 
 
static void
static void
print_hex (unsigned64 val, int nr_bits)
print_hex (unsigned64 val, int nr_bits)
{
{
  switch (nr_bits)
  switch (nr_bits)
    {
    {
    case 8:
    case 8:
      printf ("0x%02lx", (long) (unsigned8) (val));
      printf ("0x%02lx", (long) (unsigned8) (val));
      break;
      break;
    case 16:
    case 16:
      printf ("0x%04lx", (long) (unsigned16) (val));
      printf ("0x%04lx", (long) (unsigned16) (val));
      break;
      break;
    case 32:
    case 32:
      printf ("0x%08lx", (long) (unsigned32) (val));
      printf ("0x%08lx", (long) (unsigned32) (val));
      break;
      break;
    case 64:
    case 64:
      printf ("0x%08lx%08lx",
      printf ("0x%08lx%08lx",
              (long) (unsigned32) (val >> 32),
              (long) (unsigned32) (val >> 32),
              (long) (unsigned32) (val));
              (long) (unsigned32) (val));
      break;
      break;
    default:
    default:
      abort ();
      abort ();
    }
    }
}
}
 
 
 
 
int errors = 0;
int errors = 0;
 
 
 
 
#define N 8
#define N 8
#include "alu-n-tst.h"
#include "alu-n-tst.h"
#undef N
#undef N
 
 
#define N 16
#define N 16
#include "alu-n-tst.h"
#include "alu-n-tst.h"
#undef N
#undef N
 
 
#define N 32
#define N 32
#include "alu-n-tst.h"
#include "alu-n-tst.h"
#undef N
#undef N
 
 
#define N 64
#define N 64
#include "alu-n-tst.h"
#include "alu-n-tst.h"
#undef N
#undef N
 
 
 
 
 
 
int
int
main ()
main ()
{
{
  do_alu_8_tests ();
  do_alu_8_tests ();
  do_alu_16_tests ();
  do_alu_16_tests ();
  do_alu_32_tests ();
  do_alu_32_tests ();
  do_alu_64_tests ();
  do_alu_64_tests ();
  return (errors != 0);
  return (errors != 0);
}
}
 
 

powered by: WebSVN 2.1.0

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