diff -ruN ../lib/CPUObject.h ./CPUObject.h --- ../lib/CPUObject.h 2003-12-04 12:04:08.000000000 -0500 +++ ./CPUObject.h 2006-03-21 01:29:30.000000000 -0500 @@ -52,6 +52,8 @@ virtual ~CPUObject(); + void set_name( const char *id ); + const char *name() const; unsigned int size(); // how many bits (2nd ctor arg) @@ -64,7 +66,6 @@ int get_bits() const; unsigned long get_mask() const; void set_mask( unsigned long m ); - void set_name( const char *id ); private: char *myName; diff -ruN ../lib/Clock.C ./Clock.C --- ../lib/Clock.C 2003-12-04 12:03:19.000000000 -0500 +++ ./Clock.C 2006-03-21 01:29:57.000000000 -0500 @@ -54,7 +54,7 @@ trace2 = CPUObject::debug & CPUObject::trace_ticks; if( trace1 ) { - long old = cout.setf( ios::dec, ios::basefield ); + ios::fmtflags old = cout.setf( ios::dec, ios::basefield ); cout << " ________\n_____/" << setw(7) << time << " \\_____\n" << flush; (void)cout.flags( old ); diff -ruN ../lib/GNUmakefile ./GNUmakefile --- ../lib/GNUmakefile 1969-12-31 19:00:00.000000000 -0500 +++ ./GNUmakefile 2006-03-21 01:16:44.000000000 -0500 @@ -0,0 +1,16 @@ +RANLIB = ranlib +sources = $(wildcard *.C) +objs = $(sources:%.C=%.o) +headers = $(wildcard *.h) +lib = libarch.a + +all: $(lib) + +$(lib): $(objs) + $(AR) cru $@ $^; $(RANLIB) $@ + +%.o: %.C $(headers) + $(CXX) $(CXXFLAGS) -c -I. -o $@ $< + +clean: + rm -f $(lib) $(objs) diff -ruN ../lib/StorageObject.C ./StorageObject.C --- ../lib/StorageObject.C 2003-12-04 12:09:11.000000000 -0500 +++ ./StorageObject.C 2006-03-21 01:30:52.000000000 -0500 @@ -39,7 +39,7 @@ if( get_contents() != initVal ) { // switch to hex, but remember old settings - long k = cout.setf( ios::hex, ios::basefield ); + ios::fmtflags k = cout.setf( ios::hex, ios::basefield ); cout << "StorageObject " << id << ": initial value of " << initVal << " does not fit in " << numBits --- ../lib.orig/BusALU.h 2003-12-04 12:05:42.000000000 -0500 +++ BusALU.h 2006-05-21 22:22:43.000000000 -0400 @@ -93,10 +93,10 @@ enum Operation { op_none=0, op_add=1, op_sub=2, op_and=3, op_or=4, op_xor=5, op_not=6, op_extendSign=7, op_lshift=8, op_rshift=9, - op_rashift=10, op_rop1=11, op_rop2=12, op_zero=13, op_one=14 + op_rashift=10, op_rop1=11, op_rop2=12, op_zero=13, op_one=14, op_slt=15, op_sltu=16, op_nor=17 }; - static const char *opNames[int(op_one)+1]; + static const char *opNames[int(op_nor)+1]; BusALU ( const char *id, int numBits ); // constructor describes size of ALU and its name --- ../lib.orig/BusALU.C 2003-12-04 12:05:42.000000000 -0500 +++ BusALU.C 2006-05-21 22:30:07.000000000 -0400 @@ -46,10 +46,10 @@ return busALU.computeOverflow(); } -const char *BusALU::opNames[int(BusALU::op_one)+1] = { +const char *BusALU::opNames[int(BusALU::op_nor)+1] = { "op_none", "op_add", "op_sub", "op_and", "op_or", "op_xor", "op_not", "op_extendSign", "op_lshift", "op_rshift", "op_rashift", - "op_rop1", "op_rop2", "op_zero", "op_one" + "op_rop1", "op_rop2", "op_zero", "op_one", "op_slt", "op_sltu", "op_nor" }; BusALU::BusALU( const char *id, int numbits ): @@ -158,6 +158,9 @@ case op_rshift: case op_rashift: case op_rop1: + case op_slt: + case op_sltu: + case op_nor: op1Copy = op1.fetchValue(); case op_rop2: // these ops don't use OP1 @@ -181,6 +183,9 @@ case op_rshift: case op_rashift: case op_rop2: + case op_slt: + case op_sltu: + case op_nor: op2Copy = op2.fetchValue(); case op_not: // these don't use OP2 @@ -239,6 +243,16 @@ case op_one: value = 1; break; + case op_slt: + subtractFunction(); + value = value & ~(get_mask() >> 1) ? 1 : 0; + break; + case op_sltu: + value = (unsigned long)(op1Copy&get_mask()) < (unsigned long)(op2Copy&get_mask()) ? 1 : 0; + break; + case op_nor: + value = ~(op1Copy|op2Copy) & get_mask(); + break; case op_none: cout << name(); cout << ": someone wants my value but"; --- ../lib.orig/Memory.C 2003-12-04 12:08:26.000000000 -0500 +++ Memory.C 2006-05-21 23:52:41.000000000 -0400 @@ -158,9 +158,15 @@ switch( op ) { case readOp: + case readBUOp: + case readBOp: + case readHUOp: + case readHOp: break; case writeOp: + case writeBOp: + case writeHOp: currentAddr = mar.uvalue(); newValue = writeFlow.fetchValue(); if( CPUObject::debug&CPUObject::trace ) { @@ -193,6 +198,14 @@ break; case readOp: + case readBUOp: + case readBOp: + case readHUOp: + case readHOp: + if(op == readBUOp || op == readBOp) + lastAddr = actualAddr; + else if(op == readHUOp || op == readHOp) + lastAddr = actualAddr + dataPathWidth / 2 - 1; if( rangeError = (highPoint < lastAddr) ) { return 0; } @@ -207,6 +219,10 @@ mem.get( a ); } } + + if(op == readHOp && (tempStore & 0x8000) != 0) tempStore |= 0xffff0000; + else if(op == readBOp && (tempStore & 0x80) != 0) tempStore |= 0xffffff00; + if( CPUObject::debug&CPUObject::trace ) { cout << name() << '@' << actualAddr << "-->" << tempStore; @@ -233,13 +248,20 @@ switch( op ) { case readOp: + case readBUOp: break; + case writeBOp: + case writeHOp: case writeOp: // note that LSB is in highest address // by default; if byteSwap, LSB is in // lowest address tempStore = newValue; lastAddr = currentAddr+dataPathWidth-1; + if(op == writeBOp) + lastAddr = currentAddr; + else if(op == writeHOp) + lastAddr = currentAddr + dataPathWidth / 2 - 1; if( rangeError = (highPoint < lastAddr) ) { return; } --- ../lib.orig/Memory.h 2003-12-04 12:07:30.000000000 -0500 +++ Memory.h 2006-05-21 23:48:07.000000000 -0400 @@ -38,12 +38,14 @@ friend class Memory; +public: + long get( long index ); + void put( long index, long value ); + private: LongArray(); ~LongArray(); void allocate( long sz ); - long get( long index ); - void put( long index, long value ); long size; long *data; }; @@ -70,7 +72,7 @@ OutFlow & READ() { return readFlow; } // a reference to the memory unit's outgoing data path for reading - enum Operation { none, loadOp, readOp, writeOp }; + enum Operation { none, loadOp, readOp, writeOp, readBUOp, readBOp, readHUOp, readHOp, writeBOp, writeHOp }; void perform( Operation o ); // to be performed on the next clock void read() { perform( readOp ); } // shorthand for perform(readOp) void write() { perform( writeOp ); } // shorthand for perform(writeOp) @@ -107,8 +109,10 @@ unsigned long currentAddr; long newValue; +public: LongArray mem; +private: unsigned long highPoint; int unitSize; int rangeError;