com.cmpware.cmp.links
Class FIFO

java.lang.Object
  extended by com.cmpware.cmp.Link
      extended by com.cmpware.cmp.links.FIFO
All Implemented Interfaces:
MemoryMappedIOReader, MemoryMappedIOWriter
Direct Known Subclasses:
CellBE_FIFO

public class FIFO
extends Link

This class implements a synchronous FIFO. This is used as a link component to build inter-processor communication networks. The input port of the FIFO is typically mapped to a memory mapped IO address on one processor and the output port to a memory mapped IO address on another processor. This creates a communication link between the processors. Note that the internal implementation of this link object requires some care to support the multiprocessor simulation environment. All state update should be done at commit time.

Copyright (c) 2004 Cmpware, Inc. All Rights Reserved.

Author:
SAG

Field Summary
static java.lang.String copyright
          Copyright string
static int DEFAULT_SIZE
          The default FIFO size
protected  int[] fifo
          The FIFO data
protected  int head
          The FIFO 'head' pointer
protected  MemoryMappedIOException mmioe
          A Memory Mapped IO Execption (so we don't have to keep re-allocating them)
protected  int readAddr
          The read address (for information only)
protected  int readCount
          The number of reads
protected  boolean readFlag
          This flag indicates that a read was performed on this cycle
protected  int readStallCount
          The number of read stalls
protected  int tail
          The FIFO 'tail' pointer
protected  int writeAddr
          The write address (for information only)
protected  int writeCount
          The number of writes
protected  int writeStallCount
          The number of write stalls
protected  boolean writtenFlag
          This flag indicates that a write was performed on this cycle
 
Constructor Summary
FIFO()
          This constructor allocates a FIFO using the default FIFO size.
FIFO(int size)
          This constructor allocates a FIFO.
 
Method Summary
 int free()
          This method returns the number of remaining slots in the FIFO.
 int getReadAddress()
          This method returns the processor address to which the read port of this Memory Mapped IO is mapped.
 int getReadCount()
          This method returns the number of times the read port has been accessed.
 int getReadStallCount()
          This method returns the number of times the read port has stalled.
 int getValue()
          This method returns the most recently written value of the Memory Mapped IO.
 int getWriteAddress()
          This method returns the processor address to which the write port of this Memory Mapped IO is mapped.
 int getWriteCount()
          This method returns the number of times the write port has been accessed.
 int getWriteStallCount()
          This method returns the number of times the write port has stalled.
protected  boolean isEmpty()
          This method returns a true if the FIFO is empty and a false otherwise.
protected  boolean isFull()
          This method returns a true if the FIFO is full and a false otherwise.
 boolean isReadable()
          This method returns a true if the Memory Mapped IO is currently readable.
 boolean isWriteable()
          This method returns a true if the Memory Mapped IO port is currently writeable.
 int read()
          This method reads a value from the Memory Mapped IO port.
 void readCommit()
          All Memory Mapped IO reads are performed whenever data is available.
 void reset()
          This abstract class is used to reset the link.
 void setBufferSize(int size)
          This method is used to set the buffer size in the communication link.
 void setReadAddress(int addr)
          This method sets the read address of the Memeory Mapped IO.
 void setWriteAddress(int addr)
          This method sets the write address of the Memory Mapped IO.
 int used()
          This method returns the number of used slots in the FIFO.
 void write(int val)
          This method writes a word to the Memory Mapped IO.
 void writeCommit()
          All Memory Mapped IO writes are performed whenever data is available.
 
Methods inherited from class com.cmpware.cmp.Link
get
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright
Copyright string

See Also:
Constant Field Values

DEFAULT_SIZE

public static final int DEFAULT_SIZE
The default FIFO size

See Also:
Constant Field Values

fifo

protected int[] fifo
The FIFO data


head

protected int head
The FIFO 'head' pointer


tail

protected int tail
The FIFO 'tail' pointer


readAddr

protected int readAddr
The read address (for information only)


writeAddr

protected int writeAddr
The write address (for information only)


readCount

protected int readCount
The number of reads


writeCount

protected int writeCount
The number of writes


readStallCount

protected int readStallCount
The number of read stalls


writeStallCount

protected int writeStallCount
The number of write stalls


writtenFlag

protected boolean writtenFlag
This flag indicates that a write was performed on this cycle


readFlag

protected boolean readFlag
This flag indicates that a read was performed on this cycle


mmioe

protected MemoryMappedIOException mmioe
A Memory Mapped IO Execption (so we don't have to keep re-allocating them)

Constructor Detail

FIFO

public FIFO()
This constructor allocates a FIFO using the default FIFO size.


FIFO

public FIFO(int size)
This constructor allocates a FIFO.

Parameters:
size - the FIFO size.
Method Detail

setBufferSize

public void setBufferSize(int size)
Description copied from class: Link
This method is used to set the buffer size in the communication link. The method defined here does nothing. If the subclass of Link needs the ability to set a buffer size, it should overload this method.

Overrides:
setBufferSize in class Link
Parameters:
size - The buffer size.

reset

public void reset()
Description copied from interface: MemoryMappedIOReader
This abstract class is used to reset the link. This may be necessary in links that have state.


write

public void write(int val)
           throws MemoryMappedIOException
Description copied from interface: MemoryMappedIOWriter
This method writes a word to the Memory Mapped IO.

Parameters:
val - The value to write to the Memory Mapped IO.
Throws:
MemoryMappedIOException - - this method throws a MemoryMappedIOException if the write could not be completed on this cycle. This will typically cause a stall of the processor and a retry on the next cycle.

read

public int read()
         throws MemoryMappedIOException
Description copied from interface: MemoryMappedIOReader
This method reads a value from the Memory Mapped IO port.

Returns:
This method reads a value from the Memory mapped IO port.
Throws:
MemoryMappedIOException - - this method throws a MemoryMappedIOException if the read could not be completed on this cycle. This will typically cause a stall of the processor and a retry on the next cycle.

writeCommit

public void writeCommit()
Description copied from interface: MemoryMappedIOWriter
All Memory Mapped IO writes are performed whenever data is available. But because this is a multiprocessor simulation environment, it may not be proper to flag this communication resource as "free" until the end of the simulation cycle. This is necessary to preserve clock boundaries in multiprocessor simulation environments. This method should be called at the end of all activity in a simulation cycle and should tag the resource as free as necessary.


readCommit

public void readCommit()
Description copied from interface: MemoryMappedIOReader
All Memory Mapped IO reads are performed whenever data is available. But because this is a multiprocessor simulation environment, it may not be proper to flag this communication resource as "free" until the end of the simulation cycle. This is necessary to preserve clock boundaries in multiprocessor simulation environments. This method should be called at the end of all activity in a simulation cycle and should tag the resource as free as necessary.


setReadAddress

public void setReadAddress(int addr)
Description copied from interface: MemoryMappedIOReader
This method sets the read address of the Memeory Mapped IO. Note that is only provides the adddress value for convenience when displaying Memory Mapped IO status information. This does not effect how the Memory Mapped IO is decoded.

Parameters:
addr - The Memory Mapped IO read address.

getReadAddress

public int getReadAddress()
Description copied from interface: MemoryMappedIOReader
This method returns the processor address to which the read port of this Memory Mapped IO is mapped.

Returns:
This method returns the processor address to which the read port of this Memory Mapped IO is mapped.

getReadCount

public int getReadCount()
Description copied from interface: MemoryMappedIOReader
This method returns the number of times the read port has been accessed.

Returns:
This method returns the number of times the read port has been accessed.

getReadStallCount

public int getReadStallCount()
Description copied from interface: MemoryMappedIOReader
This method returns the number of times the read port has stalled.

Returns:
This method returns the number of times the read port has stalled.

setWriteAddress

public void setWriteAddress(int addr)
Description copied from interface: MemoryMappedIOWriter
This method sets the write address of the Memory Mapped IO. Note that is only provides the adddress value for convenience when displaying Memory Mapped IO information. This does not effect how the Memory Mapped IO port is decoded.

Parameters:
addr - The Memory Mapped IO write address.

getWriteAddress

public int getWriteAddress()
Description copied from interface: MemoryMappedIOWriter
This method returns the processor address to which the write port of this Memory Mapped IO is mapped.

Returns:
This method returns the processor address to which the write port of this Memory Mapped IO is mapped.

getWriteCount

public int getWriteCount()
Description copied from interface: MemoryMappedIOWriter
This method returns the number of times the write port has been accessed.

Returns:
This method returns the number of times the write port has been accessed.

getWriteStallCount

public int getWriteStallCount()
Description copied from interface: MemoryMappedIOWriter
This method returns the number of times the write port has stalled.

Returns:
This method returns the number of times the write port has stalled.

getValue

public int getValue()
Description copied from interface: MemoryMappedIOReader
This method returns the most recently written value of the Memory Mapped IO. Note that this value may or may not have already been read.

Returns:
This method returns the most recently written value of the Memory Mapped IO. Note that this value may or may not have already been read.

isReadable

public boolean isReadable()
Description copied from interface: MemoryMappedIOReader
This method returns a true if the Memory Mapped IO is currently readable. A false is returned otherwise.

Returns:
This method returns a true if the Memory Mapped IO is currently readable. A false is returned otherwise.

isWriteable

public boolean isWriteable()
Description copied from interface: MemoryMappedIOWriter
This method returns a true if the Memory Mapped IO port is currently writeable. A false is returned otherwise.

Returns:
This method returns a true if the Memory Mapped IO port is currently writeable. A false is returned otherwise.

used

public int used()
This method returns the number of used slots in the FIFO.

Returns:
This method returns the number of used slots in the FIFO.

free

public int free()
This method returns the number of remaining slots in the FIFO.

Returns:
This method returns the number of remaining slots in the FIFO.

isEmpty

protected boolean isEmpty()
This method returns a true if the FIFO is empty and a false otherwise.


isFull

protected boolean isFull()
This method returns a true if the FIFO is full and a false otherwise.