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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [sw/] [iss/] [cpu/] [FetchUnit.hh] - Diff between revs 199 and 200

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

Rev 199 Rev 200
/*!
/*!
  AEMB INSTRUCTION SET SIMULATOR
  AEMB INSTRUCTION SET SIMULATOR
  Copyright (C) 2009 Shawn Tan 
  Copyright (C) 2009 Shawn Tan 
  This program is free software: you can redistribute it and/or modify
  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
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  (at your option) any later version.
  This program is distributed in the hope that it will be useful, but
  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  General Public License for more details.
  You should have received a copy of the GNU General Public License
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see
  along with this program.  If not, see
  .
  .
*/
*/
#ifndef AEMBINSTRUCTION_H_
#ifndef AEMBINSTRUCTION_H_
#define AEMBINSTRUCTION_H_
#define AEMBINSTRUCTION_H_
using namespace std;
using namespace std;
namespace aemb
namespace aemb
{
{
 
 
        typedef enum
        typedef enum
        {
        {
                OPC_ADD = 000,
                OPC_ADD = 000,
                OPC_RSUB = 001,
                OPC_RSUB = 001,
                OPC_ADDC = 002,
                OPC_ADDC = 002,
                OPC_RSUBC = 003,
                OPC_RSUBC = 003,
                OPC_ADDK = 004,
                OPC_ADDK = 004,
                OPC_RSUBK = 005,
                OPC_RSUBK = 005,
                OPC_ADDKC = 006,
                OPC_ADDKC = 006,
                OPC_RSUBKC = 007,
                OPC_RSUBKC = 007,
                OPC_CMP = 005,
                OPC_CMP = 005,
                OPC_CMPU = 005,
                OPC_CMPU = 005,
                OPC_ADDI = 010,
                OPC_ADDI = 010,
                OPC_RSUBI = 011,
                OPC_RSUBI = 011,
                OPC_ADDIC = 012,
                OPC_ADDIC = 012,
                OPC_RSUBIC = 013,
                OPC_RSUBIC = 013,
                OPC_ADDIK = 014,
                OPC_ADDIK = 014,
                OPC_RSUBIK = 015,
                OPC_RSUBIK = 015,
                OPC_ADDIKC = 016,
                OPC_ADDIKC = 016,
                OPC_RSUBIKC = 017,
                OPC_RSUBIKC = 017,
                OPC_MUL = 020,
                OPC_MUL = 020,
                OPC_BSRL = 021,
                OPC_BSRL = 021,
                OPC_BSRA = 021,
                OPC_BSRA = 021,
                OPC_BSLL = 021,
                OPC_BSLL = 021,
                OPC_MULI = 030,
                OPC_MULI = 030,
                OPC_BSRLI = 031,
                OPC_BSRLI = 031,
                OPC_BSRAI = 031,
                OPC_BSRAI = 031,
                OPC_BSLLI = 031,
                OPC_BSLLI = 031,
                OPC_IDIV = 032,
                OPC_IDIV = 032,
                OPC_IDIVU = 032,
                OPC_IDIVU = 032,
                OPC_OR = 040,
                OPC_OR = 040,
                OPC_AND = 041,
                OPC_AND = 041,
                OPC_XOR = 042,
                OPC_XOR = 042,
                OPC_ANDN = 043,
                OPC_ANDN = 043,
        } opcodes;
        } opcodes;
/**
/**
 * FetchUnit formats.
 * FetchUnit formats.
 */
 */
union uInstFormat
union uInstFormat
{
{
        int word;
        int word;
        /**
        /**
         * R-format opcode
         * R-format opcode
         */
         */
        struct sFormatR
        struct sFormatR
        {
        {
                int im:11; // reserved
                int im:11; // reserved
                unsigned int rb:5; // rb
                unsigned int rb:5; // rb
                unsigned int ra:5; // ra
                unsigned int ra:5; // ra
                unsigned int rd:5; // rd
                unsigned int rd:5; // rd
                unsigned int op:6; // opcode
                unsigned int op:6; // opcode
        } r;
        } r;
        /**
        /**
         * I-format opcode
         * I-format opcode
         */
         */
        struct sFormatI
        struct sFormatI
        {
        {
                int im:16; // immediate
                int im:16; // immediate
                unsigned int ra:5; // ra
                unsigned int ra:5; // ra
                unsigned int rd:5; // rd
                unsigned int rd:5; // rd
                unsigned int op:6; // opcode
                unsigned int op:6; // opcode
        } i;
        } i;
};
};
typedef uInstFormat InstFormat;
typedef uInstFormat InstFormat;
class FetchUnit
class FetchUnit
{
{
        int r_pc;
        int r_pc;
public:
public:
        void reset();
        void reset();
        /**
        /**
         * Tokenise instructions.
         * Tokenise instructions.
         * Decode the raw instructions into the opcode structure.
         * Decode the raw instructions into the opcode structure.
         * @param opc Opcode raw value
         * @param opc Opcode raw value
         * @return structure holding the opcode
         * @return structure holding the opcode
         */
         */
        InstFormat tokInst(const int opc);
        InstFormat tokInst(const int opc);
        /**
        /**
         * Get PC
         * Get PC
         */
         */
        int getPC();
        int getPC();
        /**
        /**
         * Set PC
         * Set PC
         */
         */
        void setPC(const int pc);
        void setPC(const int pc);
        FetchUnit();
        FetchUnit();
        virtual ~FetchUnit();
        virtual ~FetchUnit();
};
};
}
}
#endif /*InstRUCTION_H_*/
#endif /*InstRUCTION_H_*/
 
 

powered by: WebSVN 2.1.0

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