jmce - 1_02

jmce.zilog.z80
Class CTC

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.AbstractPeripheral
          extended by jmce.zilog.z80.CTC
All Implemented Interfaces:
CycleListener, Hardware, MemoryReadListener, MemoryWriteListener, Peripheral, ResetListener

public class CTC
extends AbstractPeripheral
implements ResetListener, MemoryReadListener, MemoryWriteListener, CycleListener

Z80 CTC

The Z80 CTC have 4 different channel that can operate as counter or timer.

Each channel have a control register :

 BIT 7 1 Enable interrupt
 BIT 6 0 Timer mode / 1 Counter mode
 BIT 5 0 Prescaler 16 / 1 Prescaler 256 (Only in timer mode)
 BIT 4 0 Count failing edge / 1 Count rising edge 
 BIT 3 0 Counter automatic trigger / 1 External trigger (ignored)
 BIT 2 1 Time constants follow
 BIT 1 1 Software reset.
 BIT 0 1 Control word / 0 Interrupt vector.
 
 

Properties :

base - Base address of the peripheral (default to 0)

Since:
1.01
Version:
1.01
Author:
Mario Viara

Field Summary
static int CTC_CHANNEL
           
static int CW_IE
          Enable interrupt
static int CW_RESET
          Software reset
static int CW_VECTOR
          Interrupt vector
 
Fields inherited from class jmce.sim.AbstractPeripheral
cpu
 
Constructor Summary
CTC()
          Default constructor
 
Method Summary
 void count(int i, int n)
          Called by external peripheral to count pulse.
 void cycle(int n)
          Called at every instruction cycle to decrement the timer.
 int getBase()
          Return the base address.
 int readMemory(Memory m, int address, int value)
          Called when the memory is readed.
 void registerCPU(CPU cpu)
          Register a parent CPU for future reference.
 void reset(CPU cpu)
           
 void reset(int ch)
          Reset a CTC channel.
 void setBase(int base)
          Set the base addres of this CTC
 java.lang.String toString()
           
 void writeMemory(Memory m, int address, int value, int oldValue)
          Called when a memory write event occours.
 
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, reset, 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, reset, setHardware, setHardware, setName
 

Field Detail

CTC_CHANNEL

public static final int CTC_CHANNEL
See Also:
Constant Field Values

CW_IE

public static final int CW_IE
Enable interrupt

See Also:
Constant Field Values

CW_VECTOR

public static final int CW_VECTOR
Interrupt vector

See Also:
Constant Field Values

CW_RESET

public static final int CW_RESET
Software reset

See Also:
Constant Field Values
Constructor Detail

CTC

public CTC()
Default constructor

Method Detail

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

reset

public void reset(CPU cpu)
           throws SIMException
Specified by:
reset in interface ResetListener
Throws:
SIMException

readMemory

public int readMemory(Memory m,
                      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:
m - - 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

writeMemory

public void writeMemory(Memory m,
                        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:
m - - Memory involved in the write operation.
address - - Address written.
value - - Value written.
oldValue - - Old value of this memory location.
Throws:
SIMException

count

public final void count(int i,
                        int n)
                 throws SIMException
Called by external peripheral to count pulse.

Throws:
SIMException

cycle

public final void cycle(int n)
                 throws SIMException
Called at every instruction cycle to decrement the timer.

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)

reset

public void reset(int ch)
Reset a CTC channel.

Called at CPU reset or when the software reset bit is set.


setBase

public void setBase(int base)
Set the base addres of this CTC


getBase

public int getBase()
Return the base address.


toString

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

jmce - 1_02