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:
36
src/qsim-harp.cpp
Normal file
36
src/qsim-harp.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user