Revision b774eb5849c908e62da544ad461f8dd1c7ee8c66 authored by Ron Burkey on 13 September 2016, 00:43:11 UTC, committed by Ron Burkey on 13 September 2016, 00:43:11 UTC
to set a given memory location to a value (particularly, INx); and b) the ability to toggle logging on an off. The Pultorak simulator also no longer displays status messages while free-running. The idea is to use this to check discrepancies with handling the DSKY-keypad inputs.
1 parent c32edf6
reg.h
#ifndef reg_H
#define reg_H
#include <iostream>
#include <ostream>
#include <string.h>
#include <stdio.h>
using namespace std;
class reg
{
public:
virtual unsigned
read()
{
return mask & slaveVal;
}
virtual void
write(unsigned v)
{
load = true;
masterVal = mask & v;
}
// asynchronous clear
void
clear()
{
slaveVal = 0;
}
// load is set when a register is written into.
void
clk()
{
if (load)
slaveVal = masterVal;
load = false;
}
unsigned
readField(unsigned msb, unsigned lsb); // bitfield numbered n - 1
void
writeField(unsigned msb, unsigned lsb, unsigned v); // bitfield numbered n - 1
// Write a 16-bit word (in) into the register. Transpose the bits according to
// the specification (ib).
void
writeShift(unsigned in, unsigned* ib);
// Return a shifted 16-bit word. Transpose the 'in' bits according to
// the specification 'ib'. 'Or' the result to out and return the value.
unsigned
shiftData(unsigned out, unsigned in, unsigned* ib);
unsigned
outmask()
{
return mask;
}
protected:
virtual
~reg()
{
}
reg(unsigned s, const char* fs) :
size(s), mask(0), masterVal(0), slaveVal(0), fmtString(fs), load(false)
{
mask = buildMask(size);
}
static unsigned
buildMask(unsigned s);
friend ostream&
operator <<(ostream& os, const reg& r)
{
char buf[32];
sprintf(buf, r.fmtString, r.slaveVal);
os << buf;
return os;
}
private:
unsigned size; // bits
unsigned masterVal;
unsigned slaveVal;
unsigned mask;
const char* fmtString;
bool load;
reg(); // prevent instantiation of default constructor
};
#endif
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...