sim
Class CharacterDevice

java.lang.Object
  |
  +--sim.CharacterDevice
All Implemented Interfaces:
Memory

class CharacterDevice
extends java.lang.Object
implements Memory

A character I/O terminal device that implements our memory interface. See appendix A.8 in Patterson & Hennesey for a full description of how it works, but here are the basics. The device has 4 (word sized) registers: Receiver control (0), Receiver data (1), Transmitter control (2), and Transmitter data (3). The low order byte of the two data registers contain the data just read or the data two write. Bit zero of the two control registers is a ready bit. For the read control, it is on when data is available. For write control, it is on when the device is ready to accept another data item. Bit one of the two control registers is an interrupt enable bit. If this is set to on, an interrupt will be raised whenever the ready bit is one (for the read control, this means that data is available; for write control this means the device is ready to accept more data).


Field Summary
(package private)  int base
           
(package private)  java.io.InputStream is
           
(package private)  Mips machine
           
(package private)  java.io.OutputStream os
           
(package private)  int RxCtl
           
(package private)  int RxData
           
(package private)  int TxCtl
           
(package private)  int TxData
           
 
Constructor Summary
(package private) CharacterDevice(Mips machine, java.io.InputStream is, java.io.OutputStream os, int address)
           
 
Method Summary
 void doCycle()
           
 int getSize()
           
 void initialize()
          Set the registers to their initial state.
 byte readByte(int address)
           
 int readWord(int address)
           
 java.lang.String toString()
           
 void writeByte(int address, byte value)
           
 void writeWord(int address, int value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

is

java.io.InputStream is

os

java.io.OutputStream os

machine

Mips machine

base

int base

RxCtl

int RxCtl

RxData

int RxData

TxData

int TxData

TxCtl

int TxCtl
Constructor Detail

CharacterDevice

CharacterDevice(Mips machine,
                java.io.InputStream is,
                java.io.OutputStream os,
                int address)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSize

public int getSize()
Specified by:
getSize in interface Memory

initialize

public void initialize()
Set the registers to their initial state.

Specified by:
initialize in interface Memory

doCycle

public void doCycle()
Specified by:
doCycle in interface Memory

readByte

public byte readByte(int address)
Specified by:
readByte in interface Memory

writeByte

public void writeByte(int address,
                      byte value)
Specified by:
writeByte in interface Memory

readWord

public int readWord(int address)
Specified by:
readWord in interface Memory

writeWord

public void writeWord(int address,
                      int value)
Specified by:
writeWord in interface Memory