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

Subversion Repositories aemb

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /aemb
    from Rev 197 to Rev 198
    Reverse comparison

Rev 197 → Rev 198

/trunk/sw/iss/iss.cc
0,0 → 1,38
/*!
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 "mem/aembInstMemory.hh"
 
#include <stdio.h>
 
using namespace std;
 
int main(int argc, char *argv[])
{
printf("AEMB-ISS Copyright (C) 2009 Shawn Tan <shawn.tan@aeste.net>\n");
printf("This program comes with ABSOLUTELY NO WARRANTY.\n");
printf("This is free software, and you are welcome to redistribute it under certain conditions.\n");
aembInstMemory imem;
imem.getVmem();
imem.dumpMem();
return 0;
}
/trunk/sw/iss/cpu/aembInstruction.hh
0,0 → 1,45
#ifndef AEMBINSTRUCTION_H_
#define AEMBINSTRUCTION_H_
 
/**
* R-format opcode
*/
typedef struct
{
int op:6; // opcode
int rd:5; // rd
int ra:5; // ra
int rb:5; // rb
int im:11; // reserved
} aembFormatR;
 
/**
* I-format opcode
*/
typedef struct
{
int op:6; // opcode
int rd:5; // rd
int ra:5; // ra
int im:16; // immediate
} aembFormatI;
 
/**
* Instruction formats.
*/
typedef union
{
int word;
aembFormatR fmtr;
aembFormatI fmti;
} aembInstFormat;
 
class aembInstruction
{
public:
aembInstFormat getDecoded(const int opc);
aembInstruction();
virtual ~aembInstruction();
};
 
#endif /*AEMBINSTRUCTION_H_*/
/trunk/sw/iss/cpu/aembRegisterGP.cc
0,0 → 1,41
/*!
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 "aembRegisterGP.hh"
 
void aembRegisterGP::putRegister(const int reg, const int data)
{
regfile.at(reg) = data;
}
 
int aembRegisterGP::getRegister(const int reg)
{
return (reg > 0) ? regfile.at(reg) : 0;
}
 
aembRegisterGP::aembRegisterGP()
{
for (int i=0; i<32; ++i) {
regfile.push_back(0);
}
}
 
aembRegisterGP::~aembRegisterGP()
{
}
/trunk/sw/iss/cpu/aembInstruction.cc
0,0 → 1,16
#include "aembInstruction.hh"
 
aembInstFormat getDecoded(const int opc)
{
aembInstFormat tmp;
tmp.word = opc;
return tmp;
}
 
aembInstruction::aembInstruction()
{
}
 
aembInstruction::~aembInstruction()
{
}
/trunk/sw/iss/cpu/aembRegisterGP.hh
0,0 → 1,54
/*!
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;
 
/**
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 aembRegisterGP
{
vector<int> regfile; ///< internal general purpose register file
public:
/**
* Put a value into a register.
* @param reg Register number [0:31].
* @param data Register data to write
**/
void putRegister(const int reg, const int data);
/**
* Get a value from a register.
* @param reg Register number [0:31].
* @return Value of the register.
**/
int getRegister(const int reg);
aembRegisterGP();
~aembRegisterGP();
};
 
#endif
/trunk/sw/iss/iss.hh
0,0 → 1,26
/*!
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 ISS_HH_
#define ISS_HH_
 
 
 
 
#endif /*ISS_HH_*/
/trunk/sw/iss/mem/aembInstMemory.cc
0,0 → 1,111
/*!
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 "aembInstMemory.hh"
 
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
 
using namespace std;
 
void aembInstMemory::putInst(const int addr, const int data)
{
int word = addr >> 2; // word align the address
mem.insert(make_pair(word, data));
}
 
int aembInstMemory::getInst(const int addr)
{
int word = addr >> 2; // word align the address
assert(!(addr & 0x03)); // check word alignment
map<int,int>::iterator data = mem.find(word);
assert(data != mem.end()); // check if the address is valid
return data->second;
}
 
int aembInstMemory::getVmem()
{
char str[255];
char *tok = NULL;
char *cend = NULL;
long addr, data;
 
while (fgets(str, 255, stdin) != NULL) {
switch(str[0]) {
case '@':
// extract address
tok = strtok(str," ");
cend = tok;
cend++;
addr = strtoul(cend, &cend, 16);
#ifndef NDEBUG
printf("\n");
#endif
// extract data
//tok = strtok(NULL," ");
while ((tok = strtok(NULL, " ")) != NULL) {
data = strtoul(tok, &cend, 16);
putInst((addr << 2), data);
 
#ifndef NDEBUG
printf("\t%X:%.8X", (unsigned int)addr,(unsigned int)data);
#endif
 
++addr;
}
break;
 
default: // ignored line
//fprintf(stderr,"*** Error parsing VMEM format ***\n");
break;
}
}
#ifndef NDEBUG
printf("\nVMEM size: %d",mem.size());
#endif
return mem.size();
}
 
void aembInstMemory::dumpMem()
{
map<int,int>::iterator iter;
for (iter = mem.begin(); iter != mem.end(); ++iter) {
#ifndef NDEBUG
printf("\n%X : %.8X",iter->first, iter->second);
#endif
}
}
 
aembInstMemory::aembInstMemory()
{
}
 
aembInstMemory::~aembInstMemory()
{
}
/trunk/sw/iss/mem/aembDataMemory.hh
0,0 → 1,54
/*!
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 AEMBDATAMEMORY_H_
#define AEMBDATAMEMORY_H_
 
#include <map>
 
using std::map;
 
class aembDataMemory
{
map<int,int> mem;
public:
/**
* Generic memory read
* @param addr Address to read.
* @return memory word read.
* */
int getData(const int addr);
 
/**
* Generic memory write
* @param addr Address to write
* @param data Data to write
*/
void putData(const int addr, const int data);
 
/**
* Align address
* @param addr Address to align
**/
 
aembDataMemory();
virtual ~aembDataMemory();
};
 
#endif /*AEMBDATAMEMORY_H_*/
/trunk/sw/iss/mem/aembInstMemory.hh
0,0 → 1,61
/*!
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 AEMBINSTMEMORY_H_
#define AEMBINSTMEMORY_H_
 
#include <map>
 
using std::map;
 
class aembInstMemory
{
map<int,int> mem; ///< Instruction memory storage
 
/**
* Generic memory write
* @param addr Address to write
* @param data Data to write
*/
void putInst(const int addr, const int data);
 
public:
/**
* Generic memory read
* @param addr Address to read.
* @return memory word read.
* */
int getInst(const int addr);
 
/**
* Read VMEM from stdin.
* @return size of the instruction space
**/
int getVmem();
 
void dumpMem();
 
aembInstMemory();
virtual ~aembInstMemory();
};
 
#endif /*AEMBINSTMEMORY_H_*/
/trunk/sw/iss/mem/aembDataMemory.cc
0,0 → 1,44
/*!
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 "aembDataMemory.hh"
#include <utility>
 
using std::map;
using std::make_pair;
 
void aembDataMemory::putData(const int addr, const int data)
{
int word = addr >> 2; // word align the address
mem.insert(make_pair(word, data));
}
 
int aembDataMemory::getData(const int addr)
{
int word = addr >> 2; // word align the address
map<int,int>::iterator data = mem.find(word);
return data->second;
}
 
aembDataMemory::aembDataMemory()
{
}
 
aembDataMemory::~aembDataMemory()
{
}

powered by: WebSVN 2.1.0

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