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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [host/] [regdefs.cpp] - Diff between revs 8 and 45

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

Rev 8 Rev 45
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    regdefs.cpp
// Filename:    regdefs.cpp
//
//
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
//
//
// Purpose:     To give human readable names to the various registers available
// Purpose:     To give human readable names to the various registers available
//              internal to the processor on the wishbone bus.  This file is
//              internal to the processor on the wishbone bus.  This file is
//      primarily used for name to number translation within wbregs.cpp.
//      primarily used for name to number translation within wbregs.cpp.
//      All names for a given register are equivalent, save only that the
//      All names for a given register are equivalent, save only that the
//      register will always be identified by its first name in any output.
//      register will always be identified by its first name in any output.
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) 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 MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for 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.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <strings.h>
#include <strings.h>
#include <ctype.h>
#include <ctype.h>
#include "regdefs.h"
#include "regdefs.h"
 
 
const   REGNAME raw_bregs[] = {
const   REGNAME raw_bregs[] = {
        { R_VERSION,    "VERSION"               },
        { R_VERSION,    "VERSION"               },
        { R_ICONTROL,   "ICONTROL"              },
        { R_ICONTROL,   "ICONTROL"              },
        { R_ICONTROL,   "INT"                   },
        { R_ICONTROL,   "INT"                   },
        { R_ICONTROL,   "PIC"                   },
        { R_ICONTROL,   "PIC"                   },
        { R_ICONTROL,   "INTC"                  },
        { R_ICONTROL,   "INTC"                  },
        { R_BUSERR,     "BUSERR"                },
        { R_BUSERR,     "BUSERR"                },
        { R_BUSERR,     "BUS"                   },
        { R_BUSERR,     "BUS"                   },
        { R_ITIMERA,    "TMRA"                  },
        { R_ITIMERA,    "TMRA"                  },
        { R_ITIMERB,    "TMRB"                  },
        { R_ITIMERB,    "TMRB"                  },
        { R_PWM,        "PWMAUDIO"              },
        { R_PWM,        "PWMAUDIO"              },
        { R_PWM,        "PWM"                   },
        { R_PWM,        "PWM"                   },
        { R_PWM,        "PWMDATA"               },
        { R_PWM,        "PWMDATA"               },
        { R_PWM,        "AUDIO"                 },
        { R_PWM,        "AUDIO"                 },
        { R_SPIO,       "SPIO"                  },
        { R_SPIO,       "SPIO"                  },
        { R_GPIO,       "GPIO"                  },
        { R_GPIO,       "GPIO"                  },
        { R_UART,       "UART"                  },
        { R_UART,       "UART"                  },
        { R_UART,       "UART-RX"               },
        { R_UART,       "UART-RX"               },
        { R_UART,       "UARTRX"                },
        { R_UART,       "UARTRX"                },
        { R_UART,       "RX"                    },
        { R_UART,       "RX"                    },
        { R_UART,       "UART-TX"               },
        { R_UART,       "UART-TX"               },
        { R_UART,       "UARTTX"                },
        { R_UART,       "UARTTX"                },
        { R_UART,       "TX"                    },
        { R_UART,       "TX"                    },
        //
        //
        { R_QSPI_EREG,  "QSPIEREG"              },
        { R_QSPI_EREG,  "QSPIEREG"              },
        { R_QSPI_EREG,  "QSPIE"                 },
        { R_QSPI_EREG,  "QSPIE"                 },
        { R_QSPI_CREG,  "QSPICONF"              },
        { R_QSPI_CREG,  "QSPICONF"              },
        { R_QSPI_CREG,  "QSPIC"                 },
        { R_QSPI_CREG,  "QSPIC"                 },
        { R_QSPI_SREG,  "QSPISTAT"              },
        { R_QSPI_SREG,  "QSPISTAT"              },
        { R_QSPI_SREG,  "QSPIS"                 },
        { R_QSPI_SREG,  "QSPIS"                 },
        { R_QSPI_IDREG, "QSPIID"                },
        { R_QSPI_IDREG, "QSPIID"                },
        { R_QSPI_IDREG, "QSPII"                 },
        { R_QSPI_IDREG, "QSPII"                 },
        //
        //
        { R_CLOCK,      "CLOCK"                 },
        // The real-time-clock registers have been removed
        { R_CLOCK,      "TIME"                  },
        //      (they never fit in the core)
        { R_TIMER,      "TIMER"                 },
        //
        { R_STOPWATCH,  "STOPWACH"              },
        // The real-time-date register has been removed
        { R_STOPWATCH,  "STOPWATCH"             },
        //      (it never fit either)
        { R_CKALARM,    "CKALARM"               },
        //
        { R_CKALARM,    "ALARM"                 },
        // The wishbone scope
        // { R_DATE,    "DATE"                  },
        //
        // Scopes are defined and come and go.  Be aware, therefore, not all
 
        // of these scopes may be defined at the same time.
 
        { R_SCOPE,      "SCOPE"                 },
        { R_SCOPE,      "SCOPE"                 },
        { R_SCOPE,      "SCOP"                  },
        { R_SCOPE,      "SCOP"                  },
        { R_SCOPED,     "SCOPDATA"              },
        { R_SCOPED,     "SCOPDATA"              },
        { R_SCOPED,     "SCDATA"                },
        { R_SCOPED,     "SCDATA"                },
        { R_SCOPED,     "SCOPED"                },
        { R_SCOPED,     "SCOPED"                },
        { R_SCOPED,     "SCOPD"                 },
        { R_SCOPED,     "SCOPD"                 },
        //
        //
        // For working with the ICAPE interface ... if I can ever get a
        // The ICAPE interface registers have been removed.
        // testing environment suitable to prove that it works.
 
        //
 
        { R_CFG_CRC,    "FPGACRC"               },
 
        { R_CFG_FAR_MAJ, "FPGAFARH"             },
 
        { R_CFG_FAR_MIN, "FPGAFARL"             },
 
        { R_CFG_FDRI,   "FPGAFDRI"              },
 
        { R_CFG_FDRO,   "FPGAFDRO"              },
 
        { R_CFG_CMD,    "FPGACMD"               },
 
        { R_CFG_CTL,    "FPGACTL"               },
 
        { R_CFG_MASK,   "FPGAMASK"              },
 
        { R_CFG_STAT,   "FPGASTAT"              },
 
        { R_CFG_LOUT,   "FPGALOUT"              },
 
        { R_CFG_COR1,   "FPGACOR1"              },
 
        { R_CFG_COR2,   "FPGACOR2"              },
 
        { R_CFG_PWRDN,  "FPGAPWRDN"             },
 
        { R_CFG_FLR,    "FPGAFLR"               },
 
        { R_CFG_IDCODE, "FPGAIDCODE"            },
 
        { R_CFG_CWDT,   "FPGACWDT"              },
 
        { R_CFG_HCOPT,  "FPGAHCOPT"             },
 
        { R_CFG_CSBO,   "FPGACSBO"              },
 
        { R_CFG_GEN1,   "FPGAGEN1"              },
 
        { R_CFG_GEN2,   "FPGAGEN2"              },
 
        { R_CFG_GEN3,   "FPGAGEN3"              },
 
        { R_CFG_GEN4,   "FPGAGEN4"              },
 
        { R_CFG_GEN5,   "FPGAGEN5"              },
 
        { R_CFG_MODE,   "FPGAMODE"              },
 
        { R_CFG_GWE,    "FPGAGWE"               },
 
        { R_CFG_GTS,    "FPGAGTS"               },
 
        { R_CFG_MFWR,   "FPGAMFWR"              },
 
        { R_CFG_CCLK,   "FPGACCLK"              },
 
        { R_CFG_SEU,    "FPGASEU"               },
 
        { R_CFG_EXP,    "FPGAEXP"               },
 
        { R_CFG_RDBK,   "FPGARDBK"              },
 
        { R_CFG_BOOTSTS, "BOOTSTS"              },
 
        { R_CFG_EYE,    "FPGAEYE"               },
 
        { R_CFG_CBC,    "FPGACBC"               },
 
        //
        //
        { RAMBASE,      "MEM"                   },
        { RAMBASE,      "MEM"                   },
        { SPIFLASH,     "FLASH"                 }
        { SPIFLASH,     "FLASH"                 }
};
};
 
 
#define RAW_NREGS       (sizeof(raw_bregs)/sizeof(bregs[0]))
#define RAW_NREGS       (sizeof(raw_bregs)/sizeof(bregs[0]))
 
 
const   REGNAME *bregs = raw_bregs;
const   REGNAME *bregs = raw_bregs;
const   int     NREGS = RAW_NREGS;
const   int     NREGS = RAW_NREGS;
 
 
unsigned        addrdecode(const char *v) {
unsigned        addrdecode(const char *v) {
        if (isalpha(v[0])) {
        if (isalpha(v[0])) {
                for(int i=0; i<NREGS; i++)
                for(int i=0; i<NREGS; i++)
                        if (strcasecmp(v, bregs[i].m_name)==0)
                        if (strcasecmp(v, bregs[i].m_name)==0)
                                return bregs[i].m_addr;
                                return bregs[i].m_addr;
                fprintf(stderr, "Unknown register: %s\n", v);
                fprintf(stderr, "Unknown register: %s\n", v);
                exit(-2);
                exit(-2);
        } else
        } else
                return strtoul(v, NULL, 0);
                return strtoul(v, NULL, 0);
}
}
 
 
const   char *addrname(const unsigned v) {
const   char *addrname(const unsigned v) {
        for(int i=0; i<NREGS; i++)
        for(int i=0; i<NREGS; i++)
                if (bregs[i].m_addr == v)
                if (bregs[i].m_addr == v)
                        return bregs[i].m_name;
                        return bregs[i].m_name;
        return NULL;
        return NULL;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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