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:
Record Field | Description |
Full Usage:
head
Field type: int
Modifiers: mutable |
|
Full Usage:
isEmpty
Field type: bool
Modifiers: mutable |
|
Full Usage:
isFull
Field type: bool
Modifiers: mutable |
|
Full Usage:
numLanes
Field type: int
|
|
Full Usage:
numRows
Field type: int
|
|
Full Usage:
optEntry
Field type: 'a option[]
|
|
Full Usage:
tail
Field type: int
Modifiers: mutable |
|
|
Instance member | Description |
Full Usage:
this.canDequeue withOpt
Parameters:
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)
|
|
check whether a new address adr can be added to buffer bf
|
Full Usage:
this.canEnqOpt ()
Returns: bool
|
check whether a value x can be added to this.optEntry[i]
|
|
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
|
Full Usage:
this.canEnqValOut (bf, numCopies)
Parameters:
addressBuf
numCopies : int
Returns: bool
|
check whether numCopies of an output value v can be added to buffer this.valEntry[i][bf]
|
|
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)
|
|
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
|
Full Usage:
this.enqOpt x
Parameters:
'a
|
add value x to the first entry None in this.optEntry[i], otherwise add a new entry x at its tail
|
|
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) |
|
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)
|
Full Usage:
this.indexDec i
Parameters:
int
Returns: int
|
decrementing index i modulo the length (= this.numRows) of the buffer
|
Full Usage:
this.indexInc i
Parameters:
int
Returns: int
|
incrementing index i modulo the length (= this.numRows) of the buffer
|
Full Usage:
this.indexList
Returns: int list
|
compute the list of indices from head to tail as an iterator
|
|
print the buffer entries to output stream with some indentation
|
|
write the buffer entries as html table to output stream
|