Additional debugging info.
git-svn-id: http://www.cdkersey.com/harp/harptool@115 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
# HARPtools by Chad D. Kersey, Summer 2011 #
|
# HARPtools by Chad D. Kersey, Summer 2011 #
|
||||||
################################################################################
|
################################################################################
|
||||||
CXXFLAGS=-g -fPIC -DUSE_DEBUG=3
|
CXXFLAGS=-g -DUSE_DEBUG=1 #-fPIC
|
||||||
|
|
||||||
LIB_OBJS=args.o obj.o mem.o core.o instruction.o enc.o util.o lex.yy.o
|
LIB_OBJS=args.o obj.o mem.o core.o instruction.o enc.o util.o lex.yy.o
|
||||||
|
|
||||||
all: harptool libharplib.so libharplib.a #libqsim-harp.so
|
all: harptool # libharplib.so libharplib.a libqsim-harp.so
|
||||||
|
|
||||||
# Use -static so we don't have to install the library in order to just run
|
# Use -static so we don't have to install the library in order to just run
|
||||||
# Harptool.
|
# Harptool.
|
||||||
@@ -26,9 +26,9 @@ harptool.o : harptool.cpp include/types.h include/core.h include/enc.h \
|
|||||||
include/archdef.h include/args.h include/help.h
|
include/archdef.h include/args.h include/help.h
|
||||||
instruction.o : instruction.cpp include/instruction.h include/obj.h
|
instruction.o : instruction.cpp include/instruction.h include/obj.h
|
||||||
obj.o : obj.cpp include/types.h include/obj.h include/util.h \
|
obj.o : obj.cpp include/types.h include/obj.h include/util.h \
|
||||||
include/asm-tokens.h
|
include/asm-tokens.h include/debug.h
|
||||||
util.o : util.cpp include/types.h include/util.h
|
util.o : util.cpp include/types.h include/util.h
|
||||||
mem.o : mem.cpp include/types.h include/util.h include/mem.h
|
mem.o : mem.cpp include/types.h include/util.h include/mem.h include/debug.h
|
||||||
core.o : core.cpp include/types.h include/util.h include/mem.h \
|
core.o : core.cpp include/types.h include/util.h include/mem.h \
|
||||||
include/debug.h include/archdef.h
|
include/debug.h include/archdef.h
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ namespace Harp {
|
|||||||
|
|
||||||
template <typename T> class Reg {
|
template <typename T> class Reg {
|
||||||
public:
|
public:
|
||||||
Reg(): cpuId(0), regNum(0) {}
|
Reg(): cpuId(0), regNum(0), val(0) {}
|
||||||
Reg(Word c, Word n): cpuId(c), regNum(n) {}
|
Reg(Word c, Word n): cpuId(c), regNum(n), val(0) {}
|
||||||
|
|
||||||
Reg &operator=(T r) { val = r; doWrite(); return *this; }
|
Reg &operator=(T r) { val = r; doWrite(); return *this; }
|
||||||
operator T() { doRead(); return val; }
|
operator T() { doRead(); return val; }
|
||||||
|
|||||||
@@ -10,10 +10,14 @@
|
|||||||
#define D(lvl, x) do { \
|
#define D(lvl, x) do { \
|
||||||
using namespace std; \
|
using namespace std; \
|
||||||
if ((lvl) <= USE_DEBUG) { \
|
if ((lvl) <= USE_DEBUG) { \
|
||||||
cout << "DEBUG " << __FILE__ << ':' << dec << __LINE__ << ": " \
|
cerr << "DEBUG " << __FILE__ << ':' << dec << __LINE__ << ": " \
|
||||||
<< x << endl; \
|
<< x << endl; \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#define D_RAW(x) do { \
|
||||||
|
std::cerr << x; \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define D(lvl, x) do {} while(0)
|
#define D(lvl, x) do {} while(0)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ RamMemDevice::RamMemDevice(const char *filename, Size wordSize) :
|
|||||||
ifstream input(filename);
|
ifstream input(filename);
|
||||||
|
|
||||||
if (!input) {
|
if (!input) {
|
||||||
cout << "Error reading file \"" << filename << "\" into RomMemDevice.\n";
|
cout << "Error reading file \"" << filename << "\" into RamMemDevice.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "include/obj.h"
|
#include "include/obj.h"
|
||||||
#include "include/util.h"
|
#include "include/util.h"
|
||||||
#include "include/asm-tokens.h"
|
#include "include/asm-tokens.h"
|
||||||
|
#include "include/debug.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -485,9 +486,13 @@ void HOFWriter::write(std::ostream &output, const Obj &obj) {
|
|||||||
for (Size i = 0; i < obj.chunks.size(); i++) {
|
for (Size i = 0; i < obj.chunks.size(); i++) {
|
||||||
offsets[i] = output.tellp();
|
offsets[i] = output.tellp();
|
||||||
|
|
||||||
/* Chunk name */
|
// Is it a data chunk?
|
||||||
DataChunk *dc = dynamic_cast<DataChunk*>(obj.chunks[i]);
|
DataChunk *dc = dynamic_cast<DataChunk*>(obj.chunks[i]);
|
||||||
if (!dc) { cout << "HOFWriter::write(): invalid chunk type.\n"; exit(1); }
|
if (!dc) { cout << "HOFWriter::write(): invalid chunk type.\n"; exit(1); }
|
||||||
|
|
||||||
|
D(1, "Writing chunk \"" << dc->name << "\", size=" << dc->contents.size());
|
||||||
|
|
||||||
|
// Chunk name
|
||||||
output.write(dc->name.c_str(), dc->name.length() + 1);
|
output.write(dc->name.c_str(), dc->name.length() + 1);
|
||||||
|
|
||||||
/* Padding */
|
/* Padding */
|
||||||
@@ -625,6 +630,8 @@ Obj *HOFReader::read(std::istream &input) {
|
|||||||
dc->refs.push_back(r);
|
dc->refs.push_back(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D(1, "Reading chunk \"" << name << "\", size " << dSize);
|
||||||
|
|
||||||
/* Get the contents. */
|
/* Get the contents. */
|
||||||
input.read((char*)&dc->contents[0], dSize);
|
input.read((char*)&dc->contents[0], dSize);
|
||||||
dc->size = size;
|
dc->size = size;
|
||||||
|
|||||||
@@ -6,24 +6,33 @@
|
|||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/* sieve of erastophanes: Find some primes. */
|
/* sieve of erastophanes: Find some primes. */
|
||||||
.def SIZE 0x2000 /* TODO: How should I write constants? */
|
.def SIZE 0x1000
|
||||||
|
|
||||||
.align 4096
|
.align 4096
|
||||||
.perm x
|
.perm x
|
||||||
.entry
|
.entry
|
||||||
.global
|
.global
|
||||||
entry: ldi %r7, hello
|
entry: ldi %r7, hello; jali %r5, puts;
|
||||||
jali %r5, puts
|
|
||||||
ldi %r0, #2; /* i = 2 */
|
ldi %r0, #2; /* i = 2 */
|
||||||
loop1: muli %r1, %r0, __WORD;
|
loop1: addi %r7, %r0, #0;
|
||||||
|
jali %r5, printdec;
|
||||||
|
|
||||||
|
muli %r1, %r0, __WORD;
|
||||||
|
ldi %r7, wrstr;
|
||||||
|
jali %r5, puts;
|
||||||
st %r0, %r1, array;
|
st %r0, %r1, array;
|
||||||
|
ldi %r7, wrfin;
|
||||||
|
jali %r5, puts;
|
||||||
addi %r0, %r0, #1;
|
addi %r0, %r0, #1;
|
||||||
subi %r1, %r0, SIZE;
|
subi %r1, %r0, SIZE;
|
||||||
rtop @p0, %r1;
|
rtop @p0, %r1;
|
||||||
@p0 ? jmpi loop1;
|
@p0 ? jmpi loop1;
|
||||||
|
|
||||||
ldi %r0, #1;
|
ldi %r7, xstr;
|
||||||
|
jali %r5, puts;
|
||||||
|
|
||||||
|
ldi %r0, #1;
|
||||||
loop2: addi %r0, %r0, #1;
|
loop2: addi %r0, %r0, #1;
|
||||||
muli %r1, %r0, __WORD;
|
muli %r1, %r0, __WORD;
|
||||||
ld %r1, %r1, array;
|
ld %r1, %r1, array;
|
||||||
@@ -69,10 +78,13 @@ loop4: ld %r1, %r0, array;
|
|||||||
trap; /* All traps currently cause a halt. */
|
trap; /* All traps currently cause a halt. */
|
||||||
|
|
||||||
.perm rw /* TODO: How should I write section permissions? */
|
.perm rw /* TODO: How should I write section permissions? */
|
||||||
/* TODO: String literals! */
|
|
||||||
.string hello "\"Harp!\" is how a harp seal says hello!\n"
|
.string hello "\"Harp!\" is how a harp seal says hello!\n"
|
||||||
|
.string wrstr "Doing write\n"
|
||||||
|
.string wrfin "Done write\n"
|
||||||
|
.string xstr "Exiting loop\n"
|
||||||
|
|
||||||
.global
|
.global
|
||||||
.word array 0 /* Basically, 0 and 1 are pre-cleared. */
|
.word array 0 /* Basically, 0 and 1 are pre-cleared. */
|
||||||
.word _0 0 /* Given a name, contents are zero. */
|
.word _0 0 /* Given a name, contents are zero. */
|
||||||
.word 0x1ffe /* Empty space of size SIZE-2 bytes. */
|
_arr:
|
||||||
|
.word 0xffe /* Empty space of size SIZE-2 words. */
|
||||||
|
|||||||
Reference in New Issue
Block a user