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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [lib/] [zlib_inflate/] [inflate.c] - Diff between revs 1275 and 1765

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

Rev 1275 Rev 1765
/* inflate.c -- zlib interface to inflate modules
/* inflate.c -- zlib interface to inflate modules
 * Copyright (C) 1995-1998 Mark Adler
 * Copyright (C) 1995-1998 Mark Adler
 * For conditions of distribution and use, see copyright notice in zlib.h
 * For conditions of distribution and use, see copyright notice in zlib.h
 */
 */
 
 
#include <linux/module.h>
#include <linux/module.h>
#include <linux/zutil.h>
#include <linux/zutil.h>
#include "infblock.h"
#include "infblock.h"
#include "infutil.h"
#include "infutil.h"
 
 
int ZEXPORT zlib_inflate_workspacesize(void)
int ZEXPORT zlib_inflate_workspacesize(void)
{
{
  return sizeof(struct inflate_workspace);
  return sizeof(struct inflate_workspace);
}
}
 
 
 
 
int ZEXPORT zlib_inflateReset(z)
int ZEXPORT zlib_inflateReset(z)
z_streamp z;
z_streamp z;
{
{
  if (z == Z_NULL || z->state == Z_NULL || z->workspace == Z_NULL)
  if (z == Z_NULL || z->state == Z_NULL || z->workspace == Z_NULL)
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  z->total_in = z->total_out = 0;
  z->total_in = z->total_out = 0;
  z->msg = Z_NULL;
  z->msg = Z_NULL;
  z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
  z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
  zlib_inflate_blocks_reset(z->state->blocks, z, Z_NULL);
  zlib_inflate_blocks_reset(z->state->blocks, z, Z_NULL);
  return Z_OK;
  return Z_OK;
}
}
 
 
 
 
int ZEXPORT zlib_inflateEnd(z)
int ZEXPORT zlib_inflateEnd(z)
z_streamp z;
z_streamp z;
{
{
  if (z == Z_NULL || z->state == Z_NULL || z->workspace == Z_NULL)
  if (z == Z_NULL || z->state == Z_NULL || z->workspace == Z_NULL)
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  if (z->state->blocks != Z_NULL)
  if (z->state->blocks != Z_NULL)
    zlib_inflate_blocks_free(z->state->blocks, z);
    zlib_inflate_blocks_free(z->state->blocks, z);
  z->state = Z_NULL;
  z->state = Z_NULL;
  return Z_OK;
  return Z_OK;
}
}
 
 
 
 
int ZEXPORT zlib_inflateInit2_(z, w, version, stream_size)
int ZEXPORT zlib_inflateInit2_(z, w, version, stream_size)
z_streamp z;
z_streamp z;
int w;
int w;
const char *version;
const char *version;
int stream_size;
int stream_size;
{
{
  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
  if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
      stream_size != sizeof(z_stream) || z->workspace == Z_NULL)
      stream_size != sizeof(z_stream) || z->workspace == Z_NULL)
      return Z_VERSION_ERROR;
      return Z_VERSION_ERROR;
 
 
  /* initialize state */
  /* initialize state */
  if (z == Z_NULL)
  if (z == Z_NULL)
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  z->msg = Z_NULL;
  z->msg = Z_NULL;
  z->state = &WS(z)->internal_state;
  z->state = &WS(z)->internal_state;
  z->state->blocks = Z_NULL;
  z->state->blocks = Z_NULL;
 
 
  /* handle undocumented nowrap option (no zlib header or check) */
  /* handle undocumented nowrap option (no zlib header or check) */
  z->state->nowrap = 0;
  z->state->nowrap = 0;
  if (w < 0)
  if (w < 0)
  {
  {
    w = - w;
    w = - w;
    z->state->nowrap = 1;
    z->state->nowrap = 1;
  }
  }
 
 
  /* set window size */
  /* set window size */
  if (w < 8 || w > 15)
  if (w < 8 || w > 15)
  {
  {
    zlib_inflateEnd(z);
    zlib_inflateEnd(z);
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  }
  }
  z->state->wbits = (uInt)w;
  z->state->wbits = (uInt)w;
 
 
  /* create inflate_blocks state */
  /* create inflate_blocks state */
  if ((z->state->blocks =
  if ((z->state->blocks =
      zlib_inflate_blocks_new(z, z->state->nowrap ? Z_NULL : zlib_adler32, (uInt)1 << w))
      zlib_inflate_blocks_new(z, z->state->nowrap ? Z_NULL : zlib_adler32, (uInt)1 << w))
      == Z_NULL)
      == Z_NULL)
  {
  {
    zlib_inflateEnd(z);
    zlib_inflateEnd(z);
    return Z_MEM_ERROR;
    return Z_MEM_ERROR;
  }
  }
 
 
  /* reset state */
  /* reset state */
  zlib_inflateReset(z);
  zlib_inflateReset(z);
  return Z_OK;
  return Z_OK;
}
}
 
 
 
 
/*
/*
 * At the end of a Deflate-compressed PPP packet, we expect to have seen
 * At the end of a Deflate-compressed PPP packet, we expect to have seen
 * a `stored' block type value but not the (zero) length bytes.
 * a `stored' block type value but not the (zero) length bytes.
 */
 */
static int zlib_inflate_packet_flush(inflate_blocks_statef *s)
static int zlib_inflate_packet_flush(inflate_blocks_statef *s)
{
{
    if (s->mode != LENS)
    if (s->mode != LENS)
        return Z_DATA_ERROR;
        return Z_DATA_ERROR;
    s->mode = TYPE;
    s->mode = TYPE;
    return Z_OK;
    return Z_OK;
}
}
 
 
 
 
int ZEXPORT zlib_inflateInit_(z, version, stream_size)
int ZEXPORT zlib_inflateInit_(z, version, stream_size)
z_streamp z;
z_streamp z;
const char *version;
const char *version;
int stream_size;
int stream_size;
{
{
  return zlib_inflateInit2_(z, DEF_WBITS, version, stream_size);
  return zlib_inflateInit2_(z, DEF_WBITS, version, stream_size);
}
}
 
 
#undef NEEDBYTE
#undef NEEDBYTE
#undef NEXTBYTE
#undef NEXTBYTE
#define NEEDBYTE {if(z->avail_in==0)goto empty;r=trv;}
#define NEEDBYTE {if(z->avail_in==0)goto empty;r=trv;}
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
 
 
int ZEXPORT zlib_inflate(z, f)
int ZEXPORT zlib_inflate(z, f)
z_streamp z;
z_streamp z;
int f;
int f;
{
{
  int r, trv;
  int r, trv;
  uInt b;
  uInt b;
 
 
  if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
  if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  trv = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
  trv = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
  r = Z_BUF_ERROR;
  r = Z_BUF_ERROR;
  while (1) switch (z->state->mode)
  while (1) switch (z->state->mode)
  {
  {
    case METHOD:
    case METHOD:
      NEEDBYTE
      NEEDBYTE
      if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED)
      if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED)
      {
      {
        z->state->mode = I_BAD;
        z->state->mode = I_BAD;
        z->msg = (char*)"unknown compression method";
        z->msg = (char*)"unknown compression method";
        z->state->sub.marker = 5;       /* can't try inflateSync */
        z->state->sub.marker = 5;       /* can't try inflateSync */
        break;
        break;
      }
      }
      if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
      if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
      {
      {
        z->state->mode = I_BAD;
        z->state->mode = I_BAD;
        z->msg = (char*)"invalid window size";
        z->msg = (char*)"invalid window size";
        z->state->sub.marker = 5;       /* can't try inflateSync */
        z->state->sub.marker = 5;       /* can't try inflateSync */
        break;
        break;
      }
      }
      z->state->mode = FLAG;
      z->state->mode = FLAG;
    case FLAG:
    case FLAG:
      NEEDBYTE
      NEEDBYTE
      b = NEXTBYTE;
      b = NEXTBYTE;
      if (((z->state->sub.method << 8) + b) % 31)
      if (((z->state->sub.method << 8) + b) % 31)
      {
      {
        z->state->mode = I_BAD;
        z->state->mode = I_BAD;
        z->msg = (char*)"incorrect header check";
        z->msg = (char*)"incorrect header check";
        z->state->sub.marker = 5;       /* can't try inflateSync */
        z->state->sub.marker = 5;       /* can't try inflateSync */
        break;
        break;
      }
      }
      if (!(b & PRESET_DICT))
      if (!(b & PRESET_DICT))
      {
      {
        z->state->mode = BLOCKS;
        z->state->mode = BLOCKS;
        break;
        break;
      }
      }
      z->state->mode = DICT4;
      z->state->mode = DICT4;
    case DICT4:
    case DICT4:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need = (uLong)NEXTBYTE << 24;
      z->state->sub.check.need = (uLong)NEXTBYTE << 24;
      z->state->mode = DICT3;
      z->state->mode = DICT3;
    case DICT3:
    case DICT3:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need += (uLong)NEXTBYTE << 16;
      z->state->sub.check.need += (uLong)NEXTBYTE << 16;
      z->state->mode = DICT2;
      z->state->mode = DICT2;
    case DICT2:
    case DICT2:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need += (uLong)NEXTBYTE << 8;
      z->state->sub.check.need += (uLong)NEXTBYTE << 8;
      z->state->mode = DICT1;
      z->state->mode = DICT1;
    case DICT1:
    case DICT1:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need += (uLong)NEXTBYTE;
      z->state->sub.check.need += (uLong)NEXTBYTE;
      z->adler = z->state->sub.check.need;
      z->adler = z->state->sub.check.need;
      z->state->mode = DICT0;
      z->state->mode = DICT0;
      return Z_NEED_DICT;
      return Z_NEED_DICT;
    case DICT0:
    case DICT0:
      z->state->mode = I_BAD;
      z->state->mode = I_BAD;
      z->msg = (char*)"need dictionary";
      z->msg = (char*)"need dictionary";
      z->state->sub.marker = 0;       /* can try inflateSync */
      z->state->sub.marker = 0;       /* can try inflateSync */
      return Z_STREAM_ERROR;
      return Z_STREAM_ERROR;
    case BLOCKS:
    case BLOCKS:
      r = zlib_inflate_blocks(z->state->blocks, z, r);
      r = zlib_inflate_blocks(z->state->blocks, z, r);
      if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0)
      if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0)
          r = zlib_inflate_packet_flush(z->state->blocks);
          r = zlib_inflate_packet_flush(z->state->blocks);
      if (r == Z_DATA_ERROR)
      if (r == Z_DATA_ERROR)
      {
      {
        z->state->mode = I_BAD;
        z->state->mode = I_BAD;
        z->state->sub.marker = 0;       /* can try inflateSync */
        z->state->sub.marker = 0;       /* can try inflateSync */
        break;
        break;
      }
      }
      if (r == Z_OK)
      if (r == Z_OK)
        r = trv;
        r = trv;
      if (r != Z_STREAM_END)
      if (r != Z_STREAM_END)
        return r;
        return r;
      r = trv;
      r = trv;
      zlib_inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
      zlib_inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
      if (z->state->nowrap)
      if (z->state->nowrap)
      {
      {
        z->state->mode = I_DONE;
        z->state->mode = I_DONE;
        break;
        break;
      }
      }
      z->state->mode = CHECK4;
      z->state->mode = CHECK4;
    case CHECK4:
    case CHECK4:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need = (uLong)NEXTBYTE << 24;
      z->state->sub.check.need = (uLong)NEXTBYTE << 24;
      z->state->mode = CHECK3;
      z->state->mode = CHECK3;
    case CHECK3:
    case CHECK3:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need += (uLong)NEXTBYTE << 16;
      z->state->sub.check.need += (uLong)NEXTBYTE << 16;
      z->state->mode = CHECK2;
      z->state->mode = CHECK2;
    case CHECK2:
    case CHECK2:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need += (uLong)NEXTBYTE << 8;
      z->state->sub.check.need += (uLong)NEXTBYTE << 8;
      z->state->mode = CHECK1;
      z->state->mode = CHECK1;
    case CHECK1:
    case CHECK1:
      NEEDBYTE
      NEEDBYTE
      z->state->sub.check.need += (uLong)NEXTBYTE;
      z->state->sub.check.need += (uLong)NEXTBYTE;
 
 
      if (z->state->sub.check.was != z->state->sub.check.need)
      if (z->state->sub.check.was != z->state->sub.check.need)
      {
      {
        z->state->mode = I_BAD;
        z->state->mode = I_BAD;
        z->msg = (char*)"incorrect data check";
        z->msg = (char*)"incorrect data check";
        z->state->sub.marker = 5;       /* can't try inflateSync */
        z->state->sub.marker = 5;       /* can't try inflateSync */
        break;
        break;
      }
      }
      z->state->mode = I_DONE;
      z->state->mode = I_DONE;
    case I_DONE:
    case I_DONE:
      return Z_STREAM_END;
      return Z_STREAM_END;
    case I_BAD:
    case I_BAD:
      return Z_DATA_ERROR;
      return Z_DATA_ERROR;
    default:
    default:
      return Z_STREAM_ERROR;
      return Z_STREAM_ERROR;
  }
  }
 empty:
 empty:
  if (f != Z_PACKET_FLUSH)
  if (f != Z_PACKET_FLUSH)
    return r;
    return r;
  z->state->mode = I_BAD;
  z->state->mode = I_BAD;
  z->msg = (char *)"need more for packet flush";
  z->msg = (char *)"need more for packet flush";
  z->state->sub.marker = 0;       /* can try inflateSync */
  z->state->sub.marker = 0;       /* can try inflateSync */
  return Z_DATA_ERROR;
  return Z_DATA_ERROR;
}
}
 
 
 
 
int ZEXPORT zlib_inflateSync(z)
int ZEXPORT zlib_inflateSync(z)
z_streamp z;
z_streamp z;
{
{
  uInt n;       /* number of bytes to look at */
  uInt n;       /* number of bytes to look at */
  Bytef *p;     /* pointer to bytes */
  Bytef *p;     /* pointer to bytes */
  uInt m;       /* number of marker bytes found in a row */
  uInt m;       /* number of marker bytes found in a row */
  uLong r, w;   /* temporaries to save total_in and total_out */
  uLong r, w;   /* temporaries to save total_in and total_out */
 
 
  /* set up */
  /* set up */
  if (z == Z_NULL || z->state == Z_NULL)
  if (z == Z_NULL || z->state == Z_NULL)
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  if (z->state->mode != I_BAD)
  if (z->state->mode != I_BAD)
  {
  {
    z->state->mode = I_BAD;
    z->state->mode = I_BAD;
    z->state->sub.marker = 0;
    z->state->sub.marker = 0;
  }
  }
  if ((n = z->avail_in) == 0)
  if ((n = z->avail_in) == 0)
    return Z_BUF_ERROR;
    return Z_BUF_ERROR;
  p = z->next_in;
  p = z->next_in;
  m = z->state->sub.marker;
  m = z->state->sub.marker;
 
 
  /* search */
  /* search */
  while (n && m < 4)
  while (n && m < 4)
  {
  {
    static const Byte mark[4] = {0, 0, 0xff, 0xff};
    static const Byte mark[4] = {0, 0, 0xff, 0xff};
    if (*p == mark[m])
    if (*p == mark[m])
      m++;
      m++;
    else if (*p)
    else if (*p)
      m = 0;
      m = 0;
    else
    else
      m = 4 - m;
      m = 4 - m;
    p++, n--;
    p++, n--;
  }
  }
 
 
  /* restore */
  /* restore */
  z->total_in += p - z->next_in;
  z->total_in += p - z->next_in;
  z->next_in = p;
  z->next_in = p;
  z->avail_in = n;
  z->avail_in = n;
  z->state->sub.marker = m;
  z->state->sub.marker = m;
 
 
  /* return no joy or set up to restart on a new block */
  /* return no joy or set up to restart on a new block */
  if (m != 4)
  if (m != 4)
    return Z_DATA_ERROR;
    return Z_DATA_ERROR;
  r = z->total_in;  w = z->total_out;
  r = z->total_in;  w = z->total_out;
  zlib_inflateReset(z);
  zlib_inflateReset(z);
  z->total_in = r;  z->total_out = w;
  z->total_in = r;  z->total_out = w;
  z->state->mode = BLOCKS;
  z->state->mode = BLOCKS;
  return Z_OK;
  return Z_OK;
}
}
 
 
 
 
/* Returns true if inflate is currently at the end of a block generated
/* Returns true if inflate is currently at the end of a block generated
 * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
 * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
 * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
 * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
 * but removes the length bytes of the resulting empty stored block. When
 * but removes the length bytes of the resulting empty stored block. When
 * decompressing, PPP checks that at the end of input packet, inflate is
 * decompressing, PPP checks that at the end of input packet, inflate is
 * waiting for these length bytes.
 * waiting for these length bytes.
 */
 */
int ZEXPORT zlib_inflateSyncPoint(z)
int ZEXPORT zlib_inflateSyncPoint(z)
z_streamp z;
z_streamp z;
{
{
  if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
  if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
    return Z_STREAM_ERROR;
    return Z_STREAM_ERROR;
  return zlib_inflate_blocks_sync_point(z->state->blocks);
  return zlib_inflate_blocks_sync_point(z->state->blocks);
}
}
 
 
/*
/*
 * This subroutine adds the data at next_in/avail_in to the output history
 * This subroutine adds the data at next_in/avail_in to the output history
 * without performing any output.  The output buffer must be "caught up";
 * without performing any output.  The output buffer must be "caught up";
 * i.e. no pending output (hence s->read equals s->write), and the state must
 * i.e. no pending output (hence s->read equals s->write), and the state must
 * be BLOCKS (i.e. we should be willing to see the start of a series of
 * be BLOCKS (i.e. we should be willing to see the start of a series of
 * BLOCKS).  On exit, the output will also be caught up, and the checksum
 * BLOCKS).  On exit, the output will also be caught up, and the checksum
 * will have been updated if need be.
 * will have been updated if need be.
 */
 */
static int zlib_inflate_addhistory(inflate_blocks_statef *s,
static int zlib_inflate_addhistory(inflate_blocks_statef *s,
                                      z_stream              *z)
                                      z_stream              *z)
{
{
    uLong b;              /* bit buffer */  /* NOT USED HERE */
    uLong b;              /* bit buffer */  /* NOT USED HERE */
    uInt k;               /* bits in bit buffer */ /* NOT USED HERE */
    uInt k;               /* bits in bit buffer */ /* NOT USED HERE */
    uInt t;               /* temporary storage */
    uInt t;               /* temporary storage */
    Bytef *p;             /* input data pointer */
    Bytef *p;             /* input data pointer */
    uInt n;               /* bytes available there */
    uInt n;               /* bytes available there */
    Bytef *q;             /* output window write pointer */
    Bytef *q;             /* output window write pointer */
    uInt m;               /* bytes to end of window or read pointer */
    uInt m;               /* bytes to end of window or read pointer */
 
 
    if (s->read != s->write)
    if (s->read != s->write)
        return Z_STREAM_ERROR;
        return Z_STREAM_ERROR;
    if (s->mode != TYPE)
    if (s->mode != TYPE)
        return Z_DATA_ERROR;
        return Z_DATA_ERROR;
 
 
    /* we're ready to rock */
    /* we're ready to rock */
    LOAD
    LOAD
    /* while there is input ready, copy to output buffer, moving
    /* while there is input ready, copy to output buffer, moving
     * pointers as needed.
     * pointers as needed.
     */
     */
    while (n) {
    while (n) {
        t = n;  /* how many to do */
        t = n;  /* how many to do */
        /* is there room until end of buffer? */
        /* is there room until end of buffer? */
        if (t > m) t = m;
        if (t > m) t = m;
        /* update check information */
        /* update check information */
        if (s->checkfn != Z_NULL)
        if (s->checkfn != Z_NULL)
            s->check = (*s->checkfn)(s->check, q, t);
            s->check = (*s->checkfn)(s->check, q, t);
        memcpy(q, p, t);
        memcpy(q, p, t);
        q += t;
        q += t;
        p += t;
        p += t;
        n -= t;
        n -= t;
        z->total_out += t;
        z->total_out += t;
        s->read = q;    /* drag read pointer forward */
        s->read = q;    /* drag read pointer forward */
/*      WWRAP  */       /* expand WWRAP macro by hand to handle s->read */
/*      WWRAP  */       /* expand WWRAP macro by hand to handle s->read */
        if (q == s->end) {
        if (q == s->end) {
            s->read = q = s->window;
            s->read = q = s->window;
            m = WAVAIL;
            m = WAVAIL;
        }
        }
    }
    }
    UPDATE
    UPDATE
    return Z_OK;
    return Z_OK;
}
}
 
 
 
 
/*
/*
 * This subroutine adds the data at next_in/avail_in to the output history
 * This subroutine adds the data at next_in/avail_in to the output history
 * without performing any output.  The output buffer must be "caught up";
 * without performing any output.  The output buffer must be "caught up";
 * i.e. no pending output (hence s->read equals s->write), and the state must
 * i.e. no pending output (hence s->read equals s->write), and the state must
 * be BLOCKS (i.e. we should be willing to see the start of a series of
 * be BLOCKS (i.e. we should be willing to see the start of a series of
 * BLOCKS).  On exit, the output will also be caught up, and the checksum
 * BLOCKS).  On exit, the output will also be caught up, and the checksum
 * will have been updated if need be.
 * will have been updated if need be.
 */
 */
 
 
int ZEXPORT zlib_inflateIncomp(z)
int ZEXPORT zlib_inflateIncomp(z)
z_stream *z;
z_stream *z;
{
{
    if (z->state->mode != BLOCKS)
    if (z->state->mode != BLOCKS)
        return Z_DATA_ERROR;
        return Z_DATA_ERROR;
    return zlib_inflate_addhistory(z->state->blocks, z);
    return zlib_inflate_addhistory(z->state->blocks, z);
}
}
 
 

powered by: WebSVN 2.1.0

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