sim
Class BlockDevice

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

class BlockDevice
extends java.lang.Object
implements Memory

Implements a block device. Provides three registers:

  1. 0: Block Address (device source or destination)
  2. 4: Memory Address (memory source or destination)
  3. 8: Control (bit0 = ready, bit1 = interrupt enable, bit2 = write bit3 = read). The ready bit is on when the device is ready to read or write more data. If bit1 is on, an interrupt will be delivered when the device completes its current operation. To initiate a write, bit2 is strobed; a read bit3 is strobed.


Field Summary
(package private)  int base
           
(package private)  int blockAddr
           
(package private)  int blockSize
           
(package private)  int ctl
           
(package private)  java.io.RandomAccessFile file
           
(package private)  Mips machine
           
(package private)  int memAddr
           
 
Constructor Summary
BlockDevice(Mips machine, java.io.RandomAccessFile file, int address, int blockSize)
          Make a new block device connected to the given machine, at the given address, of the given block transfer size.
 
Method Summary
 void doCycle()
           
 int getSize()
           
 void initialize()
           
 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

file

java.io.RandomAccessFile file

machine

Mips machine

base

int base

blockAddr

int blockAddr

memAddr

int memAddr

blockSize

int blockSize

ctl

int ctl
Constructor Detail

BlockDevice

public BlockDevice(Mips machine,
                   java.io.RandomAccessFile file,
                   int address,
                   int blockSize)
Make a new block device connected to the given machine, at the given address, of the given block transfer size.

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()
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