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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_50/] [or1ksim/] [testbench/] [acv_gpio.c] - Diff between revs 997 and 1024

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

Rev 997 Rev 1024
Line 38... Line 38...
/* fails if x is false */
/* fails if x is false */
#define ASSERT(x) ((x)?1: fail (__FILE__, __LINE__))
#define ASSERT(x) ((x)?1: fail (__FILE__, __LINE__))
 
 
static void fail (char *file, int line)
static void fail (char *file, int line)
{
{
  PRINTF( "Test failed in %s:%i\n", file, line );
  printf( "Test failed in %s:%i\n", file, line );
  report( 0xeeeeeeee );
  report( 0xeeeeeeee );
  exit( 1 );
  exit( 1 );
}
}
 
 
 
 
Line 54... Line 54...
  while ( 1 ) {
  while ( 1 ) {
    unsigned long curr = *rgpio_in;
    unsigned long curr = *rgpio_in;
    if ( curr == value )
    if ( curr == value )
      return;
      return;
    if ( curr != first ) {
    if ( curr != first ) {
      PRINTF( "While waiting for 0x%08lX, input changed from 0x%08lX to 0x%08lX\n", value, first, curr );
      printf( "While waiting for 0x%08lX, input changed from 0x%08lX to 0x%08lX\n", value, first, curr );
      ASSERT( 0 );
      ASSERT( 0 );
    }
    }
  }
  }
}
}
 
 
Line 81... Line 81...
 
 
 
 
 
 
static void test_registers( void )
static void test_registers( void )
{
{
  PRINTF( "Testing initial values of all registers\n" );
  printf( "Testing initial values of all registers\n" );
  ASSERT( *rgpio_oe == 0 );
  ASSERT( *rgpio_oe == 0 );
  ASSERT( *rgpio_inte == 0 );
  ASSERT( *rgpio_inte == 0 );
  ASSERT( *rgpio_ptrig == 0 );
  ASSERT( *rgpio_ptrig == 0 );
  ASSERT( *rgpio_ctrl == 0 );
  ASSERT( *rgpio_ctrl == 0 );
  ASSERT( *rgpio_ints == 0 );
  ASSERT( *rgpio_ints == 0 );
 
 
  PRINTF( "Verifying that RGPIO_IN is read-only\n" );
  printf( "Verifying that RGPIO_IN is read-only\n" );
  {
  {
    unsigned long value = *rgpio_in;
    unsigned long value = *rgpio_in;
    unsigned i;
    unsigned i;
    *rgpio_in = ~value;
    *rgpio_in = ~value;
    ASSERT( *rgpio_in == value );
    ASSERT( *rgpio_in == value );
Line 108... Line 108...
static void test_simple_io( void )
static void test_simple_io( void )
{
{
  unsigned i;
  unsigned i;
  unsigned long oe;
  unsigned long oe;
 
 
  PRINTF( "Testing simple I/O\n" );
  printf( "Testing simple I/O\n" );
  for ( i = 1, oe = 1; i < 31; ++ i, oe = (oe << 1) | 1 ) {
  for ( i = 1, oe = 1; i < 31; ++ i, oe = (oe << 1) | 1 ) {
    *rgpio_oe = oe;
    *rgpio_oe = oe;
 
 
    *rgpio_out = 0xFFFFFFFF;
    *rgpio_out = 0xFFFFFFFF;
    wait_input( 0xFFFFFFFF );
    wait_input( 0xFFFFFFFF );
Line 139... Line 139...
 
 
static void test_interrupts( void )
static void test_interrupts( void )
{
{
  unsigned i;
  unsigned i;
 
 
  PRINTF( "Testing interrupts\n" );
  printf( "Testing interrupts\n" );
 
 
  *rgpio_oe = 0x80000000;
  *rgpio_oe = 0x80000000;
  int_count = 0;
  int_count = 0;
  *rgpio_inte = 0x7fffffff;
  *rgpio_inte = 0x7fffffff;
  *rgpio_ptrig = 0x7fffffff;
  *rgpio_ptrig = 0x7fffffff;
Line 163... Line 163...
}
}
 
 
static void test_external_clock( void )
static void test_external_clock( void )
{
{
  unsigned i;
  unsigned i;
  PRINTF( "Testing external clock\n" );
  printf( "Testing external clock\n" );
 
 
  *rgpio_oe = 0x80000000;
  *rgpio_oe = 0x80000000;
  *rgpio_inte = 0x7fffffff;
  *rgpio_inte = 0x7fffffff;
  *rgpio_ptrig = 0x7fffffff;
  *rgpio_ptrig = 0x7fffffff;
 
 
Line 198... Line 198...
}
}
 
 
 
 
static void endshake( void )
static void endshake( void )
{
{
  PRINTF( "Finishing simulation\n" );
  printf( "Finishing simulation\n" );
  *rgpio_oe = 0xffff0000;
  *rgpio_oe = 0xffff0000;
  *rgpio_out = 0x12340000;
  *rgpio_out = 0x12340000;
  wait_input( 0x12345678 );
  wait_input( 0x12345678 );
  *rgpio_oe = 0xffffffff;
  *rgpio_oe = 0xffffffff;
  *rgpio_out = 0xDeadDead;
  *rgpio_out = 0xDeadDead;
}
}
 
 
 
 
int main()
int main()
{
{
  PRINTF( "Starting GPIO test\n" );
  printf( "Starting GPIO test\n" );
 
 
  init_interrupts();
  init_interrupts();
 
 
  test_registers();
  test_registers();
  test_simple_io();
  test_simple_io();
  test_interrupts();
  test_interrupts();
  test_external_clock();
  test_external_clock();
  endshake();
  endshake();
 
 
  PRINTF( "Ending GPIO test\n" );
  printf( "Ending GPIO test\n" );
 
 
  report (0xdeaddead);
  report (0xdeaddead);
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

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