Additional debugging info.

git-svn-id: http://www.cdkersey.com/harp/harptool@115 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
chad 2013-01-17 09:04:30 +00:00
parent 3ceabe2a61
commit 4428bcd1b7
7 changed files with 41 additions and 17 deletions

View file

@ -0,0 +1 @@
_ Large expanses of space intentionally

View file

@ -1,11 +1,11 @@
################################################################################
# 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
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
# 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
instruction.o : instruction.cpp include/instruction.h include/obj.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
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 \
include/debug.h include/archdef.h

View file

@ -20,8 +20,8 @@ namespace Harp {
template <typename T> class Reg {
public:
Reg(): cpuId(0), regNum(0) {}
Reg(Word c, Word n): cpuId(c), regNum(n) {}
Reg(): cpuId(0), regNum(0), val(0) {}
Reg(Word c, Word n): cpuId(c), regNum(n), val(0) {}
Reg &operator=(T r) { val = r; doWrite(); return *this; }
operator T() { doRead(); return val; }

View file

@ -10,10 +10,14 @@
#define D(lvl, x) do { \
using namespace std; \
if ((lvl) <= USE_DEBUG) { \
cout << "DEBUG " << __FILE__ << ':' << dec << __LINE__ << ": " \
cerr << "DEBUG " << __FILE__ << ':' << dec << __LINE__ << ": " \
<< x << endl; \
} \
} while(0)
#define D_RAW(x) do { \
std::cerr << x; \
} while (0)
#else
#define D(lvl, x) do {} while(0)

View file

@ -24,7 +24,7 @@ RamMemDevice::RamMemDevice(const char *filename, Size wordSize) :
ifstream input(filename);
if (!input) {
cout << "Error reading file \"" << filename << "\" into RomMemDevice.\n";
cout << "Error reading file \"" << filename << "\" into RamMemDevice.\n";
exit(1);
}

View file

@ -5,6 +5,7 @@
#include "include/obj.h"
#include "include/util.h"
#include "include/asm-tokens.h"
#include "include/debug.h"
#include <iostream>
#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++) {
offsets[i] = output.tellp();
/* Chunk name */
// Is it a data chunk?
DataChunk *dc = dynamic_cast<DataChunk*>(obj.chunks[i]);
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);
/* Padding */
@ -625,6 +630,8 @@ Obj *HOFReader::read(std::istream &input) {
dc->refs.push_back(r);
}
D(1, "Reading chunk \"" << name << "\", size " << dSize);
/* Get the contents. */
input.read((char*)&dc->contents[0], dSize);
dc->size = size;

View file

@ -6,24 +6,33 @@
*******************************************************************************/
/* sieve of erastophanes: Find some primes. */
.def SIZE 0x2000 /* TODO: How should I write constants? */
.def SIZE 0x1000
.align 4096
.perm x
.entry
.global
entry: ldi %r7, hello
jali %r5, puts
entry: ldi %r7, hello; jali %r5, puts;
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;
ldi %r7, wrfin;
jali %r5, puts;
addi %r0, %r0, #1;
subi %r1, %r0, SIZE;
rtop @p0, %r1;
@p0 ? jmpi loop1;
ldi %r0, #1;
ldi %r7, xstr;
jali %r5, puts;
ldi %r0, #1;
loop2: addi %r0, %r0, #1;
muli %r1, %r0, __WORD;
ld %r1, %r1, array;
@ -69,10 +78,13 @@ loop4: ld %r1, %r0, array;
trap; /* All traps currently cause a halt. */
.perm rw /* TODO: How should I write section permissions? */
/* TODO: String literals! */
.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
.word array 0 /* Basically, 0 and 1 are pre-cleared. */
.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. */