simX refactoring + removed oldRTL + CSR updates

This commit is contained in:
Blaise Tine
2021-02-06 12:52:54 -08:00
parent 111cc29482
commit 6c1dc96626
131 changed files with 4014 additions and 12138 deletions

View File

@@ -1,28 +1,25 @@
/*******************************************************************************
HARPtools by Chad D. Kersey, Summer 2011
*******************************************************************************/
#include <vector>
#include "include/types.h"
#include "include/util.h"
#include <iostream>
#include <stdexcept>
#include "types.h"
#include "util.h"
using namespace Harp;
using namespace std;
using namespace vortex;
// Make it easy for autotools-based build systems to detect this library.
extern "C" {
int harplib_present = 1;
Word vortex::signExt(Word w, Size bit, Word mask) {
if (w >> (bit - 1))
w |= ~mask;
return w;
}
void Harp::wordToBytes(Byte *b, Word_u w, Size wordSize) {
void vortex::wordToBytes(Byte *b, Word_u w, Size wordSize) {
while (wordSize--) {
*(b++) = w & 0xff;
w >>= 8;
}
}
Word_u Harp::bytesToWord(const Byte *b, Size wordSize) {
Word_u vortex::bytesToWord(const Byte *b, Size wordSize) {
Word_u w = 0;
b += wordSize-1;
while (wordSize--) {
@@ -32,7 +29,7 @@ Word_u Harp::bytesToWord(const Byte *b, Size wordSize) {
return w;
}
Word_u Harp::flagsToWord(bool r, bool w, bool x) {
Word_u vortex::flagsToWord(bool r, bool w, bool x) {
Word_u word = 0;
if (r) word |= RD_USR;
if (w) word |= WR_USR;
@@ -40,19 +37,21 @@ Word_u Harp::flagsToWord(bool r, bool w, bool x) {
return word;
}
void Harp::wordToFlags(bool &r, bool &w, bool &x, Word_u f) {
void vortex::wordToFlags(bool &r, bool &w, bool &x, Word_u f) {
r = f & RD_USR;
w = f & WR_USR;
x = f & EX_USR;
}
Byte Harp::readByte(const vector<Byte> &b, Size &n) {
if (b.size() <= n) throw OutOfBytes();
Byte vortex::readByte(const std::vector<Byte> &b, Size &n) {
if (b.size() <= n)
throw std::out_of_range("out of range");
return b[n++];
}
Word_u Harp::readWord(const vector<Byte> &b, Size &n, Size wordSize) {
// if (b.size() - n < wordSize) throw OutOfBytes();
Word_u vortex::readWord(const std::vector<Byte> &b, Size &n, Size wordSize) {
if (b.size() - n < wordSize)
throw std::out_of_range("out of range");
Word_u w(0);
n += wordSize;
// std::cout << "wordSize: " << wordSize << "\n";
@@ -62,16 +61,15 @@ Word_u Harp::readWord(const vector<Byte> &b, Size &n, Size wordSize) {
w |= b[n - i - 1];
}
// cout << "b[0]" << std::hex << w << "\n";
// throw OutOfBytes();
return w;
}
void Harp::writeByte(vector<Byte> &p, Size &n, Byte b) {
void vortex::writeByte(std::vector<Byte> &p, Size &n, Byte b) {
if (p.size() <= n) p.resize(n+1);
p[n++] = b;
}
void Harp::writeWord(vector<Byte> &p, Size &n, Size wordSize, Word w) {
void vortex::writeWord(std::vector<Byte> &p, Size &n, Size wordSize, Word w) {
if (p.size() < (n+wordSize)) p.resize(n+wordSize);
while (wordSize--) {
p[n++] = w & 0xff;