Added some qsim support

git-svn-id: http://www.cdkersey.com/harp/harptool@77 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
chad
2012-03-11 16:47:02 +00:00
parent 59976a7e11
commit bd2c5724f8
8 changed files with 67 additions and 14 deletions

View File

@@ -30,19 +30,26 @@ void Harp::reg_doWrite(Word cpuId, Word regNum) {
Core::Core(const ArchDef &a, Decoder &d, MemoryUnit &mem, Word id) :
a(a), iDec(d), mem(mem), pc(0), interruptEnable(false), supervisorMode(true),
activeThreads(1), reg(0), pred(0), shadowReg(a.getNRegs()), shadowPReg(a.getNPRegs()),
interruptEntry(0), id(id)
activeThreads(1), reg(0), pred(0), shadowReg(a.getNRegs()),
shadowPReg(a.getNPRegs()), interruptEntry(0), id(id)
{
/* Build the register file. */
Word regNum(0);
for (Word j = 0; j < a.getNThds(); ++j) {
std::cout << "Pushing back a new register vector.\n";
reg.push_back(vector<Reg<Word> >(0));
for (Word i = 0; i < a.getNRegs(); ++i)
for (Word i = 0; i < a.getNRegs(); ++i) {
std::cout << "Pushing back a new register in thread " << j << "\n";
reg[j].push_back(Reg<Word>(id, regNum++));
}
pred.push_back(vector<Reg<bool> >(0));
for (Word i = 0; i < a.getNPRegs(); ++i)
std::cout << "getnpregs returns " << a.getNPRegs() << '\n';
for (Word i = 0; i < a.getNPRegs(); ++i) {
std::cout << "Pushing back predicate reg " << i << ", thread " << j
<< "\n";
pred[j].push_back(Reg<bool>(id, regNum++));
}
}
/* Set initial register contents. */
@@ -55,6 +62,8 @@ void Core::step() {
if (activeThreads == 0) return;
cout << "in step pc=0x" << hex << pc << '\n';
/* Fetch and decode. */
if (wordSize < sizeof(pc)) pc &= ((1ll<<(wordSize*8))-1);
Instruction *inst;
@@ -78,7 +87,9 @@ void Core::step() {
interrupt(pf.notFound?1:2);
}
} while (fetchMore);
cout << "Fetched at 0x" << hex << pc << '\n';
//cout << "0x" << hex << pc << ": " << *inst << '\n';
cout << "sizeof(core)=" << dec << sizeof(*this) << '\n';
#ifdef EMU_INSTRUMENTATION
{ Addr pcPhys(mem.virtToPhys(pc));