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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [cpu-config.c] - Diff between revs 100 and 224

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 100 Rev 224
/* cpu-config.c -- CPU configuration
/* cpu-config.c -- CPU configuration
 
 
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
   Copyright (C) 2008 Embecosm Limited
   Copyright (C) 2008 Embecosm Limited
 
 
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
 
 
   This file is part of OpenRISC 1000 Architectural Simulator.
   This file is part of OpenRISC 1000 Architectural Simulator.
 
 
   This program is free software; you can redistribute it and/or modify it
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   under the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 3 of the License, or (at your option)
   Software Foundation; either version 3 of the License, or (at your option)
   any later version.
   any later version.
 
 
   This program is distributed in the hope that it will be useful, but WITHOUT
   This program is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.
   more details.
 
 
   You should have received a copy of the GNU General Public License along
   You should have received a copy of the GNU General Public License along
   with this program.  If not, see <http://www.gnu.org/licenses/>. */
   with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 
/* This program is commented throughout in a fashion suitable for processing
/* This program is commented throughout in a fashion suitable for processing
   with Doxygen. */
   with Doxygen. */
 
 
/* Broken out from sim-config.c */
/* Broken out from sim-config.c */
 
 
 
 
/* Autoconf and/or portability configuration */
/* Autoconf and/or portability configuration */
#include "config.h"
#include "config.h"
 
 
/* System includes */
/* System includes */
#include <stdio.h>
#include <stdio.h>
 
 
/* Package includes */
/* Package includes */
#include "cpu-config.h"
#include "cpu-config.h"
#include "sim-config.h"
#include "sim-config.h"
#include "spr-defs.h"
#include "spr-defs.h"
#include "execute.h"
#include "execute.h"
 
 
 
 
#define WARNING(s) fprintf (stderr, "Warning: config.%s: %s\n", cur_section->name, (s))
#define WARNING(s) fprintf (stderr, "Warning: config.cpu: %s\n", (s))
 
 
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!Set the CPU version
/*!Set the CPU version
 
 
   Value must be an 8-bit integer. Larger values are truncated with a warning.
   Value must be an 8-bit integer. Larger values are truncated with a warning.
 
 
   @param[in] val  The value to use
   @param[in] val  The value to use
   @param[in] dat  The config data structure (not used here)                 */
   @param[in] dat  The config data structure (not used here)                 */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
cpu_ver (union param_val  val,
cpu_ver (union param_val  val,
         void            *dat)
         void            *dat)
{
{
  if (val.int_val > 0xff)
  if (val.int_val > 0xff)
    {
    {
      WARNING ("CPU version > 8 bits truncated\n");
      WARNING ("CPU version > 8 bits truncated\n");
    }
    }
 
 
  cpu_state.sprs[SPR_VR] &= ~SPR_VR_VER;
  cpu_state.sprs[SPR_VR] &= ~SPR_VR_VER;
  cpu_state.sprs[SPR_VR] |= (val.int_val & 0xff) << SPR_VR_VER_OFF;
  cpu_state.sprs[SPR_VR] |= (val.int_val & 0xff) << SPR_VR_VER_OFF;
 
 
}       /* cpu_ver() */
}       /* cpu_ver() */
 
 
 
 
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!Set the CPU configuration
/*!Set the CPU configuration
 
 
   Value must be an 8-bit integer. Larger values are truncated with a warning.
   Value must be an 8-bit integer. Larger values are truncated with a warning.
 
 
   @param[in] val  The value to use
   @param[in] val  The value to use
   @param[in] dat  The config data structure (not used here)                 */
   @param[in] dat  The config data structure (not used here)                 */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
cpu_cfg (union param_val  val,
cpu_cfg (union param_val  val,
         void            *dat)
         void            *dat)
{
{
  if (val.int_val > 0xff)
  if (val.int_val > 0xff)
    {
    {
      WARNING ("CPU configuration > 8 bits truncated\n");
      WARNING ("CPU configuration > 8 bits truncated\n");
    }
    }
 
 
  cpu_state.sprs[SPR_VR] &= ~SPR_VR_CFG;
  cpu_state.sprs[SPR_VR] &= ~SPR_VR_CFG;
  cpu_state.sprs[SPR_VR] |= (val.int_val & 0xff) << SPR_VR_CFG_OFF;
  cpu_state.sprs[SPR_VR] |= (val.int_val & 0xff) << SPR_VR_CFG_OFF;
 
 
}       /* cpu_cfg() */
}       /* cpu_cfg() */
 
 
 
 
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!Set the CPU revision
/*!Set the CPU revision
 
 
   Value must be an 6-bit integer. Larger values are truncated with a warning.
   Value must be an 6-bit integer. Larger values are truncated with a warning.
 
 
 
 
   @param[in] val  The value to use
   @param[in] val  The value to use
   @param[in] dat  The config data structure (not used here)                 */
   @param[in] dat  The config data structure (not used here)                 */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
cpu_rev (union param_val  val,
cpu_rev (union param_val  val,
         void            *dat)
         void            *dat)
{
{
  if (val.int_val > 0x3f)
  if (val.int_val > 0x3f)
    {
    {
      WARNING ("CPU revision > 6 bits truncated\n");
      WARNING ("CPU revision > 6 bits truncated\n");
    }
    }
 
 
  cpu_state.sprs[SPR_VR] &= ~SPR_VR_REV_OFF ;
  cpu_state.sprs[SPR_VR] &= ~SPR_VR_REV_OFF ;
  cpu_state.sprs[SPR_VR] |= (val.int_val & 0x3f) << SPR_VR_REV_OFF ;
  cpu_state.sprs[SPR_VR] |= (val.int_val & 0x3f) << SPR_VR_REV_OFF ;
 
 
}       /* cpu_rev() */
}       /* cpu_rev() */
 
 
 
 
static void
static void
cpu_upr (union param_val val, void *dat)
cpu_upr (union param_val val, void *dat)
{
{
  cpu_state.sprs[SPR_UPR] = val.int_val;
  cpu_state.sprs[SPR_UPR] = val.int_val;
}
}
 
 
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!Set the CPU configuration
/*!Set the CPU configuration
 
 
   Value must be just the OB32S instruction set bit. Nothing else is currently
   Value must be just the OB32S instruction set bit. Nothing else is currently
   supported. If other values are specified, they will be set, but with a
   supported. If other values are specified, they will be set, but with a
   warning.
   warning.
 
 
 
 
   @param[in] val  The value to use
   @param[in] val  The value to use
   @param[in] dat  The config data structure (not used here)                 */
   @param[in] dat  The config data structure (not used here)                 */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
cpu_cfgr (union param_val  val,
cpu_cfgr (union param_val  val,
          void            *dat)
          void            *dat)
{
{
  if (SPR_CPUCFGR_OB32S != val.int_val)
  if (SPR_CPUCFGR_OB32S != val.int_val)
    {
    {
      WARNING ("CPU configuration: only OB32S currently supported\n");
      WARNING ("CPU configuration: only OB32S currently supported\n");
    }
    }
 
 
  cpu_state.sprs[SPR_CPUCFGR] = val.int_val;
  cpu_state.sprs[SPR_CPUCFGR] = val.int_val;
 
 
}       /* cpu_cfgr() */
}       /* cpu_cfgr() */
 
 
 
 
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!Set the CPU supervision register
/*!Set the CPU supervision register
 
 
   Only the lowest 17 bits may be set. The top 4 bits are for context ID's
   Only the lowest 17 bits may be set. The top 4 bits are for context ID's
   (not currently supported), the rest are reserved and should not be set.
   (not currently supported), the rest are reserved and should not be set.
 
 
   If such values are specified, the value will be set (it has no effect), but
   If such values are specified, the value will be set (it has no effect), but
   with a warning.
   with a warning.
 
 
   @param[in] val  The value to use
   @param[in] val  The value to use
   @param[in] dat  The config data structure (not used here)                 */
   @param[in] dat  The config data structure (not used here)                 */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
cpu_sr (union param_val  val,
cpu_sr (union param_val  val,
        void            *dat)
        void            *dat)
{
{
  if (0 != (val.int_val & 0xf0000000))
  if (0 != (val.int_val & 0xf0000000))
    {
    {
      WARNING ("Supervision Register ContextID not supported: ignored\n");
      WARNING ("Supervision Register ContextID not supported: ignored\n");
    }
    }
  else if (val.int_val > 0x1ffff)
  else if (val.int_val > 0x1ffff)
    {
    {
      WARNING ("Supervision Register reserved bits set: ignored\n");
      WARNING ("Supervision Register reserved bits set: ignored\n");
    }
    }
 
 
  cpu_state.sprs[SPR_SR] = val.int_val;
  cpu_state.sprs[SPR_SR] = val.int_val;
 
 
}       /* cpu_sr() */
}       /* cpu_sr() */
 
 
 
 
static void
static void
cpu_hazards (union param_val val, void *dat)
cpu_hazards (union param_val val, void *dat)
{
{
  config.cpu.hazards = val.int_val;
  config.cpu.hazards = val.int_val;
}
}
 
 
static void
static void
cpu_superscalar (union param_val val, void *dat)
cpu_superscalar (union param_val val, void *dat)
{
{
  config.cpu.superscalar = val.int_val;
  config.cpu.superscalar = val.int_val;
}
}
 
 
static void
static void
cpu_dependstats (union param_val val, void *dat)
cpu_dependstats (union param_val val, void *dat)
{
{
  config.cpu.dependstats = val.int_val;
  config.cpu.dependstats = val.int_val;
}
}
 
 
static void
static void
cpu_sbuf_len (union param_val val, void *dat)
cpu_sbuf_len (union param_val val, void *dat)
{
{
  if (val.int_val >= MAX_SBUF_LEN)
  if (val.int_val >= MAX_SBUF_LEN)
    {
    {
      config.cpu.sbuf_len = MAX_SBUF_LEN - 1;
      config.cpu.sbuf_len = MAX_SBUF_LEN - 1;
      WARNING ("sbuf_len too large; truncated.");
      WARNING ("sbuf_len too large; truncated.");
    }
    }
  else if (val.int_val < 0)
  else if (val.int_val < 0)
    {
    {
      config.cpu.sbuf_len = 0;
      config.cpu.sbuf_len = 0;
      WARNING ("sbuf_len negative; disabled.");
      WARNING ("sbuf_len negative; disabled.");
    }
    }
  else
  else
    config.cpu.sbuf_len = val.int_val;
    config.cpu.sbuf_len = val.int_val;
}
}
 
 
static void
static void
cpu_hardfloat (union param_val val, void *dat)
cpu_hardfloat (union param_val val, void *dat)
{
{
  config.cpu.hardfloat = val.int_val;
  config.cpu.hardfloat = val.int_val;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!Register the functions to handle a section cpu
/*!Register the functions to handle a section cpu
 
 
   This section does not allocate dynamically a data structure holding its
   This section does not allocate dynamically a data structure holding its
   config information. It's all in the global config.sim data
   config information. It's all in the global config.sim data
   structure. Therefore it does not need a start and end function to
   structure. Therefore it does not need a start and end function to
   initialize default values (although it might be clearer to do so). The
   initialize default values (although it might be clearer to do so). The
   default values are set in init_defconfig().                               */
   default values are set in init_defconfig().                               */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
void
reg_cpu_sec ()
reg_cpu_sec ()
{
{
  struct config_section *sec = reg_config_sec ("cpu", NULL, NULL);
  struct config_section *sec = reg_config_sec ("cpu", NULL, NULL);
 
 
  reg_config_param (sec, "ver",         paramt_int, cpu_ver);
  reg_config_param (sec, "ver",         PARAMT_INT, cpu_ver);
  reg_config_param (sec, "cfg",         paramt_int, cpu_cfg);
  reg_config_param (sec, "cfg",         PARAMT_INT, cpu_cfg);
  reg_config_param (sec, "rev",         paramt_int, cpu_rev);
  reg_config_param (sec, "rev",         PARAMT_INT, cpu_rev);
  reg_config_param (sec, "upr",         paramt_int, cpu_upr);
  reg_config_param (sec, "upr",         PARAMT_INT, cpu_upr);
  reg_config_param (sec, "cfgr",        paramt_int, cpu_cfgr);
  reg_config_param (sec, "cfgr",        PARAMT_INT, cpu_cfgr);
  reg_config_param (sec, "sr",          paramt_int, cpu_sr);
  reg_config_param (sec, "sr",          PARAMT_INT, cpu_sr);
  reg_config_param (sec, "superscalar", paramt_int, cpu_superscalar);
  reg_config_param (sec, "superscalar", PARAMT_INT, cpu_superscalar);
  reg_config_param (sec, "hazards",     paramt_int, cpu_hazards);
  reg_config_param (sec, "hazards",     PARAMT_INT, cpu_hazards);
  reg_config_param (sec, "dependstats", paramt_int, cpu_dependstats);
  reg_config_param (sec, "dependstats", PARAMT_INT, cpu_dependstats);
  reg_config_param (sec, "sbuf_len",    paramt_int, cpu_sbuf_len);
  reg_config_param (sec, "sbuf_len",    PARAMT_INT, cpu_sbuf_len);
  reg_config_param (sec, "hardfloat",   paramt_int, cpu_hardfloat);
  reg_config_param (sec, "hardfloat",   PARAMT_INT, cpu_hardfloat);
 
 
}       /* reg_cpu_sec() */
}       /* reg_cpu_sec() */
 
 

powered by: WebSVN 2.1.0

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