URL
https://opencores.org/ocsvn/aemb/aemb/trunk
Subversion Repositories aemb
Compare Revisions
- This comparison shows the changes necessary to convert path
/aemb/trunk/sw/iss/cpu
- from Rev 198 to Rev 199
- ↔ Reverse comparison
Rev 198 → Rev 199
/aembInstruction.cc
File deleted
/aembRegisterGP.cc
File deleted
/aembRegisterGP.hh
File deleted
/aembInstruction.hh
File deleted
/RegisterFile.hh
0,0 → 1,94
/*! |
AEMB INSTRUCTION SET SIMULATOR |
Copyright (C) 2009 Shawn Tan <shawn.tan@aeste.net> |
|
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 Software Foundation, either version 3 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, but |
WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program. If not, see |
<http://www.gnu.org/licenses/>. |
*/ |
|
#ifndef _AEMBREGISTERGP_H_ |
#define _AEMBREGISTERGP_H_ |
|
#include <vector> |
|
using std::vector; |
|
namespace aemb { |
|
/** |
* List of special function registers |
*/ |
typedef enum |
{ |
SFR_PC = 0, |
SFR_MSR = 1, |
SFR_EAR = 3, |
SFR_ESR = 5, |
} SpecialRegs; |
|
/** |
Behavioral class for the general purpose register file that can |
only be read from and written to. It has internal mechanisms to |
check for data hazards. |
*/ |
|
class RegisterFile |
{ |
vector<int> regfile; ///< internal general purpose register file |
int rsfr; |
public: |
|
void reset(); |
|
/** |
* Put a value into a register. |
* @param gpr Register number [0:31]. |
* @param data Register data to write |
*/ |
|
void setRegister(const int gpr, const int data); |
|
/** |
* Get a value from a register. |
* @param gpr Register number [0:31]. |
* @return Value of the register. |
*/ |
|
int getRegister(const int gpr); |
|
/** |
* Get the value of a special register. |
* @param sfr Special register number |
* @return Special register value |
*/ |
|
int getSpecial(const int sfr); |
|
/** |
* Set the value of a special register |
* @param sfr Special register number |
* @param imm32 Special register value |
*/ |
|
void setSpecial(const int sfr, const int imm32); |
|
int clrSpecial(const int imm14); |
int setSpecial(const int imm14); |
|
RegisterFile(); |
~RegisterFile(); |
}; |
|
} |
#endif |
/FetchUnit.hh
0,0 → 1,136
/*! |
AEMB INSTRUCTION SET SIMULATOR |
Copyright (C) 2009 Shawn Tan <shawn.tan@aeste.net> |
|
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 Software Foundation, either version 3 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, but |
WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program. If not, see |
<http://www.gnu.org/licenses/>. |
*/ |
|
#ifndef AEMBINSTRUCTION_H_ |
#define AEMBINSTRUCTION_H_ |
|
using namespace std; |
|
namespace aemb |
{ |
|
typedef enum |
{ |
OPC_ADD = 000, |
OPC_RSUB = 001, |
OPC_ADDC = 002, |
OPC_RSUBC = 003, |
OPC_ADDK = 004, |
OPC_RSUBK = 005, |
OPC_ADDKC = 006, |
OPC_RSUBKC = 007, |
|
OPC_CMP = 005, |
OPC_CMPU = 005, |
|
OPC_ADDI = 010, |
OPC_RSUBI = 011, |
OPC_ADDIC = 012, |
OPC_RSUBIC = 013, |
OPC_ADDIK = 014, |
OPC_RSUBIK = 015, |
OPC_ADDIKC = 016, |
OPC_RSUBIKC = 017, |
|
OPC_MUL = 020, |
OPC_BSRL = 021, |
OPC_BSRA = 021, |
OPC_BSLL = 021, |
OPC_MULI = 030, |
OPC_BSRLI = 031, |
OPC_BSRAI = 031, |
OPC_BSLLI = 031, |
|
OPC_IDIV = 032, |
OPC_IDIVU = 032, |
|
OPC_OR = 040, |
OPC_AND = 041, |
OPC_XOR = 042, |
OPC_ANDN = 043, |
|
|
} opcodes; |
|
/** |
* FetchUnit formats. |
*/ |
union uInstFormat |
{ |
int word; |
|
/** |
* R-format opcode |
*/ |
struct sFormatR |
{ |
int im:11; // reserved |
unsigned int rb:5; // rb |
unsigned int ra:5; // ra |
unsigned int rd:5; // rd |
unsigned int op:6; // opcode |
} r; |
|
/** |
* I-format opcode |
*/ |
struct sFormatI |
{ |
int im:16; // immediate |
unsigned int ra:5; // ra |
unsigned int rd:5; // rd |
unsigned int op:6; // opcode |
} i; |
}; |
|
typedef uInstFormat InstFormat; |
|
class FetchUnit |
{ |
int r_pc; |
|
public: |
|
void reset(); |
|
/** |
* Tokenise instructions. |
* Decode the raw instructions into the opcode structure. |
* @param opc Opcode raw value |
* @return structure holding the opcode |
*/ |
|
InstFormat tokInst(const int opc); |
|
/** |
* Get PC |
*/ |
int getPC(); |
|
/** |
* Set PC |
*/ |
void setPC(const int pc); |
|
FetchUnit(); |
virtual ~FetchUnit(); |
}; |
|
} |
#endif /*InstRUCTION_H_*/ |
/FixedPointUnit.hh
0,0 → 1,11
#ifndef FIXEDPOINTUNIT_H_ |
#define FIXEDPOINTUNIT_H_ |
|
class FixedPointUnit |
{ |
public: |
FixedPointUnit(); |
virtual ~FixedPointUnit(); |
}; |
|
#endif /*FIXEDPOINTUNIT_H_*/ |
/RegisterFile.cc
0,0 → 1,80
/*! |
AEMB INSTRUCTION SET SIMULATOR |
Copyright (C) 2009 Shawn Tan <shawn.tan@aeste.net> |
|
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 Software Foundation, either version 3 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, but |
WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program. If not, see |
<http://www.gnu.org/licenses/>. |
*/ |
|
#include <assert.h> |
|
#include "RegisterFile.hh" |
|
using namespace std; |
|
namespace aemb { |
|
void RegisterFile::setRegister(const int gpr, const int data) |
{ |
regfile.at(gpr) = data; |
} |
|
int RegisterFile::getRegister(const int gpr) |
{ |
return (gpr > 0) ? regfile.at(gpr) : 0; |
} |
|
int RegisterFile::getSpecial(const int sfr) |
{ |
int tmp; |
switch (sfr) { |
case SFR_MSR: |
tmp = rsfr; |
break; |
default: // invalid sfr |
assert(0); |
break; |
} |
return tmp; |
} |
|
void RegisterFile::setSpecial(const int sfr, const int imm32) |
{ |
switch (sfr) { |
case SFR_MSR: |
rsfr = imm32; |
break; |
default: // invalid sfr |
assert(0); |
break; |
} |
} |
|
void RegisterFile::reset() |
{ |
regfile.clear(); |
for (int i=0; i<32; ++i) { |
regfile.push_back(0); |
} |
} |
|
RegisterFile::RegisterFile() |
{ |
} |
|
RegisterFile::~RegisterFile() |
{ |
} |
|
} |
/FetchUnit.cc
0,0 → 1,57
/*! |
AEMB INSTRUCTION SET SIMULATOR |
Copyright (C) 2009 Shawn Tan <shawn.tan@aeste.net> |
|
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 Software Foundation, either version 3 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, but |
WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program. If not, see |
<http://www.gnu.org/licenses/>. |
*/ |
|
#include <assert.h> |
#include "FetchUnit.hh" |
|
namespace aemb |
{ |
|
int FetchUnit::getPC() |
{ |
return r_pc; |
} |
|
void FetchUnit::setPC(const int pc) |
{ |
assert( !(pc & 0x03) ); // check for alignment |
r_pc = pc; |
} |
|
InstFormat FetchUnit::tokInst(const int opc) |
{ |
InstFormat tmp; |
tmp.word = opc; |
return tmp; |
} |
|
void FetchUnit::reset() |
{ |
setPC(0); |
} |
|
FetchUnit::FetchUnit() |
{ |
} |
|
FetchUnit::~FetchUnit() |
{ |
} |
|
} |
/FixedPointUnit.cc
0,0 → 1,9
#include "FixedPointUnit.hh" |
|
FixedPointUnit::FixedPointUnit() |
{ |
} |
|
FixedPointUnit::~FixedPointUnit() |
{ |
} |