Some (untested) code for a QSim interface.

git-svn-id: http://www.cdkersey.com/harp/harptool@33 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
chad
2011-10-19 22:51:41 +00:00
parent 15774083d0
commit 6cd25d547a
5 changed files with 205 additions and 9 deletions

36
src/qsim-harp.cpp Normal file
View File

@@ -0,0 +1,36 @@
/*******************************************************************************
HARPtools by Chad D. Kersey, Summer 2011
*******************************************************************************/
#include "include/qsim-harp.h"
#include <iostream>
#include <string>
using namespace Harp;
using namespace std;
Harp::OSDomain::OSDomain(ArchDef arch, string imgFile) :
mu(4096, arch.getWordSize()), ram(imgFile.c_str(), arch.getWordSize()),
{
cpus.push_back(Cpu(*this));
console = new ConsoleMemDevice(arch.getWordSize(), cout, cpus[0].core);
mu.attach(ram, 0);
mu.attach(*console, 1ll<<(arch.getWordSize()*8 - 1));
}
void Harp::OSDomain::connect_console(std::ostream &s) {
/* For now this does nothing. ConsoleMemDevice is not redirectable. */
}
Harp::OSDomain::Cpu::Cpu(Harp::OSDomain &osd) :
osd(osd), dec(new WordDecoder(osd.arch)), core(osd.arch, *dec, osd.mu)
{
}
uint64_t Harp::OSDomain::Cpu::run(uint64_t n) {
uint64_t i;
for (i = 0; i < n; ++i) core.step();
return i;
}