Averest


'a buffer Type

This buffer class implements the buffers of the processing units inside a SCAD machine where each processing unit has at most one input and at most one output buffer, since each buffer itself can have several lanes for input/output values and even an optional lane having another type of values. Each entry i in an input/output lane bf is a pair valEntry[i][bf]=(adr,v) consisting of an optional address adr and an optional value v, while the optional lanes entries optEntry[i] can store any optional values. The overall buffer works as a FIFO queue and each lanes behave as such in a special was as well: At any time, the entries from head to tail are in use where head and tail are the indices of the first and last entry in use. Since both the empty and the full buffer satisfy tail+1=head, additional flags isEmpty and isFull are used to check whether the buffer is empty or full (it can have at most numRows entries). Enqueue operations work as follows:

  • enqAdr(bf,adr) adds address adr to the lane bf: First, the oldest entry (None,*) of the lane is searched, and if it exists, the address is stored in there. Otherwise, a new tail is added to the entire buffer, i.e., to all lanes, and the lane bf has the tail (adr,None).
  • enqValInp(src,tgt,v) adds value v to the lane bf where tgt=(tU,bf) holds: First, the oldest entry (src,None) of the lane bf is searched, and if it exists, the value is stored in there. Otherwise, the oldest entry (None,None) of the lane bf is searched, and if it exists, the value is stored in there. Otherwise, a new tail is added to the entire buffer, i.e., to all lanes, and the lane bf has the tail (None,v).
  • enqValOut(bf,v,nc) adds nc copies of value v to the lane bf: First, the oldest entry (*,None) of the lane bf is searched, and if exists, the nc copies are added from there on. It may be necessary that new tail numRows have to be added to the buffer to this end.
  • enqOpt(bf,x) adds value x to the optional lane: First, the oldest entry None of the lane is searched, and if it exists, the address is stored in there. Otherwise, a new tail is added to the entire buffer, i.e., to all lanes, and the optional lane has the tail x.
All enqueue operations can fail if there is not enough space in the buffer. This can be tested using the functions canEnqAdr, canEnqValInp, canEnqValOut, and canEnqOpt. The dequeue operation reads out the value entries in the lanes of the head of the buffer plus the head element of the optional lane. If some fields of the head row should not be defined, it returns None and leaves the head unchanged.

Record fields

Record Field Description

head

Full Usage: head

Field type: int
Modifiers: mutable

Field type: int

isEmpty

Full Usage: isEmpty

Field type: bool
Modifiers: mutable

Field type: bool

isFull

Full Usage: isFull

Field type: bool
Modifiers: mutable

Field type: bool

numLanes

Full Usage: numLanes

Field type: int

Field type: int

numRows

Full Usage: numRows

Field type: int

Field type: int

optEntry

Full Usage: optEntry

Field type: 'a option[]

Field type: 'a option[]

tail

Full Usage: tail

Field type: int
Modifiers: mutable

Field type: int

valEntry

Full Usage: valEntry

Field type: (address option * value option)[][]

Field type: (address option * value option)[][]

Instance members

Instance member Description

this.canDequeue withOpt

Full Usage: this.canDequeue withOpt

Parameters:
    withOpt : bool

Returns: bool

check whether the head can be dequeued, i.e., whether all fields in the head element are defined values (withOpt also considers the optional lane)

withOpt : bool
Returns: bool

this.canEnqAdr bf

Full Usage: this.canEnqAdr bf

Parameters:
Returns: bool

check whether a new address adr can be added to buffer bf

bf : addressBuf
Returns: bool

this.canEnqOpt ()

Full Usage: this.canEnqOpt ()

Returns: bool

check whether a value x can be added to this.optEntry[i]

Returns: bool

this.canEnqValInp (src, tgt)

Full Usage: this.canEnqValInp (src, tgt)

Parameters:
Returns: bool

check whether a new value v sent from buffer src to this input buffer tgt=(x,bf) can be added to this buffer; the value should be added to the first entry (src,None) found, otherwise to the first entry (None,None) found, otherwise, a new entry is added

src : address
tgt : address
Returns: bool

this.canEnqValOut (bf, numCopies)

Full Usage: this.canEnqValOut (bf, numCopies)

Parameters:
Returns: bool

check whether numCopies of an output value v can be added to buffer this.valEntry[i][bf]

bf : addressBuf
numCopies : int
Returns: bool

this.dequeue withOpt

Full Usage: this.dequeue withOpt

Parameters:
    withOpt : bool

Returns: ((address * value)[] * 'a option) option

return the head of the buffer element provided that the buffer is not empty and all fields of the head entry are defined, otherwise, return None and leave the buffer unchanged (withOpt specifies that also the optional lane must have a defined value)

withOpt : bool
Returns: ((address * value)[] * 'a option) option

this.enqAdr (bf, adr)

Full Usage: this.enqAdr (bf, adr)

Parameters:

add a new address adr in valEntry[i][bf] where i is either the oldest entry with undefined address field, or a new created entry

bf : addressBuf
adr : address

this.enqOpt x

Full Usage: this.enqOpt x

Parameters:
    x : 'a

add value x to the first entry None in this.optEntry[i], otherwise add a new entry x at its tail

x : 'a

this.enqValInp (src, tgt, v)

Full Usage: this.enqValInp (src, tgt, v)

Parameters:

add an input value v that is sent from buffer src to this buffer tgtU:bf; the value is added to the first entry (src,None) found, otherwise to the first entry (None,None) found, otherwise, a new entry is added (note that input buffers are only queues per src address)

src : address
tgt : address
v : value

this.enqValOut (bf, v, numCopies)

Full Usage: this.enqValOut (bf, v, numCopies)

Parameters:

add numCopies of an output value v to the first entries (*,None) in buffer this.valEntry[i][bf], and add new entries (None,v) if needed and possible (note that output buffers are really queues)

bf : addressBuf
v : value
numCopies : int

this.indexDec i

Full Usage: this.indexDec i

Parameters:
    i : int

Returns: int

decrementing index i modulo the length (= this.numRows) of the buffer

i : int
Returns: int

this.indexInc i

Full Usage: this.indexInc i

Parameters:
    i : int

Returns: int

incrementing index i modulo the length (= this.numRows) of the buffer

i : int
Returns: int

this.indexList

Full Usage: this.indexList

Returns: int list

compute the list of indices from head to tail as an iterator

Returns: int list

this.writeTo ostr indent

Full Usage: this.writeTo ostr indent

Parameters:

print the buffer entries to output stream with some indentation

ostr : TextWriter
indent : string

this.writeToHtml withOpt ostr

Full Usage: this.writeToHtml withOpt ostr

Parameters:

write the buffer entries as html table to output stream

withOpt : bool
ostr : TextWriter