jmce - 1_02

jmce.mos
Class VIA6522

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.AbstractPeripheral
          extended by jmce.mos.VIA6522
All Implemented Interfaces:
CycleListener, Hardware, MemoryReadListener, MemoryWriteListener, Peripheral

public class VIA6522
extends AbstractPeripheral
implements MemoryWriteListener, MemoryReadListener, CycleListener

MOS VIA6522 - Versatile Interface Adapter.

The VIA6522 support two 8 bit bidirectional port (port A and port B) and 2 different timers.

Register

All address are relative to the base address. The base address can be set using a method setBase().

Limitations

Since:
1.01
Version:
1.00
Author:
Mario Viara

Field Summary
static int ACR
          Auxiliary control register
static int IER
          Interrupt enable register
static int IER_CA1
           
static int IER_CA2
           
static int IER_CB1
           
static int IER_CB2
           
static int IER_CONTROL
           
static int IER_SHIFT
           
static int IER_TIMER1
           
static int IER_TIMER2
           
static int IFR
          Interrupt flag register
static int PAD
          Port A Direction Register
static int PAR
          Port A register
static int PARA
          Port a no handshake
static int PBD
          Port B direction register
static int PBR
          Port B register
static int PCR
          Peripheral control register
static int T1CH
          Timer 1 high byte counter register
static int T1CL
          Timer 1 low byte counter register
static int T1LH
          Yimer 1 high byte latch register
static int T1LL
          Timer 1 low byte latch register
static int T2H
          Timer2 hi byte
static int T2L
          Timer2 low byte
 
Fields inherited from class jmce.sim.AbstractPeripheral
cpu
 
Constructor Summary
VIA6522()
          Default constructor
VIA6522(java.lang.String name, int base)
          Constructor with name and base address
 
Method Summary
 void addCA2MemoryWriteListener(MemoryWriteListener l)
           
 void addPortAWriteListener(MemoryWriteListener l)
          Add a new memory write listener to Port A register.
 void addPortBWriteListener(MemoryWriteListener l)
          Add a new memory write listener to Port B register.
 void cycle(int n)
          Cycle listener.
 int getBase()
          Return the base for this VIA
 int getTimer2Counter()
           
 boolean readCA1()
           
 boolean readCA2()
           
 boolean readCB1()
           
 boolean readCB2()
           
 int readMemory(Memory memory, int address, int value)
          Called when the memory is readed.
 int readPortA()
          Return the value for the Port A
 int readPortB()
           
 void registerCPU(CPU cpu)
          Register a parent CPU for future reference.
 void reset()
          Reset the the device to the initial state.
 void setBase(int base)
          Set the base address of this VIA
 java.lang.String toString()
           
 void writeCA1(boolean mode)
           
 void writeCA2(boolean mode)
           
 void writeCB1(boolean mode)
           
 void writeCB2(boolean mode)
           
 void writeMemory(Memory memory, int address, int value, int oldValue)
          Called when a memory write event occours.
 void writePortA(int a)
          Set the value for port A input called from other peripheral.
 void writePortB(int b)
          Set the value of the input for port B
 
Methods inherited from class jmce.sim.AbstractPeripheral
idle, setIdle, setLive
 
Methods inherited from class jmce.sim.AbstractHardware
addHardware, createFrame, destroy, getHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareForName, getHardwareInstances, getHardwareTree, getName, getParent, init, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmce.sim.Hardware
addHardware, destroy, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareInstances, getHardwareTree, getName, getParent, init, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName
 

Field Detail

PBR

public static final int PBR
Port B register

See Also:
Constant Field Values

PAR

public static final int PAR
Port A register

See Also:
Constant Field Values

PBD

public static final int PBD
Port B direction register

See Also:
Constant Field Values

PAD

public static final int PAD
Port A Direction Register

See Also:
Constant Field Values

IFR

public static final int IFR
Interrupt flag register

See Also:
Constant Field Values

IER

public static final int IER
Interrupt enable register

See Also:
Constant Field Values

IER_CONTROL

public static final int IER_CONTROL
See Also:
Constant Field Values

IER_TIMER1

public static final int IER_TIMER1
See Also:
Constant Field Values

IER_TIMER2

public static final int IER_TIMER2
See Also:
Constant Field Values

IER_CB1

public static final int IER_CB1
See Also:
Constant Field Values

IER_CB2

public static final int IER_CB2
See Also:
Constant Field Values

IER_SHIFT

public static final int IER_SHIFT
See Also:
Constant Field Values

IER_CA1

public static final int IER_CA1
See Also:
Constant Field Values

IER_CA2

public static final int IER_CA2
See Also:
Constant Field Values

ACR

public static final int ACR
Auxiliary control register

See Also:
Constant Field Values

PCR

public static final int PCR
Peripheral control register

See Also:
Constant Field Values

T1CL

public static final int T1CL
Timer 1 low byte counter register

See Also:
Constant Field Values

T1CH

public static final int T1CH
Timer 1 high byte counter register

See Also:
Constant Field Values

T1LL

public static final int T1LL
Timer 1 low byte latch register

See Also:
Constant Field Values

T1LH

public static final int T1LH
Yimer 1 high byte latch register

See Also:
Constant Field Values

T2L

public static final int T2L
Timer2 low byte

See Also:
Constant Field Values

T2H

public static final int T2H
Timer2 hi byte

See Also:
Constant Field Values

PARA

public static final int PARA
Port a no handshake

See Also:
Constant Field Values
Constructor Detail

VIA6522

public VIA6522()
        throws SIMException
Default constructor

Throws:
SIMException

VIA6522

public VIA6522(java.lang.String name,
               int base)
        throws SIMException
Constructor with name and base address

Throws:
SIMException
Method Detail

getBase

public int getBase()
Return the base for this VIA


setBase

public void setBase(int base)
Set the base address of this VIA


reset

public void reset()
           throws SIMException
Description copied from interface: Hardware
Reset the the device to the initial state. This method will be called after init.

Specified by:
reset in interface Hardware
Overrides:
reset in class AbstractHardware
Throws:
SIMException

registerCPU

public void registerCPU(CPU cpu)
                 throws SIMException
Description copied from interface: Peripheral
Register a parent CPU for future reference.

Specified by:
registerCPU in interface Peripheral
Overrides:
registerCPU in class AbstractPeripheral
Throws:
SIMException

cycle

public void cycle(int n)
           throws SIMException
Description copied from interface: CycleListener
Cycle listener. This type of listener is very time consuming and must be used only when necessary because can have great impact on the simulator performance.

Specified by:
cycle in interface CycleListener
Parameters:
n - - The number of microprocessor cycle elapsed from the last call.
Throws:
SIMException
See Also:
CPU.addCycleListener(jmce.sim.CycleListener)

writeMemory

public void writeMemory(Memory memory,
                        int address,
                        int value,
                        int oldValue)
                 throws SIMException
Description copied from interface: MemoryWriteListener
Called when a memory write event occours.

This method is called when a memory write operation occours in the specified memory.

Specified by:
writeMemory in interface MemoryWriteListener
Parameters:
memory - - Memory involved in the write operation.
address - - Address written.
value - - Value written.
oldValue - - Old value of this memory location.
Throws:
SIMException

readMemory

public int readMemory(Memory memory,
                      int address,
                      int value)
               throws SIMException
Description copied from interface: MemoryReadListener
Called when the memory is readed.

This is method is called to notify a read at the specified memory loction.

Specified by:
readMemory in interface MemoryReadListener
Parameters:
memory - - Memory readed.
address - - Address where the operation occours.
value - - Value readed from the phisical memory or from previus installed listener.
Returns:
Value readed from the memory.
Throws:
SIMException

writePortA

public void writePortA(int a)
                throws SIMException
Set the value for port A input called from other peripheral.

Throws:
SIMException

readPortA

public int readPortA()
              throws SIMException
Return the value for the Port A

Throws:
SIMException

writePortB

public void writePortB(int b)
                throws SIMException
Set the value of the input for port B

Throws:
SIMException

readPortB

public int readPortB()
              throws SIMException
Throws:
SIMException

addPortAWriteListener

public void addPortAWriteListener(MemoryWriteListener l)
Add a new memory write listener to Port A register. Catch only write from the cpu.


addPortBWriteListener

public void addPortBWriteListener(MemoryWriteListener l)
Add a new memory write listener to Port B register. Catch only write from the cpu.


readCB2

public boolean readCB2()

writeCB2

public void writeCB2(boolean mode)
              throws SIMException
Throws:
SIMException

readCA1

public boolean readCA1()

writeCA1

public void writeCA1(boolean mode)
              throws SIMException
Throws:
SIMException

addCA2MemoryWriteListener

public void addCA2MemoryWriteListener(MemoryWriteListener l)

readCA2

public boolean readCA2()

writeCA2

public void writeCA2(boolean mode)
              throws SIMException
Throws:
SIMException

readCB1

public boolean readCB1()

writeCB1

public void writeCB1(boolean mode)
              throws SIMException
Throws:
SIMException

getTimer2Counter

public int getTimer2Counter()

toString

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

jmce - 1_02